Loading services/core/java/com/android/server/notification/NotificationManagerService.java +4 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ import static android.app.StatusBarManager.ACTION_KEYGUARD_PRIVATE_NOTIFICATIONS import static android.app.StatusBarManager.EXTRA_KM_PRIVATE_NOTIFS_ALLOWED; import static android.app.backup.NotificationLoggingConstants.DATA_TYPE_ZEN_CONFIG; import static android.app.backup.NotificationLoggingConstants.ERROR_XML_PARSING; import static android.content.Context.BIND_ALLOW_FREEZE; import static android.content.Context.BIND_ALLOW_WHITELIST_MANAGEMENT; import static android.content.Context.BIND_AUTO_CREATE; import static android.content.Context.BIND_FOREGROUND_SERVICE; Loading Loading @@ -13715,6 +13716,9 @@ public class NotificationManagerService extends SystemService { if (reportNlsStartAndEnd()) { freezeFlags = BIND_SIMULATE_ALLOW_FREEZE; } if (Flags.allowFreezingIdleNls()) { freezeFlags |= BIND_ALLOW_FREEZE; } // Most of the same flags as the base, but also add BIND_NOT_PERCEPTIBLE // because too many 3P apps could be kept in memory as notification listeners and // cause extreme memory pressure. services/core/java/com/android/server/notification/flags.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -184,6 +184,13 @@ flag { bug: "380297485" } flag { name: "allow_freezing_idle_nls" namespace: "backstage_power" description: "Allows freezing idle notification listener services" bug: "344050265" } flag { name: "log_cached_posts" namespace: "systemui" Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationListenersTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.notification; import static android.Manifest.permission.RECEIVE_SENSITIVE_NOTIFICATIONS; import static android.content.Context.BIND_ALLOW_FREEZE; import static android.content.Context.BIND_SIMULATE_ALLOW_FREEZE; import static android.content.pm.PackageManager.MATCH_ANY_USER; import static android.permission.PermissionManager.PERMISSION_GRANTED; Loading @@ -26,6 +27,7 @@ import static android.service.notification.NotificationListenerService.FLAG_FILT import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_SILENT; import static android.service.notification.NotificationListenerService.NOTIFICATION_CHANNEL_OR_GROUP_ADDED; import static com.android.server.notification.Flags.FLAG_ALLOW_FREEZING_IDLE_NLS; import static com.android.server.notification.NotificationManagerService.NotificationListeners.BINDER_TAG_ON_INTERRUPTION_FILTER_CHANGED; import static com.android.server.notification.NotificationManagerService.NotificationListeners.BINDER_TAG_ON_LISTENER_CONNECTED; import static com.android.server.notification.NotificationManagerService.NotificationListeners.BINDER_TAG_ON_LISTENER_HINTS_CHANGED; Loading Loading @@ -446,6 +448,12 @@ public class NotificationListenersTest extends UiServiceTestCase { BIND_SIMULATE_ALLOW_FREEZE); } @Test @EnableFlags(FLAG_ALLOW_FREEZING_IDLE_NLS) public void testBindFlagsIncludesAllowFreeze() { assertThat(mListeners.getBindFlags() & BIND_ALLOW_FREEZE).isEqualTo(BIND_ALLOW_FREEZE); } private ManagedServices.ManagedServiceInfo getNewManagedServiceInfo( IBinderSession iBinderSession) { return mListeners.new ManagedServiceInfo(mock(INotificationListener.class), mCn1, Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +4 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ import static android.app.StatusBarManager.ACTION_KEYGUARD_PRIVATE_NOTIFICATIONS import static android.app.StatusBarManager.EXTRA_KM_PRIVATE_NOTIFS_ALLOWED; import static android.app.backup.NotificationLoggingConstants.DATA_TYPE_ZEN_CONFIG; import static android.app.backup.NotificationLoggingConstants.ERROR_XML_PARSING; import static android.content.Context.BIND_ALLOW_FREEZE; import static android.content.Context.BIND_ALLOW_WHITELIST_MANAGEMENT; import static android.content.Context.BIND_AUTO_CREATE; import static android.content.Context.BIND_FOREGROUND_SERVICE; Loading Loading @@ -13715,6 +13716,9 @@ public class NotificationManagerService extends SystemService { if (reportNlsStartAndEnd()) { freezeFlags = BIND_SIMULATE_ALLOW_FREEZE; } if (Flags.allowFreezingIdleNls()) { freezeFlags |= BIND_ALLOW_FREEZE; } // Most of the same flags as the base, but also add BIND_NOT_PERCEPTIBLE // because too many 3P apps could be kept in memory as notification listeners and // cause extreme memory pressure.
services/core/java/com/android/server/notification/flags.aconfig +7 −0 Original line number Diff line number Diff line Loading @@ -184,6 +184,13 @@ flag { bug: "380297485" } flag { name: "allow_freezing_idle_nls" namespace: "backstage_power" description: "Allows freezing idle notification listener services" bug: "344050265" } flag { name: "log_cached_posts" namespace: "systemui" Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationListenersTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.notification; import static android.Manifest.permission.RECEIVE_SENSITIVE_NOTIFICATIONS; import static android.content.Context.BIND_ALLOW_FREEZE; import static android.content.Context.BIND_SIMULATE_ALLOW_FREEZE; import static android.content.pm.PackageManager.MATCH_ANY_USER; import static android.permission.PermissionManager.PERMISSION_GRANTED; Loading @@ -26,6 +27,7 @@ import static android.service.notification.NotificationListenerService.FLAG_FILT import static android.service.notification.NotificationListenerService.FLAG_FILTER_TYPE_SILENT; import static android.service.notification.NotificationListenerService.NOTIFICATION_CHANNEL_OR_GROUP_ADDED; import static com.android.server.notification.Flags.FLAG_ALLOW_FREEZING_IDLE_NLS; import static com.android.server.notification.NotificationManagerService.NotificationListeners.BINDER_TAG_ON_INTERRUPTION_FILTER_CHANGED; import static com.android.server.notification.NotificationManagerService.NotificationListeners.BINDER_TAG_ON_LISTENER_CONNECTED; import static com.android.server.notification.NotificationManagerService.NotificationListeners.BINDER_TAG_ON_LISTENER_HINTS_CHANGED; Loading Loading @@ -446,6 +448,12 @@ public class NotificationListenersTest extends UiServiceTestCase { BIND_SIMULATE_ALLOW_FREEZE); } @Test @EnableFlags(FLAG_ALLOW_FREEZING_IDLE_NLS) public void testBindFlagsIncludesAllowFreeze() { assertThat(mListeners.getBindFlags() & BIND_ALLOW_FREEZE).isEqualTo(BIND_ALLOW_FREEZE); } private ManagedServices.ManagedServiceInfo getNewManagedServiceInfo( IBinderSession iBinderSession) { return mListeners.new ManagedServiceInfo(mock(INotificationListener.class), mCn1, Loading