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

Commit 2f5bb9c5 authored by Nan Wu's avatar Nan Wu Committed by Android Build Coastguard Worker
Browse files

RESTRICT AUTOMERGE

Log to detect usage of whitelistToken when sending non-PI target

Log ActivityManagerService.sendIntentSender if the target is not a
PendingIntent and a non-null whitelistToken is sent to the client.
This is simply to detect if there are real cases this would happen
before we decide simply remove whitelistToken in that case.

Do not pass  whitelistToken when sending non-PI target

In ActivityManagerService.sendIntentSender, if the target is not a
PendingIntent, do not send whitelistToken to the client.

Bug: 279428283
Test: Manual test
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:5f12deecd46e79212deba584a1afea97d401dd52)
Merged-In: I017486354a1ab2f14d0472c355583d53c27c4810
Change-Id: I017486354a1ab2f14d0472c355583d53c27c4810
parent 3dadbf43
Loading
Loading
Loading
Loading
+16 −4
Original line number Original line Diff line number Diff line
@@ -162,7 +162,6 @@ import android.app.AppOpsManagerInternal.CheckOpsDelegate;
import android.app.ApplicationErrorReport;
import android.app.ApplicationErrorReport;
import android.app.ApplicationExitInfo;
import android.app.ApplicationExitInfo;
import android.app.ApplicationThreadConstants;
import android.app.ApplicationThreadConstants;
import android.app.AppOpsManager;
import android.app.BroadcastOptions;
import android.app.BroadcastOptions;
import android.app.ContentProviderHolder;
import android.app.ContentProviderHolder;
import android.app.IActivityController;
import android.app.IActivityController;
@@ -5780,12 +5779,12 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    }
    @Override
    @Override
    public int sendIntentSender(IIntentSender target, IBinder whitelistToken, int code,
    public int sendIntentSender(IIntentSender target, IBinder allowlistToken, int code,
            Intent intent, String resolvedType,
            Intent intent, String resolvedType,
            IIntentReceiver finishedReceiver, String requiredPermission, Bundle options) {
            IIntentReceiver finishedReceiver, String requiredPermission, Bundle options) {
        if (target instanceof PendingIntentRecord) {
        if (target instanceof PendingIntentRecord) {
            return ((PendingIntentRecord)target).sendWithResult(code, intent, resolvedType,
            return ((PendingIntentRecord)target).sendWithResult(code, intent, resolvedType,
                    whitelistToken, finishedReceiver, requiredPermission, options);
                    allowlistToken, finishedReceiver, requiredPermission, options);
        } else {
        } else {
            if (intent == null) {
            if (intent == null) {
                // Weird case: someone has given us their own custom IIntentSender, and now
                // Weird case: someone has given us their own custom IIntentSender, and now
@@ -5797,7 +5796,20 @@ public class ActivityManagerService extends IActivityManager.Stub
                intent = new Intent(Intent.ACTION_MAIN);
                intent = new Intent(Intent.ACTION_MAIN);
            }
            }
            try {
            try {
                target.send(code, intent, resolvedType, whitelistToken, null,
                if (allowlistToken != null) {
                    final int callingUid = Binder.getCallingUid();
                    final String packageName;
                    final long token = Binder.clearCallingIdentity();
                    try {
                        packageName = AppGlobals.getPackageManager().getNameForUid(callingUid);
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
                    Slog.wtf(TAG, "Send a non-null allowlistToken to a non-PI target."
                            + " Calling package: " + packageName + "; intent: " + intent
                            + "; options: " + options);
                }
                target.send(code, intent, resolvedType, null, null,
                        requiredPermission, options);
                        requiredPermission, options);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
            }
            }