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

Commit 91a53a89 authored by Rhed Jao's avatar Rhed Jao
Browse files

Applying package visibility rules to the broadcast of overlay changed

The broadcast intent ACTION_OVERLAY_CHANGED reveals existence
information of packages in the device. This cl passes an allowed
list to exclude illegitimate receivers for the target package
when broadcasting the intent.

Bug: 238299601
Test: atest AppEnumerationTests
Change-Id: Ia69ff3b5a652066609ffe690a8ab8ab2ad8ea445
parent ef4a7f30
Loading
Loading
Loading
Loading
+9 −6
Original line number Original line Diff line number Diff line
@@ -39,6 +39,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.annotation.UserIdInt;
import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
import android.app.IActivityManager;
import android.app.IActivityManager;
import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Context;
@@ -1416,16 +1417,18 @@ public final class OverlayManagerService extends SystemService {


    private static void broadcastActionOverlayChanged(@NonNull final Set<String> targetPackages,
    private static void broadcastActionOverlayChanged(@NonNull final Set<String> targetPackages,
            final int userId) {
            final int userId) {
        final PackageManagerInternal pmInternal =
                LocalServices.getService(PackageManagerInternal.class);
        final ActivityManagerInternal amInternal =
                LocalServices.getService(ActivityManagerInternal.class);
        CollectionUtils.forEach(targetPackages, target -> {
        CollectionUtils.forEach(targetPackages, target -> {
            final Intent intent = new Intent(ACTION_OVERLAY_CHANGED,
            final Intent intent = new Intent(ACTION_OVERLAY_CHANGED,
                    Uri.fromParts("package", target, null));
                    Uri.fromParts("package", target, null));
            intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
            intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
            try {
            final int[] allowList = pmInternal.getVisibilityAllowList(target, userId);
                ActivityManager.getService().broadcastIntent(null, intent, null, null, 0, null,
            amInternal.broadcastIntent(intent, null /* resultTo */, null /* requiredPermissions */,
                        null, null, android.app.AppOpsManager.OP_NONE, null, false, false, userId);
                    false /* serialized */, userId, allowList, null /* filterExtrasForReceiver */,
            } catch (RemoteException e) {
                    null /* bOptions */);
                Slog.e(TAG, "broadcastActionOverlayChanged remote exception", e);
            }
        });
        });
    }
    }