Loading core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java +3 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,9 @@ public final class SystemUiDeviceConfigFlags { */ public static final String NAS_DEFAULT_SERVICE = "nas_default_service"; /** (boolean) Whether notify() calls to NMS should acquire and hold WakeLocks. */ public static final String NOTIFY_WAKELOCK = "nms_notify_wakelock"; // Flags related to media notifications /** Loading services/core/java/com/android/server/notification/NotificationManagerService.java +4 −1 Original line number Diff line number Diff line Loading @@ -6597,7 +6597,10 @@ public class NotificationManagerService extends SystemService { } private PostNotificationTracker acquireWakeLockForPost(String pkg, int uid) { if (mFlagResolver.isEnabled(WAKE_LOCK_FOR_POSTING_NOTIFICATION)) { if (mFlagResolver.isEnabled(WAKE_LOCK_FOR_POSTING_NOTIFICATION) && Binder.withCleanCallingIdentity( () -> DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NOTIFY_WAKELOCK, false))) { // The package probably doesn't have WAKE_LOCK permission and should not require it. return Binder.withCleanCallingIdentity(() -> { WakeLock wakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +19 −1 Original line number Diff line number Diff line Loading @@ -587,6 +587,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { return wl; }); mTestFlagResolver.setFlagOverride(WAKE_LOCK_FOR_POSTING_NOTIFICATION, true); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NOTIFY_WAKELOCK, "true", false); // apps allowed as convos mService.setStringArrayResourceValue(PKG_O); Loading Loading @@ -1929,8 +1931,24 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } @Test public void enqueueNotification_wakeLockFlagOff_noWakeLock() throws Exception { public void enqueueNotification_wakeLockSystemPropertyOff_noWakeLock() throws Exception { mTestFlagResolver.setFlagOverride(WAKE_LOCK_FOR_POSTING_NOTIFICATION, false); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NOTIFY_WAKELOCK, "true", false); mBinderService.enqueueNotificationWithTag(PKG, PKG, "enqueueNotification_setsWakeLockWorkSource", 0, generateNotificationRecord(null).getNotification(), 0); waitForIdle(); verifyZeroInteractions(mPowerManager); } @Test public void enqueueNotification_wakeLockDeviceConfigOff_noWakeLock() throws Exception { mTestFlagResolver.setFlagOverride(WAKE_LOCK_FOR_POSTING_NOTIFICATION, true); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NOTIFY_WAKELOCK, "false", false); mBinderService.enqueueNotificationWithTag(PKG, PKG, "enqueueNotification_setsWakeLockWorkSource", 0, Loading Loading
core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java +3 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,9 @@ public final class SystemUiDeviceConfigFlags { */ public static final String NAS_DEFAULT_SERVICE = "nas_default_service"; /** (boolean) Whether notify() calls to NMS should acquire and hold WakeLocks. */ public static final String NOTIFY_WAKELOCK = "nms_notify_wakelock"; // Flags related to media notifications /** Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +4 −1 Original line number Diff line number Diff line Loading @@ -6597,7 +6597,10 @@ public class NotificationManagerService extends SystemService { } private PostNotificationTracker acquireWakeLockForPost(String pkg, int uid) { if (mFlagResolver.isEnabled(WAKE_LOCK_FOR_POSTING_NOTIFICATION)) { if (mFlagResolver.isEnabled(WAKE_LOCK_FOR_POSTING_NOTIFICATION) && Binder.withCleanCallingIdentity( () -> DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NOTIFY_WAKELOCK, false))) { // The package probably doesn't have WAKE_LOCK permission and should not require it. return Binder.withCleanCallingIdentity(() -> { WakeLock wakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +19 −1 Original line number Diff line number Diff line Loading @@ -587,6 +587,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { return wl; }); mTestFlagResolver.setFlagOverride(WAKE_LOCK_FOR_POSTING_NOTIFICATION, true); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NOTIFY_WAKELOCK, "true", false); // apps allowed as convos mService.setStringArrayResourceValue(PKG_O); Loading Loading @@ -1929,8 +1931,24 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } @Test public void enqueueNotification_wakeLockFlagOff_noWakeLock() throws Exception { public void enqueueNotification_wakeLockSystemPropertyOff_noWakeLock() throws Exception { mTestFlagResolver.setFlagOverride(WAKE_LOCK_FOR_POSTING_NOTIFICATION, false); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NOTIFY_WAKELOCK, "true", false); mBinderService.enqueueNotificationWithTag(PKG, PKG, "enqueueNotification_setsWakeLockWorkSource", 0, generateNotificationRecord(null).getNotification(), 0); waitForIdle(); verifyZeroInteractions(mPowerManager); } @Test public void enqueueNotification_wakeLockDeviceConfigOff_noWakeLock() throws Exception { mTestFlagResolver.setFlagOverride(WAKE_LOCK_FOR_POSTING_NOTIFICATION, true); DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI, SystemUiDeviceConfigFlags.NOTIFY_WAKELOCK, "false", false); mBinderService.enqueueNotificationWithTag(PKG, PKG, "enqueueNotification_setsWakeLockWorkSource", 0, Loading