Merge "Update language to comply with Android's inclusive language guidance" am: 007cc402c1 am: 698a6c7c59 am: b4743356b4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1376497 Change-Id: I7192a3edf8397218ede9a8a9016f2fd9c31af928
This commit is contained in:
@@ -58,16 +58,16 @@ public class BinderCallsStatsService extends Binder {
|
|||||||
|
|
||||||
/** Resolves the work source of an incoming binder transaction. */
|
/** Resolves the work source of an incoming binder transaction. */
|
||||||
static class AuthorizedWorkSourceProvider implements BinderInternal.WorkSourceProvider {
|
static class AuthorizedWorkSourceProvider implements BinderInternal.WorkSourceProvider {
|
||||||
private ArraySet<Integer> mAppIdWhitelist;
|
private ArraySet<Integer> mAppIdTrustlist;
|
||||||
|
|
||||||
AuthorizedWorkSourceProvider() {
|
AuthorizedWorkSourceProvider() {
|
||||||
mAppIdWhitelist = new ArraySet<>();
|
mAppIdTrustlist = new ArraySet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int resolveWorkSourceUid(int untrustedWorkSourceUid) {
|
public int resolveWorkSourceUid(int untrustedWorkSourceUid) {
|
||||||
final int callingUid = getCallingUid();
|
final int callingUid = getCallingUid();
|
||||||
final int appId = UserHandle.getAppId(callingUid);
|
final int appId = UserHandle.getAppId(callingUid);
|
||||||
if (mAppIdWhitelist.contains(appId)) {
|
if (mAppIdTrustlist.contains(appId)) {
|
||||||
final int workSource = untrustedWorkSourceUid;
|
final int workSource = untrustedWorkSourceUid;
|
||||||
final boolean isWorkSourceSet = workSource != Binder.UNSET_WORKSOURCE;
|
final boolean isWorkSourceSet = workSource != Binder.UNSET_WORKSOURCE;
|
||||||
return isWorkSourceSet ? workSource : callingUid;
|
return isWorkSourceSet ? workSource : callingUid;
|
||||||
@@ -76,13 +76,13 @@ public class BinderCallsStatsService extends Binder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void systemReady(Context context) {
|
public void systemReady(Context context) {
|
||||||
mAppIdWhitelist = createAppidWhitelist(context);
|
mAppIdTrustlist = createAppidTrustlist(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dump(PrintWriter pw, AppIdToPackageMap packageMap) {
|
public void dump(PrintWriter pw, AppIdToPackageMap packageMap) {
|
||||||
pw.println("AppIds of apps that can set the work source:");
|
pw.println("AppIds of apps that can set the work source:");
|
||||||
final ArraySet<Integer> whitelist = mAppIdWhitelist;
|
final ArraySet<Integer> trustlist = mAppIdTrustlist;
|
||||||
for (Integer appId : whitelist) {
|
for (Integer appId : trustlist) {
|
||||||
pw.println("\t- " + packageMap.mapAppId(appId));
|
pw.println("\t- " + packageMap.mapAppId(appId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,12 +91,12 @@ public class BinderCallsStatsService extends Binder {
|
|||||||
return Binder.getCallingUid();
|
return Binder.getCallingUid();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArraySet<Integer> createAppidWhitelist(Context context) {
|
private ArraySet<Integer> createAppidTrustlist(Context context) {
|
||||||
// Use a local copy instead of mAppIdWhitelist to prevent concurrent read access.
|
// Use a local copy instead of mAppIdTrustlist to prevent concurrent read access.
|
||||||
final ArraySet<Integer> whitelist = new ArraySet<>();
|
final ArraySet<Integer> trustlist = new ArraySet<>();
|
||||||
|
|
||||||
// We trust our own process.
|
// We trust our own process.
|
||||||
whitelist.add(UserHandle.getAppId(Process.myUid()));
|
trustlist.add(UserHandle.getAppId(Process.myUid()));
|
||||||
// We only need to initialize it once. UPDATE_DEVICE_STATS is a system permission.
|
// We only need to initialize it once. UPDATE_DEVICE_STATS is a system permission.
|
||||||
final PackageManager pm = context.getPackageManager();
|
final PackageManager pm = context.getPackageManager();
|
||||||
final String[] permissions = { android.Manifest.permission.UPDATE_DEVICE_STATS };
|
final String[] permissions = { android.Manifest.permission.UPDATE_DEVICE_STATS };
|
||||||
@@ -109,12 +109,12 @@ public class BinderCallsStatsService extends Binder {
|
|||||||
try {
|
try {
|
||||||
final int uid = pm.getPackageUid(pkgInfo.packageName, queryFlags);
|
final int uid = pm.getPackageUid(pkgInfo.packageName, queryFlags);
|
||||||
final int appId = UserHandle.getAppId(uid);
|
final int appId = UserHandle.getAppId(uid);
|
||||||
whitelist.add(appId);
|
trustlist.add(appId);
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
Slog.e(TAG, "Cannot find uid for package name " + pkgInfo.packageName, e);
|
Slog.e(TAG, "Cannot find uid for package name " + pkgInfo.packageName, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return whitelist;
|
return trustlist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user