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

Commit 5c3706c2 authored by Tony Wickham's avatar Tony Wickham Committed by Android (Google) Code Review
Browse files

Merge "Make sure notification listener stays unbound on reboot when badging...

Merge "Make sure notification listener stays unbound on reboot when badging disabled" into ub-launcher3-edmonton
parents b67e3533 7aa922c9
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -150,22 +150,12 @@ public class NotificationListener extends NotificationListenerService {
    public void onCreate() {
        super.onCreate();
        sIsCreated = true;
        mNotificationBadgingObserver = new SettingsObserver.Secure(getContentResolver()) {
            @Override
            public void onSettingChanged(boolean isNotificationBadgingEnabled) {
                if (!isNotificationBadgingEnabled) {
                    requestUnbind();
                }
            }
        };
        mNotificationBadgingObserver.register(NOTIFICATION_BADGING);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        sIsCreated = false;
        mNotificationBadgingObserver.unregister();
    }

    public static @Nullable NotificationListener getInstanceIfConnected() {
@@ -203,6 +193,17 @@ public class NotificationListener extends NotificationListenerService {
    public void onListenerConnected() {
        super.onListenerConnected();
        sIsConnected = true;

        mNotificationBadgingObserver = new SettingsObserver.Secure(getContentResolver()) {
            @Override
            public void onSettingChanged(boolean isNotificationBadgingEnabled) {
                if (!isNotificationBadgingEnabled) {
                    requestUnbind();
                }
            }
        };
        mNotificationBadgingObserver.register(NOTIFICATION_BADGING);

        onNotificationFullRefresh();
    }

@@ -214,6 +215,7 @@ public class NotificationListener extends NotificationListenerService {
    public void onListenerDisconnected() {
        super.onListenerDisconnected();
        sIsConnected = false;
        mNotificationBadgingObserver.unregister();
    }

    @Override