Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b9a8666e authored by Robert Sesek's avatar Robert Sesek
Browse files

Add external services, a way to run isolated processes as a different package.

This adds android:externalService boolean attribute to <service>. If that
attribute is true, then bindService() may be called with
BIND_EXTERNAL_SERVICE to create the new service process under the calling
package's name and uid. The service will execute the code from the package in
which it is declared, but will appear to run as the calling application.

External services may only be used if android:exported="false" and
android:isolatedProcess="true".

Bug: 22084679
Bug: 21643067
Change-Id: I3c3a5f0ef58738316c5efeab9044e43e09220d01
parent 6ec7ed2f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -328,6 +328,15 @@ public abstract class Context {
     */
    public static final int BIND_NOT_VISIBLE = 0x40000000;

    /**
     * Flag for {@link #bindService}: The service being bound is an
     * {@link android.R.attr#isolatedProcess isolated},
     * {@link android.R.attr#externalService external} service.  This binds the service into the
     * calling application's package, rather than the package in which the service is declared.
     * @hide
     */
    public static final int BIND_EXTERNAL_SERVICE = 0x80000000;

    /**
     * Returns an AssetManager instance for the application's package.
     * <p>
+5 −0
Original line number Diff line number Diff line
@@ -3885,6 +3885,11 @@ public class PackageParser {
                false)) {
            s.info.flags |= ServiceInfo.FLAG_ISOLATED_PROCESS;
        }
        if (sa.getBoolean(
                com.android.internal.R.styleable.AndroidManifestService_externalService,
                false)) {
            s.info.flags |= ServiceInfo.FLAG_EXTERNAL_SERVICE;
        }
        if (sa.getBoolean(
                com.android.internal.R.styleable.AndroidManifestService_singleUser,
                false)) {
+8 −0
Original line number Diff line number Diff line
@@ -48,6 +48,14 @@ public class ServiceInfo extends ComponentInfo
     */
    public static final int FLAG_ISOLATED_PROCESS = 0x0002;

    /**
     * Bit in {@link #flags}: If set, the service can be bound and run in the
     * calling application's package, rather than the package in which it is
     * declared.  Set from {@link android.R.attr#externalService} attribute.
     * @hide
     */
    public static final int FLAG_EXTERNAL_SERVICE = 0x0004;

    /**
     * Bit in {@link #flags}: If set, a single instance of the service will
     * run for all users on the device.  Set from the
+4 −0
Original line number Diff line number Diff line
@@ -1748,6 +1748,10 @@
        <attr name="isolatedProcess" format="boolean" />
        <attr name="singleUser" />
        <attr name="encryptionAware" />
        <!-- @hide If the service is an {@link #isolatedProcess} service, this permits a client to
             bind to the service as if it were running it its own package.  The service must also be
             {@link #exported} if this flag is set. -->
        <attr name="externalService" format="boolean" />
    </declare-styleable>

    <!-- The <code>receiver</code> tag declares an
+1 −0
Original line number Diff line number Diff line
@@ -2689,6 +2689,7 @@
    <public type="attr" name="tickMarkTint" />
    <public type="attr" name="tickMarkTintMode" />
    <public type="attr" name="canPerformGestures" />
    <public type="attr" name="externalService" />

    <public type="style" name="Theme.Material.Light.DialogWhenLarge.DarkActionBar" />
    <public type="style" name="Widget.Material.SeekBar.Discrete" />
Loading