Merge "Animate device controls launches from lockscreen" into sc-v2-dev am: f9c7a7de95
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16075529 Change-Id: I0e0add276d5c2eae8bc5ffc977683542c99d8041
This commit is contained in:
committed by
Automerger Merge Worker
commit
f3250d44de
@@ -112,20 +112,9 @@ class DeviceControlsTile @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
mUiHandler.post {
|
mUiHandler.post {
|
||||||
if (keyguardStateController.isUnlocked) {
|
val showOverLockscreenWhenLocked = state.state == Tile.STATE_ACTIVE
|
||||||
mActivityStarter.startActivity(
|
mActivityStarter.startActivity(
|
||||||
intent, true /* dismissShade */, animationController)
|
intent, true /* dismissShade */, animationController, showOverLockscreenWhenLocked)
|
||||||
} 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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1078,10 +1078,14 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
|
|||||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
.putExtra(ControlsUiController.EXTRA_ANIMATE, true);
|
.putExtra(ControlsUiController.EXTRA_ANIMATE, true);
|
||||||
|
|
||||||
|
ActivityLaunchAnimator.Controller controller =
|
||||||
|
v != null ? ActivityLaunchAnimator.Controller.fromView(v, null /* cujType */)
|
||||||
|
: null;
|
||||||
if (mControlsComponent.getVisibility() == AVAILABLE) {
|
if (mControlsComponent.getVisibility() == AVAILABLE) {
|
||||||
mContext.startActivity(intent);
|
mActivityStarter.startActivity(intent, true /* dismissShade */, controller,
|
||||||
|
true /* showOverLockscreenWhenLocked */);
|
||||||
} else {
|
} 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.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.ArgumentCaptor
|
import org.mockito.ArgumentCaptor
|
||||||
import org.mockito.ArgumentMatchers.anyInt
|
|
||||||
import org.mockito.ArgumentMatchers.anyBoolean
|
import org.mockito.ArgumentMatchers.anyBoolean
|
||||||
import org.mockito.Captor
|
import org.mockito.Captor
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
import org.mockito.Mockito.doNothing
|
import org.mockito.Mockito.doNothing
|
||||||
import org.mockito.Mockito.never
|
|
||||||
import org.mockito.Mockito.nullable
|
import org.mockito.Mockito.nullable
|
||||||
import org.mockito.Mockito.spy
|
import org.mockito.Mockito.spy
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
@@ -272,28 +270,7 @@ class DeviceControlsTileTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun handleClick_availableAndLocked_activityStarted() {
|
fun handleClick_available_shownOverLockscreenWhenLocked() {
|
||||||
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() {
|
|
||||||
verify(controlsListingController).observe(
|
verify(controlsListingController).observe(
|
||||||
any(LifecycleOwner::class.java),
|
any(LifecycleOwner::class.java),
|
||||||
capture(listingCallbackCaptor)
|
capture(listingCallbackCaptor)
|
||||||
@@ -307,16 +284,16 @@ class DeviceControlsTileTest : SysuiTestCase() {
|
|||||||
tile.click(null /* view */)
|
tile.click(null /* view */)
|
||||||
testableLooper.processAllMessages()
|
testableLooper.processAllMessages()
|
||||||
|
|
||||||
verify(activityStarter, never()).postStartActivityDismissingKeyguard(any(), anyInt())
|
|
||||||
verify(activityStarter).startActivity(
|
verify(activityStarter).startActivity(
|
||||||
intentCaptor.capture(),
|
intentCaptor.capture(),
|
||||||
eq(true) /* dismissShade */,
|
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)
|
assertThat(intentCaptor.value.component?.className).isEqualTo(CONTROLS_ACTIVITY_CLASS_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun handleClick_availableAfterUnlockAndIsLocked_keyguardDismissRequired() {
|
fun handleClick_availableAfterUnlock_notShownOverLockscreenWhenLocked() {
|
||||||
verify(controlsListingController).observe(
|
verify(controlsListingController).observe(
|
||||||
any(LifecycleOwner::class.java),
|
any(LifecycleOwner::class.java),
|
||||||
capture(listingCallbackCaptor)
|
capture(listingCallbackCaptor)
|
||||||
@@ -331,38 +308,11 @@ class DeviceControlsTileTest : SysuiTestCase() {
|
|||||||
tile.click(null /* view */)
|
tile.click(null /* view */)
|
||||||
testableLooper.processAllMessages()
|
testableLooper.processAllMessages()
|
||||||
|
|
||||||
verify(activityStarter, never()).startActivity(
|
verify(activityStarter).startActivity(
|
||||||
any(),
|
intentCaptor.capture(),
|
||||||
anyBoolean() /* dismissShade */,
|
anyBoolean() /* dismissShade */,
|
||||||
nullable(ActivityLaunchAnimator.Controller::class.java))
|
nullable(ActivityLaunchAnimator.Controller::class.java),
|
||||||
verify(activityStarter).postStartActivityDismissingKeyguard(
|
eq(false) /* showOverLockscreenWhenLocked */)
|
||||||
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))
|
|
||||||
assertThat(intentCaptor.value.component?.className).isEqualTo(CONTROLS_ACTIVITY_CLASS_NAME)
|
assertThat(intentCaptor.value.component?.className).isEqualTo(CONTROLS_ACTIVITY_CLASS_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user