Application Lifecycle: OverviewApplication ManagerThe Application Manager controls application lifetime and execution. This is the component that is responsible for maintaining the simple application task model that users expect on a phone. The application manager starts and stops applications as appropriate, ensures that the current running application controls the main display, maintains a running list of applications, places applications in the background, and prevents multiple launches of a single application.
The Application Manager will run in its own process. Applications will run in their own processes and control their own UI. This simple mapping of applications to processes provides a secure, stable model for application execution. To maximize utility on small screen form factors, we will preserve the standard Palm OS behavior of having one main UI application at a time, with that application having drawing control of the main panel of the screen (exclusive of status bars, etc.) When the user runs a new application, the system will generally ask the current one to exit (although there is a facility for applications which need to continue execution in the background). Also, as in old Palm OS and desktop operating systems like Mac OS, we will only support running a single simultaneous instance of any given application. Detailed documentation on the Attention Manager can be found here. How Applications Get InstalledApplications are packaged in a format called a bundle. A bundle is a collection of files stored in a cramfs disk image (similar to a .iso or a Mac TM .dmg file), and usually cryptographically signed. A bundle always contains a file called "Manifest.xml". That file contains meta information about the rest of the bundle: what it is, default settings, preferences, etc. All applications are packaged as bundles, but things that are not applications (like data) can also be packaged as bundles. By wrapping an entire application as a bundle, users and programs can deal with arbitrarilycomplicated things as a single file. Bundles have the extension ".bar" (for "bundle archive"). An application is linked as a dynamic library (by using the "shared" option to gcc), with the entry point "alp_main()" instead of the conventional main(). You can see a sample"hello world" application in directory hiker/main/samples. You can see the linker options used in the Makefile in the same directory. Bundle ManagerThe Hiker component that processes bundles is Bundle Manager. Bundle Manager is responsible for controlling how applications, and supplemental data for applications (libraries, resources, etc.), are loaded onto an ALP system, manipulated, transmitted off to other systems, and removed. In a real system, new applications will appear on the device through the Exchange The Bundle Manager is the sole way in which third-party applications are distributed and loaded onto a device. Applications are allowed to read the files in their bundles directly, via the POSIX file i/o routines. Apart from that, the Bundle Manager server is the only software that can access the bundle folders on the internal filesystem. Users have to interact with Bundle Manager to install or remove software, and that software must be in bundle form. The Bundle Manager is designed around the notion of 'Bundles' as concrete immutable lumps of information which are managed on a device, where each Bundle can contain an arbitrary amount of data in a format appropriate to that Bundle. Each Bundle type is defined both in terms of how it is stored on the device, and as a "flattened" format suitable for transmission as a stream out of the device. (These formats may be the same, different, or overlap at various times). The Bundle Manager combines a file format for distributing single files that contain applications and all their dependencies (application name, icon, localized resources, dependant libraries, etc) along with functions for installing, removing, and enumerating application “bundles”. The Bundle Manager takes care of allocation of per-application storage locations in writeable storage in the file system, and providing access to localized resources contained within the bundle. Through the Bundle Manager enumeration mechanism, multiple application types are merged and can be launched through a common mechanism. We would include the SDK tool that is necessary to create application bundles from a set of files. Although binary executables could be loaded onto a device through other means (say, an FTP client dumping a file to the /tmp folder), the launcher and other system components would not provide any UI to launch that executable, nor provide any means to execute it with other than the most restricted permissions. Bundle Manager also supports:
Application helper routines to retrieve localized icons and names for an app in a Since it is a GUI component, and Hiker is GUI-neutral,
Launcher is not part of this Detailed documentation on the Bundle Manager can be found here. Starting and Stopping ApplicationsFrom experience with PalmOS we conclude that handheld devices work best when apps don't try to share the limited screen space. Only one app will use the GUI at a time. Furthermore, you almost never exit an application explicitly. Typically, you start another application (by pressing the home key or the launch button, etc). The Application Server component then ends the current application for you, and starts the new application in its place. There are no application buttons in our sample code, so instead we explicitly ask the The Application ServerThe application server or "appserver" is a Linux daemon that starts when the system
You can review the public API for the appserver here. You will see routines like alp_status_t alp_app_launch
That routine tells the application server to tell the native process launcher to start the the stated application. Note: Bundles used to be called "packages" and some of the header file names still reflect that. NLPDWe want applications to start as quickly as possible, and we structured the launch code in
an unusual way to achieve this.
The largest part of application start up time is consumed in the runtime
linker. The runtime
linker gets the shared libraries ready to run and initializes all of the global variables.
Most application code (on handheld devices) uses a small number of the same shared
libraries. We reduce startup When nlpd receives the "launch" order from the application server, it forks a copy of This performance optimization requires an application to be a shared library, so it can be
loaded into the address space using dlopen. You can see the code in file g_closure_invoke(ptr, &return_value, 3, params, NULL); g_closure is a routine in glib that abstracts dlopen. nlpd sets the current working directory to the directory where the bundle is stored. The application can thus retrieve files, e.g. icons, stored in its bundle. Nlpd also makes some security- and identity-related settings. Because it is the general template for starting a new application process, nlpd is also called the "cookie cutter". See here for additional details on the application lifecycle components. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Copyright © 2007, The Hiker Project. All rights reserved. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||