Wednesday 10 July 2013

Re:[Ubuntu-phone] Making Android system properties available to Upstart

Sometimes I saw things like below in the logcat:
I/ServiceManager(  128): Waiting for service SurfaceFlinger...

If the Android services are registed in  ServiceManager, maybe we can simply ask   ServiceManager  when specific Android services are ready.

------------------ Original ------------------
From:  "James Hunt"<james.hunt@ubuntu.com>;
Date:  Thu, Jul 11, 2013 01:01 AM
To:  "ubuntu-devel"<ubuntu-devel@lists.ubuntu.com>; "ubuntu-phone@lists.launchpad.net"<ubuntu-phone@lists.launchpad.net>;
Subject:  [Ubuntu-phone] Making Android system properties available to Upstart

As already explained by Oli, the Ubuntu Touch "flipped" architecture runs the
Android services within an LXC container. This brings a number of advantages but
there is a problem: knowing when specific Android services are ready. This is
needed such that the Ubuntu Upstart jobs running on the host side can start as
soon as possible, but no sooner ;)

Currently, the approach is to use heuristics to determine the "readiness" of
the Android services, but this can be unreliable. A better solution would be to
have a way to create Upstart events on the host-side when services changes occur
in the Android environment.

The plan at this stage is to make use of Androids System Properties and create a
2-part solution:

1) Create an Upstart bridge that runs on the host.

This bridge will listen on a socket and read data in the form:

  <name>=<value>\n

This will be converted into an upstart event of the form:

  <event-name> <name>=<value>

The <event-name> will be specified as an argument to the bridge for security
reasons and would be set to something like "android-property" for Touch.

The bridge would run at the system level (as root) on the host (since it has to
start *before* the Android container, but the events it generates would be
accessible to the Session (once that has been converted to use an Upstart
Session Init) as ":sys:<event-name>" allowing Upstart jobs to specify conditions
such as:

  # run job when ueventd has started in Androids LXC container
  start on :sys:android-property init.svc.ueventd=running

2) Create an Android service that runs early in the Android boot process.

This service would:

- connect to the well-known socket the bridge is already listening on.
- monitor Androids System Properties and write them to the socket in the form:

      <name>=<value>\n

----------

Ideally, we would just have a single Upstart bridge on the host side which is
able to monitor property changes (*) without the need for "helper" processes on
the Android side.

There are a number of solutions that involve modifying Androids init, but we're
attempting to avoid doing that.

If anyone knows of a better way to solve this problem, please jump in.

Kind regards,

James.
--
James Hunt

(*) - just like 'watchprop' does in the Android environment.
____________________________________
#upstart on freenode
http://upstart.ubuntu.com/cookbook
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

--
Mailing list: https://launchpad.net/~ubuntu-phone
Post to     : ubuntu-phone@lists.launchpad.net
Unsubscribe : https://launchpad.net/~ubuntu-phone
More help   : https://help.launchpad.net/ListHelp
.