diff options
| author | 2023-12-11 14:57:35 +0000 | |
|---|---|---|
| committer | 2023-12-11 14:57:35 +0000 | |
| commit | 28084ee553157733f4e3d10f4bf77a8798959e81 (patch) | |
| tree | 753efefeeb4464491f988daa5ac83f701a8fda15 | |
| parent | 7a85cfb8ba66c51ab05c7c498885f6bb45599bed (diff) | |
| parent | 1e0277df430b050f7e3c43a22235389cda766f0e (diff) | |
Merge "Make APIs related to SdkSandbox public" into main
| -rw-r--r-- | core/api/current.txt | 2 | ||||
| -rw-r--r-- | core/api/module-lib-current.txt | 2 | ||||
| -rw-r--r-- | core/api/test-current.txt | 2 | ||||
| -rw-r--r-- | core/java/android/os/Process.java | 22 |
4 files changed, 13 insertions, 15 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index d490c3f4d17c..3875ab514746 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -33344,6 +33344,7 @@ package android.os { 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); @@ -33358,6 +33359,7 @@ package android.os { 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 e7803fbf011d..a9064b4c8f78 100644 --- a/core/api/module-lib-current.txt +++ b/core/api/module-lib-current.txt @@ -418,8 +418,6 @@ 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 diff --git a/core/api/test-current.txt b/core/api/test-current.txt index 39f2737dc880..d1f4d142d7cc 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -2337,9 +2337,7 @@ 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 diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index 7e07e1f2e499..f99ce223154e 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -21,6 +21,7 @@ import static android.annotation.SystemApi.Client.MODULE_LIBRARIES; 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,13 +979,8 @@ 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 + /** Returns whether the provided UID belongs to an sdk_sandbox process(@see https://developer.android.com/design-for-safety/privacy-sandbox/sdk-runtime). */ + @SuppressLint("UnflaggedApi") // promoting from @SystemApi. @android.ravenwood.annotation.RavenwoodKeep public static final boolean isSdkSandboxUid(int uid) { uid = UserHandle.getAppId(uid); @@ -992,15 +988,19 @@ public class Process { } /** + * Returns the app uid corresponding to an sdk sandbox uid. * - * 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 SdkSandboxUid */ - @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); } |