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

Commit 26735977 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fixes broadcast filtering for multi-user sys apps" into rvc-dev am:...

Merge "Fixes broadcast filtering for multi-user sys apps" into rvc-dev am: 55d0fb08 am: f75666d1

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

Change-Id: I62e3584760b84a881f43c1e57e02984ca7e2c54e
parents 045040e4 f75666d1
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -15788,9 +15788,10 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        if (receivers != null && broadcastWhitelist != null) {
            for (int i = receivers.size() - 1; i >= 0; i--) {
                final int uid = receivers.get(i).activityInfo.applicationInfo.uid;
                if (uid >= Process.FIRST_APPLICATION_UID
                        && Arrays.binarySearch(broadcastWhitelist, UserHandle.getAppId(uid)) < 0) {
                final int receiverAppId = UserHandle.getAppId(
                        receivers.get(i).activityInfo.applicationInfo.uid);
                if (receiverAppId >= Process.FIRST_APPLICATION_UID
                        && Arrays.binarySearch(broadcastWhitelist, receiverAppId) < 0) {
                    receivers.remove(i);
                }
            }
@@ -16436,9 +16437,9 @@ public class ActivityManagerService extends IActivityManager.Stub
            // if a uid whitelist was provided, remove anything in the application space that wasn't
            // in it.
            for (int i = registeredReceivers.size() - 1; i >= 0; i--) {
                final int uid = registeredReceivers.get(i).owningUid;
                if (uid >= Process.FIRST_APPLICATION_UID
                        && Arrays.binarySearch(broadcastWhitelist, UserHandle.getAppId(uid)) < 0) {
                final int owningAppId = UserHandle.getAppId(registeredReceivers.get(i).owningUid);
                if (owningAppId >= Process.FIRST_APPLICATION_UID
                        && Arrays.binarySearch(broadcastWhitelist, owningAppId) < 0) {
                    registeredReceivers.remove(i);
                }
            }
+4 −3
Original line number Diff line number Diff line
@@ -859,8 +859,9 @@ public class AppsFilter {
            PackageSetting targetPkgSetting, int userId) {
        Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "shouldFilterApplication");
        try {
            if (callingUid < Process.FIRST_APPLICATION_UID
                    || UserHandle.getAppId(callingUid) == targetPkgSetting.appId) {
            int callingAppId = UserHandle.getAppId(callingUid);
            if (callingAppId < Process.FIRST_APPLICATION_UID
                    || callingAppId == targetPkgSetting.appId) {
                return false;
            }
            if (mShouldFilterCache != null) { // use cache
@@ -885,7 +886,7 @@ public class AppsFilter {
                    return false;
                }
            }
            if (DEBUG_LOGGING || mFeatureConfig.isLoggingEnabled(UserHandle.getAppId(callingUid))) {
            if (DEBUG_LOGGING || mFeatureConfig.isLoggingEnabled(callingAppId)) {
                log(callingSetting, targetPkgSetting, "BLOCKED");
            }
            return !DEBUG_ALLOW_ALL;
+16 −0
Original line number Diff line number Diff line
@@ -512,6 +512,22 @@ public class AppsFilterTest {
                null, target, SYSTEM_USER));
    }

    @Test
    public void testSystemUidSecondaryUser_DoesntFilter() throws Exception {
        final AppsFilter appsFilter =
                new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
        simulateAddBasicAndroid(appsFilter);
        appsFilter.onSystemReady();

        PackageSetting target = simulateAddPackage(appsFilter,
                pkg("com.some.package"), DUMMY_TARGET_APPID);

        assertFalse(appsFilter.shouldFilterApplication(0, null, target, SECONDARY_USER));
        assertFalse(appsFilter.shouldFilterApplication(
                UserHandle.getUid(SECONDARY_USER, Process.FIRST_APPLICATION_UID - 1),
                null, target, SECONDARY_USER));
    }

    @Test
    public void testNonSystemUid_NoCallingSetting_Filters() throws Exception {
        final AppsFilter appsFilter =