Remove NotificationPresenter#getEntryManager.

Instead, pass it along with calls to setUpWithPresenter.

Bug: 63874929
Bug: 62602530
Test: runtest systemui
Test: Compile and run
Change-Id: Icd60cf671b12b33d4565cc608c6141cd580c790e
This commit is contained in:
Eliot Courtney
2017-12-14 19:38:52 +09:00
parent 8f56b0e345
commit 4a96b36fd9
15 changed files with 75 additions and 82 deletions

View File

@@ -71,10 +71,8 @@ public class NotificationGutsManager implements Dumpable {
// which notification is currently being longpress-examined by the user
private NotificationGuts mNotificationGutsExposed;
private NotificationMenuRowPlugin.MenuItem mGutsMenuItem;
private NotificationPresenter mPresenter;
// TODO: Create NotificationListContainer interface and use it instead of
// NotificationStackScrollLayout here
protected NotificationPresenter mPresenter;
protected NotificationEntryManager mEntryManager;
private NotificationListContainer mListContainer;
private NotificationInfo.CheckSaveListener mCheckSaveListener;
private OnSettingsClickListener mOnSettingsClickListener;
@@ -95,10 +93,12 @@ public class NotificationGutsManager implements Dumpable {
mContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
}
public void setUp(NotificationPresenter presenter, NotificationListContainer listContainer,
public void setUpWithPresenter(NotificationPresenter presenter,
NotificationEntryManager entryManager, NotificationListContainer listContainer,
NotificationInfo.CheckSaveListener checkSaveListener,
OnSettingsClickListener onSettingsClickListener) {
mPresenter = presenter;
mEntryManager = entryManager;
mListContainer = listContainer;
mCheckSaveListener = checkSaveListener;
mOnSettingsClickListener = onSettingsClickListener;
@@ -166,8 +166,7 @@ public class NotificationGutsManager implements Dumpable {
String key = sbn.getKey();
if (key.equals(mKeyToRemoveOnGutsClosed)) {
mKeyToRemoveOnGutsClosed = null;
mPresenter.getEntryManager().removeNotification(key,
mPresenter.getEntryManager().getLatestRankingMap());
mEntryManager.removeNotification(key, mEntryManager.getLatestRankingMap());
}
});

View File

@@ -39,7 +39,8 @@ public class NotificationListener extends NotificationListenerWithPlugins {
private final NotificationRemoteInputManager mRemoteInputManager;
private final Context mContext;
private NotificationPresenter mPresenter;
protected NotificationPresenter mPresenter;
protected NotificationEntryManager mEntryManager;
public NotificationListener(NotificationRemoteInputManager remoteInputManager,
Context context) {
@@ -59,7 +60,7 @@ public class NotificationListener extends NotificationListenerWithPlugins {
final RankingMap currentRanking = getCurrentRanking();
mPresenter.getHandler().post(() -> {
for (StatusBarNotification sbn : notifications) {
mPresenter.getEntryManager().addNotification(sbn, currentRanking);
mEntryManager.addNotification(sbn, currentRanking);
}
});
}
@@ -74,7 +75,7 @@ public class NotificationListener extends NotificationListenerWithPlugins {
String key = sbn.getKey();
mRemoteInputManager.getKeysKeptForRemoteInput().remove(key);
boolean isUpdate =
mPresenter.getEntryManager().getNotificationData().get(key) != null;
mEntryManager.getNotificationData().get(key) != null;
// In case we don't allow child notifications, we ignore children of
// notifications that have a summary, since` we're not going to show them
// anyway. This is true also when the summary is canceled,
@@ -87,17 +88,17 @@ public class NotificationListener extends NotificationListenerWithPlugins {
// Remove existing notification to avoid stale data.
if (isUpdate) {
mPresenter.getEntryManager().removeNotification(key, rankingMap);
mEntryManager.removeNotification(key, rankingMap);
} else {
mPresenter.getEntryManager().getNotificationData()
mEntryManager.getNotificationData()
.updateRanking(rankingMap);
}
return;
}
if (isUpdate) {
mPresenter.getEntryManager().updateNotification(sbn, rankingMap);
mEntryManager.updateNotification(sbn, rankingMap);
} else {
mPresenter.getEntryManager().addNotification(sbn, rankingMap);
mEntryManager.addNotification(sbn, rankingMap);
}
});
}
@@ -110,7 +111,7 @@ public class NotificationListener extends NotificationListenerWithPlugins {
if (sbn != null && !onPluginNotificationRemoved(sbn, rankingMap)) {
final String key = sbn.getKey();
mPresenter.getHandler().post(() -> {
mPresenter.getEntryManager().removeNotification(key, rankingMap);
mEntryManager.removeNotification(key, rankingMap);
});
}
}
@@ -121,13 +122,15 @@ public class NotificationListener extends NotificationListenerWithPlugins {
if (rankingMap != null) {
RankingMap r = onPluginRankingUpdate(rankingMap);
mPresenter.getHandler().post(() -> {
mPresenter.getEntryManager().updateNotificationRanking(r);
mEntryManager.updateNotificationRanking(r);
});
}
}
public void setUpWithPresenter(NotificationPresenter presenter) {
public void setUpWithPresenter(NotificationPresenter presenter,
NotificationEntryManager entryManager) {
mPresenter = presenter;
mEntryManager = entryManager;
try {
registerAsSystemService(mContext,

View File

@@ -81,7 +81,7 @@ public class NotificationLockscreenUserManager implements Dumpable {
isCurrentProfile(getSendingUserId())) {
mUsersAllowingPrivateNotifications.clear();
updateLockscreenNotificationSetting();
mPresenter.getEntryManager().updateNotifications();
mEntryManager.updateNotifications();
} else if (Intent.ACTION_DEVICE_LOCKED_CHANGED.equals(action)) {
if (userId != mCurrentUserId && isCurrentProfile(userId)) {
mPresenter.onWorkChallengeChanged();
@@ -157,6 +157,7 @@ public class NotificationLockscreenUserManager implements Dumpable {
protected int mCurrentUserId = 0;
protected NotificationPresenter mPresenter;
protected NotificationEntryManager mEntryManager;
protected ContentObserver mLockscreenSettingsObserver;
protected ContentObserver mSettingsObserver;
@@ -170,8 +171,10 @@ public class NotificationLockscreenUserManager implements Dumpable {
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
}
public void setUpWithPresenter(NotificationPresenter presenter) {
public void setUpWithPresenter(NotificationPresenter presenter,
NotificationEntryManager entryManager) {
mPresenter = presenter;
mEntryManager = entryManager;
mLockscreenSettingsObserver = new ContentObserver(mPresenter.getHandler()) {
@Override
@@ -182,7 +185,7 @@ public class NotificationLockscreenUserManager implements Dumpable {
mUsersAllowingNotifications.clear();
// ... and refresh all the notifications
updateLockscreenNotificationSetting();
mPresenter.getEntryManager().updateNotifications();
mEntryManager.updateNotifications();
}
};
@@ -191,7 +194,7 @@ public class NotificationLockscreenUserManager implements Dumpable {
public void onChange(boolean selfChange) {
updateLockscreenNotificationSetting();
if (mDeviceProvisionedController.isDeviceProvisioned()) {
mPresenter.getEntryManager().updateNotifications();
mEntryManager.updateNotifications();
}
}
};
@@ -271,13 +274,13 @@ public class NotificationLockscreenUserManager implements Dumpable {
*/
public boolean shouldHideNotifications(String key) {
return isLockscreenPublicMode(mCurrentUserId)
&& mPresenter.getEntryManager().getNotificationData().getVisibilityOverride(key) ==
&& mEntryManager.getNotificationData().getVisibilityOverride(key) ==
Notification.VISIBILITY_SECRET;
}
public boolean shouldShowOnKeyguard(StatusBarNotification sbn) {
return mShowLockscreenNotifications
&& !mPresenter.getEntryManager().getNotificationData().isAmbient(sbn.getKey());
&& !mEntryManager.getNotificationData().isAmbient(sbn.getKey());
}
private void setShowLockscreenNotifications(boolean show) {
@@ -395,7 +398,7 @@ public class NotificationLockscreenUserManager implements Dumpable {
}
private boolean packageHasVisibilityOverride(String key) {
return mPresenter.getEntryManager().getNotificationData().getVisibilityOverride(key) ==
return mEntryManager.getNotificationData().getVisibilityOverride(key) ==
Notification.VISIBILITY_PRIVATE;
}

View File

@@ -49,7 +49,7 @@ public class NotificationLogger {
private final NotificationListenerService mNotificationListener;
private final UiOffloadThread mUiOffloadThread;
protected NotificationPresenter mPresenter;
protected NotificationEntryManager mEntryManager;
protected Handler mHandler = new Handler();
protected IStatusBarService mBarService;
private long mLastVisibilityReportUptimeMs;
@@ -96,8 +96,8 @@ public class NotificationLogger {
// notifications.
// 3. Report newly visible and no-longer visible notifications.
// 4. Keep currently visible notifications for next report.
ArrayList<NotificationData.Entry> activeNotifications = mPresenter.getEntryManager().
getNotificationData().getActiveNotifications();
ArrayList<NotificationData.Entry> activeNotifications = mEntryManager
.getNotificationData().getActiveNotifications();
int N = activeNotifications.size();
for (int i = 0; i < N; i++) {
NotificationData.Entry entry = activeNotifications.get(i);
@@ -140,9 +140,9 @@ public class NotificationLogger {
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
}
public void setUpWithPresenter(NotificationPresenter presenter,
public void setUpWithEntryManager(NotificationEntryManager entryManager,
NotificationListContainer listContainer) {
mPresenter = presenter;
mEntryManager = entryManager;
mListContainer = listContainer;
}

View File

@@ -43,7 +43,8 @@ public class NotificationMediaManager implements Dumpable {
private final Context mContext;
private final MediaSessionManager mMediaSessionManager;
private NotificationPresenter mPresenter;
protected NotificationPresenter mPresenter;
protected NotificationEntryManager mEntryManager;
private MediaController mMediaController;
private String mMediaNotificationKey;
private MediaMetadata mMediaMetadata;
@@ -82,8 +83,10 @@ public class NotificationMediaManager implements Dumpable {
// in session state
}
public void setUpWithPresenter(NotificationPresenter presenter) {
public void setUpWithPresenter(NotificationPresenter presenter,
NotificationEntryManager entryManager) {
mPresenter = presenter;
mEntryManager = entryManager;
}
public void onNotificationRemoved(String key) {
@@ -104,8 +107,8 @@ public class NotificationMediaManager implements Dumpable {
public void findAndUpdateMediaNotifications() {
boolean metaDataChanged = false;
synchronized (mPresenter.getEntryManager().getNotificationData()) {
ArrayList<NotificationData.Entry> activeNotifications = mPresenter.getEntryManager()
synchronized (mEntryManager.getNotificationData()) {
ArrayList<NotificationData.Entry> activeNotifications = mEntryManager
.getNotificationData().getActiveNotifications();
final int N = activeNotifications.size();
@@ -192,7 +195,7 @@ public class NotificationMediaManager implements Dumpable {
}
if (metaDataChanged) {
mPresenter.getEntryManager().updateNotifications();
mEntryManager.updateNotifications();
}
mPresenter.updateMediaMetaData(metaDataChanged, true);
}

View File

@@ -97,13 +97,6 @@ public interface NotificationPresenter extends NotificationData.Environment,
*/
boolean isDeviceInVrMode();
/**
* Returns the NotificationEntryManager for this presenter.
*
* @return NotificationEntryManager
*/
NotificationEntryManager getEntryManager();
/**
* Updates the visual representation of the notifications.
*/

View File

@@ -83,6 +83,7 @@ public class NotificationRemoteInputManager implements Dumpable {
protected RemoteInputController mRemoteInputController;
protected NotificationPresenter mPresenter;
protected NotificationEntryManager mEntryManager;
protected IStatusBarService mBarService;
protected Callback mCallback;
@@ -273,16 +274,18 @@ public class NotificationRemoteInputManager implements Dumpable {
}
public void setUpWithPresenter(NotificationPresenter presenter,
NotificationEntryManager entryManager,
Callback callback,
RemoteInputController.Delegate delegate) {
mPresenter = presenter;
mEntryManager = entryManager;
mCallback = callback;
mRemoteInputController = new RemoteInputController(delegate);
mRemoteInputController.addCallback(new RemoteInputController.Callback() {
@Override
public void onRemoteInputSent(NotificationData.Entry entry) {
if (FORCE_REMOTE_INPUT_HISTORY && mKeysKeptForRemoteInput.contains(entry.key)) {
mPresenter.getEntryManager().removeNotification(entry.key, null);
mEntryManager.removeNotification(entry.key, null);
} else if (mRemoteInputEntriesToRemoveOnCollapse.contains(entry)) {
// We're currently holding onto this notification, but from the apps point of
// view it is already canceled, so we'll need to cancel it on the apps behalf
@@ -290,7 +293,7 @@ public class NotificationRemoteInputManager implements Dumpable {
// bit.
mPresenter.getHandler().postDelayed(() -> {
if (mRemoteInputEntriesToRemoveOnCollapse.remove(entry)) {
mPresenter.getEntryManager().removeNotification(entry.key, null);
mEntryManager.removeNotification(entry.key, null);
}
}, REMOTE_INPUT_KEPT_ENTRY_AUTO_CANCEL_DELAY);
}
@@ -336,8 +339,7 @@ public class NotificationRemoteInputManager implements Dumpable {
for (int i = 0; i < mRemoteInputEntriesToRemoveOnCollapse.size(); i++) {
NotificationData.Entry entry = mRemoteInputEntriesToRemoveOnCollapse.valueAt(i);
mRemoteInputController.removeRemoteInput(entry, null);
mPresenter.getEntryManager().removeNotification(entry.key,
mPresenter.getEntryManager().getLatestRankingMap());
mEntryManager.removeNotification(entry.key, mEntryManager.getLatestRankingMap());
}
mRemoteInputEntriesToRemoveOnCollapse.clear();
}

View File

@@ -644,7 +644,7 @@ public class StatusBar extends SystemUI implements DemoMode,
mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
mLockPatternUtils = new LockPatternUtils(mContext);
mMediaManager.setUpWithPresenter(this);
mMediaManager.setUpWithPresenter(this, mEntryManager);
// Connect in to the status bar manager service
mCommandQueue = getComponent(CommandQueue.class);
@@ -670,7 +670,7 @@ public class StatusBar extends SystemUI implements DemoMode,
mContext.registerReceiver(mWallpaperChangedReceiver, wallpaperChangedFilter);
mWallpaperChangedReceiver.onReceive(mContext, null);
mLockscreenUserManager.setUpWithPresenter(this);
mLockscreenUserManager.setUpWithPresenter(this, mEntryManager);
mCommandQueue.disable(switches[0], switches[6], false /* animate */);
setSystemUiVisibility(switches[1], switches[7], switches[8], 0xffffffff,
fullscreenStackBounds, dockedStackBounds);
@@ -685,7 +685,7 @@ public class StatusBar extends SystemUI implements DemoMode,
}
// Set up the initial notification state.
mNotificationListener.setUpWithPresenter(this);
mNotificationListener.setUpWithPresenter(this, mEntryManager);
if (DEBUG) {
Log.d(TAG, String.format(
@@ -753,7 +753,7 @@ public class StatusBar extends SystemUI implements DemoMode,
// into fragments, but the rest here, it leaves some awkward lifecycle and whatnot.
mNotificationPanel = mStatusBarWindow.findViewById(R.id.notification_panel);
mStackScroller = mStatusBarWindow.findViewById(R.id.notification_stack_scroller);
mGutsManager.setUp(this, mStackScroller, mCheckSaveListener,
mGutsManager.setUpWithPresenter(this, mEntryManager, mStackScroller, mCheckSaveListener,
key -> {
try {
mBarService.onNotificationSettingsViewed(key);
@@ -761,7 +761,7 @@ public class StatusBar extends SystemUI implements DemoMode,
// if we're here we're dead
}
});
mNotificationLogger.setUpWithPresenter(this, mStackScroller);
mNotificationLogger.setUpWithEntryManager(mEntryManager, mStackScroller);
mNotificationPanel.setStatusBar(this);
mNotificationPanel.setGroupManager(mGroupManager);
mAboveShelfObserver = new AboveShelfObserver(mStackScroller);
@@ -2728,19 +2728,20 @@ public class StatusBar extends SystemUI implements DemoMode,
private void addStatusBarWindow() {
makeStatusBarView();
mStatusBarWindowManager = Dependency.get(StatusBarWindowManager.class);
mRemoteInputManager.setUpWithPresenter(this, this, new RemoteInputController.Delegate() {
public void setRemoteInputActive(NotificationData.Entry entry,
boolean remoteInputActive) {
mHeadsUpManager.setRemoteInputActive(entry, remoteInputActive);
}
public void lockScrollTo(NotificationData.Entry entry) {
mStackScroller.lockScrollTo(entry.row);
}
public void requestDisallowLongPressAndDismiss() {
mStackScroller.requestDisallowLongPress();
mStackScroller.requestDisallowDismiss();
}
});
mRemoteInputManager.setUpWithPresenter(this, mEntryManager, this,
new RemoteInputController.Delegate() {
public void setRemoteInputActive(NotificationData.Entry entry,
boolean remoteInputActive) {
mHeadsUpManager.setRemoteInputActive(entry, remoteInputActive);
}
public void lockScrollTo(NotificationData.Entry entry) {
mStackScroller.lockScrollTo(entry.row);
}
public void requestDisallowLongPressAndDismiss() {
mStackScroller.requestDisallowLongPress();
mStackScroller.requestDisallowDismiss();
}
});
mStatusBarWindowManager.add(mStatusBarWindow, getStatusBarHeight());
}
@@ -4825,11 +4826,6 @@ public class StatusBar extends SystemUI implements DemoMode,
return mVrMode;
}
@Override
public NotificationEntryManager getEntryManager() {
return mEntryManager;
}
private final BroadcastReceiver mBannerActionBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {

View File

@@ -155,7 +155,6 @@ public class NotificationEntryManagerTest extends SysuiTestCase {
mCountDownLatch = new CountDownLatch(1);
when(mPresenter.getHandler()).thenReturn(mHandler);
when(mPresenter.getEntryManager()).thenReturn(mEntryManager);
when(mPresenter.getNotificationLockscreenUserManager()).thenReturn(mLockscreenUserManager);
when(mPresenter.getGroupManager()).thenReturn(mGroupManager);
when(mRemoteInputManager.getController()).thenReturn(mRemoteInputController);

View File

@@ -74,7 +74,6 @@ public class NotificationListenerTest extends SysuiTestCase {
mKeysKeptForRemoteInput = new HashSet<>();
when(mPresenter.getHandler()).thenReturn(mHandler);
when(mPresenter.getEntryManager()).thenReturn(mEntryManager);
when(mEntryManager.getNotificationData()).thenReturn(mNotificationData);
when(mRemoteInputManager.getKeysKeptForRemoteInput()).thenReturn(mKeysKeptForRemoteInput);
@@ -82,7 +81,7 @@ public class NotificationListenerTest extends SysuiTestCase {
mSbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME, 0, null, TEST_UID, 0,
new Notification(), UserHandle.CURRENT, null, 0);
mListener.setUpWithPresenter(mPresenter);
mListener.setUpWithPresenter(mPresenter, mEntryManager);
}
@Test

View File

@@ -80,10 +80,9 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
when(mUserManager.getProfiles(mCurrentUserId)).thenReturn(Lists.newArrayList(
new UserInfo(mCurrentUserId, "", 0), new UserInfo(mCurrentUserId + 1, "", 0)));
when(mPresenter.getHandler()).thenReturn(mHandler);
when(mPresenter.getEntryManager()).thenReturn(mEntryManager);
mLockscreenUserManager = new TestNotificationLockscreenUserManager(mContext);
mLockscreenUserManager.setUpWithPresenter(mPresenter);
mLockscreenUserManager.setUpWithPresenter(mPresenter, mEntryManager);
}
@Test

View File

@@ -73,7 +73,6 @@ public class NotificationLoggerTest extends SysuiTestCase {
mDependency.injectTestDependency(NotificationEntryManager.class, mEntryManager);
mDependency.injectTestDependency(NotificationListener.class, mListener);
when(mPresenter.getEntryManager()).thenReturn(mEntryManager);
when(mEntryManager.getNotificationData()).thenReturn(mNotificationData);
mSbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME, 0, null, TEST_UID,
@@ -83,7 +82,7 @@ public class NotificationLoggerTest extends SysuiTestCase {
mLogger = new TestableNotificationLogger(mListener, mDependency.get(UiOffloadThread.class),
mBarService);
mLogger.setUpWithPresenter(mPresenter, mListContainer);
mLogger.setUpWithEntryManager(mEntryManager, mListContainer);
}
@Test

View File

@@ -59,7 +59,6 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase {
mHandler = new Handler(Looper.getMainLooper());
when(mPresenter.getHandler()).thenReturn(mHandler);
when(mPresenter.getEntryManager()).thenReturn(mEntryManager);
when(mEntryManager.getLatestRankingMap()).thenReturn(mRanking);
mRemoteInputManager = new TestableNotificationRemoteInputManager(mLockscreenUserManager,
@@ -69,8 +68,8 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase {
mEntry = new NotificationData.Entry(mSbn);
mEntry.row = mRow;
mRemoteInputManager.setUpWithPresenterForTest(mPresenter, mCallback, mDelegate,
mController);
mRemoteInputManager.setUpWithPresenterForTest(mPresenter, mEntryManager, mCallback,
mDelegate, mController);
}
@Test
@@ -115,10 +114,11 @@ public class NotificationRemoteInputManagerTest extends SysuiTestCase {
}
public void setUpWithPresenterForTest(NotificationPresenter presenter,
NotificationEntryManager entryManager,
Callback callback,
RemoteInputController.Delegate delegate,
RemoteInputController controller) {
super.setUpWithPresenter(presenter, callback, delegate);
super.setUpWithPresenter(presenter, entryManager, callback, delegate);
mRemoteInputController = controller;
}
}

View File

@@ -71,7 +71,6 @@ public class NotificationViewHierarchyManagerTest extends SysuiTestCase {
mDependency.injectTestDependency(NotificationGroupManager.class, mGroupManager);
mDependency.injectTestDependency(VisualStabilityManager.class, mVisualStabilityManager);
when(mPresenter.getEntryManager()).thenReturn(mEntryManager);
when(mEntryManager.getNotificationData()).thenReturn(mNotificationData);
mViewHierarchyManager = new NotificationViewHierarchyManager(mLockscreenUserManager,

View File

@@ -53,7 +53,6 @@ import android.support.test.metricshelper.MetricsAsserts;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.testing.TestableLooper.RunWithLooper;
import android.util.DisplayMetrics;
import android.util.SparseArray;
import android.view.ViewGroup.LayoutParams;
@@ -195,7 +194,7 @@ public class StatusBarTest extends SysuiTestCase {
mStatusBar.mComponents = mContext.getComponents();
mEntryManager.setUpForTest(mStatusBar, mStackScroller, mStatusBar, mHeadsUpManager,
mNotificationData);
mNotificationLogger.setUpWithPresenter(mStatusBar, mStackScroller);
mNotificationLogger.setUpWithEntryManager(mEntryManager, mStackScroller);
TestableLooper.get(this).setMessageHandler(m -> {
if (m.getCallback() == mStatusBar.mNotificationLogger.getVisibilityReporter()) {