diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java index 62b50044132e4..5b4d65290146a 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardHostView.java @@ -137,6 +137,10 @@ public class KeyguardHostView extends FrameLayout implements SecurityCallback { mCancelAction = cancelAction; } + public boolean hasDismissActions() { + return mDismissAction != null || mCancelAction != null; + } + public void cancelDismissAction() { setOnDismissAction(null, null); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java index d609ae7b7374c..fcd4e8f3669f5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java @@ -330,6 +330,10 @@ public class KeyguardBouncer { } } + public boolean willDismissWithAction() { + return mKeyguardView != null && mKeyguardView.hasDismissActions(); + } + protected void ensureView() { // Removal of the view might be deferred to reduce unlock latency, // in this case we need to force the removal, otherwise we'll diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 8cd6295f7ee1e..82469742020e4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -4654,9 +4654,12 @@ public class StatusBar extends SystemUI implements DemoMode, if (mBouncerShowing) { // Bouncer needs the front scrim when it's on top of an activity, - // tapping on a notification or editing QS. - mScrimController.transitionTo(mIsOccluded || mNotificationPanel.needsScrimming() ? - ScrimState.BOUNCER_SCRIMMED : ScrimState.BOUNCER); + // tapping on a notification, editing QS or being dismissed by + // FLAG_DISMISS_KEYGUARD_ACTIVITY. + ScrimState state = mIsOccluded || mNotificationPanel.needsScrimming() + || mStatusBarKeyguardViewManager.willDismissWithAction() ? + ScrimState.BOUNCER_SCRIMMED : ScrimState.BOUNCER; + mScrimController.transitionTo(state); } else if (mLaunchCameraOnScreenTurningOn || isInLaunchTransition()) { mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback); } else if (mBrightnessMirrorVisible) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index 56a7b1ba37d1e..1a64b0000647b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -140,11 +140,14 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } private void onPanelExpansionChanged(float expansion, boolean tracking) { - // We don't want to translate the bounce when the keyguard is occluded, because we're in - // a FLAG_SHOW_WHEN_LOCKED activity and need to conserve the original animation. - // We also don't want to show the bouncer when the user quickly taps on the display. + // We don't want to translate the bounce when: + // • Keyguard is occluded, because we're in a FLAG_SHOW_WHEN_LOCKED activity and need to + // conserve the original animation. + // • The user quickly taps on the display and we show "swipe up to unlock." + // • Keyguard will be dismissed by an action. a.k.a: FLAG_DISMISS_KEYGUARD_ACTIVITY final boolean noLongerTracking = mLastTracking != tracking && !tracking; - if (mOccluded || mNotificationPanelView.isUnlockHintRunning()) { + if (mOccluded || mNotificationPanelView.isUnlockHintRunning() + || mBouncer.willDismissWithAction()) { mBouncer.setExpansion(0); } else if (mShowing && mStatusBar.isKeyguardCurrentlySecure() && !mDozing) { mBouncer.setExpansion(expansion); @@ -696,6 +699,10 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } } + public boolean willDismissWithAction() { + return mBouncer.willDismissWithAction(); + } + private static class DismissWithActionRequest { final OnDismissAction dismissAction; final Runnable cancelAction; diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardHostViewTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardHostViewTest.java new file mode 100644 index 0000000000000..3f85c9d169c7c --- /dev/null +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardHostViewTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.keyguard; + +import static org.mockito.Mockito.mock; + +import android.test.suitebuilder.annotation.SmallTest; +import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; + +import com.android.systemui.SysuiTestCase; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +@SmallTest +@RunWith(AndroidTestingRunner.class) +@TestableLooper.RunWithLooper +public class KeyguardHostViewTest extends SysuiTestCase { + + private KeyguardHostView mKeyguardHostView; + + @Before + public void setup() { + mKeyguardHostView = new KeyguardHostView(getContext()); + } + + @Test + public void testHasDismissActions() { + Assert.assertFalse("Action not set yet", mKeyguardHostView.hasDismissActions()); + mKeyguardHostView.setOnDismissAction(mock(KeyguardHostView.OnDismissAction.class), + null /* cancelAction */); + Assert.assertTrue("Action should exist", mKeyguardHostView.hasDismissActions()); + } +} diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java index a37947df7094e..67453d5da6c75 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java @@ -22,6 +22,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.spy; @@ -307,4 +308,12 @@ public class KeyguardBouncerTest extends SysuiTestCase { mBouncer.isSecure(), mode != KeyguardSecurityModel.SecurityMode.None); } } + + @Test + public void testWillDismissWithAction() { + mBouncer.ensureView(); + Assert.assertFalse("Action not set yet", mBouncer.willDismissWithAction()); + when(mKeyguardHostView.hasDismissActions()).thenReturn(true); + Assert.assertTrue("Action should exist", mBouncer.willDismissWithAction()); + } }