OMS7-N: Introduce the OverlayManagerService [2/11]

Add a new system service to manage Runtime Resource Overlays. This will
offload the PackageManagerService and allow administration of overlay
packages while affected packages continue to execute.

Overlays can be enabled or disabled during runtime. To the running
application the change is invisible. Technically, the overlay is added
or removed from the running application similarly to how multi-window
affects resources.

Before an overlay can be enabled it has to be approved. This happens
during package installation or upgrade and if an error occurs, the
overlay is marked as not approved.

The system performs the following security checks, in
the order listed, to determine if an overlay can be approved:

  1. Is the overlay package pre-installed? If yes, OK to use.

  2. Are the target and overlay packages signed with the same
     certificate? If yes, OK to use.

  3. Is the overlay dangerous? If no, OK to use.

An overlay is said to be dangerous if it modifies resources not
explicitly specified by the target as OK to overlay. (This is done by
adding <overlay type="..." name="..."/> tags to the target's resources.)

The decision to approve/not approve an overlay is not re-evaluated until
the next time either the overlay or its target package is changed.

The order in which a set of overlays is loaded may also be changed
during runtime. The underlying mechanics are the same as for when an
overlay is enabled or disabled.

When an overlay changes state, e.g. becomes enabled, the
OverlayManagerService will broadcast one of the new intents
android.intent.action.OVERLAY_ADDED, *_CHANGED, *_REMOVED or
*.OVERLAYS_REORDERED.

Clients that wish to read information about overlays for users other
than themselves are required to hold the
android.permission.INTERACT_ACROSS_USERS_FULL permission. This mirrors
the protection level of PackageManager.getPackageInfo.

Clients that wish to change the information are required to
hold the permission android.permission.CHANGE_CONFIGURATION.

Each pair of overlay package and corresponding target package is
respresented by a new OverlayInfo class. This class mirrors the
existing PackageInfo class.

Overlay packages are handled per Android user. The data is persisted in
/data/system/overlays.xml.

Change-Id: Icc3c7daa25345d20bc5014b865024422eab72f5b
14 files changed