Skip to content

Commit c8db24b

Browse files
author
Christoph Studer
committed
SysUI: Display group children when no summary is present
Also move common notification filtering into NotificationData such that clients won't have to do it themselves anymore. Probably also fixes a couple of multi-user issues. Bug: 16302692 Bug: 16224431 Change-Id: Ic3c11cd1a224044486f5544e068ca5297d30c521
1 parent 4579fd2 commit c8db24b

5 files changed

Lines changed: 230 additions & 194 deletions

File tree

core/java/android/app/Notification.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,6 +1731,20 @@ public boolean isValid() {
17311731
return contentView != null || extras.getBoolean(Builder.EXTRA_REBUILD_CONTENT_VIEW);
17321732
}
17331733

1734+
/**
1735+
* @hide
1736+
*/
1737+
public boolean isGroupSummary() {
1738+
return mGroupKey != null && (flags & FLAG_GROUP_SUMMARY) != 0;
1739+
}
1740+
1741+
/**
1742+
* @hide
1743+
*/
1744+
public boolean isGroupChild() {
1745+
return mGroupKey != null && (flags & FLAG_GROUP_SUMMARY) == 0;
1746+
}
1747+
17341748
/**
17351749
* Builder class for {@link Notification} objects.
17361750
*

packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import android.content.res.Configuration;
3737
import android.database.ContentObserver;
3838
import android.graphics.Rect;
39-
import android.graphics.Typeface;
4039
import android.graphics.drawable.Drawable;
4140
import android.net.Uri;
4241
import android.os.Build;
@@ -96,7 +95,8 @@
9695

9796
public 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

Comments
 (0)