Merge changes from topics "sp-permissions", "sp-pm-uid-apis"
* changes: Add Process.toSupplementalUid to @TestApi Handle supplemental process uid range for uid-based PM apis
This commit is contained in:
@@ -1753,6 +1753,7 @@ package android.os {
|
||||
|
||||
public class Process {
|
||||
method public static final int getThreadScheduler(int) throws java.lang.IllegalArgumentException;
|
||||
method public static final int toSupplementalUid(int);
|
||||
field public static final int FIRST_APP_ZYGOTE_ISOLATED_UID = 90000; // 0x15f90
|
||||
field public static final int FIRST_ISOLATED_UID = 99000; // 0x182b8
|
||||
field public static final int LAST_APP_ZYGOTE_ISOLATED_UID = 98999; // 0x182b7
|
||||
|
||||
@@ -929,6 +929,7 @@ public class Process {
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi(client = MODULE_LIBRARIES)
|
||||
@TestApi
|
||||
public static final int toSupplementalUid(int uid) {
|
||||
return uid + (FIRST_SUPPLEMENTAL_UID - FIRST_APPLICATION_UID);
|
||||
}
|
||||
|
||||
@@ -2134,6 +2134,9 @@ public class ComputerEngine implements Computer {
|
||||
private String[] getPackagesForUidInternal(int uid, int callingUid) {
|
||||
final boolean isCallerInstantApp = getInstantAppPackageName(callingUid) != null;
|
||||
final int userId = UserHandle.getUserId(uid);
|
||||
if (Process.isSupplemental(uid)) {
|
||||
uid = getSupplementalProcessUid();
|
||||
}
|
||||
final int appId = UserHandle.getAppId(uid);
|
||||
return getPackagesForUidInternalBody(callingUid, userId, appId, isCallerInstantApp);
|
||||
}
|
||||
@@ -4292,6 +4295,9 @@ public class ComputerEngine implements Computer {
|
||||
if (getInstantAppPackageName(callingUid) != null) {
|
||||
return null;
|
||||
}
|
||||
if (Process.isSupplemental(uid)) {
|
||||
uid = getSupplementalProcessUid();
|
||||
}
|
||||
final int callingUserId = UserHandle.getUserId(callingUid);
|
||||
final int appId = UserHandle.getAppId(uid);
|
||||
final Object obj = mSettings.getSettingBase(appId);
|
||||
@@ -4324,7 +4330,11 @@ public class ComputerEngine implements Computer {
|
||||
final int callingUserId = UserHandle.getUserId(callingUid);
|
||||
final String[] names = new String[uids.length];
|
||||
for (int i = uids.length - 1; i >= 0; i--) {
|
||||
final int appId = UserHandle.getAppId(uids[i]);
|
||||
int uid = uids[i];
|
||||
if (Process.isSupplemental(uid)) {
|
||||
uid = getSupplementalProcessUid();
|
||||
}
|
||||
final int appId = UserHandle.getAppId(uid);
|
||||
final Object obj = mSettings.getSettingBase(appId);
|
||||
if (obj instanceof SharedUserSetting) {
|
||||
final SharedUserSetting sus = (SharedUserSetting) obj;
|
||||
@@ -4370,6 +4380,9 @@ public class ComputerEngine implements Computer {
|
||||
if (getInstantAppPackageName(callingUid) != null) {
|
||||
return 0;
|
||||
}
|
||||
if (Process.isSupplemental(uid)) {
|
||||
uid = getSupplementalProcessUid();
|
||||
}
|
||||
final int callingUserId = UserHandle.getUserId(callingUid);
|
||||
final int appId = UserHandle.getAppId(uid);
|
||||
final Object obj = mSettings.getSettingBase(appId);
|
||||
@@ -4395,6 +4408,9 @@ public class ComputerEngine implements Computer {
|
||||
if (getInstantAppPackageName(callingUid) != null) {
|
||||
return 0;
|
||||
}
|
||||
if (Process.isSupplemental(uid)) {
|
||||
uid = getSupplementalProcessUid();
|
||||
}
|
||||
final int callingUserId = UserHandle.getUserId(callingUid);
|
||||
final int appId = UserHandle.getAppId(uid);
|
||||
final Object obj = mSettings.getSettingBase(appId);
|
||||
@@ -4419,6 +4435,9 @@ public class ComputerEngine implements Computer {
|
||||
if (getInstantAppPackageName(Binder.getCallingUid()) != null) {
|
||||
return false;
|
||||
}
|
||||
if (Process.isSupplemental(uid)) {
|
||||
uid = getSupplementalProcessUid();
|
||||
}
|
||||
final int appId = UserHandle.getAppId(uid);
|
||||
final Object obj = mSettings.getSettingBase(appId);
|
||||
if (obj instanceof SharedUserSetting) {
|
||||
@@ -5543,6 +5562,9 @@ public class ComputerEngine implements Computer {
|
||||
|
||||
@Override
|
||||
public int getUidTargetSdkVersion(int uid) {
|
||||
if (Process.isSupplemental(uid)) {
|
||||
uid = getSupplementalProcessUid();
|
||||
}
|
||||
final int appId = UserHandle.getAppId(uid);
|
||||
final SettingBase settingBase = mSettings.getSettingBase(appId);
|
||||
if (settingBase instanceof SharedUserSetting) {
|
||||
@@ -5569,6 +5591,9 @@ public class ComputerEngine implements Computer {
|
||||
@Nullable
|
||||
@Override
|
||||
public ArrayMap<String, ProcessInfo> getProcessesForUid(int uid) {
|
||||
if (Process.isSupplemental(uid)) {
|
||||
uid = getSupplementalProcessUid();
|
||||
}
|
||||
final int appId = UserHandle.getAppId(uid);
|
||||
final SettingBase settingBase = mSettings.getSettingBase(appId);
|
||||
if (settingBase instanceof SharedUserSetting) {
|
||||
@@ -5598,4 +5623,8 @@ public class ComputerEngine implements Computer {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private int getSupplementalProcessUid() {
|
||||
return getPackage(mService.getSupplementalProcessPackageName()).getUid();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user