summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eric Berglund <ericberglund@google.com> 2020-02-25 17:37:15 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-02-25 17:37:15 +0000
commitb896072638b5950593962667a34c75f3713bb8e5 (patch)
tree61f4324ac99fc73c0d83623823de8ce70a21d0b2
parent6075dd7f58766902e06941552f27ff5ceacd369f (diff)
parentcbfe702556fea02b6a2d467419cb719274c154fc (diff)
Merge "DO NOT MERGE Hold onto NotificationListener when reconnecting notifications UI." into qt-qpr1-dev
-rw-r--r--packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java34
1 files changed, 15 insertions, 19 deletions
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
index 4e1f552f7f99..5d240f173d17 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
@@ -41,7 +41,6 @@ import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
-import android.os.RemoteException;
import android.util.Log;
import android.view.Display;
import android.view.GestureDetector;
@@ -654,20 +653,22 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
}
});
- if (mCarNotificationListener != null) {
- try {
- // If we already had a notification listener we need to unreigster is before
- // making a new one
- mCarNotificationListener.unregisterAsSystemService();
- } catch (RemoteException e) {
- Log.e(TAG, "Error unregistering notification listener.");
- }
- }
-
- mCarNotificationListener = new CarNotificationListener();
mCarUxRestrictionManagerWrapper = new CarUxRestrictionManagerWrapper();
- mNotificationDataManager = new NotificationDataManager();
+ if (mCarNotificationListener == null) {
+ // Only make and register a listener if we don't already have one since
+ // #connectNotificationsUI can be called multiple times on locale change.
+ mCarNotificationListener = new CarNotificationListener();
+ mNotificationDataManager = new NotificationDataManager();
+
+ CarHeadsUpNotificationManager carHeadsUpNotificationManager =
+ new CarSystemUIHeadsUpNotificationManager(mContext,
+ mNotificationClickHandlerFactory, mNotificationDataManager);
+ mCarNotificationListener.registerAsSystemService(mContext,
+ mCarUxRestrictionManagerWrapper,
+ carHeadsUpNotificationManager, mNotificationDataManager);
+ }
+
mNotificationDataManager.setOnUnseenCountUpdateListener(() -> {
if (mNavigationBarView != null && mNotificationDataManager != null) {
onUseenCountUpdate(mNotificationDataManager.getUnseenNotificationCount());
@@ -676,13 +677,8 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
mEnableHeadsUpNotificationWhenNotificationShadeOpen = mContext.getResources().getBoolean(
R.bool.config_enableHeadsUpNotificationWhenNotificationShadeOpen);
- CarHeadsUpNotificationManager carHeadsUpNotificationManager =
- new CarSystemUIHeadsUpNotificationManager(mContext,
- mNotificationClickHandlerFactory, mNotificationDataManager);
- mNotificationClickHandlerFactory.setNotificationDataManager(mNotificationDataManager);
- mCarNotificationListener.registerAsSystemService(mContext, mCarUxRestrictionManagerWrapper,
- carHeadsUpNotificationManager, mNotificationDataManager);
+ mNotificationClickHandlerFactory.setNotificationDataManager(mNotificationDataManager);
mNotificationView = mStatusBarWindow.findViewById(R.id.notification_view);
View glassPane = mStatusBarWindow.findViewById(R.id.glass_pane);