Merge "Make APIs related to SdkSandbox public" into main
diff --git a/core/api/current.txt b/core/api/current.txt
index df073dd..7ab234a 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -33391,6 +33391,7 @@
public class Process {
ctor public Process();
+ method public static final int getAppUidForSdkSandboxUid(int);
method public static final long getElapsedCpuTime();
method public static final int[] getExclusiveCores();
method public static final int getGidForName(String);
@@ -33405,6 +33406,7 @@
method public static final boolean isIsolated();
method public static final boolean isIsolatedUid(int);
method public static final boolean isSdkSandbox();
+ method public static final boolean isSdkSandboxUid(int);
method public static final void killProcess(int);
method public static final int myPid();
method @NonNull public static String myProcessName();
diff --git a/core/api/module-lib-current.txt b/core/api/module-lib-current.txt
index de330de..c1b9f64 100644
--- a/core/api/module-lib-current.txt
+++ b/core/api/module-lib-current.txt
@@ -395,8 +395,6 @@
}
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
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index 812ba6d..ad8b685 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -2343,9 +2343,7 @@
}
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
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java
index 80ec458..f952fcf 100644
--- a/core/java/android/os/Process.java
+++ b/core/java/android/os/Process.java
@@ -21,6 +21,7 @@
import android.annotation.ElapsedRealtimeLong;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.annotation.UptimeMillisLong;
@@ -978,12 +979,10 @@
}
/**
- * Returns whether the provided UID belongs to a SDK sandbox process.
- *
- * @hide
+ * Returns whether the provided UID belongs to an sdk sandbox process
+ * @see android.app.sdksandbox.SdkSandboxManager
*/
- @SystemApi(client = MODULE_LIBRARIES)
- @TestApi
+ @SuppressLint("UnflaggedApi") // promoting from @SystemApi.
@android.ravenwood.annotation.RavenwoodKeep
public static final boolean isSdkSandboxUid(int uid) {
uid = UserHandle.getAppId(uid);
@@ -991,15 +990,20 @@
}
/**
+ * Returns the app uid corresponding to an sdk sandbox uid.
+ * @see android.app.sdksandbox.SdkSandboxManager
*
- * Returns the app process corresponding to an sdk sandbox process.
+ * @param uid the sdk sandbox uid
+ * @return the app uid for the given sdk sandbox uid
*
- * @hide
+ * @throws IllegalArgumentException if input is not an sdk sandbox uid
*/
- @SystemApi(client = MODULE_LIBRARIES)
- @TestApi
+ @SuppressLint("UnflaggedApi") // promoting from @SystemApi.
@android.ravenwood.annotation.RavenwoodKeep
public static final int getAppUidForSdkSandboxUid(int uid) {
+ if (!isSdkSandboxUid(uid)) {
+ throw new IllegalArgumentException("Input UID is not an SDK sandbox UID");
+ }
return uid - (FIRST_SDK_SANDBOX_UID - FIRST_APPLICATION_UID);
}