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

Commit 5e8514bd authored by Martijn Coenen's avatar Martijn Coenen Committed by Automerger Merge Worker
Browse files

Merge "Add a new UID range for SDK sandbox processes." am: 7647d8cd am: 33cee096

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2019995

Change-Id: Id50b1a1853b477ada5d1f66c59894166cb5410c6
parents 254ef629 33cee096
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -30532,6 +30532,7 @@ package android.os {
    method public static final boolean is64Bit();
    method public static boolean isApplicationUid(int);
    method public static final boolean isIsolated();
    method public static final boolean isSdkSandbox();
    method public static final void killProcess(int);
    method public static final int myPid();
    method public static final int myTid();
+3 −0
Original line number Diff line number Diff line
@@ -290,6 +290,9 @@ package android.os {
  }

  public class Process {
    method public static final int getAppUidForSdkSandboxUid(int);
    method public static final boolean isSdkSandboxUid(int);
    method public static final int toSdkSandboxUid(int);
    field public static final int NFC_UID = 1027; // 0x403
    field public static final int VPN_UID = 1016; // 0x3f8
  }
+3 −0
Original line number Diff line number Diff line
@@ -1718,7 +1718,10 @@ package android.os {
  }

  public class Process {
    method public static final int getAppUidForSdkSandboxUid(int);
    method public static final int getThreadScheduler(int) throws java.lang.IllegalArgumentException;
    method public static final boolean isSdkSandboxUid(int);
    method public static final int toSdkSandboxUid(int);
    field public static final int FIRST_APP_ZYGOTE_ISOLATED_UID = 90000; // 0x15f90
    field public static final int FIRST_ISOLATED_UID = 99000; // 0x182b8
    field public static final int LAST_APP_ZYGOTE_ISOLATED_UID = 98999; // 0x182b7
+98 −35
Original line number Diff line number Diff line
@@ -276,6 +276,26 @@ public class Process {
     */
    public static final int LAST_APPLICATION_UID = 19999;

    /**
     * Defines the start of a range of UIDs going from this number to
     * {@link #LAST_SDK_SANDBOX_UID} that are reserved for assigning to
     * sdk sandbox processes. There is a 1-1 mapping between a sdk sandbox
     * process UID and the app that it belongs to, which can be computed by
     * subtracting (FIRST_SDK_SANDBOX_UID - FIRST_APPLICATION_UID) from the
     * uid of a sdk sandbox process.
     *
     * Note that there are no GIDs associated with these processes; storage
     * attribution for them will be done using project IDs.
     * @hide
     */
    public static final int FIRST_SDK_SANDBOX_UID = 20000;

    /**
     * Last UID that is used for sdk sandbox processes.
     * @hide
     */
    public static final int LAST_SDK_SANDBOX_UID = 29999;

    /**
     * First uid used for fully isolated sandboxed processes spawned from an app zygote
     * @hide
@@ -821,6 +841,49 @@ public class Process {
                || (uid >= FIRST_APP_ZYGOTE_ISOLATED_UID && uid <= LAST_APP_ZYGOTE_ISOLATED_UID);
    }

    /**
     * Returns whether the provided UID belongs to a SDK sandbox process.
     *
     * @hide
     */
    @SystemApi(client = MODULE_LIBRARIES)
    @TestApi
    public static final boolean isSdkSandboxUid(int uid) {
        uid = UserHandle.getAppId(uid);
        return (uid >= FIRST_SDK_SANDBOX_UID && uid <= LAST_SDK_SANDBOX_UID);
    }

    /**
     *
     * Returns the app process corresponding to an sdk sandbox process.
     *
     * @hide
     */
    @SystemApi(client = MODULE_LIBRARIES)
    @TestApi
    public static final int getAppUidForSdkSandboxUid(int uid) {
        return uid - (FIRST_SDK_SANDBOX_UID - FIRST_APPLICATION_UID);
    }

    /**
     *
     * Returns the sdk sandbox process corresponding to an app process.
     *
     * @hide
     */
    @SystemApi(client = MODULE_LIBRARIES)
    @TestApi
    public static final int toSdkSandboxUid(int uid) {
        return uid + (FIRST_SDK_SANDBOX_UID - FIRST_APPLICATION_UID);
    }

    /**
     * Returns whether the current process is a sdk sandbox process.
     */
    public static final boolean isSdkSandbox() {
        return isSdkSandboxUid(myUid());
    }

    /**
     * Returns the UID assigned to a particular user name, or -1 if there is
     * none.  If the given string consists of only numbers, it is converted