Loading apex/jobscheduler/framework/java/com/android/server/DeviceIdleInternal.java +1 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ public interface DeviceIdleInternal { String reason); // duration in milliseconds long getNotificationWhitelistDuration(); long getNotificationAllowlistDuration(); void setJobsActive(boolean active); Loading apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java +10 −9 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -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("="); Loading Loading @@ -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 Loading core/java/android/app/Notification.java +8 −8 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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, Loading Loading @@ -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(); Loading Loading @@ -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; Loading Loading @@ -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) { Loading services/core/java/com/android/server/notification/NotificationManagerService.java +7 −7 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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)); } } Loading Loading @@ -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 Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading Loading
apex/jobscheduler/framework/java/com/android/server/DeviceIdleInternal.java +1 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ public interface DeviceIdleInternal { String reason); // duration in milliseconds long getNotificationWhitelistDuration(); long getNotificationAllowlistDuration(); void setJobsActive(boolean active); Loading
apex/jobscheduler/service/java/com/android/server/DeviceIdleController.java +10 −9 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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); Loading Loading @@ -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("="); Loading Loading @@ -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 Loading
core/java/android/app/Notification.java +8 −8 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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, Loading Loading @@ -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(); Loading Loading @@ -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; Loading Loading @@ -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) { Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +7 −7 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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)); } } Loading Loading @@ -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 Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading