Replace 'whitelist' with 'allowlist'
Test: atest Bug: 161889253 Change-Id: I94a43c1c995052b034d8a5377786e1a15e4c9c59
This commit is contained in:
@@ -37,7 +37,7 @@ public interface DeviceIdleInternal {
|
||||
String reason);
|
||||
|
||||
// duration in milliseconds
|
||||
long getNotificationWhitelistDuration();
|
||||
long getNotificationAllowlistDuration();
|
||||
|
||||
void setJobsActive(boolean active);
|
||||
|
||||
|
||||
@@ -890,7 +890,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
|
||||
@@ -1124,9 +1125,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 #KEY_NOTIFICATION_ALLOWLIST_DURATION
|
||||
*/
|
||||
public long NOTIFICATION_WHITELIST_DURATION;
|
||||
public long NOTIFICATION_ALLOWLIST_DURATION;
|
||||
|
||||
/**
|
||||
* Pre idle time factor use to make idle delay longer
|
||||
@@ -1230,8 +1231,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);
|
||||
@@ -1343,8 +1344,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("=");
|
||||
@@ -1792,8 +1793,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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -515,7 +515,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;
|
||||
@@ -1722,7 +1722,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
|
||||
@@ -5775,21 +5775,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));
|
||||
}
|
||||
}
|
||||
@@ -7642,7 +7642,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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user