From b2c5dc522ae2c784ad1f413491e6893c53c34b52 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Mon, 24 Jun 2019 15:46:52 -0700 Subject: [PATCH] Fixed the appearance of the heads up statusbar view on the lockscreen The text is now based on the sensitivity of the notifications which also makes sure that dynamic privacy and other functions work properly and aren't based on the global public device state but individual. Bug: 130327302 Test: add hun on lockscreen, observe correct text Change-Id: I26a12ff6395dbbfb30bf87f0da1fa0a951edec94 --- .../statusbar/HeadsUpStatusBarView.java | 14 +++------- .../NotificationViewHierarchyManager.java | 2 +- .../collection/NotificationEntry.java | 26 +++++++++++++++++++ .../stack/NotificationStackScrollLayout.java | 2 +- .../phone/HeadsUpAppearanceController.java | 3 +-- 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java index 3f1ff33437b99..4597b16568849 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/HeadsUpStatusBarView.java @@ -43,7 +43,6 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout { private static final String HEADS_UP_STATUS_BAR_VIEW_SUPER_PARCELABLE = "heads_up_status_bar_view_super_parcelable"; private static final String FIRST_LAYOUT = "first_layout"; - private static final String PUBLIC_MODE = "public_mode"; private static final String VISIBILITY = "visibility"; private static final String ALPHA = "alpha"; private int mAbsoluteStartPadding; @@ -54,7 +53,6 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout { private Rect mLayoutedIconRect = new Rect(); private int[] mTmpPosition = new int[2]; private boolean mFirstLayout = true; - private boolean mPublicMode; private int mMaxWidth; private View mRootView; private int mSysWinInset; @@ -121,7 +119,6 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout { bundle.putParcelable(HEADS_UP_STATUS_BAR_VIEW_SUPER_PARCELABLE, super.onSaveInstanceState()); bundle.putBoolean(FIRST_LAYOUT, mFirstLayout); - bundle.putBoolean(PUBLIC_MODE, mPublicMode); bundle.putInt(VISIBILITY, getVisibility()); bundle.putFloat(ALPHA, getAlpha()); @@ -139,7 +136,6 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout { Parcelable superState = bundle.getParcelable(HEADS_UP_STATUS_BAR_VIEW_SUPER_PARCELABLE); super.onRestoreInstanceState(superState); mFirstLayout = bundle.getBoolean(FIRST_LAYOUT, true); - mPublicMode = bundle.getBoolean(PUBLIC_MODE, false); if (bundle.containsKey(VISIBILITY)) { setVisibility(bundle.getInt(VISIBILITY)); } @@ -166,11 +162,13 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout { if (entry != null) { mShowingEntry = entry; CharSequence text = entry.headsUpStatusBarText; - if (mPublicMode) { + if (entry.isSensitive()) { text = entry.headsUpStatusBarTextPublic; } mTextView.setText(text); - } else { + mShowingEntry.setOnSensitiveChangedListener(() -> setEntry(entry)); + } else if (mShowingEntry != null){ + mShowingEntry.setOnSensitiveChangedListener(null); mShowingEntry = null; } } @@ -273,10 +271,6 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout { mTextView.setTextColor(DarkIconDispatcher.getTint(area, this, tint)); } - public void setPublicMode(boolean publicMode) { - mPublicMode = publicMode; - } - public void setOnDrawingRectChangedListener(Runnable onDrawingRectChangedListener) { mOnDrawingRectChangedListener = onDrawingRectChangedListener; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java index 0b3c6a5518e71..787cc971e6a12 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationViewHierarchyManager.java @@ -161,7 +161,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle boolean deviceSensitive = devicePublic && !mLockscreenUserManager.userAllowsPrivateNotificationsInPublic( currentUserId); - ent.getRow().setSensitive(sensitive, deviceSensitive); + ent.setSensitive(sensitive, deviceSensitive); ent.getRow().setNeedsRedaction(needsRedaction); if (mGroupManager.isChildInGroupWithSummary(ent.notification)) { NotificationEntry summary = mGroupManager.getGroupSummary(ent.notification); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java index 9184dec7c8c86..9db715d129a53 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java @@ -173,6 +173,8 @@ public final class NotificationEntry { * the lock screen/status bar and in the top section in the shade. */ private boolean mHighPriority; + private boolean mSensitive = true; + private Runnable mOnSensitiveChangedListener; public NotificationEntry(StatusBarNotification n) { this(n, null); @@ -859,6 +861,30 @@ public final class NotificationEntry { return Objects.equals(n.category, category); } + /** + * Set this notification to be sensitive. + * + * @param sensitive true if the content of this notification is sensitive right now + * @param deviceSensitive true if the device in general is sensitive right now + */ + public void setSensitive(boolean sensitive, boolean deviceSensitive) { + getRow().setSensitive(sensitive, deviceSensitive); + if (sensitive != mSensitive) { + mSensitive = sensitive; + if (mOnSensitiveChangedListener != null) { + mOnSensitiveChangedListener.run(); + } + } + } + + public boolean isSensitive() { + return mSensitive; + } + + public void setOnSensitiveChangedListener(Runnable listener) { + mOnSensitiveChangedListener = listener; + } + /** Information about a suggestion that is being edited. */ public static class EditedSuggestionInfo { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index 44e5aeff2c72e..92b8090994d77 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -5241,7 +5241,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd boolean publicMode = mLockscreenUserManager.isAnyProfilePublicMode(); if (mHeadsUpAppearanceController != null) { - mHeadsUpAppearanceController.setPublicMode(publicMode); + mHeadsUpAppearanceController.onStateChanged(); } SysuiStatusBarStateController state = (SysuiStatusBarStateController) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java index 66903fa531e08..4ef19fb2f7b5d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpAppearanceController.java @@ -400,8 +400,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener, mHeadsUpStatusBarView.onDarkChanged(area, darkIntensity, tint); } - public void setPublicMode(boolean publicMode) { - mHeadsUpStatusBarView.setPublicMode(publicMode); + public void onStateChanged() { updateTopEntry(); }