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

Commit 9e4b2c12 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

More android.os work for Ravenwood, with CTS.

Bring along simple UID math utility methods, and the ability to
detect 32-vs-64-bit environments.

Bug: 292141694
Test: atest-dev CtsOsTestCasesRavenwood CtsOsTestCases
Change-Id: I5f3841dbe5cae703facc9020ba8c5405aa3ebcae
parent b641d53b
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -832,10 +832,16 @@ public class Process {
    /**
     * Returns true if the current process is a 64-bit runtime.
     */
    @android.ravenwood.annotation.RavenwoodReplace
    public static final boolean is64Bit() {
        return VMRuntime.getRuntime().is64Bit();
    }

    /** @hide */
    public static final boolean is64Bit$ravenwood() {
        return "amd64".equals(System.getProperty("os.arch"));
    }

    private static SomeArgs sIdentity$ravenwood;

    /** @hide */
@@ -906,6 +912,7 @@ public class Process {
     * {@link #myUid()} in that a particular user will have multiple
     * distinct apps running under it each with their own uid.
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static UserHandle myUserHandle() {
        return UserHandle.of(UserHandle.getUserId(myUid()));
    }
@@ -914,6 +921,7 @@ public class Process {
     * Returns whether the given uid belongs to a system core component or not.
     * @hide
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static boolean isCoreUid(int uid) {
        return UserHandle.isCore(uid);
    }
@@ -924,6 +932,7 @@ public class Process {
     * @return Whether the uid corresponds to an application sandbox running in
     *     a specific user.
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static boolean isApplicationUid(int uid) {
        return UserHandle.isApp(uid);
    }
@@ -931,6 +940,7 @@ public class Process {
    /**
     * Returns whether the current process is in an isolated sandbox.
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static final boolean isIsolated() {
        return isIsolated(myUid());
    }
@@ -942,6 +952,7 @@ public class Process {
    @Deprecated
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.TIRAMISU,
            publicAlternatives = "Use {@link #isIsolatedUid(int)} instead.")
    @android.ravenwood.annotation.RavenwoodKeep
    public static final boolean isIsolated(int uid) {
        return isIsolatedUid(uid);
    }
@@ -949,6 +960,7 @@ public class Process {
    /**
     * Returns whether the process with the given {@code uid} is an isolated sandbox.
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static final boolean isIsolatedUid(int uid) {
        uid = UserHandle.getAppId(uid);
        return (uid >= FIRST_ISOLATED_UID && uid <= LAST_ISOLATED_UID)
@@ -962,6 +974,7 @@ public class Process {
     */
    @SystemApi(client = MODULE_LIBRARIES)
    @TestApi
    @android.ravenwood.annotation.RavenwoodKeep
    public static final boolean isSdkSandboxUid(int uid) {
        uid = UserHandle.getAppId(uid);
        return (uid >= FIRST_SDK_SANDBOX_UID && uid <= LAST_SDK_SANDBOX_UID);
@@ -975,6 +988,7 @@ public class Process {
     */
    @SystemApi(client = MODULE_LIBRARIES)
    @TestApi
    @android.ravenwood.annotation.RavenwoodKeep
    public static final int getAppUidForSdkSandboxUid(int uid) {
        return uid - (FIRST_SDK_SANDBOX_UID - FIRST_APPLICATION_UID);
    }
@@ -987,6 +1001,7 @@ public class Process {
     */
    @SystemApi(client = MODULE_LIBRARIES)
    @TestApi
    @android.ravenwood.annotation.RavenwoodKeep
    public static final int toSdkSandboxUid(int uid) {
        return uid + (FIRST_SDK_SANDBOX_UID - FIRST_APPLICATION_UID);
    }
@@ -994,6 +1009,7 @@ public class Process {
    /**
     * Returns whether the current process is a sdk sandbox process.
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static final boolean isSdkSandbox() {
        return isSdkSandboxUid(myUid());
    }
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import java.util.Random;
/**
 * Representation of a user on the device.
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public final class UserHandle implements Parcelable {
    // NOTE: keep logic in sync with system/core/libcutils/multiuser.c

+1 −0
Original line number Diff line number Diff line
@@ -7,3 +7,4 @@ android.os.Binder$IdentitySupplier
android.os.IBinder
android.os.Process
android.os.SystemClock
android.os.UserHandle