Merge "Animate device controls launches from lockscreen" into sc-v2-dev am: f9c7a7de95 am: f3250d44de
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16075529 Change-Id: I43ca076bc451f42f691d1d3feff3dabc4f664cd6
This commit is contained in:
committed by
Automerger Merge Worker
commit
3d921c46dc
@@ -112,20 +112,9 @@ class DeviceControlsTile @Inject constructor(
|
||||
}
|
||||
|
||||
mUiHandler.post {
|
||||
if (keyguardStateController.isUnlocked) {
|
||||
mActivityStarter.startActivity(
|
||||
intent, true /* dismissShade */, animationController)
|
||||
} else {
|
||||
if (state.state == Tile.STATE_ACTIVE) {
|
||||
mHost.collapsePanels()
|
||||
// With an active tile, don't use ActivityStarter so that the activity is
|
||||
// started without prompting keyguard unlock.
|
||||
mContext.startActivity(intent)
|
||||
} else {
|
||||
mActivityStarter.postStartActivityDismissingKeyguard(
|
||||
intent, 0 /* delay */, animationController)
|
||||
}
|
||||
}
|
||||
val showOverLockscreenWhenLocked = state.state == Tile.STATE_ACTIVE
|
||||
mActivityStarter.startActivity(
|
||||
intent, true /* dismissShade */, animationController, showOverLockscreenWhenLocked)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1078,10 +1078,14 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
|
||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.putExtra(ControlsUiController.EXTRA_ANIMATE, true);
|
||||
|
||||
ActivityLaunchAnimator.Controller controller =
|
||||
v != null ? ActivityLaunchAnimator.Controller.fromView(v, null /* cujType */)
|
||||
: null;
|
||||
if (mControlsComponent.getVisibility() == AVAILABLE) {
|
||||
mContext.startActivity(intent);
|
||||
mActivityStarter.startActivity(intent, true /* dismissShade */, controller,
|
||||
true /* showOverLockscreenWhenLocked */);
|
||||
} else {
|
||||
mActivityStarter.postStartActivityDismissingKeyguard(intent, 0 /* delay */);
|
||||
mActivityStarter.postStartActivityDismissingKeyguard(intent, 0 /* delay */, controller);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,13 +52,11 @@ import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentCaptor
|
||||
import org.mockito.ArgumentMatchers.anyInt
|
||||
import org.mockito.ArgumentMatchers.anyBoolean
|
||||
import org.mockito.Captor
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.doNothing
|
||||
import org.mockito.Mockito.never
|
||||
import org.mockito.Mockito.nullable
|
||||
import org.mockito.Mockito.spy
|
||||
import org.mockito.Mockito.verify
|
||||
@@ -272,28 +270,7 @@ class DeviceControlsTileTest : SysuiTestCase() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun handleClick_availableAndLocked_activityStarted() {
|
||||
verify(controlsListingController).observe(
|
||||
any(LifecycleOwner::class.java),
|
||||
capture(listingCallbackCaptor)
|
||||
)
|
||||
`when`(controlsComponent.getVisibility()).thenReturn(ControlsComponent.Visibility.AVAILABLE)
|
||||
`when`(keyguardStateController.isUnlocked).thenReturn(false)
|
||||
|
||||
listingCallbackCaptor.value.onServicesUpdated(listOf(serviceInfo))
|
||||
testableLooper.processAllMessages()
|
||||
|
||||
tile.click(null /* view */)
|
||||
testableLooper.processAllMessages()
|
||||
|
||||
// The activity should be started right away and not require a keyguard dismiss.
|
||||
verifyZeroInteractions(activityStarter)
|
||||
verify(spiedContext).startActivity(intentCaptor.capture())
|
||||
assertThat(intentCaptor.value.component?.className).isEqualTo(CONTROLS_ACTIVITY_CLASS_NAME)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun handleClick_availableAndUnlocked_activityStarted() {
|
||||
fun handleClick_available_shownOverLockscreenWhenLocked() {
|
||||
verify(controlsListingController).observe(
|
||||
any(LifecycleOwner::class.java),
|
||||
capture(listingCallbackCaptor)
|
||||
@@ -307,16 +284,16 @@ class DeviceControlsTileTest : SysuiTestCase() {
|
||||
tile.click(null /* view */)
|
||||
testableLooper.processAllMessages()
|
||||
|
||||
verify(activityStarter, never()).postStartActivityDismissingKeyguard(any(), anyInt())
|
||||
verify(activityStarter).startActivity(
|
||||
intentCaptor.capture(),
|
||||
eq(true) /* dismissShade */,
|
||||
nullable(ActivityLaunchAnimator.Controller::class.java))
|
||||
nullable(ActivityLaunchAnimator.Controller::class.java),
|
||||
eq(true) /* showOverLockscreenWhenLocked */)
|
||||
assertThat(intentCaptor.value.component?.className).isEqualTo(CONTROLS_ACTIVITY_CLASS_NAME)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun handleClick_availableAfterUnlockAndIsLocked_keyguardDismissRequired() {
|
||||
fun handleClick_availableAfterUnlock_notShownOverLockscreenWhenLocked() {
|
||||
verify(controlsListingController).observe(
|
||||
any(LifecycleOwner::class.java),
|
||||
capture(listingCallbackCaptor)
|
||||
@@ -331,38 +308,11 @@ class DeviceControlsTileTest : SysuiTestCase() {
|
||||
tile.click(null /* view */)
|
||||
testableLooper.processAllMessages()
|
||||
|
||||
verify(activityStarter, never()).startActivity(
|
||||
any(),
|
||||
anyBoolean() /* dismissShade */,
|
||||
nullable(ActivityLaunchAnimator.Controller::class.java))
|
||||
verify(activityStarter).postStartActivityDismissingKeyguard(
|
||||
intentCaptor.capture(),
|
||||
anyInt(),
|
||||
nullable(ActivityLaunchAnimator.Controller::class.java))
|
||||
assertThat(intentCaptor.value.component?.className).isEqualTo(CONTROLS_ACTIVITY_CLASS_NAME)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun handleClick_availableAfterUnlockAndIsUnlocked_activityStarted() {
|
||||
verify(controlsListingController).observe(
|
||||
any(LifecycleOwner::class.java),
|
||||
capture(listingCallbackCaptor)
|
||||
)
|
||||
`when`(controlsComponent.getVisibility())
|
||||
.thenReturn(ControlsComponent.Visibility.AVAILABLE_AFTER_UNLOCK)
|
||||
`when`(keyguardStateController.isUnlocked).thenReturn(true)
|
||||
|
||||
listingCallbackCaptor.value.onServicesUpdated(listOf(serviceInfo))
|
||||
testableLooper.processAllMessages()
|
||||
|
||||
tile.click(null /* view */)
|
||||
testableLooper.processAllMessages()
|
||||
|
||||
verify(activityStarter, never()).postStartActivityDismissingKeyguard(any(), anyInt())
|
||||
verify(activityStarter).startActivity(
|
||||
intentCaptor.capture(),
|
||||
eq(true) /* dismissShade */,
|
||||
nullable(ActivityLaunchAnimator.Controller::class.java))
|
||||
anyBoolean() /* dismissShade */,
|
||||
nullable(ActivityLaunchAnimator.Controller::class.java),
|
||||
eq(false) /* showOverLockscreenWhenLocked */)
|
||||
assertThat(intentCaptor.value.component?.className).isEqualTo(CONTROLS_ACTIVITY_CLASS_NAME)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user