Vous êtes sur la page 1sur 10

Android Applications Coexistence with Another platform White paper

Android Applications Coexistence with Another platform


White paper

Abstract
This paper describes the different approaches to run an Android Application on Another platform OS. We discuss android stack and different components and runtime requirements to run an android application. This paper also gives idea about solution and ideas under development. A sample execution process explains about probable way about how an android application can execute on another platform.

Parveen Jain Contact

Android Applications Coexistence with Another platform White paper

Contents
1. 2. 3. 4. 5. Introduction Android Architecture Co-existence Approach Conclusion Reference

Figures
Figure 1 : Android Stack Architecture 3 Figure 2 : Android Runtime Environment 4 Figure 3 : Android Application building blocks 4 Figure 4 : Possible Customization in Android Runtime Environment 5 Figure 5 : Android Application Framework Abstraction 6 Figure 6 : Android Libraries Abstraction Approach 7

Android Applications Coexistence with Another platform White paper

1. Introduction
During the past few years, there is a steep rise in the application development for mobile devices based on different Mobile Platforms like Apples iPhone, Microsofts Windows Mobile/Phone, BlackBerry, Palms WebOS, and Googles Android OS. This gives lots of choices to users while purchasing a new Smartphone i.e. phone model and platform. Unfortunately, picking the phone inherently means users dont have a choice in the OS it uses as they come pre-loaded. This problem could be solved if it is possible to run a mobile application written for one platform to any other platform. This document explores different possibilities to run an application developed for Android on any another platform (could be Linux flavor like MeeGo or Windows or other). This document covers brief about Android Architecture, Some possible Coexistence Approaches and refer some other under development solutions.

2. Android Architecture
Why Android based Application? There are some of the following reasons Android as a platform has a rich ecosystem of downloadable applications, leveraging it would offer to OEMs an economical way to populate their application stores and provide Application interoperability across different Platform. Android as an embedded operating system is not limited for mobile devices; it is actually more than that like it used in Automobile, Tablet PC, Cameras, Setup box and other embedded devices. Android is an open source platform so the costs of designing the android application are drastically reduced. It is not a Linux OS, but it use basic Linux kernel for basic OS operation and enhance this kernel for its own use. Android OS is more of an open-source software stack for embedded devices that include an operating system, middleware and some key Java applications that are essential and common while running on a Java-based, object-oriented application framework on top of Java core libraries running on a Dalvik virtual machine. Android Applications are different than standard mobile applications in two major ways. 1. By Default installed Android application (packaged as an Apk) runs in its own Linux process, has its own Dalvik VM instance and is assigned a unique user ID. There exists 1 thread per process, called as main thread. The main thread has a Looper instance to handle the messages from the message queue. It pops off the messages from message queue and invokes the corresponding methods to handle it. 2. Android application life cycle is managed by the Android Framework.

2.1 Architecture
Five major components constitute the Android system from the lowest level (closest to hardware) to highest level (closest to the user). They are - Linux kernel, Android Runtime, Libraries, Application Framework, and Applications. Figure 1 shows the Android system stack.

Android Applications Coexistence with Another platform White paper

Figure 1 : Android Stack Architecture [Source: http://developer.android.com/guide/basics/what-is-android.html]

2.1.1 Applications
Applications run on top of application framework. Android applications are a set of Developer made applications and core applications (shipped with Android including an email client, SMS program, calendar and others) written in Java programming language.

2.1.2 Application Framework


Application framework is the management layer in Android. It provides a set of basic tools and APIs with which a developer can build much more complex tools and Applications. The application framework consists of a set of managers like Activity manage Window manager Content providers: View system Resource manager Notication manager etc.

2.1.3 Libraries
A set of core C/C++ libraries used by various components of the Android system and Framework. Libraries can be considered as a set of instructions that tell the device how to handle different kinds of data. These libraries are not directly exposed to developer.

2.1.4 Android Runtime


Core Java libraries: These libraries provide most of the functionalities available in the core libraries of the Java programming language. 3

Android Applications Coexistence with Another platform White paper

Dalvik virtual machine: Dalvik VM is software applications that behaves as if it is an independent device with its own operating system and provide a virtualization layer that interprets the applications written in Java. Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. It is Similar to JVM but is an optimized version of the same. It has following properties. An interpreter-only register-based virtual machine Designed to allow multiple instances to run at once Relying on underlying OS for process isolation, threading support and low-level memory management. Execute Dalvik Executable (.dex) format which are converted at compile time from standard class and jar files and will zipped into Android package (APK)

2.1.5 Linux Kernel


Linux Kernel Android is built on top of Linux operating system version 2.6 which acts as an abstraction layer between the hardware and the rest of the software stack. It offers all the basic system services like security, memory management, process management, network stack and driver model.

2.2 Android Application Building block and Run time


Application Runtime
To run Android application following are components are required: Virtual Machine: It provides the Sand Box runtime environment to an Application. Application: Android Application is packaged as APK contains dex, res etc. Launcher: This application will launch Android application and associate it with Virtual Machine. Android Framework managers & Services: It is requiring running and managing android application lifecycle. These manager and services are distributed among Android Application Framework, Core libraries and Linux kernel patches

Launcher

Android Execution

Runtime Environment
Dalvik VM

Android Framework JNI Android Core Libs Linux OS Figure 2 : Android Runtime Environment

Application building block


Activity Intent Receiver UI Component typically corresponding to one screen Set and respond to notifications or status change. Can wakeup or initiate Application. Service Content Provider UI Less task ran in background. Enable application to share Data Content Provider Services Figure 3 : Android Application building blocks
Activity 1

APK Process
Activity 2 Activity n

Android Applications Coexistence with Another platform White paper

3. Co-existence Approach
Since Android Application runs in its Android runtime environment which is tightly coupled with Android stack then how could non-Android device run application made specifically for Google's Android platform? So to run Android app on other platform we have following choices - Either Re-write the app according to target platform or some common app platform like HTML5, 3 rd party platform like PhoneGAP etc. But this is not coexistence. - Or Devoid Android runtime environment from Android Stack. This can be achieved by replacing maximum runtime components (Servers, managers and services) with target Platform one or some Platform independent ones. Android is not a application framework but it is a full-blown operating system and all apps that run on Android phones or tablets run in a virtual machine (VM), called Dalvik. So if we can recreate that emulation environment on another OS, the apps should run as normal and without any kind of performance hit to the apps operation. The solution is much like the Java Virtual Machine on a desktop. It brings greater security because apps in a VM are essentially walled off from other applications and from the device's Operating System. When the app in a VM crashes, it has no effect on other applications or on the Operating System, ensuring stability. Also replace maximum runtime components (Servers, managers and services) with target Platform one or some Platform independent ones.
Android Execution

Application Process Runtime Environment Base OS Core Libs


VM

Application

J N

Customized Manager and services

Launcher

Application Framework

Linux iOS Window etc

Figure 4 : Possible Customization in Android Runtime Environment Following section explains the about some possible customizations in the Android runtime Environment components 1. Virtual Machine: Since android application runs in Sand Box environment and this environment can be provided by some Virtual machine it could be Standard JVM or Dalvik VM or some other customized form of Dalvik VM (decoupled Dalvik from Android Stack).
[Typically JVM is used for desktop not for embedded device because it is not optimized to support embedded system. While Android Dalvik VM is well optimized for embedded device but it is tightly coupled with android stack. So there shall be a need to make DVM independent of android stack.]

2. Launcher: a launcher application needs to be developed to parse and launch the Android application APK/JAR and associate it with VM(JVM or DVM or etc)

Android Applications Coexistence with Another platform White paper

3. Application: To run android application in VM, either directly running the Android Application APK file or converting Android application package file into some other form that will be easily understand by the target VM environment like convert into a JAR file and then running JAR on JVM. 4. Android Framework Mangers/Services: It is requiring run and manage android application lifecycle. Android application developed using this framework API so Framework cannot be 100% replaced. Here are two possibilities Either Port complete Framework on the target OS Or make a wrapper of Android application framework which internally uses native OS application framework so that Android application can be run without any code modification. 5. JNI abstraction: This layer is required to call or interaction of JAVA code with modules written in core C/C++ languages.

Android Native libraries and services : The core services used by the android framework to
provide necessary feature to execute an application. These core services are written in C/C++ languages and directly interact with underlying core OS. Here we have choice to replace maximum services by the services which are independent of Android Stack. Some candidate service are like BIONIC, HAL Hardware Abstraction layer, Webkit, Media Framework, SQLite, SGL (SKIA Graphics lib)

6. OS Kernel and Extensions: Following Kernel extensions are important because Application framework
and core manager and services depend on them. a. Binder: Binder driver facilitates inter-process communication and data sharing between applications and services through the use of shared memory. Either we can port the same Driver to Target OS or write a new with same interface which will use native IPC mechanism. b. Power Management: Android has its own power management but application should use the native platform power policies.

3.1 Approaches
Following are the two possible approaches based on above discussion

A. Android Framework Abstraction


In this replace android application framework with native application framework. This will achieve by abstracting Android Framework so that this abstraction diverts calls to native application framework calls. Abstraction would be done at Android Application framework level. As explain in fig Android application run in VM environment and calls android APK while android APIs internally diverted to native framework. In this approach android application running on another OS seems as native to target OS. Android Application (JAR) Runtime Environment
JVM

Android Framework Abstraction JNI Native core application Framework


[QT/GTK/Open Source/WinAPI etc]

Native libraries and services Core OS (Linux/Win/IOS etc)

Figure 5 : Android Application Framework Abstraction 6

Android Applications Coexistence with Another platform White paper

B. Android Libraries Abstraction


In this approach android framework and supported framework services remain as such and replace android core libraries with native one as much as possible. This would be achieved by writing JNI abstraction so that Framework services use native core libraries as much as possible. Abstraction would be done at Android Core libraries. As explain in fig Android application run in VM environment with full android framework runtime. This framework will use both android and native core libraries to reduce the footprint as much as possible. Maintenance could be high in this approach Android Application (JAR/Dex) Runtime Environment JVM/DVM/customized DVM Android Application Framework and services JNI Android libraries Native core libraries [QT / GTK / Open Source / and services WinAPI etc] Core OS (Linux)

Figure 6 : Android Libraries Abstraction Approach

3.2 Sample Execution Process


Android RTE [ARTE]: Java application native to Target OS (for example MeeGo) execute in its VM JVM. 1. Singleton Application and provides Android RTE to Android Application. 2. Provide functionality to install android app on MeeGo. 3. When First Time execute, it will initialize all required services and manager in a similar way and structure to Android. This can be done at MeeGo Boot Time or mix need to think. 4. After initialization this app displays a screen which display all installed android applications. Android Application is a bundle of some related Activities with One activity configured as First/Start Activity. 5. Now user can execute any application. 6. Android application will execute in same JVM instance as some sub activity of ARTE. 7. Here user has no choice to move to main ATRE screen from android app with some Home H/W key. Home Key invoke MeeGo Home screen. 8. Because all short keys or H/W key as specific to Native OS i.e. MeeGo. 9. On close Android app, control move to ARTE main screen display all installed Android Apps. 10. On close of ARTE, control display last screen of MeeGo. ARTE will not close, this will execute as background process in idle stage. 11. When user click on ATRE on MeeGo Home screen. If it is First time (or Android RTE is corrupted) then execute 4. If not then last screen Main screen or any Android Activity last stage

Android Applications Coexistence with Another platform White paper

3.3 Limitations
Android Architectural limitations: Android tight coupling with Linux kernel patches like Binder, Power Mgmt etc. Applications should follow target OS power mgmt policies. Dalvik Virtual machine and Android stack are tightly coupled with each other. Native code written in C/C++ dependent on Bionic is tightly coupled with it Final APIs/features support will depend on the integration of Android framework and core service with native OS. As Android RTE will use native libraries and services, some of the Android APIs may not be supported and it may have impact on some specific features like UXD experience, UXD experience may little different on another Platform as compare to Android Platform. It may possible, only one android app will execute at a time. Workaround could be running android app in Dalvik VM which will in turn execute within JVM. This make more than one android apps will execute but I guess it make significant performance hit Quite possible, android application (APK) may not run directly on the target platform. It may require repackaging the existing android APK to some other form depending on the target VM environment like JAR. Permission to Google market support.

3.4SOME OTHER APPROACHES


A. Virtualization Approaches
Virtualization is a technology that enables multiple operating systems or virtual machines to run simultaneously on a mobile phone by dividing the resources of a computer into multiple execution environments. It uses a hypervisor to create secure separation between the underlying hardware and the software that runs on top of it. The actual machine on which the virtualization takes place is referred as Host Machine and guest machine is refers to the virtual machine. Virtualization technology has been used widely for many years in other fields such as data servers (storage virtualization) and personal computers (desktop virtualization).

Emulation: Emulation is another kind of virtualization technology in which complete hardware architecture is
virtualized and will be created as a software component. This software will replace the functionality of a designated hardware processor and associated hardware systems. In this the guest OS may not have to be modified to run on an incompatible architecture. For example Android Device emulator comes as a part of the Android SDK.

B. RIM-Blackberry Playbook
RIM also support Android Applications on its upcoming QNX-based Playbook tablet with certain limitations. App Player: RIM will launch an optional "app player" that provide an application run-time environment for Android v2.3 apps. This new app player will allow users to download Android apps from BlackBerry App World and run them on their BlackBerry Playbook. This will be placed in a secure "sandbox" on the BlackBerry Playbook where the Android apps can be run. Android Apps: Android apps will not ran directly, some changes are required to make it run on Blackberry. Following the changes and steps required to make android app to compatible on blackberry. Repackaging Code signing Submit it to the BlackBerry App World Approved Distributed through BlackBerry App World.

Android Applications Coexistence with Another platform White paper

C. Alien Dalvik
Myriad Alien Dalvik brings Android applications to non-Android devices, allowing OEMs, operators and application stores to leverage the Android eco-system across a much wider range of mobile devices. Following are the possible major components of the solution: Repackage: Android application need to be repackaged with Alien sdk. This repackaged Application will install on MeeGo device from OEM/Operator/3rd Party Apps Store. Re-Write: Applications which are device-dependent or do need to be modified then re-write the application natively for MeeGo with Alien SDK. Alien Dalvik runtime: This will provide runtime environment for an Android repackaged application to execute on MeeGo. This has been made possible through a very tight integration of the Android runtime and the use of Myriad Dalvik Turbo technology. Runtime alien Dalvik can be pre-installed or automatically downloaded with the first Android application.

4. Conclusion
As we discussed in the paper, technically it is possible to develop runtime environment to run an Android application on a device running on another OS. For this we have to develop or customize interpreter like JVM/DVM and use native OS services as much as possible. One more possibilities we use some standard open source services and bundle them in a single package so that it work on most of the platform OS available. It is clear that with any approach there are some limitation associated with it like development time, maintenance effort and frequency due to rapid change technology. Also there is need to modify Android application package according to our approach like convert it into JAR or any custom format so that developed runtime can understand it. This paper also briefly explore possible approach used by some different under development project going on.

5. Reference
Android developer guide <http://developer.android.com/guide/index.html> Alien Dalvik Solution <http://www.myriadgroup.com/Device-Manufacturers/Android-solutions/Alien-Dalvik.aspx> Mariad Alien Dalvik Demo <http://www.youtube.com/watch?v=mXWEyKjwk2g> Google Project <http://code.google.com/p/android-dalvik-vm-on-java> Goggle Projects: <http://code.google.com/p/android-dalvik-vm-on-java>, <http://code.google.com/p/dvk/> Ubuntu wiki <https://wiki.ubuntu.com/Specs/AndroidExecutionEnvironment> [7] IcedRobot <http://www.icedrobot.org >
[1] [2] [3] [4] [5] [6]

Vous aimerez peut-être aussi