Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9c7a7de authored by Jordan Demeulenaere's avatar Jordan Demeulenaere Committed by Android (Google) Code Review
Browse files

Merge "Animate device controls launches from lockscreen" into sc-v2-dev

parents bb6c39d3 b713d930
Loading
Loading
Loading
Loading
+3 −14
Original line number Diff line number Diff line
@@ -112,20 +112,9 @@ class DeviceControlsTile @Inject constructor(
        }

        mUiHandler.post {
            if (keyguardStateController.isUnlocked) {
            val showOverLockscreenWhenLocked = state.state == Tile.STATE_ACTIVE
            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)
                }
            }
                intent, true /* dismissShade */, animationController, showOverLockscreenWhenLocked)
        }
    }

+6 −2
Original line number Diff line number Diff line
@@ -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);
        }
    }

+7 −57
Original line number Diff line number Diff line
@@ -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)
    }