summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/LauncherAppState.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/LauncherAppState.java')
-rw-r--r--src/com/android/launcher3/LauncherAppState.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index cf20febd5..1ffe41bc6 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -16,6 +16,7 @@
package com.android.launcher3;
+import android.content.ComponentName;
import android.content.ContentProviderClient;
import android.content.Context;
import android.content.Intent;
@@ -28,13 +29,17 @@ import com.android.launcher3.compat.PackageInstallerCompat;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dynamicui.ExtractionUtils;
+import com.android.launcher3.notification.NotificationListener;
import com.android.launcher3.util.ConfigMonitor;
import com.android.launcher3.util.Preconditions;
+import com.android.launcher3.util.SettingsObserver;
import com.android.launcher3.util.TestingUtils;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
+import static com.android.launcher3.SettingsActivity.NOTIFICATION_BADGING;
+
public class LauncherAppState {
public static final boolean PROFILE_STARTUP = FeatureFlags.IS_DOGFOOD_BUILD;
@@ -47,7 +52,7 @@ public class LauncherAppState {
private final IconCache mIconCache;
private final WidgetPreviewLoader mWidgetCache;
private final InvariantDeviceProfile mInvariantDeviceProfile;
-
+ private final SettingsObserver mNotificationBadgingObserver;
public static LauncherAppState getInstance(final Context context) {
if (INSTANCE == null) {
@@ -117,6 +122,23 @@ public class LauncherAppState {
new ConfigMonitor(mContext).register();
ExtractionUtils.startColorExtractionServiceIfNecessary(mContext);
+
+ if (!mContext.getResources().getBoolean(R.bool.notification_badging_enabled)) {
+ mNotificationBadgingObserver = null;
+ } else {
+ // Register an observer to rebind the notification listener when badging is re-enabled.
+ mNotificationBadgingObserver = new SettingsObserver.Secure(
+ mContext.getContentResolver()) {
+ @Override
+ public void onSettingChanged(boolean isNotificationBadgingEnabled) {
+ if (isNotificationBadgingEnabled) {
+ NotificationListener.requestRebind(new ComponentName(
+ mContext, NotificationListener.class));
+ }
+ }
+ };
+ mNotificationBadgingObserver.register(NOTIFICATION_BADGING);
+ }
}
/**
@@ -127,6 +149,9 @@ public class LauncherAppState {
final LauncherAppsCompat launcherApps = LauncherAppsCompat.getInstance(mContext);
launcherApps.removeOnAppsChangedCallback(mModel);
PackageInstallerCompat.getInstance(mContext).onStop();
+ if (mNotificationBadgingObserver != null) {
+ mNotificationBadgingObserver.unregister();
+ }
}
LauncherModel setLauncher(Launcher launcher) {