Just An Application

August 19, 2009

A Standalone Android Runtime: Binders, Processes, And User Ids

Filed under: Android, Java, Mobile Java, Standalone Android Runtime — Tags: , , , — Simon Lewis @ 8:13 pm

The Android runtime is dependent on the use of Binders (android.os.Binder) and associated classes, for example, Parcels (android.os.Parcel), for communicating between the processes comprising the runtime, and will not work at all without them.

As well as supporting the transmission of data as is usual with most forms of IPC, the Binder mechanism supports the transmission of Binders themselves between processes, as well as File descriptors, and for the equivalent of each invocation provides the process id and user id of the process from which it originates. See the android.os.Binder methods

    public static int getCallingPid()

and

    public static int getCallingUid()

respectively.

These ids are used extensively for permission checking and are an important part of the security mechanism.

The implementation of Binders, and Parcels etc., is nearly entirely native, the core of the implementation being a dedicated device driver.

Since the System Server will not start without functioning Binders however, it is necessary to come up with a substitute.

There is no exact counterpart to Binders in standard Java, but it is not difficult to transfer data between processes using pure Java. The functional equivalent of transferring Binders is also comparatively simple. The Binder and Parcel classes can then be modified to use the substitute IPC mechanism. Although initially some of the more intricate parts of the semantics are not being faithfully reproduced it is sufficient to get things going

Process and User ids are a bit more problematic. Neither of them are accessible in standard Java, after all they might not event exist depending on the underlying OS, but since we control the entire runtime environment including process creation we can mimic the Process and User ids as necessary and make them available for use by our substitute Binder mechanism.


Copyright (c) 2009 By Simon Lewis. All Rights Reserved.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: