Merge "API to get the sdk sandbox uid for an app uid" into main

This commit is contained in:
Palak Chaudhary 2024-01-10 09:02:23 +00:00 committed by Android (Google) Code Review
commit 72235db203
2 changed files with 22 additions and 0 deletions

View File

@ -33410,6 +33410,7 @@ package android.os {
method public static final long getElapsedCpuTime();
method public static final int[] getExclusiveCores();
method public static final int getGidForName(String);
method @FlaggedApi("com.android.sdksandbox.flags.sdk_sandbox_uid_to_app_uid_api") public static final int getSdkSandboxUidForAppUid(int);
method public static long getStartElapsedRealtime();
method public static long getStartRequestedElapsedRealtime();
method public static long getStartRequestedUptimeMillis();

View File

@ -19,6 +19,7 @@ package android.os;
import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
import android.annotation.ElapsedRealtimeLong;
import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
@ -37,6 +38,7 @@ import android.webkit.WebViewZygote;
import com.android.internal.os.SomeArgs;
import com.android.internal.util.Preconditions;
import com.android.sdksandbox.flags.Flags;
import dalvik.system.VMRuntime;
@ -1016,10 +1018,29 @@ public class Process {
@SystemApi(client = MODULE_LIBRARIES)
@TestApi
@android.ravenwood.annotation.RavenwoodKeep
// TODO(b/318651609): Deprecate once Process#getSdkSandboxUidForAppUid is rolled out to 100%
public static final int toSdkSandboxUid(int uid) {
return uid + (FIRST_SDK_SANDBOX_UID - FIRST_APPLICATION_UID);
}
/**
* Returns the sdk sandbox uid corresponding to an app uid.
* @see android.app.sdksandbox.SdkSandboxManager
*
* @param uid the app uid
* @return the sdk sandbox uid for the given app uid
*
* @throws IllegalArgumentException if input is not an app uid
*/
@FlaggedApi(Flags.FLAG_SDK_SANDBOX_UID_TO_APP_UID_API)
@android.ravenwood.annotation.RavenwoodKeep
public static final int getSdkSandboxUidForAppUid(int uid) {
if (!isApplicationUid(uid)) {
throw new IllegalArgumentException("Input UID is not an app UID");
}
return uid + (FIRST_SDK_SANDBOX_UID - FIRST_APPLICATION_UID);
}
/**
* Returns whether the current process is a sdk sandbox process.
*/