Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47481f81 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add the BIND_ALLOW_FREEZE flag to NLS bindings" into main

parents 63a6e7e7 5f79688e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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.
+7 −0
Original line number Diff line number Diff line
@@ -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"
+8 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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,