diff options
4 files changed, 10 insertions, 57 deletions
diff --git a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java index 0a69ea8ce633..048912c0b2e2 100644 --- a/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java +++ b/core/java/com/android/internal/config/sysui/SystemUiDeviceConfigFlags.java @@ -118,9 +118,6 @@ 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 /** diff --git a/core/java/com/android/internal/config/sysui/SystemUiSystemPropertiesFlags.java b/core/java/com/android/internal/config/sysui/SystemUiSystemPropertiesFlags.java index 9233050c97ad..8de448be440b 100644 --- a/core/java/com/android/internal/config/sysui/SystemUiSystemPropertiesFlags.java +++ b/core/java/com/android/internal/config/sysui/SystemUiSystemPropertiesFlags.java @@ -74,10 +74,6 @@ public class SystemUiSystemPropertiesFlags { public static final Flag LOG_DND_STATE_EVENTS = releasedFlag("persist.sysui.notification.log_dnd_state_events"); - /** Gating the holding of WakeLocks until NLSes are told about a new notification. */ - public static final Flag WAKE_LOCK_FOR_POSTING_NOTIFICATION = - releasedFlag("persist.sysui.notification.wake_lock_for_posting_notification"); - /** Gating storing NotificationRankingUpdate ranking map in shared memory. */ public static final Flag RANKING_UPDATE_ASHMEM = devFlag( "persist.sysui.notification.ranking_update_ashmem"); diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index be6133b5b6ae..1afa3ed97463 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -118,7 +118,6 @@ import static android.service.notification.NotificationListenerService.TRIM_FULL import static android.service.notification.NotificationListenerService.TRIM_LIGHT; import static android.view.WindowManager.LayoutParams.TYPE_TOAST; -import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.WAKE_LOCK_FOR_POSTING_NOTIFICATION; import static com.android.internal.util.FrameworkStatsLog.DND_MODE_RULE; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES; import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_CHANNEL_PREFERENCES; @@ -533,6 +532,8 @@ public class NotificationManagerService extends SystemService { @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.S_V2) private static final long NOTIFICATION_LOG_ASSISTANT_CANCEL = 195579280L; + private static final Duration POST_WAKE_LOCK_TIMEOUT = Duration.ofSeconds(30); + private IActivityManager mAm; private ActivityTaskManagerInternal mAtm; private ActivityManager mActivityManager; @@ -6676,22 +6677,14 @@ public class NotificationManagerService extends SystemService { } private PostNotificationTracker acquireWakeLockForPost(String pkg, int uid) { - 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, - "NotificationManagerService:post:" + pkg); - wakeLock.setWorkSource(new WorkSource(uid, pkg)); - // TODO(b/275044361): Adjust to a more reasonable number when we have the data. - wakeLock.acquire(30_000); - return mPostNotificationTrackerFactory.newTracker(wakeLock); - }); - } else { - return mPostNotificationTrackerFactory.newTracker(null); - } + // 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, + "NotificationManagerService:post:" + pkg); + wakeLock.setWorkSource(new WorkSource(uid, pkg)); + wakeLock.acquire(POST_WAKE_LOCK_TIMEOUT.toMillis()); + return mPostNotificationTrackerFactory.newTracker(wakeLock); + }); } /** 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 37f49838a61b..70e5c2e1b198 100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -83,7 +83,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_TOAST; import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.FSI_FORCE_DEMOTE; import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.SHOW_STICKY_HUN_FOR_DENIED_FSI; -import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.WAKE_LOCK_FOR_POSTING_NOTIFICATION; import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN; import static com.android.server.am.PendingIntentRecord.FLAG_ACTIVITY_SENDER; import static com.android.server.am.PendingIntentRecord.FLAG_BROADCAST_SENDER; @@ -128,7 +127,6 @@ import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; import static java.util.Collections.emptyList; @@ -596,9 +594,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { mAcquiredWakeLocks.add(wl); 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); @@ -1964,34 +1959,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } @Test - 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, - generateNotificationRecord(null).getNotification(), 0); - waitForIdle(); - - verifyZeroInteractions(mPowerManager); - } - - @Test public void testCancelNonexistentNotification() throws Exception { mBinderService.cancelNotificationWithTag(PKG, PKG, "testCancelNonexistentNotification", 0, 0); |