Merge "Fix issue where notifications are visible during screen off if bypass is enabled." into sc-dev am: f3f485c453

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14904072

Change-Id: Iddc430d3e7e1ed883505d63f81307edab69cb10b
This commit is contained in:
Josh Tsuji
2021-06-09 23:52:19 +00:00
committed by Automerger Merge Worker
4 changed files with 25 additions and 24 deletions

View File

@@ -98,8 +98,6 @@ class NotificationWakeUpCoordinator @Inject constructor(
}
}
private var animatingScreenOff = false
private var collapsedEnoughToHide: Boolean = false
var pulsing: Boolean = false
@@ -236,11 +234,11 @@ class NotificationWakeUpCoordinator @Inject constructor(
}
override fun onDozeAmountChanged(linear: Float, eased: Float) {
if (overrideDozeAmountIfBypass()) {
if (overrideDozeAmountIfAnimatingScreenOff(linear)) {
return
}
if (overrideDozeAmountIfAnimatingScreenOff(linear)) {
if (overrideDozeAmountIfBypass()) {
return
}
@@ -267,7 +265,7 @@ class NotificationWakeUpCoordinator @Inject constructor(
override fun onStateChanged(newState: Int) {
if (unlockedScreenOffAnimationController.shouldPlayScreenOffAnimation()) {
if (animatingScreenOff &&
if (unlockedScreenOffAnimationController.isScreenOffAnimationPlaying() &&
state == StatusBarState.KEYGUARD &&
newState == StatusBarState.SHADE) {
// If we're animating the screen off and going from KEYGUARD back to SHADE, the
@@ -275,12 +273,16 @@ class NotificationWakeUpCoordinator @Inject constructor(
// dozing) so that the notifications are no longer hidden.
setDozeAmount(0f, 0f)
}
animatingScreenOff =
state == StatusBarState.SHADE && newState == StatusBarState.KEYGUARD
}
overrideDozeAmountIfBypass()
if (overrideDozeAmountIfAnimatingScreenOff(mLinearDozeAmount)) {
return
}
if (overrideDozeAmountIfBypass()) {
return
}
if (bypassController.bypassEnabled &&
newState == StatusBarState.KEYGUARD && state == StatusBarState.SHADE_LOCKED &&
(!statusBarStateController.isDozing || shouldAnimateVisibility())) {
@@ -330,12 +332,7 @@ class NotificationWakeUpCoordinator @Inject constructor(
* animation. If true, the original doze amount should be ignored.
*/
private fun overrideDozeAmountIfAnimatingScreenOff(linearDozeAmount: Float): Boolean {
if (animatingScreenOff) {
if (linearDozeAmount == 1f) {
animatingScreenOff = false
return false
}
if (unlockedScreenOffAnimationController.isScreenOffAnimationPlaying()) {
setDozeAmount(1f, 1f)
return true
}
@@ -395,11 +392,6 @@ class NotificationWakeUpCoordinator @Inject constructor(
override fun onDozingChanged(isDozing: Boolean) {
if (isDozing) {
setNotificationsVisible(visible = false, animate = false, increaseSpeed = false)
} else {
// We only unset the flag once we fully went asleep. If the user interrupts the
// animation in the middle, we have to abort the animation as well to make sure
// the notifications are visible again.
animatingScreenOff = false
}
}

View File

@@ -106,6 +106,7 @@ import com.android.systemui.statusbar.phone.HeadsUpAppearanceController;
import com.android.systemui.statusbar.phone.HeadsUpTouchHelper;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController;
import com.android.systemui.statusbar.policy.HeadsUpUtil;
import com.android.systemui.statusbar.policy.ScrollAdapter;
import com.android.systemui.util.Assert;
@@ -456,6 +457,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
private long mNumHeadsUp;
private NotificationStackScrollLayoutController.TouchHandler mTouchHandler;
private final FeatureFlags mFeatureFlags;
private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
private boolean mShouldUseSplitNotificationShade;
private final ExpandableView.OnHeightChangedListener mOnChildHeightChangedListener =
@@ -497,11 +499,13 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
GroupMembershipManager groupMembershipManager,
GroupExpansionManager groupExpansionManager,
AmbientState ambientState,
FeatureFlags featureFlags) {
FeatureFlags featureFlags,
UnlockedScreenOffAnimationController unlockedScreenOffAnimationController) {
super(context, attrs, 0, 0);
Resources res = getResources();
mSectionsManager = notificationSectionsManager;
mFeatureFlags = featureFlags;
mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
mShouldUseSplitNotificationShade = shouldUseSplitNotificationShade(mFeatureFlags, res);
mSectionsManager.initialize(this, LayoutInflater.from(context));
mSections = mSectionsManager.createSectionsForBuckets();
@@ -606,6 +610,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
RemoteInputController remoteInputController = mRemoteInputManager.getController();
boolean showFooterView = (showDismissView || mController.hasActiveNotifications())
&& mStatusBarState != StatusBarState.KEYGUARD
&& !mUnlockedScreenOffAnimationController.isScreenOffAnimationPlaying()
&& (remoteInputController == null || !remoteInputController.isRemoteInputActive());
boolean showHistory = Settings.Secure.getIntForUser(mContext.getContentResolver(),
Settings.Secure.NOTIFICATION_HISTORY_ENABLED, 0, UserHandle.USER_CURRENT) == 1;
@@ -4617,7 +4622,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
@ShadeViewRefactor(RefactorComponent.SHADE_VIEW)
@VisibleForTesting
protected void setStatusBarState(int statusBarState) {
public void setStatusBarState(int statusBarState) {
mStatusBarState = statusBarState;
mAmbientState.setStatusBarState(statusBarState);
updateSpeedBumpIndex();

View File

@@ -4290,7 +4290,8 @@ public class NotificationPanelViewController extends PanelViewController {
/**
* Reconfigures the shade to show the AOD UI (clock, smartspace, etc). This is called by the
* screen off animation controller in order to animate in AOD without "actually" fully switching
* to the KEYGUARD state.
* to the KEYGUARD state, which is a heavy transition that causes jank as 10+ files react to the
* change.
*/
public void showAodUi() {
setDozing(true /* dozing */, false /* animate */, null);

View File

@@ -65,6 +65,7 @@ import com.android.systemui.statusbar.notification.row.FooterView;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.KeyguardBypassEnabledProvider;
import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController;
import org.junit.Assert;
import org.junit.Before;
@@ -105,6 +106,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
@Mock private NotificationSwipeHelper mNotificationSwipeHelper;
@Mock private NotificationStackScrollLayoutController mStackScrollLayoutController;
@Mock private FeatureFlags mFeatureFlags;
@Mock private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
@Before
@UiThreadTest
@@ -143,7 +145,8 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase {
mGroupMembershipManger,
mGroupExpansionManager,
mAmbientState,
mFeatureFlags);
mFeatureFlags,
mUnlockedScreenOffAnimationController);
mStackScrollerInternal.initView(getContext(), mKeyguardBypassEnabledProvider,
mNotificationSwipeHelper);
mStackScroller = spy(mStackScrollerInternal);