Update redaction upon profile changes
We can't rely on status bar state changes to update the notification list. The current user might not be set yet, causing wrong notifications to become visible. Fixes: 145135488 Test: manual Test: atest NotificationStackScrollLayoutTest Change-Id: I34d1d5f9a751c1d7680a5a5941c39b9fe33a473b
This commit is contained in:
@@ -35,6 +35,7 @@ import android.annotation.NonNull;
|
|||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.UserInfo;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
@@ -56,6 +57,7 @@ import android.util.DisplayMetrics;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.MathUtils;
|
import android.util.MathUtils;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
import android.util.SparseArray;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.InputDevice;
|
import android.view.InputDevice;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -99,6 +101,7 @@ import com.android.systemui.statusbar.CommandQueue;
|
|||||||
import com.android.systemui.statusbar.DragDownHelper.DragDownCallback;
|
import com.android.systemui.statusbar.DragDownHelper.DragDownCallback;
|
||||||
import com.android.systemui.statusbar.EmptyShadeView;
|
import com.android.systemui.statusbar.EmptyShadeView;
|
||||||
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
|
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
|
||||||
|
import com.android.systemui.statusbar.NotificationLockscreenUserManager.UserChangedListener;
|
||||||
import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
||||||
import com.android.systemui.statusbar.NotificationShelf;
|
import com.android.systemui.statusbar.NotificationShelf;
|
||||||
import com.android.systemui.statusbar.RemoteInputController;
|
import com.android.systemui.statusbar.RemoteInputController;
|
||||||
@@ -328,6 +331,12 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private final UserChangedListener mLockscreenUserChangeListener = new UserChangedListener() {
|
||||||
|
@Override
|
||||||
|
public void onUserChanged(int userId) {
|
||||||
|
updateSensitiveness(false /* animated */);
|
||||||
|
}
|
||||||
|
};
|
||||||
private StatusBar mStatusBar;
|
private StatusBar mStatusBar;
|
||||||
private int[] mTempInt2 = new int[2];
|
private int[] mTempInt2 = new int[2];
|
||||||
private boolean mGenerateChildOrderChangedEvent;
|
private boolean mGenerateChildOrderChangedEvent;
|
||||||
@@ -561,6 +570,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
|
|||||||
mRoundnessManager.setAnimatedChildren(mChildrenToAddAnimated);
|
mRoundnessManager.setAnimatedChildren(mChildrenToAddAnimated);
|
||||||
mRoundnessManager.setOnRoundingChangedCallback(this::invalidate);
|
mRoundnessManager.setOnRoundingChangedCallback(this::invalidate);
|
||||||
addOnExpandedHeightChangedListener(mRoundnessManager::setExpanded);
|
addOnExpandedHeightChangedListener(mRoundnessManager::setExpanded);
|
||||||
|
mLockscreenUserManager.addUserChangedListener(mLockscreenUserChangeListener);
|
||||||
setOutlineProvider(mOutlineProvider);
|
setOutlineProvider(mOutlineProvider);
|
||||||
|
|
||||||
// Blocking helper manager wants to know the expanded state, update as well.
|
// Blocking helper manager wants to know the expanded state, update as well.
|
||||||
@@ -4611,7 +4621,8 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
|
||||||
private void setHideSensitive(boolean hideSensitive, boolean animate) {
|
private void updateSensitiveness(boolean animate) {
|
||||||
|
boolean hideSensitive = mLockscreenUserManager.isAnyProfilePublicMode();
|
||||||
if (hideSensitive != mAmbientState.isHideSensitive()) {
|
if (hideSensitive != mAmbientState.isHideSensitive()) {
|
||||||
int childCount = getChildCount();
|
int childCount = getChildCount();
|
||||||
for (int i = 0; i < childCount; i++) {
|
for (int i = 0; i < childCount; i++) {
|
||||||
@@ -5306,7 +5317,6 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
|
|||||||
|
|
||||||
private void onStatePostChange() {
|
private void onStatePostChange() {
|
||||||
boolean onKeyguard = onKeyguard();
|
boolean onKeyguard = onKeyguard();
|
||||||
boolean publicMode = mLockscreenUserManager.isAnyProfilePublicMode();
|
|
||||||
|
|
||||||
if (mHeadsUpAppearanceController != null) {
|
if (mHeadsUpAppearanceController != null) {
|
||||||
mHeadsUpAppearanceController.onStateChanged();
|
mHeadsUpAppearanceController.onStateChanged();
|
||||||
@@ -5314,7 +5324,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements ScrollAd
|
|||||||
|
|
||||||
SysuiStatusBarStateController state = (SysuiStatusBarStateController)
|
SysuiStatusBarStateController state = (SysuiStatusBarStateController)
|
||||||
Dependency.get(StatusBarStateController.class);
|
Dependency.get(StatusBarStateController.class);
|
||||||
setHideSensitive(publicMode, state.goingToFullShade() /* animate */);
|
updateSensitiveness(state.goingToFullShade() /* animate */);
|
||||||
setDimmed(onKeyguard, state.fromShadeLocked() /* animate */);
|
setDimmed(onKeyguard, state.fromShadeLocked() /* animate */);
|
||||||
setExpandingEnabled(!onKeyguard);
|
setExpandingEnabled(!onKeyguard);
|
||||||
ActivatableNotificationView activatedChild = getActivatedChild();
|
ActivatableNotificationView activatedChild = getActivatedChild();
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin;
|
|||||||
import com.android.systemui.statusbar.EmptyShadeView;
|
import com.android.systemui.statusbar.EmptyShadeView;
|
||||||
import com.android.systemui.statusbar.FeatureFlags;
|
import com.android.systemui.statusbar.FeatureFlags;
|
||||||
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
|
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
|
||||||
|
import com.android.systemui.statusbar.NotificationLockscreenUserManager.UserChangedListener;
|
||||||
import com.android.systemui.statusbar.NotificationMediaManager;
|
import com.android.systemui.statusbar.NotificationMediaManager;
|
||||||
import com.android.systemui.statusbar.NotificationPresenter;
|
import com.android.systemui.statusbar.NotificationPresenter;
|
||||||
import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
import com.android.systemui.statusbar.NotificationRemoteInputManager;
|
||||||
@@ -130,6 +131,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
|
|||||||
@Mock private ZenModeController mZenModeController;
|
@Mock private ZenModeController mZenModeController;
|
||||||
@Mock private NotificationSectionsManager mNotificationSectionsManager;
|
@Mock private NotificationSectionsManager mNotificationSectionsManager;
|
||||||
@Mock private NotificationSection mNotificationSection;
|
@Mock private NotificationSection mNotificationSection;
|
||||||
|
@Mock private NotificationLockscreenUserManager mLockscreenUserManager;
|
||||||
|
private UserChangedListener mUserChangedListener;
|
||||||
private TestableNotificationEntryManager mEntryManager;
|
private TestableNotificationEntryManager mEntryManager;
|
||||||
private int mOriginalInterruptionModelSetting;
|
private int mOriginalInterruptionModelSetting;
|
||||||
|
|
||||||
@@ -156,6 +159,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
|
|||||||
mDependency.injectMockDependency(ShadeController.class);
|
mDependency.injectMockDependency(ShadeController.class);
|
||||||
when(mRemoteInputManager.getController()).thenReturn(mRemoteInputController);
|
when(mRemoteInputManager.getController()).thenReturn(mRemoteInputController);
|
||||||
|
|
||||||
|
ArgumentCaptor<UserChangedListener> userChangedCaptor = ArgumentCaptor
|
||||||
|
.forClass(UserChangedListener.class);
|
||||||
mEntryManager = new TestableNotificationEntryManager(
|
mEntryManager = new TestableNotificationEntryManager(
|
||||||
mock(NotifLog.class),
|
mock(NotifLog.class),
|
||||||
mock(NotificationGroupManager.class),
|
mock(NotificationGroupManager.class),
|
||||||
@@ -195,10 +200,12 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
|
|||||||
mHeadsUpManager,
|
mHeadsUpManager,
|
||||||
mKeyguardBypassController,
|
mKeyguardBypassController,
|
||||||
new FalsingManagerFake(),
|
new FalsingManagerFake(),
|
||||||
mock(NotificationLockscreenUserManager.class),
|
mLockscreenUserManager,
|
||||||
mock(NotificationGutsManager.class),
|
mock(NotificationGutsManager.class),
|
||||||
mZenModeController,
|
mZenModeController,
|
||||||
mNotificationSectionsManager);
|
mNotificationSectionsManager);
|
||||||
|
verify(mLockscreenUserManager).addUserChangedListener(userChangedCaptor.capture());
|
||||||
|
mUserChangedListener = userChangedCaptor.getValue();
|
||||||
mStackScroller = spy(mStackScrollerInternal);
|
mStackScroller = spy(mStackScrollerInternal);
|
||||||
mStackScroller.setShelf(notificationShelf);
|
mStackScroller.setShelf(notificationShelf);
|
||||||
mStackScroller.setStatusBar(mBar);
|
mStackScroller.setStatusBar(mBar);
|
||||||
@@ -278,6 +285,12 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
|
|||||||
verify(mBlockingHelperManager).setNotificationShadeExpanded(100f);
|
verify(mBlockingHelperManager).setNotificationShadeExpanded(100f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOnStatePostChange_verifyIfProfileIsPublic() {
|
||||||
|
mUserChangedListener.onUserChanged(0);
|
||||||
|
verify(mLockscreenUserManager).isAnyProfilePublicMode();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void manageNotifications_visible() {
|
public void manageNotifications_visible() {
|
||||||
FooterView view = mock(FooterView.class);
|
FooterView view = mock(FooterView.class);
|
||||||
|
|||||||
Reference in New Issue
Block a user