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
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java
index daec1721..13572fb 100644
--- a/core/java/android/os/Process.java
+++ b/core/java/android/os/Process.java
@@ -832,10 +832,16 @@
/**
* 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 @@
* {@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 @@
* 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 @@
* @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 @@
/**
* 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 @@
@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 @@
/**
* 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 @@
*/
@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 @@
*/
@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 @@
*/
@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 @@
/**
* Returns whether the current process is a sdk sandbox process.
*/
+ @android.ravenwood.annotation.RavenwoodKeep
public static final boolean isSdkSandbox() {
return isSdkSandboxUid(myUid());
}
diff --git a/core/java/android/os/UserHandle.java b/core/java/android/os/UserHandle.java
index cac7f3b..0644ef1 100644
--- a/core/java/android/os/UserHandle.java
+++ b/core/java/android/os/UserHandle.java
@@ -36,6 +36,7 @@
/**
* 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
diff --git a/ravenwood/ravenwood-annotation-allowed-classes.txt b/ravenwood/ravenwood-annotation-allowed-classes.txt
index 776a19a..930dfc9 100644
--- a/ravenwood/ravenwood-annotation-allowed-classes.txt
+++ b/ravenwood/ravenwood-annotation-allowed-classes.txt
@@ -7,3 +7,4 @@
android.os.IBinder
android.os.Process
android.os.SystemClock
+android.os.UserHandle