summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/notification
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2018-10-17 10:25:14 -0700
committerSunny Goyal <sunnygoyal@google.com>2018-10-17 12:07:13 -0700
commit420d54544e1386862d80a131d19a68049a879bf1 (patch)
tree4b316dc4f5a4f17075dfefb84230c457c0ef4f9c /src/com/android/launcher3/notification
parent55ba0dcaaf65ca6a9ce8f973d100b4619724d3b4 (diff)
downloadpackages_apps_Trebuchet-420d54544e1386862d80a131d19a68049a879bf1.tar.gz
packages_apps_Trebuchet-420d54544e1386862d80a131d19a68049a879bf1.tar.bz2
packages_apps_Trebuchet-420d54544e1386862d80a131d19a68049a879bf1.zip
Using a common class for observing secure settings
Bug: 117519297 Change-Id: Ie9d948130aea50bf10c9fc625fdb16f4cfc4712e
Diffstat (limited to 'src/com/android/launcher3/notification')
-rw-r--r--src/com/android/launcher3/notification/NotificationListener.java27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/com/android/launcher3/notification/NotificationListener.java b/src/com/android/launcher3/notification/NotificationListener.java
index 68cf7dec0..f27b72819 100644
--- a/src/com/android/launcher3/notification/NotificationListener.java
+++ b/src/com/android/launcher3/notification/NotificationListener.java
@@ -16,7 +16,7 @@
package com.android.launcher3.notification;
-import static com.android.launcher3.SettingsActivity.NOTIFICATION_BADGING;
+import static com.android.launcher3.util.SecureSettingsObserver.newNotificationSettingsObserver;
import android.annotation.TargetApi;
import android.app.Notification;
@@ -28,14 +28,13 @@ import android.os.Message;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.text.TextUtils;
-import android.util.ArraySet;
import android.util.Log;
import android.util.Pair;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.PackageUserKey;
-import com.android.launcher3.util.SettingsObserver;
+import com.android.launcher3.util.SecureSettingsObserver;
import java.util.ArrayList;
import java.util.Arrays;
@@ -43,7 +42,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import androidx.annotation.Nullable;
@@ -79,7 +77,7 @@ public class NotificationListener extends NotificationListenerService {
/** The last notification key that was dismissed from launcher UI */
private String mLastKeyDismissedByLauncher;
- private SettingsObserver mNotificationBadgingObserver;
+ private SecureSettingsObserver mNotificationBadgingObserver;
private final Handler.Callback mWorkerCallback = new Handler.Callback() {
@Override
@@ -196,19 +194,20 @@ public class NotificationListener extends NotificationListenerService {
super.onListenerConnected();
sIsConnected = true;
- mNotificationBadgingObserver = new SettingsObserver.Secure(getContentResolver()) {
- @Override
- public void onSettingChanged(boolean isNotificationBadgingEnabled) {
- if (!isNotificationBadgingEnabled && sIsConnected) {
- requestUnbind();
- }
- }
- };
- mNotificationBadgingObserver.register(NOTIFICATION_BADGING);
+ mNotificationBadgingObserver =
+ newNotificationSettingsObserver(this, this::onNotificationBadgingChanged);
+ mNotificationBadgingObserver.register();
+ mNotificationBadgingObserver.dispatchOnChange();
onNotificationFullRefresh();
}
+ private void onNotificationBadgingChanged(boolean isNotificationBadgingEnabled) {
+ if (!isNotificationBadgingEnabled && sIsConnected) {
+ requestUnbind();
+ }
+ }
+
private void onNotificationFullRefresh() {
mWorkerHandler.obtainMessage(MSG_NOTIFICATION_FULL_REFRESH).sendToTarget();
}