Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97ca24ba authored by Marcin Oczeretko's avatar Marcin Oczeretko Committed by Automerger Merge Worker
Browse files

Merge "Update language to comply with Android's inclusive language guidance"...

Merge "Update language to comply with Android's inclusive language guidance" am: 007cc402 am: 698a6c7c am: b4743356 am: b211b969 am: 3a467f68

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1376497

Change-Id: I02e7c0927f881373ade3f8f44184104c85830e5a
parents da47e165 3a467f68
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -59,16 +59,16 @@ public class BinderCallsStatsService extends Binder {

    /** Resolves the work source of an incoming binder transaction. */
    static class AuthorizedWorkSourceProvider implements BinderInternal.WorkSourceProvider {
        private ArraySet<Integer> mAppIdWhitelist;
        private ArraySet<Integer> mAppIdTrustlist;

        AuthorizedWorkSourceProvider() {
            mAppIdWhitelist = new ArraySet<>();
            mAppIdTrustlist = new ArraySet<>();
        }

        public int resolveWorkSourceUid(int untrustedWorkSourceUid) {
            final int callingUid = getCallingUid();
            final int appId = UserHandle.getAppId(callingUid);
            if (mAppIdWhitelist.contains(appId)) {
            if (mAppIdTrustlist.contains(appId)) {
                final int workSource = untrustedWorkSourceUid;
                final boolean isWorkSourceSet = workSource != Binder.UNSET_WORKSOURCE;
                return isWorkSourceSet ?  workSource : callingUid;
@@ -77,13 +77,13 @@ public class BinderCallsStatsService extends Binder {
        }

        public void systemReady(Context context) {
            mAppIdWhitelist = createAppidWhitelist(context);
            mAppIdTrustlist = createAppidTrustlist(context);
        }

        public void dump(PrintWriter pw, AppIdToPackageMap packageMap) {
            pw.println("AppIds of apps that can set the work source:");
            final ArraySet<Integer> whitelist = mAppIdWhitelist;
            for (Integer appId : whitelist) {
            final ArraySet<Integer> trustlist = mAppIdTrustlist;
            for (Integer appId : trustlist) {
                pw.println("\t- " + packageMap.mapAppId(appId));
            }
        }
@@ -92,12 +92,12 @@ public class BinderCallsStatsService extends Binder {
            return Binder.getCallingUid();
        }

        private ArraySet<Integer> createAppidWhitelist(Context context) {
            // Use a local copy instead of mAppIdWhitelist to prevent concurrent read access.
            final ArraySet<Integer> whitelist = new ArraySet<>();
        private ArraySet<Integer> createAppidTrustlist(Context context) {
            // Use a local copy instead of mAppIdTrustlist to prevent concurrent read access.
            final ArraySet<Integer> trustlist = new ArraySet<>();

            // 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.
            final PackageManager pm = context.getPackageManager();
            final String[] permissions = { android.Manifest.permission.UPDATE_DEVICE_STATS };
@@ -110,12 +110,12 @@ public class BinderCallsStatsService extends Binder {
                try {
                    final int uid = pm.getPackageUid(pkgInfo.packageName, queryFlags);
                    final int appId = UserHandle.getAppId(uid);
                    whitelist.add(appId);
                    trustlist.add(appId);
                } catch (NameNotFoundException e) {
                    Slog.e(TAG, "Cannot find uid for package name " + pkgInfo.packageName, e);
                }
            }
            return whitelist;
            return trustlist;
        }
    }