summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTony <twickham@google.com>2018-04-17 18:54:10 -0700
committerTony <twickham@google.com>2018-04-17 18:54:10 -0700
commit7aa922c912230ada9812f9f61c93594635d1b0ec (patch)
treef87ed5b35e06b7067c26f06b07a4cdf6a021a3e0 /src
parentde967a2355752c2653ed14a1d57a7a8c8c2eef57 (diff)
downloadandroid_packages_apps_Trebuchet-7aa922c912230ada9812f9f61c93594635d1b0ec.tar.gz
android_packages_apps_Trebuchet-7aa922c912230ada9812f9f61c93594635d1b0ec.tar.bz2
android_packages_apps_Trebuchet-7aa922c912230ada9812f9f61c93594635d1b0ec.zip
Make sure notification listener stays unbound on reboot when badging disabled
We were requesting unbind in onCreate(), but the NotificationListenerService documentation for requestUnbind() clearly states "The service should wait for the {@link #onListenerConnected()} event before performing this operation. I know it's tempting, but you must wait." I was tempted, and I did not wait. :( The fact that the notification listener was binding even though the setting was off was not only inefficient, but also had at least one user-visible bug: because secure settings are set per user, the global badging setting actually only applies canShowBadge = false for user 0; other users such as work profile still show badges. Repro steps: 1. Have a work profile 2. Get a notification on work profile app and normal app 3. Turn off global badging setting ("Allow notification dots" from home settings) 4. Reboot the device In this case, we get onCreate, call requestUnbind() which is ignored since we aren't bound, then get onBind() and onListenerConnected() etc. Thus the work profile app has a notification dot and other apps don't. Bug: 71545493 Change-Id: I7f7dc219b25c28257f8b98fba7e362b99d3cba45
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/notification/NotificationListener.java22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/com/android/launcher3/notification/NotificationListener.java b/src/com/android/launcher3/notification/NotificationListener.java
index 117287ba7..b527b6a8d 100644
--- a/src/com/android/launcher3/notification/NotificationListener.java
+++ b/src/com/android/launcher3/notification/NotificationListener.java
@@ -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