diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2020-09-14 22:44:28 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-09-14 22:44:28 +0000 |
commit | bc93881957cd39e810aa67bea67ffe6a67da9c2a (patch) | |
tree | 5f41853fd7232fa5f90f30efa058bd3e6a07b1c8 | |
parent | 9af4f1d3000b9d5e56ac508b76f791563205c230 (diff) | |
parent | e022945d69a3f31b9fed18c8bff2805d43914231 (diff) |
Merge "Replace 'whitelist' with 'allowlist'" am: 8ac6819c0e am: 3563eeb4ae am: 1d3e694b97 am: e022945d69
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1427048
Change-Id: I5725049a13c30e122e1f8b5e4e772b7431a4e32d
5 files changed, 27 insertions, 26 deletions
diff --git a/apex/jobscheduler/framework/java/com/android/server/DeviceIdleInternal.java b/apex/jobscheduler/framework/java/com/android/server/DeviceIdleInternal.java index 6475f5706a6d..18643ed91276 100644 --- a/apex/jobscheduler/framework/java/com/android/server/DeviceIdleInternal.java +++ b/apex/jobscheduler/framework/java/com/android/server/DeviceIdleInternal.java @@ -37,7 +37,7 @@ public interface DeviceIdleInternal { String reason); // duration in milliseconds - long getNotificationWhitelistDuration(); + long getNotificationAllowlistDuration(); void setJobsActive(boolean active); diff --git a/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java b/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java index ac58f3d6a94d..67912723e7b4 100644 --- a/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java +++ b/apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java @@ -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 diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index af36260fedf2..2e42ae48e9b6 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -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) { diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index a0f83731ccca..5ddb6e1b04f6 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -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 @@ -5769,21 +5769,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)); } } @@ -7638,7 +7638,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 diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index 52e08187b2ca..24384b1d4f31 100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -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); |