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

Commit 71c18d2a authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Replace 'whitelist' with 'allowlist'

Change-Id: If7422064e59e6c055c9dae092ead298b81cf41e8
Test: atest
Bug: 161889253
Merged-In: I94a43c1c995052b034d8a5377786e1a15e4c9c59
parent fc6fbde5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ public interface DeviceIdleInternal {
            String reason);

    // duration in milliseconds
    long getNotificationWhitelistDuration();
    long getNotificationAllowlistDuration();

    void setJobsActive(boolean active);

+10 −9
Original line number Diff line number Diff line
@@ -891,7 +891,8 @@ public class DeviceIdleController extends SystemService
                "mms_temp_app_whitelist_duration";
        private static final String KEY_SMS_TEMP_APP_WHITELIST_DURATION =
                "sms_temp_app_whitelist_duration";
        private static final String KEY_NOTIFICATION_WHITELIST_DURATION =
        // TODO(b/124466289): update value to match the name
        private static final String KEY_NOTIFICATION_ALLOWLIST_DURATION =
                "notification_whitelist_duration";
        /**
         * Whether to wait for the user to unlock the device before causing screen-on to
@@ -1125,9 +1126,9 @@ public class DeviceIdleController extends SystemService
         * Amount of time we would like to whitelist an app that is handling a
         * {@link android.app.PendingIntent} triggered by a {@link android.app.Notification}.
         * @see Settings.Global#DEVICE_IDLE_CONSTANTS
         * @see #KEY_NOTIFICATION_WHITELIST_DURATION
         * @see #NOTIFICATION_ALLOWLIST_DURATION
         */
        public long NOTIFICATION_WHITELIST_DURATION;
        public long NOTIFICATION_ALLOWLIST_DURATION;

        /**
         * Pre idle time factor use to make idle delay longer
@@ -1231,8 +1232,8 @@ public class DeviceIdleController extends SystemService
                        KEY_MMS_TEMP_APP_WHITELIST_DURATION, 60 * 1000L);
                SMS_TEMP_APP_WHITELIST_DURATION = mParser.getDurationMillis(
                        KEY_SMS_TEMP_APP_WHITELIST_DURATION, 20 * 1000L);
                NOTIFICATION_WHITELIST_DURATION = mParser.getDurationMillis(
                        KEY_NOTIFICATION_WHITELIST_DURATION, 30 * 1000L);
                NOTIFICATION_ALLOWLIST_DURATION = mParser.getDurationMillis(
                        KEY_NOTIFICATION_ALLOWLIST_DURATION, 30 * 1000L);
                WAIT_FOR_UNLOCK = mParser.getBoolean(KEY_WAIT_FOR_UNLOCK, true);
                PRE_IDLE_FACTOR_LONG = mParser.getFloat(KEY_PRE_IDLE_FACTOR_LONG, 1.67f);
                PRE_IDLE_FACTOR_SHORT = mParser.getFloat(KEY_PRE_IDLE_FACTOR_SHORT, 0.33f);
@@ -1344,8 +1345,8 @@ public class DeviceIdleController extends SystemService
            TimeUtils.formatDuration(SMS_TEMP_APP_WHITELIST_DURATION, pw);
            pw.println();

            pw.print("    "); pw.print(KEY_NOTIFICATION_WHITELIST_DURATION); pw.print("=");
            TimeUtils.formatDuration(NOTIFICATION_WHITELIST_DURATION, pw);
            pw.print("    "); pw.print(KEY_NOTIFICATION_ALLOWLIST_DURATION); pw.print("=");
            TimeUtils.formatDuration(NOTIFICATION_ALLOWLIST_DURATION, pw);
            pw.println();

            pw.print("    "); pw.print(KEY_WAIT_FOR_UNLOCK); pw.print("=");
@@ -1790,8 +1791,8 @@ public class DeviceIdleController extends SystemService

        // duration in milliseconds
        @Override
        public long getNotificationWhitelistDuration() {
            return mConstants.NOTIFICATION_WHITELIST_DURATION;
        public long getNotificationAllowlistDuration() {
            return mConstants.NOTIFICATION_ALLOWLIST_DURATION;
        }

        @Override
+8 −8
Original line number Diff line number Diff line
@@ -958,7 +958,7 @@ public class Notification implements Parcelable
     *
     * @hide
     */
    private IBinder mWhitelistToken;
    private IBinder mAllowlistToken;

    /**
     * Must be set by a process to start associating tokens with Notification objects
@@ -966,7 +966,7 @@ public class Notification implements Parcelable
     *
     * @hide
     */
    static public IBinder processWhitelistToken;
    static public IBinder processAllowlistToken;

    /**
     * {@link #extras} key: this is the title of the notification,
@@ -2245,12 +2245,12 @@ public class Notification implements Parcelable
    {
        int version = parcel.readInt();

        mWhitelistToken = parcel.readStrongBinder();
        if (mWhitelistToken == null) {
            mWhitelistToken = processWhitelistToken;
        mAllowlistToken = parcel.readStrongBinder();
        if (mAllowlistToken == null) {
            mAllowlistToken = processAllowlistToken;
        }
        // Propagate this token to all pending intents that are unmarshalled from the parcel.
        parcel.setClassCookie(PendingIntent.class, mWhitelistToken);
        parcel.setClassCookie(PendingIntent.class, mAllowlistToken);

        when = parcel.readLong();
        creationTime = parcel.readLong();
@@ -2368,7 +2368,7 @@ public class Notification implements Parcelable
     * @hide
     */
    public void cloneInto(Notification that, boolean heavy) {
        that.mWhitelistToken = this.mWhitelistToken;
        that.mAllowlistToken = this.mAllowlistToken;
        that.when = this.when;
        that.creationTime = this.creationTime;
        that.mSmallIcon = this.mSmallIcon;
@@ -2678,7 +2678,7 @@ public class Notification implements Parcelable
    private void writeToParcelImpl(Parcel parcel, int flags) {
        parcel.writeInt(1);

        parcel.writeStrongBinder(mWhitelistToken);
        parcel.writeStrongBinder(mAllowlistToken);
        parcel.writeLong(when);
        parcel.writeLong(creationTime);
        if (mSmallIcon == null && icon != 0) {
+7 −7
Original line number Diff line number Diff line
@@ -510,7 +510,7 @@ public class NotificationManagerService extends SystemService {

    private static final int MY_UID = Process.myUid();
    private static final int MY_PID = Process.myPid();
    private static final IBinder WHITELIST_TOKEN = new Binder();
    private static final IBinder ALLOWLIST_TOKEN = new Binder();
    protected RankingHandler mRankingHandler;
    private long mLastOverRateLogTime;
    private float mMaxPackageEnqueueRate = DEFAULT_MAX_NOTIFICATION_ENQUEUE_RATE;
@@ -1706,7 +1706,7 @@ public class NotificationManagerService extends SystemService {
        super(context);
        mNotificationRecordLogger = notificationRecordLogger;
        mNotificationInstanceIdSequence = notificationInstanceIdSequence;
        Notification.processWhitelistToken = WHITELIST_TOKEN;
        Notification.processAllowlistToken = ALLOWLIST_TOKEN;
    }

    // TODO - replace these methods with new fields in the VisibleForTesting constructor
@@ -5762,21 +5762,21 @@ public class NotificationManagerService extends SystemService {
            mShortcutHelper.cacheShortcut(info, user);
        }

        // Whitelist pending intents.
        // temporarily allow apps to perform extra work when their pending intents are launched
        if (notification.allPendingIntents != null) {
            final int intentCount = notification.allPendingIntents.size();
            if (intentCount > 0) {
                final ActivityManagerInternal am = LocalServices
                        .getService(ActivityManagerInternal.class);
                final long duration = LocalServices.getService(
                        DeviceIdleInternal.class).getNotificationWhitelistDuration();
                        DeviceIdleInternal.class).getNotificationAllowlistDuration();
                for (int i = 0; i < intentCount; i++) {
                    PendingIntent pendingIntent = notification.allPendingIntents.valueAt(i);
                    if (pendingIntent != null) {
                        am.setPendingIntentWhitelistDuration(pendingIntent.getTarget(),
                                WHITELIST_TOKEN, duration);
                                ALLOWLIST_TOKEN, duration);
                        am.setPendingIntentAllowBgActivityStarts(pendingIntent.getTarget(),
                                WHITELIST_TOKEN, (FLAG_ACTIVITY_SENDER | FLAG_BROADCAST_SENDER
                                ALLOWLIST_TOKEN, (FLAG_ACTIVITY_SENDER | FLAG_BROADCAST_SENDER
                                        | FLAG_SERVICE_SENDER));
                    }
                }
@@ -7629,7 +7629,7 @@ public class NotificationManagerService extends SystemService {
                    // make sure deleteIntent cannot be used to start activities from background
                    LocalServices.getService(ActivityManagerInternal.class)
                            .clearPendingIntentAllowBgActivityStarts(deleteIntent.getTarget(),
                            WHITELIST_TOKEN);
                            ALLOWLIST_TOKEN);
                    deleteIntent.send();
                } catch (PendingIntent.CanceledException ex) {
                    // do nothing - there's no relevant way to recover, and
+1 −1
Original line number Diff line number Diff line
@@ -385,7 +385,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        MockitoAnnotations.initMocks(this);

        DeviceIdleInternal deviceIdleInternal = mock(DeviceIdleInternal.class);
        when(deviceIdleInternal.getNotificationWhitelistDuration()).thenReturn(3000L);
        when(deviceIdleInternal.getNotificationAllowlistDuration()).thenReturn(3000L);
        ActivityManagerInternal activityManagerInternal = mock(ActivityManagerInternal.class);

        LocalServices.removeServiceForTest(UriGrantsManagerInternal.class);