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

Commit f5e73ef9 authored by Hui Yu's avatar Hui Yu
Browse files

Specify temp-allowlist reasonCode while calling setPendingIntentAllowlistDuration().

Delete the overloaded version of setPendingIntentAllowlistDuration() without reasonCode.

Bug: 171305836
Test: atest cts/tests/app/src/android/app/cts/ActivityManagerFgsBgStartTest.java
Reboot device, observe "tempAllowListReason" in logcat.

Change-Id: Ib8bd22eefb5d5f308d2bcca17221499c2a6adc79
parent 24eadb70
Loading
Loading
Loading
Loading
+0 −4
Original line number Original line Diff line number Diff line
@@ -113,10 +113,6 @@ public abstract class ActivityManagerInternal {
            IBinder allowlistToken, long duration, @TempAllowListType int type,
            IBinder allowlistToken, long duration, @TempAllowListType int type,
            @ReasonCode int reasonCode, @Nullable String reason);
            @ReasonCode int reasonCode, @Nullable String reason);


    @Deprecated
    public abstract void setPendingIntentWhitelistDuration(IIntentSender target,
            IBinder allowlistToken, long duration, @TempAllowListType int type);

    /**
    /**
     * Returns the flags set for a {@link PendingIntent}.
     * Returns the flags set for a {@link PendingIntent}.
     */
     */
+0 −7
Original line number Original line Diff line number Diff line
@@ -15126,13 +15126,6 @@ public class ActivityManagerService extends IActivityManager.Stub
                    duration, type, reasonCode, reason);
                    duration, type, reasonCode, reason);
        }
        }
        @Override
        public void setPendingIntentWhitelistDuration(IIntentSender target, IBinder allowlistToken,
                long duration, int type) {
            mPendingIntentController.setPendingIntentAllowlistDuration(target, allowlistToken,
                    duration, type, REASON_UNKNOWN, "");
        }
        @Override
        @Override
        public int getPendingIntentFlags(IIntentSender target) {
        public int getPendingIntentFlags(IIntentSender target) {
            return mPendingIntentController.getPendingIntentFlags(target);
            return mPendingIntentController.getPendingIntentFlags(target);
+6 −3
Original line number Original line Diff line number Diff line
@@ -64,6 +64,8 @@ import static android.media.AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY;
import static android.media.AudioAttributes.USAGE_NOTIFICATION_RINGTONE;
import static android.media.AudioAttributes.USAGE_NOTIFICATION_RINGTONE;
import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL;
import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL;
import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_NORMAL;
import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_NORMAL;
import static android.os.PowerWhitelistManager.REASON_NOTIFICATION_SERVICE;
import static android.os.PowerWhitelistManager.TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED;
import static android.os.UserHandle.USER_NULL;
import static android.os.UserHandle.USER_NULL;
import static android.os.UserHandle.USER_SYSTEM;
import static android.os.UserHandle.USER_SYSTEM;
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_ALERTING;
import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_ALERTING;
@@ -6001,10 +6003,11 @@ public class NotificationManagerService extends SystemService {
                for (int i = 0; i < intentCount; i++) {
                for (int i = 0; i < intentCount; i++) {
                    PendingIntent pendingIntent = notification.allPendingIntents.valueAt(i);
                    PendingIntent pendingIntent = notification.allPendingIntents.valueAt(i);
                    if (pendingIntent != null) {
                    if (pendingIntent != null) {
                        am.setPendingIntentWhitelistDuration(pendingIntent.getTarget(),
                        am.setPendingIntentAllowlistDuration(pendingIntent.getTarget(),
                                ALLOWLIST_TOKEN, duration,
                                ALLOWLIST_TOKEN, duration,
                                BroadcastOptions.TEMPORARY_WHITELIST_TYPE_FOREGROUND_SERVICE_ALLOWED
                                TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED,
                        );
                                REASON_NOTIFICATION_SERVICE,
                                "NotificationManagerService");
                        am.setPendingIntentAllowBgActivityStarts(pendingIntent.getTarget(),
                        am.setPendingIntentAllowBgActivityStarts(pendingIntent.getTarget(),
                                ALLOWLIST_TOKEN, (FLAG_ACTIVITY_SENDER | FLAG_BROADCAST_SENDER
                                ALLOWLIST_TOKEN, (FLAG_ACTIVITY_SENDER | FLAG_BROADCAST_SENDER
                                        | FLAG_SERVICE_SENDER));
                                        | FLAG_SERVICE_SENDER));