From 7c2367f006218017381d35d0edeed27ba5cccfa6 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Wed, 30 Jan 2019 14:50:14 -0500 Subject: [PATCH] Change NotificationListener initialization - NotificationListener doesn't need a presenter - And the tests deefinitely don't need to register with the live system server Test: atest, device reboot Change-Id: I5e12cabdffc2584c1f8e62ac4c49653aeaa80eff Fixes: 123643503 --- .../android/systemui/statusbar/NotificationListener.java | 6 +----- .../src/com/android/systemui/statusbar/phone/StatusBar.java | 2 +- .../android/systemui/statusbar/NonPhoneDependencyTest.java | 1 - .../systemui/statusbar/NotificationListenerTest.java | 2 -- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java index 0583843d003b2..be63bad47d4ac 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java @@ -55,8 +55,6 @@ public class NotificationListener extends NotificationListenerWithPlugins { private final ArrayList mSettingsListeners = new ArrayList<>(); private final Context mContext; - protected NotificationPresenter mPresenter; - public NotificationListener(Context context) { mContext = context; } @@ -152,9 +150,7 @@ public class NotificationListener extends NotificationListenerWithPlugins { } } - public void setUpWithPresenter(NotificationPresenter presenter) { - mPresenter = presenter; - + public void registerAsSystemService() { try { registerAsSystemService(mContext, new ComponentName(mContext.getPackageName(), getClass().getCanonicalName()), diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index ceadd1e9fa089..46a65b34c1531 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -613,6 +613,7 @@ public class StatusBar extends SystemUI implements DemoMode, mNotificationLogger = Dependency.get(NotificationLogger.class); mRemoteInputManager = Dependency.get(NotificationRemoteInputManager.class); mNotificationListener = Dependency.get(NotificationListener.class); + mNotificationListener.registerAsSystemService(); mNetworkController = Dependency.get(NetworkController.class); mUserSwitcherController = Dependency.get(UserSwitcherController.class); mScreenLifecycle = Dependency.get(ScreenLifecycle.class); @@ -1055,7 +1056,6 @@ public class StatusBar extends SystemUI implements DemoMode, mDeviceProvisionedController); mAppOpsController.addCallback(APP_OPS, this); - mNotificationListener.setUpWithPresenter(mPresenter); mNotificationShelf.setOnActivatedListener(mPresenter); mRemoteInputManager.getController().addCallback(mStatusBarWindowController); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java index 425ca581493e6..8e92684876f66 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NonPhoneDependencyTest.java @@ -97,7 +97,6 @@ public class NonPhoneDependencyTest extends SysuiTestCase { mDelegate); lockscreenUserManager.setUpWithPresenter(mPresenter); viewHierarchyManager.setUpWithPresenter(mPresenter, mListContainer); - notificationListener.setUpWithPresenter(mPresenter); TestableLooper.get(this).processAllMessages(); assertFalse(mDependency.hasInstantiatedDependency(StatusBarWindowController.class)); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java index bcf5964bead53..cffa9c7d4deb2 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationListenerTest.java @@ -77,8 +77,6 @@ public class NotificationListenerTest extends SysuiTestCase { mListener = new NotificationListener(mContext); mSbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME, 0, null, TEST_UID, 0, new Notification(), UserHandle.CURRENT, null, 0); - - mListener.setUpWithPresenter(mPresenter); } @Test