|
Empress
Technical News - May 2010
Empress Support for Android Mobile Environment
Build Smart Android Device with Empress Database
Click
here to see Empress Press Release on Android
Introduction
Embedded devices running Linux range from cell phones, PDAs,
multimedia devices and TV set-top boxes. Google’s Android is yet another Linux
platform that empowers the development of embedded devices specifically
targeted to mobile devices. Android, which is based on a Linux Kernel, is an
operating system and software stack for mobile devices that includes middleware
and key applications. It enables developers to write Java code controlling the
embedded device via Google-developed Java libraries through a Dalvik Virtual
Machine.
As a platform Android has been extended to other embedded
devices. Those “smarter” embedded
devices that deal with richer and larger amounts of data would require a more
sophisticated database technology than SQLite, which is a storage mechanism
provided in the Android software stack.
Empress Embedded Database can provide this more sophisticated Technology
Figure 1 describes the Android platform architecture.
Developers would typically use the Google Android SDK to build Java
applications and package them in the .apk format and deliver them to users via
the Android Market.
If the application requires non-Java code such as C or C++
code, Google provides another development kit, the Native Development Kit
(NDK). The Android NDK allows developers to create Java programs that interface
to C or C++ libraries using Java Native Interface (JNI) wrappers, which are
compatible with the SDK environment.

Figure 1:
Android Platform Architecture
If the embedded device is manufactured by a vendor who
wishes to alter the default Android environment for its users, the vendor could
use the Android Source Code with a special Toolchain to do so.
In the following text we will describe how Empress fits in
the Android picture and how an Empress database is ported to one of the mobile
devices the Google Nexus One phone.
Empowering Google Android with Empress Database Technology
How does Empress fit in the Android picture? There are
several ways embedded developers can use Empress database technologies inside
an Android device.
The first way is described in Figure 2. The Empress JDBC
pure Java client could be packaged inside as a Java application to remotely
access an Empress database located somewhere on a local network or on the
Internet.

Figure 2:
Empress JDBC Client Accesses Empress Database on the Remote Location
The second way is described in Figure 3. The Empress JDBC
local access Java client could be packaged inside as a Java application to
access an Empress database locally on the same device where the database is
located.

Figure 3:
Empress JDBC Client Accesses Empress Database on the Local Device
The third way is described in Figure 4. An Embedded
developer can utilize different Empress APIs (such as ODBC or mr Kernel Level
C/C++ API) to develop their application that could access Empress databases
locally.

Figure 4:
Empress Database on the Local Device
Figure 5 shows how each method can be used concurrently. The
diagrams from Figure 2, 3 & 4 show scenarios of Empress usage and Figure 5
shows that those scenarios can all be used at the same time.

Figure 5: How
Everything Fits Together
In the following text we will describe how the actual port
on the specific device, in this case a Nexus One phone, was done with Empress.
Porting Empress Database to Nexus One Phone
In the past the Android platform has been used for several
phones including the initial HTC phone, a developer platform from HTC, the
Motorola Droid and now the Google Nexus One as manufactured by HTC for Google.
Since the Google Nexus One implemented the 2.1 version of
the Android SDK and it was the only phone from Google, it seemed like the
perfect candidate for porting Empress to it. Google had also just released the
SDK for the Nexus One as well.
Getting The Phone
The Nexus One is available from T-Mobile in the USA as a
locked phone, or from Google on-line as either a locked phone for T-Mobile or
as an unlocked phone with no carrier.
The unlocked phone was selected for porting as it is the most flexible
version available. The phone was ordered through Google on-line and had free
next day FedEx shipping bundled into the price. It arrived the next day as
promised.
The Nexus One and T-Mobile were also encountering some
usability problems with the T-Mobile network at the time, so phone orders from
Google were not as high as expected and consequently there was enough stock for
same day processing.
Setting Up The Phone
The Nexus One came with a 4GB micro SD card but no SIM card.
The battery needed to be charged before operation and that took about two
hours. Once the phone was charged, it was setup by entering a Gmail account and
configured for the local Wireless Network (WiFi). At this point, there was no
telephone service but the Nexus One could surf the web and run applications. A
SIM card was later acquired and installed in the phone to allow phone calls and
data access.
Setting Up The SDK Development Environment
The Android 2.1 Software Development Kit (SDK) allows
developers to create Java programs that can be run on an unmodified Nexus One.
Android also supplies a number of Java APIs that can be called. In addition,
developers can add in their own Java libraries. Internally, Android runs the
Dalvik Virtual Machine (VM), so that the SDK converts Java programs and
libraries to Dalvik Byte Code for execution on the Android runtime Dalvik VM.
This has the side effect of Google not needing to pay royalties to Sun
Microsystems for Java usage, since Android executes a Dalvik VM, not a Java VM.
The code is supposed to be more compact as well.
The Android SDK can be run on Linux, Windows and Mac. The
SDK was installed on Windows XP, Ubuntu 9 and Red Hat Enterprise Linux 5.4. An
emulator for the Android environment was included in the package (see Figure
6).
Figure 6:
Android Emulator
After the installation and setup, Eclipse was also
downloaded to allow for a GUI based development environment. The SDK and
emulator ran slower on Linux than Windows, so the Windows environment was
mainly used. There was also a command line interface that could run with the
emulator or the actual device that allowed execution of certain Linux commands
if they were not blocked by restrictive permissions. Thus commands such as “ls
–l”, “mount” or “cd” were unrestricted, but commands such as “su” were
restricted.
Setting Up The NDK Development Environment
The Android 1.6 Native Development Kit (NDK) allows
developers to create Java programs that interface to C or C++ libraries using
JNI wrappers, which are compatible with the SDK environment. This allows
developers to use C programs within Java.
The Android NDK was also installed on Linux and Windows, but
mainly used on Windows alongside the SDK.
Setting Up An EABI Development Environment
Ubuntu 7, 8 and 9 were set up for an EABI Development
Environment. The base OMAP-ZOOM EABI for the Access Linux Platform (ALP) has
options for running on the Android EABI including building kernels, root file
systems, programs and utilities written in C. Google is known to be slow in posting
updated versions of the Android kernel, device drivers and utilities on the
web, so the latest updates were not available from Google.
At the first stage of the port, our goal was to do as much
as possible without having to “root” the phone or modify the image. In many
ways, the Nexus One phone environment was more restrictive than Windows CE
installed on an embedded device. With Windows CE, programming is in C and has
many more system calls available. The Nexus One has been strongly restricted in
terms of adding pure C programs. As
well, dangerous system calls were not available.
Porting Empress Java to the Nexus One
The Nexus One phone was connected to the Windows SDK/NDK
development environment by USB cable. ConnectBot, which provides “ssh” and a local
command line window, was downloaded from the Google Applications store in case
it was needed.
The Eclipse GUI was then used to write a simple “Hello
World” program in Java. While the Nexus One was plugged in via USB connection,
Eclipse could actively debug and/or run a program on the phone or the Android
emulator. The Android SDK website provided information on the Java methods that
were available for the “Hello World” program. The “Hello World” program did not
have a “main”, but interfaced to a running thread on Android. The program not
only ran, but a copy was automatically downloaded and installed onto the
device. This created some conflicts with the next iteration of the “Hello
World” program and the program that had been downloaded to the device had to be
removed using Settings->Applications->Manage Applications. Eventually the
“Hello World” program and its automatic downloads were operating properly
without side effects.
Once the “Hello World” was finished, an investigation showed
that Java SQL methods were available. One of the Eclipse menus allowed
unchanged Empress Java methods to be included in a Java program build. Java
Code was written and successfully compiled as an Empress Client on the Nexus
One (see Figure 2). One of the early problems was that the Java program did not
allow access to the network. An XML file was edited to allow network access
privileges and the program proceeded to the next problem – timeout on accessing
the server. This was solved by configuring the phone’s WiFi and VPN
capabilities.
Now the program could “create tables”, “insert”, “select”,
“update” and “delete” data in a database.
After working through a number of operational requirements and dealing
with some minor coding differences, the Empress Java Client application was
complete.
After this exercise many other applications (in the .apk
format) were implemented that show Empress usage that fit other ways of usage
(see Figure 3, 4 and 5). These applications were run on both the Android
Emulator and the Nexus One.

Figure 7:
Empress running on Android Emulator
In Conclusion
The Android platform gives an excellent vehicle to embedded
developers to build embedded mobile applications. As a platform Android has
been extended to other embedded devices.
Those “smarter” embedded devices that deal with richer and larger
amounts of data would require a more sophisticated database technology than
SQLite, which is a storage mechanism provided in the Android software
stack. Empress Embedded Database can
provide this more sophisticated Technology.
Google Android and
Empress Database Technology
can be essential components
for making smart embedded devices do what they should.
Empress Software Inc.
www.empress.com
|