use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by DirtyUnicorns.
the class PhoneStatusBar method findAndUpdateMediaNotifications.
public void findAndUpdateMediaNotifications() {
boolean metaDataChanged = false;
synchronized (mNotificationData) {
ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
final int N = activeNotifications.size();
// Promote the media notification with a controller in 'playing' state, if any.
Entry mediaNotification = null;
MediaController controller = null;
for (int i = 0; i < N; i++) {
final Entry entry = activeNotifications.get(i);
if (isMediaNotification(entry)) {
final MediaSession.Token token = entry.notification.getNotification().extras.getParcelable(Notification.EXTRA_MEDIA_SESSION);
if (token != null) {
MediaController aController = new MediaController(mContext, token);
if (PlaybackState.STATE_PLAYING == getMediaControllerPlaybackState(aController)) {
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: found mediastyle controller matching " + entry.notification.getKey());
}
mediaNotification = entry;
controller = aController;
break;
}
}
}
}
if (mediaNotification == null) {
if (mMediaSessionManager != null) {
final List<MediaController> sessions = mMediaSessionManager.getActiveSessionsForUser(null, UserHandle.USER_ALL);
for (MediaController aController : sessions) {
if (PlaybackState.STATE_PLAYING == getMediaControllerPlaybackState(aController)) {
// now to see if we have one like this
final String pkg = aController.getPackageName();
for (int i = 0; i < N; i++) {
final Entry entry = activeNotifications.get(i);
if (entry.notification.getPackageName().equals(pkg)) {
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: found controller matching " + entry.notification.getKey());
}
controller = aController;
mediaNotification = entry;
break;
}
}
}
}
}
}
if (controller != null && !sameSessions(mMediaController, controller)) {
// We have a new media session
clearCurrentMediaNotification();
mMediaController = controller;
mMediaController.registerCallback(mMediaListener);
mMediaMetadata = mMediaController.getMetadata();
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: insert listener, receive metadata: " + mMediaMetadata);
}
if (mediaNotification != null) {
mMediaNotificationKey = mediaNotification.notification.getKey();
if (DEBUG_MEDIA) {
Log.v(TAG, "DEBUG_MEDIA: Found new media notification: key=" + mMediaNotificationKey + " controller=" + mMediaController);
}
}
metaDataChanged = true;
}
}
if (metaDataChanged) {
updateNotifications();
}
updateMediaMetaData(metaDataChanged, true);
}
use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by DirtyUnicorns.
the class PhoneStatusBar method updateNotificationShade.
private void updateNotificationShade() {
if (mStackScroller == null)
return;
// Do not modify the notifications during collapse.
if (isCollapsing()) {
addPostCollapseAction(new Runnable() {
@Override
public void run() {
updateNotificationShade();
}
});
return;
}
ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
ArrayList<ExpandableNotificationRow> toShow = new ArrayList<>(activeNotifications.size());
final int N = activeNotifications.size();
for (int i = 0; i < N; i++) {
Entry ent = activeNotifications.get(i);
if (ent.row.isDismissed() || ent.row.isRemoved()) {
// temporarily become children if they were isolated before.
continue;
}
int vis = ent.notification.getNotification().visibility;
// Display public version of the notification if we need to redact.
final boolean hideSensitive = !userAllowsPrivateNotificationsInPublic(ent.notification.getUserId());
boolean sensitiveNote = vis == Notification.VISIBILITY_PRIVATE;
boolean sensitivePackage = packageHasVisibilityOverride(ent.notification.getKey());
boolean sensitive = (sensitiveNote && hideSensitive) || sensitivePackage;
boolean showingPublic = sensitive && isLockscreenPublicMode();
if (showingPublic) {
updatePublicContentView(ent, ent.notification);
}
ent.row.setSensitive(sensitive, hideSensitive);
if (ent.autoRedacted && ent.legacy) {
// for legacy auto redacted notifications.
if (showingPublic) {
ent.row.setShowingLegacyBackground(false);
} else {
ent.row.setShowingLegacyBackground(true);
}
}
if (mGroupManager.isChildInGroupWithSummary(ent.row.getStatusBarNotification())) {
ExpandableNotificationRow summary = mGroupManager.getGroupSummary(ent.row.getStatusBarNotification());
List<ExpandableNotificationRow> orderedChildren = mTmpChildOrderMap.get(summary);
if (orderedChildren == null) {
orderedChildren = new ArrayList<>();
mTmpChildOrderMap.put(summary, orderedChildren);
}
orderedChildren.add(ent.row);
} else {
toShow.add(ent.row);
}
}
ArrayList<ExpandableNotificationRow> toRemove = new ArrayList<>();
for (int i = 0; i < mStackScroller.getChildCount(); i++) {
View child = mStackScroller.getChildAt(i);
if (!toShow.contains(child) && child instanceof ExpandableNotificationRow) {
toRemove.add((ExpandableNotificationRow) child);
}
}
for (ExpandableNotificationRow remove : toRemove) {
if (mGroupManager.isChildInGroupWithSummary(remove.getStatusBarNotification())) {
// we are only transfering this notification to its parent, don't generate an animation
mStackScroller.setChildTransferInProgress(true);
}
if (remove.isSummaryWithChildren()) {
remove.removeAllChildren();
}
mStackScroller.removeView(remove);
mStackScroller.setChildTransferInProgress(false);
}
removeNotificationChildren();
for (int i = 0; i < toShow.size(); i++) {
View v = toShow.get(i);
if (v.getParent() == null) {
mVisualStabilityManager.notifyViewAddition(v);
mStackScroller.addView(v);
}
}
addNotificationChildrenAndSort();
// So after all this work notifications still aren't sorted correctly.
// Let's do that now by advancing through toShow and mStackScroller in
// lock-step, making sure mStackScroller matches what we see in toShow.
int j = 0;
for (int i = 0; i < mStackScroller.getChildCount(); i++) {
View child = mStackScroller.getChildAt(i);
if (!(child instanceof ExpandableNotificationRow)) {
// We don't care about non-notification views.
continue;
}
ExpandableNotificationRow targetChild = toShow.get(j);
if (child != targetChild) {
// here and advance both lists.
if (mVisualStabilityManager.canReorderNotification(targetChild)) {
mStackScroller.changeViewPosition(targetChild, i);
} else {
mVisualStabilityManager.addReorderingAllowedCallback(this);
}
}
j++;
}
mVisualStabilityManager.onReorderingFinished();
// clear the map again for the next usage
mTmpChildOrderMap.clear();
updateRowStates();
updateSpeedbump();
updateClearAll();
updateEmptyShadeView();
updateQsExpansionEnabled();
mShadeUpdates.check();
}
use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by DirtyUnicorns.
the class BaseStatusBar method removeNotificationViews.
protected StatusBarNotification removeNotificationViews(String key, RankingMap ranking) {
NotificationData.Entry entry = mNotificationData.remove(key, ranking);
if (entry == null) {
Log.w(TAG, "removeNotification for unknown key: " + key);
return null;
}
updateNotifications();
return entry.notification;
}
use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by DirtyUnicorns.
the class BaseStatusBar method createNotificationViews.
protected NotificationData.Entry createNotificationViews(StatusBarNotification sbn) {
if (DEBUG) {
Log.d(TAG, "createNotificationViews(notification=" + sbn);
}
final StatusBarIconView iconView = createIcon(sbn);
if (iconView == null) {
return null;
}
// Construct the expanded view.
NotificationData.Entry entry = new NotificationData.Entry(sbn, iconView);
if (!inflateViews(entry, mStackScroller)) {
handleNotificationError(sbn, "Couldn't expand RemoteViews for: " + sbn);
return null;
}
return entry;
}
use of com.android.systemui.statusbar.NotificationData.Entry in project android_frameworks_base by AOSPA.
the class BaseStatusBar method updateRowStates.
/**
* Updates expanded, dimmed and locked states of notification rows.
*/
protected void updateRowStates() {
mKeyguardIconOverflowContainer.getIconsView().removeAllViews();
final int N = mStackScroller.getChildCount();
int visibleNotifications = 0;
boolean onKeyguard = mState == StatusBarState.KEYGUARD;
int maxNotifications = 0;
if (onKeyguard) {
maxNotifications = getMaxKeyguardNotifications(true);
}
Stack<ExpandableNotificationRow> stack = new Stack<>();
for (int i = N - 1; i >= 0; i--) {
View child = mStackScroller.getChildAt(i);
if (!(child instanceof ExpandableNotificationRow)) {
continue;
}
stack.push((ExpandableNotificationRow) child);
}
while (!stack.isEmpty()) {
ExpandableNotificationRow row = stack.pop();
NotificationData.Entry entry = row.getEntry();
boolean childNotification = mGroupManager.isChildInGroupWithSummary(entry.notification);
if (onKeyguard) {
row.setOnKeyguard(true);
} else {
row.setOnKeyguard(false);
row.setSystemExpanded(visibleNotifications == 0 && !childNotification);
}
boolean suppressedSummary = mGroupManager.isSummaryOfSuppressedGroup(entry.notification) && !entry.row.isRemoved();
boolean childWithVisibleSummary = childNotification && mGroupManager.getGroupSummary(entry.notification).getVisibility() == View.VISIBLE;
boolean showOnKeyguard = shouldShowOnKeyguard(entry.notification);
if (suppressedSummary || (isLockscreenPublicMode() && !mShowLockscreenNotifications) || (onKeyguard && !childWithVisibleSummary && (visibleNotifications >= maxNotifications || !showOnKeyguard))) {
entry.row.setVisibility(View.GONE);
if (onKeyguard && showOnKeyguard && !childNotification && !suppressedSummary) {
mKeyguardIconOverflowContainer.getIconsView().addNotification(entry);
}
} else {
boolean wasGone = entry.row.getVisibility() == View.GONE;
if (wasGone) {
entry.row.setVisibility(View.VISIBLE);
}
if (!childNotification && !entry.row.isRemoved()) {
if (wasGone) {
// notify the scroller of a child addition
mStackScroller.generateAddAnimation(entry.row, !showOnKeyguard);
}
visibleNotifications++;
}
}
if (row.isSummaryWithChildren()) {
List<ExpandableNotificationRow> notificationChildren = row.getNotificationChildren();
int size = notificationChildren.size();
for (int i = size - 1; i >= 0; i--) {
stack.push(notificationChildren.get(i));
}
}
}
mStackScroller.updateOverflowContainerVisibility(onKeyguard && mKeyguardIconOverflowContainer.getIconsView().getChildCount() > 0);
mStackScroller.changeViewPosition(mDismissView, mStackScroller.getChildCount() - 1);
mStackScroller.changeViewPosition(mEmptyShadeView, mStackScroller.getChildCount() - 2);
mStackScroller.changeViewPosition(mKeyguardIconOverflowContainer, mStackScroller.getChildCount() - 3);
}
Aggregations