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

Commit b9fde865 authored by Eric Chiang's avatar Eric Chiang Committed by Android (Google) Code Review
Browse files

Merge "Update PendingIntent target for multi-user"

parents 6be0efde 3d875f5f
Loading
Loading
Loading
Loading
+29 −2
Original line number Diff line number Diff line
@@ -5635,8 +5635,35 @@ public class ActivityManagerService extends IActivityManager.Stub
            IBinder allowlistToken, int code, Intent intent, String resolvedType,
            IIntentReceiver finishedReceiver, String requiredPermission, Bundle options) {
        if (target instanceof PendingIntentRecord) {
            return ((PendingIntentRecord) target).sendWithResult(caller, code, intent,
                    resolvedType, allowlistToken, finishedReceiver, requiredPermission, options);
            final PendingIntentRecord originalRecord = (PendingIntentRecord) target;
            // In multi-display scenarios, there can be background users who execute the
            // PendingIntent. In these scenarios, we don't want to use the foreground user as the
            // current user.
            final PendingIntentRecord.Key originalKey = originalRecord.key;
            final UserManagerInternal umInternal =
                    LocalServices.getService(UserManagerInternal.class);
            final int callingUserId = UserHandle.getCallingUserId();
            if (UserManager.isVisibleBackgroundUsersEnabled()
                    && originalKey.userId == UserHandle.USER_CURRENT
                    && callingUserId != UserHandle.USER_SYSTEM
                    && umInternal.isUserVisible(callingUserId)) {
                EventLogTags.writeAmIntentSenderRedirectUser(callingUserId);
                final PendingIntentRecord.Key key = new PendingIntentRecord.Key(originalKey.type,
                        originalKey.packageName, originalKey.featureId, originalKey.activity,
                        originalKey.who, originalKey.requestCode, originalKey.allIntents,
                        originalKey.allResolvedTypes, originalKey.flags, originalKey.options,
                        callingUserId);
                final PendingIntentRecord newRecord = new PendingIntentRecord(
                        originalRecord.controller, key, originalRecord.uid);
                return newRecord.sendWithResult(caller, code, intent, resolvedType, allowlistToken,
                        finishedReceiver, requiredPermission, options);
            }
            return originalRecord.sendWithResult(caller, code, intent, resolvedType, allowlistToken,
                    finishedReceiver, requiredPermission, options);
        } else {
            if (intent == null) {
                // Weird case: someone has given us their own custom IIntentSender, and now
+4 −1
Original line number Diff line number Diff line
# See system/core/logcat/event.logtags for a description of the format of this file.
# See system/logging/logcat/event.logtags for a description of the format of this file.

option java_package com.android.server.am

@@ -125,3 +125,6 @@ option java_package com.android.server.am
30100 am_foreground_service_start (User|1|5),(Component Name|3),(allowWhileInUse|1),(startReasonCode|3),(targetSdk|1|1),(callerTargetSdk|1|1),(notificationWasDeferred|1),(notificationShown|1),(durationMs|1|3),(startForegroundCount|1|1),(stopReason|3)
30101 am_foreground_service_denied (User|1|5),(Component Name|3),(allowWhileInUse|1),(startReasonCode|3),(targetSdk|1|1),(callerTargetSdk|1|1),(notificationWasDeferred|1),(notificationShown|1),(durationMs|1|3),(startForegroundCount|1|1),(stopReason|3)
30102 am_foreground_service_stop (User|1|5),(Component Name|3),(allowWhileInUse|1),(startReasonCode|3),(targetSdk|1|1),(callerTargetSdk|1|1),(notificationWasDeferred|1),(notificationShown|1),(durationMs|1|3),(startForegroundCount|1|1),(stopReason|3)

# Intent Sender redirect for UserHandle.USER_CURRENT
30110 am_intent_sender_redirect_user (userId|1|5)