3636import android .content .res .Configuration ;
3737import android .database .ContentObserver ;
3838import android .graphics .Rect ;
39- import android .graphics .Typeface ;
4039import android .graphics .drawable .Drawable ;
4140import android .net .Uri ;
4241import android .os .Build ;
9695
9796public abstract class BaseStatusBar extends SystemUI implements
9897 CommandQueue .Callbacks , ActivatableNotificationView .OnActivatedListener ,
99- RecentsComponent .Callbacks , ExpandableNotificationRow .ExpansionLogger {
98+ RecentsComponent .Callbacks , ExpandableNotificationRow .ExpansionLogger ,
99+ NotificationData .Environment {
100100 public static final String TAG = "StatusBar" ;
101101 public static final boolean DEBUG = false ;
102102 public static final boolean MULTIUSER_DEBUG = false ;
@@ -132,7 +132,7 @@ public abstract class BaseStatusBar extends SystemUI implements
132132 protected H mHandler = createHandler ();
133133
134134 // all notifications
135- protected NotificationData mNotificationData = new NotificationData () ;
135+ protected NotificationData mNotificationData ;
136136 protected NotificationStackScrollLayout mStackScroller ;
137137
138138 // for heads up notifications
@@ -201,6 +201,7 @@ public abstract class BaseStatusBar extends SystemUI implements
201201 protected NotificationOverflowContainer mKeyguardIconOverflowContainer ;
202202 protected DismissView mDismissView ;
203203
204+ @ Override // NotificationData.Environment
204205 public boolean isDeviceProvisioned () {
205206 return mDeviceProvisioned ;
206207 }
@@ -304,10 +305,6 @@ public void onListenerConnected() {
304305 @ Override
305306 public void run () {
306307 for (StatusBarNotification sbn : notifications ) {
307- if (shouldFilterOut (sbn .getNotification ())) {
308- if (DEBUG ) Log .d (TAG , "Ignoring notification: " + sbn );
309- continue ;
310- }
311308 addNotification (sbn , currentRanking );
312309 }
313310 }
@@ -322,20 +319,8 @@ public void onNotificationPosted(final StatusBarNotification sbn,
322319 @ Override
323320 public void run () {
324321 Notification n = sbn .getNotification ();
325- boolean isUpdate = mNotificationData .findByKey (sbn .getKey ()) != null
322+ boolean isUpdate = mNotificationData .get (sbn .getKey ()) != null
326323 || isHeadsUp (sbn .getKey ());
327- if (shouldFilterOut (n )) {
328- if (DEBUG ) Log .d (TAG , "Ignoring notification: " + sbn );
329- // If this is an update, i.e. the notification existed
330- // before but wasn't filtered out, remove the old
331- // instance. Otherwise just update the ranking.
332- if (isUpdate ) {
333- removeNotification (sbn .getKey (), rankingMap );
334- } else {
335- updateNotificationRanking (rankingMap );
336- }
337- return ;
338- }
339324 if (isUpdate ) {
340325 updateNotification (sbn , rankingMap );
341326 } else {
@@ -368,11 +353,6 @@ public void run() {
368353 });
369354 }
370355
371- private boolean shouldFilterOut (Notification n ) {
372- // Don't accept group children.
373- return n .getGroup () != null
374- && (n .flags & Notification .FLAG_GROUP_SUMMARY ) == 0 ;
375- }
376356 };
377357
378358 private void updateCurrentProfilesCache () {
@@ -391,6 +371,8 @@ public void start() {
391371 mWindowManagerService = WindowManagerGlobal .getWindowManagerService ();
392372 mDisplay = mWindowManager .getDefaultDisplay ();
393373
374+ mNotificationData = new NotificationData (this );
375+
394376 mDreamManager = IDreamManager .Stub .asInterface (
395377 ServiceManager .checkService (DreamService .DREAM_SERVICE ));
396378 mPowerManager = (PowerManager ) mContext .getSystemService (Context .POWER_SERVICE );
@@ -499,7 +481,8 @@ public boolean isHeadsUp(String key) {
499481 return mHeadsUpNotificationView != null && mHeadsUpNotificationView .isShowing (key );
500482 }
501483
502- public boolean notificationIsForCurrentProfiles (StatusBarNotification n ) {
484+ @ Override // NotificationData.Environment
485+ public boolean isNotificationForCurrentProfiles (StatusBarNotification n ) {
503486 final int thisUserId = mCurrentUserId ;
504487 final int notificationUserId = n .getUserId ();
505488 if (DEBUG && MULTIUSER_DEBUG ) {
@@ -881,6 +864,16 @@ public boolean userAllowsPrivateNotificationsInPublic(int userHandle) {
881864 return mUsersAllowingPrivateNotifications .get (userHandle );
882865 }
883866
867+ /**
868+ * Returns true if we're on a secure lockscreen and the user wants to hide "sensitive"
869+ * notification data. If so, private notifications should show their (possibly
870+ * auto-generated) publicVersion, and secret notifications should be totally invisible.
871+ */
872+ @ Override // NotificationData.Environment
873+ public boolean shouldHideSensitiveContents (int userid ) {
874+ return isLockscreenPublicMode () && !userAllowsPrivateNotificationsInPublic (userid );
875+ }
876+
884877 public void onNotificationClear (StatusBarNotification notification ) {
885878 try {
886879 mBarService .onNotificationClear (
@@ -1381,11 +1374,14 @@ protected void addNotificationViews(Entry entry, RankingMap ranking) {
13811374 protected void updateRowStates () {
13821375 int maxKeyguardNotifications = getMaxKeyguardNotifications ();
13831376 mKeyguardIconOverflowContainer .getIconsView ().removeAllViews ();
1384- final int N = mNotificationData .size ();
1377+
1378+ ArrayList <Entry > activeNotifications = mNotificationData .getActiveNotifications ();
1379+ final int N = activeNotifications .size ();
1380+
13851381 int visibleNotifications = 0 ;
13861382 boolean onKeyguard = mState == StatusBarState .KEYGUARD ;
13871383 for (int i = 0 ; i < N ; i ++) {
1388- NotificationData .Entry entry = mNotificationData .get (i );
1384+ NotificationData .Entry entry = activeNotifications .get (i );
13891385 if (onKeyguard ) {
13901386 entry .row .setExpansionDisabled (true );
13911387 } else {
@@ -1461,7 +1457,7 @@ public void updateNotification(StatusBarNotification notification, RankingMap ra
14611457 if (wasHeadsUp ) {
14621458 oldEntry = mHeadsUpNotificationView .getEntry ();
14631459 } else {
1464- oldEntry = mNotificationData .findByKey (key );
1460+ oldEntry = mNotificationData .get (key );
14651461 }
14661462 if (oldEntry == null ) {
14671463 return ;
@@ -1620,6 +1616,7 @@ public void updateNotification(StatusBarNotification notification, RankingMap ra
16201616 notification .getNotification ().tickerText );
16211617 oldEntry .icon .set (ic );
16221618 inflateViews (oldEntry , mStackScroller , wasHeadsUp );
1619+ mNotificationData .updateRanking (ranking );
16231620 updateNotifications ();
16241621 }
16251622 }
@@ -1630,7 +1627,7 @@ public void updateNotification(StatusBarNotification notification, RankingMap ra
16301627 updateNotificationVetoButton (oldEntry .row , notification );
16311628
16321629 // Is this for you?
1633- boolean isForCurrentUser = notificationIsForCurrentProfiles (notification );
1630+ boolean isForCurrentUser = isNotificationForCurrentProfiles (notification );
16341631 if (DEBUG ) Log .d (TAG , "notification is " + (isForCurrentUser ? "" : "not " ) + "for you" );
16351632
16361633 // Restart the ticker if it's still running
@@ -1725,14 +1722,6 @@ protected boolean shouldInterrupt(StatusBarNotification sbn) {
17251722 return interrupt ;
17261723 }
17271724
1728- // Q: What kinds of notifications should show during setup?
1729- // A: Almost none! Only things coming from the system (package is "android") that also
1730- // have special "kind" tags marking them as relevant for setup (see below).
1731- protected boolean showNotificationEvenIfUnprovisioned (StatusBarNotification sbn ) {
1732- return "android" .equals (sbn .getPackageName ())
1733- && sbn .getNotification ().extras .getBoolean (Notification .EXTRA_ALLOW_DURING_SETUP );
1734- }
1735-
17361725 public boolean inKeyguardRestrictedInputMode () {
17371726 return KeyguardTouchDelegate .getInstance (mContext ).isInputRestricted ();
17381727 }
0 commit comments