From dc10c9586e96ac37e3460d424c6cf903e7960320 Mon Sep 17 00:00:00 2001 From: Ned Burns Date: Wed, 21 Nov 2018 14:36:21 -0500 Subject: [PATCH] Inline & privatize methods in NotificationEntryManager Inline two methods that were only ever called in one other place and didn't add much in terms of readability. Change many protected methods and members to private. Test: none Change-Id: I9609e76e928b977847fa652f94496c26b1ccd7cd --- .../NotificationEntryManager.java | 77 +++++++++---------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java index 0818513faf41d..450d34d4007e5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java @@ -108,13 +108,13 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. VisualStabilityManager.Callback, BubbleController.BubbleDismissListener { private static final String TAG = "NotificationEntryMgr"; protected static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); - protected static final boolean ENABLE_HEADS_UP = true; - protected static final String SETTING_HEADS_UP_TICKER = "ticker_gets_heads_up"; + private static final boolean ENABLE_HEADS_UP = true; + private static final String SETTING_HEADS_UP_TICKER = "ticker_gets_heads_up"; - protected final NotificationMessagingUtil mMessagingUtil; + private final NotificationMessagingUtil mMessagingUtil; protected final Context mContext; protected final HashMap mPendingNotifications = new HashMap<>(); - protected final NotificationClicker mNotificationClicker = new NotificationClicker(); + private final NotificationClicker mNotificationClicker = new NotificationClicker(); private final NotificationGroupManager mGroupManager = Dependency.get(NotificationGroupManager.class); @@ -145,14 +145,15 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. private NotificationPresenter mPresenter; private Callback mCallback; protected PowerManager mPowerManager; - protected NotificationListenerService.RankingMap mLatestRankingMap; + private NotificationListenerService.RankingMap mLatestRankingMap; protected HeadsUpManager mHeadsUpManager; protected NotificationData mNotificationData; - protected ContentObserver mHeadsUpObserver; + private ContentObserver mHeadsUpObserver; protected boolean mUseHeadsUp = false; - protected boolean mDisableNotificationAlerts; + private boolean mDisableNotificationAlerts; protected NotificationListContainer mListContainer; - protected final ArrayList mNotificationLifetimeExtenders + @VisibleForTesting + final ArrayList mNotificationLifetimeExtenders = new ArrayList<>(); private ExpandableNotificationRow.OnAppOpsClickListener mOnAppOpsClickListener; private NotificationViewHierarchyManager.StatusBarStateListener mStatusBarStateListener; @@ -485,22 +486,6 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. updateNotifications(); } - /** - * Cancel this notification and tell the StatusBarManagerService / NotificationManagerService - * about the failure. - * - * WARNING: this will call back into us. Don't hold any locks. - */ - void handleNotificationError(StatusBarNotification n, String message) { - removeNotificationInternal(n.getKey(), null, true /* forceRemove */); - try { - mBarService.onNotificationError(n.getPackageName(), n.getTag(), n.getId(), n.getUid(), - n.getInitialPid(), message, n.getUserId()); - } catch (RemoteException ex) { - // The end is nigh. - } - } - private void abortExistingInflation(String key) { if (mPendingNotifications.containsKey(key)) { NotificationData.Entry entry = mPendingNotifications.get(key); @@ -513,13 +498,31 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. } } + /** + * Cancel this notification and tell the StatusBarManagerService / NotificationManagerService + * about the failure. + * + * WARNING: this will call back into us. Don't hold any locks. + */ @Override - public void handleInflationException(StatusBarNotification notification, Exception e) { - handleNotificationError(notification, e.getMessage()); + public void handleInflationException(StatusBarNotification n, Exception e) { + removeNotificationInternal(n.getKey(), null, true /* forceRemove */); + try { + mBarService.onNotificationError(n.getPackageName(), n.getTag(), n.getId(), n.getUid(), + n.getInitialPid(), e.getMessage(), n.getUserId()); + } catch (RemoteException ex) { + // The end is nigh. + } } private void addEntry(NotificationData.Entry shadeEntry) { - addNotificationViews(shadeEntry); + if (shadeEntry == null) { + return; + } + // Add the expanded view and icon. + mNotificationData.add(shadeEntry); + tagForeground(shadeEntry.notification); + updateNotifications(); mCallback.onNotificationAdded(shadeEntry); } @@ -755,17 +758,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. row.inflateViews(); } - protected void addNotificationViews(NotificationData.Entry entry) { - if (entry == null) { - return; - } - // Add the expanded view and icon. - mNotificationData.add(entry); - tagForeground(entry.notification); - updateNotifications(); - } - - protected NotificationData.Entry createNotificationViews( + private NotificationData.Entry createNotificationViews( StatusBarNotification sbn, NotificationListenerService.Ranking ranking) throws InflationException { if (DEBUG) { @@ -841,7 +834,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. } @VisibleForTesting - protected void tagForeground(StatusBarNotification notification) { + void tagForeground(StatusBarNotification notification) { ArraySet activeOps = mForegroundServiceController.getAppOps( notification.getUserId(), notification.getPackageName()); if (activeOps != null) { @@ -1098,7 +1091,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. * @param entry the entry to check * @return true if the entry should ambient pulse, false otherwise */ - protected boolean shouldPulse(NotificationData.Entry entry) { + private boolean shouldPulse(NotificationData.Entry entry) { StatusBarNotification sbn = entry.notification; if (!getShadeController().isDozing()) { @@ -1173,7 +1166,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. return true; } - protected void setNotificationShown(StatusBarNotification n) { + private void setNotificationShown(StatusBarNotification n) { setNotificationsShown(new String[]{n.getKey()}); } @@ -1185,7 +1178,7 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater. } } - protected boolean isSnoozedPackage(StatusBarNotification sbn) { + private boolean isSnoozedPackage(StatusBarNotification sbn) { return mHeadsUpManager.isSnoozed(sbn.getPackageName()); }