Happenings: droidcon London 2009
by Dj Walker-Morgan
As Android starts appearing on more devices, so developers are getting together to exchange notes on how to develop on the rapidly changing open source mobile phone platform. At the first droidcon London, subjects ranged from alternate languages, programming audio and implementing Android on devices to reverse engineering programmes, testing Android applications and the future of mobile devices.
In the first session of the day Akshay Dashrath advocated Scala as an alternative to Java, Android's default application development language. Scala is a concise, type-safe language with a number of features which could make it the "next Java" for the Java and Dalvik virtual machines. It is a combination of a functional, object-oriented and statically typed language with an ability to be easily extended. Because Scala compiles to Java byte code it can easily interoperate with existing Java code and run on Java virtual machines.
Source: Skillsmatter Unfortunately, the promise of the language is let down by a steep learning curve and the cost to performance; a Quicksort in Scala ran in 15.2 seconds, compared with 5.9 seconds for a pure Java version. The performance hit comes from a number of issues, ranging from memory overhead to the cost of boxing and unboxing variables. It was hoped that the forthcoming Dalvik just-in-time compiler and Scala 2.8 would help the performance, but the JIT compiler will of course improve performance for plain Java applications too.
Next, Andreas Reuterberg and Alex Shaw introduced the audience to Advanced Audio Programming on Android. After a short tour of the existing frameworks for managing audio such as MediaPlayer and Jet, Shaw and Reuterberg discussed AudioTrack, which gives more detailed control over the handling of audio by allowing the developer to stream audio buffers to hardware. To perform real time manipulation of the audio, the developers showed how they used the Android NDK (Native Development Kit) to write high
Source: Skillsmatter performance code for effects. In one example, a low pass filter was 4.5 times faster in native code than in Java. But raw code performance is only part of the problem. Android is multitasking and the Dalvik virtual machine pauses when doing garbage collection; both things which can cause problems when generating continuous sound. One useful hint was to always perform audio manipulation with fixed point rather than floating point math; it can be up to eleven times faster on typical Android hardware.
Gary Smith from ZiiLabs talked next on how ZiiLabs ported and accelerated Android on the ZiiEgg. The ZiiEgg, available as the ZMS05 development platform, contains a ARM Cortex-A8 CPU running at 1Ghz paired with ZiiLabs "stemcell" processing array with 64 SIMD processing elements, used for video decoding and 3D. ZiiLabs have created a version of Android 1.6 which uses the "stemcell" processor to accelerate Android's display rendering by reimplementing SurfaceFlinger, the display management layer within Android. Among the examples shown was playback of H264 video composited into an OpenGL ES 3D display.
Source: Skillsmatter In a break from traditional talks, the floor was handed over to the attendees in a "Park Bench" session. Subjects ranged here from a general dissatisfaction with the Android Marketplace and how alternative marketplaces such as AndAppStore could help many developers, and which open source libraries Android developers were using. The subject of the possibility of Android fragmenting into a number of device specific or vendor specific versions also came up; a problem which some see as a sign of the strength of Android, while others want to see a reference, community run open source Android acting as the Android "commons" in the future.
Understanding how Dalvik works was the subject of Gabor Pallor's talk on dedexer, an open source disassembly tool for android bytecode. Android uses a number of techniques to compress compiled Java code which provide a challenges for decoding compiled programs; currently dedexer is only able to provide readable assembly code, not reverse engineered Java. With the dex format, the Java class files of an application are packed into one file which shares namespace and table data; an eleven class Java application, for example, came to 21.3K in size, whilst in Dex format it was 17.6K (and after zipping, the Java file was 13.6K but the Dex file was only 9K). Pallor talked about the various optimisations in the Dex format and the pre-execution optimisation which the Dalvik virtual machine also performs. The detailed talk concluded by showing how Dalvik is "a clever compromise" for Java-like virtual machines on mobile devices where memory and CPU are limited resources, such as mobile phones.
Source: Skillsmatter Developers from RjDj, specialists in creating generated audio, returned to the subject of audio and the NDK in their presentation. After a number of compelling demonstrations of real time reactive music generation, the RjDj developers took a more detailed look at the interface between Java and native code on Android. The developers also took a moment to allow the attendees to download an early preview of their Android application. The room was then alive with feedback squeaks as the assembled developers found that many Android phones have the microphone and speaker a little too close together: the RjDj developers recommend the use of headphones and headset for listening to the generated audio.
Source: Skillsmatter Yan Minagawa then challenged the audience to think about the future of mobile devices. The theme built up during the talk was that mobile devices have only just started sensing their environment and that the next generations of devices will begin to sense and interpret everything from ambient noise to air pressure. The other challenge alluded to was the problem of parsing and tokenising speech, the predominant mobile mode of communication, yet one where mobile devices still have limited understanding of the information that passes in that mode. Finally, and somewhat practically, the talks ended with a session on how to test code for Android, with a step by step examination of how to prepare an application for unit testing, customised for Android developers.
It was clear that developers were not only wrestling with how to get high performance out of Android devices, but also with how to get their applications to users effectively, how to track Google and the phone makers developments and how to make better use of Android with other open source technologies. For some problems there were practical solutions. For example, the OpenIntents group were in attendance; Intents are how Android software registers with the operating system to indicate it can perform some action (send email, show image, etc). Other applications can then make use of the "intent" to get that software to perform that action. OpenIntents is an attempt to create a public registry for these intents and a good example of how open development can help developers.
Droidcon London 2009 was a fine, compact, conference with lots of enthusiastic Android developers wanting to know more about getting the best out of the Android platform. Slides and videos of all the presentations are available from the droidcon London 2009 site, hosted by Skillsmatter. Photos of the event are available on Flickr.
The H was a media sponsor of droidcon London 2009.