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

Commit c5babe0b authored by Bharat Singh's avatar Bharat Singh Committed by Android (Google) Code Review
Browse files

Merge changes from topic "config-anim-time-asst" into main

* changes:
  [SysUI][Floaty] Add support for dumping invocation effect related info
  [SysUI][Floaty] Wire invocation effect preferences with setUiHints
  [SysUI][Floaty] Create flow to determine if effect enabled by assistant
  [SysUI][Floaty] Add a flow to detect change in active user or assistant
  [SysUI][Floaty] Extract preferences logic to a separate class
parents 0a8961a7 137bcc32
Loading
Loading
Loading
Loading
+19 −17
Original line number Diff line number Diff line
@@ -34,10 +34,10 @@ import com.android.systemui.statusbar.notificationShadeWindowController
import com.android.systemui.testKosmos
import com.android.systemui.topui.TopUiControllerRefactor
import com.android.systemui.topui.mockTopUiController
import com.android.systemui.topwindoweffects.data.repository.InvocationEffectPreferencesImpl.Companion.DEFAULT_OUTWARD_EFFECT_DURATION_MS
import com.android.systemui.topwindoweffects.data.repository.SqueezeEffectRepositoryImpl.Companion.DEFAULT_INITIAL_DELAY_MILLIS
import com.android.systemui.topwindoweffects.data.repository.SqueezeEffectRepositoryImpl.Companion.DEFAULT_INWARD_EFFECT_DURATION
import com.android.systemui.topwindoweffects.data.repository.SqueezeEffectRepositoryImpl.Companion.DEFAULT_INWARD_EFFECT_DURATION_MILLIS
import com.android.systemui.topwindoweffects.data.repository.SqueezeEffectRepositoryImpl.Companion.DEFAULT_LONG_PRESS_POWER_DURATION_MILLIS
import com.android.systemui.topwindoweffects.data.repository.SqueezeEffectRepositoryImpl.Companion.DEFAULT_OUTWARD_EFFECT_DURATION
import com.android.systemui.topwindoweffects.data.repository.fakeSqueezeEffectRepository
import com.android.systemui.topwindoweffects.domain.interactor.SqueezeEffectInteractor
import com.android.systemui.topwindoweffects.ui.viewmodel.SqueezeEffectHapticsBuilder
@@ -45,10 +45,10 @@ import com.android.systemui.topwindoweffects.ui.viewmodel.squeezeEffectHapticPla
import com.android.wm.shell.appzoomout.appZoomOutOptional
import com.android.wm.shell.appzoomout.fakeAppZoomOut
import com.google.common.truth.Truth.assertThat
import kotlin.test.assertEquals
import kotlin.test.assertNotEquals
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -78,7 +78,9 @@ class TopLevelWindowEffectsTest : SysuiTestCase() {
            lowTickDuration = primitiveDurations[0],
            quickRiseDuration = primitiveDurations[1],
            tickDuration = primitiveDurations[2],
            totalEffectDuration = DEFAULT_OUTWARD_EFFECT_DURATION + DEFAULT_INWARD_EFFECT_DURATION,
            totalEffectDuration =
                DEFAULT_OUTWARD_EFFECT_DURATION_MS.toInt() +
                    DEFAULT_INWARD_EFFECT_DURATION_MILLIS.toInt(),
        )

    private val Kosmos.underTest by
@@ -308,12 +310,12 @@ class TopLevelWindowEffectsTest : SysuiTestCase() {
            assertThat(vibratorHelper.timesCancelled).isEqualTo(timesCancelledBefore)

            // Animation continues: complete inward animation
            animatorTestRule.advanceTimeBy(DEFAULT_INWARD_EFFECT_DURATION - 10L)
            animatorTestRule.advanceTimeBy(DEFAULT_INWARD_EFFECT_DURATION_MILLIS - 10L)
            runCurrent()
            assertThat(fakeAppZoomOut.lastTopLevelProgress).isEqualTo(1f)

            // Animation continues: complete outward animation (triggered by inward animation's end)
            animatorTestRule.advanceTimeBy(DEFAULT_OUTWARD_EFFECT_DURATION.toLong())
            animatorTestRule.advanceTimeBy(DEFAULT_OUTWARD_EFFECT_DURATION_MS)
            runCurrent()
            assertThat(fakeAppZoomOut.lastTopLevelProgress).isEqualTo(0f)

@@ -339,7 +341,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() {
            val timesCancelledBefore = vibratorHelper.timesCancelled

            // Complete inward animation
            animatorTestRule.advanceTimeBy(DEFAULT_INWARD_EFFECT_DURATION.toLong())
            animatorTestRule.advanceTimeBy(DEFAULT_INWARD_EFFECT_DURATION_MILLIS)
            runCurrent()
            assertThat(fakeAppZoomOut.lastTopLevelProgress).isEqualTo(1f) // Animation proceeds

@@ -348,7 +350,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() {
            assertThat(vibratorHelper.timesCancelled).isEqualTo(timesCancelledBefore)

            // Complete outward animation
            animatorTestRule.advanceTimeBy(DEFAULT_OUTWARD_EFFECT_DURATION.toLong())
            animatorTestRule.advanceTimeBy(DEFAULT_OUTWARD_EFFECT_DURATION_MS)
            runCurrent()
            assertThat(fakeAppZoomOut.lastTopLevelProgress).isEqualTo(0f)

@@ -378,12 +380,12 @@ class TopLevelWindowEffectsTest : SysuiTestCase() {
            val timesCancelledBefore = vibratorHelper.timesCancelled

            // Complete inward animation
            animatorTestRule.advanceTimeBy(DEFAULT_INWARD_EFFECT_DURATION.toLong())
            animatorTestRule.advanceTimeBy(DEFAULT_INWARD_EFFECT_DURATION_MILLIS)
            runCurrent()
            assertThat(fakeAppZoomOut.lastTopLevelProgress).isEqualTo(1f)

            // Outward animation is triggered by the end of the inward animation
            animatorTestRule.advanceTimeBy(DEFAULT_OUTWARD_EFFECT_DURATION.toLong())
            animatorTestRule.advanceTimeBy(DEFAULT_OUTWARD_EFFECT_DURATION_MS)
            runCurrent()
            assertThat(fakeAppZoomOut.lastTopLevelProgress).isEqualTo(0f)

@@ -412,7 +414,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() {
            advanceTime((initialDelay + 1).milliseconds)
            val timesCancelledBefore = vibratorHelper.timesCancelled
            // Progress half-way into inward animation
            animatorTestRule.advanceTimeBy(DEFAULT_INWARD_EFFECT_DURATION.toLong() / 2)
            animatorTestRule.advanceTimeBy(DEFAULT_INWARD_EFFECT_DURATION_MILLIS / 2)
            runCurrent()

            val progressBeforeCancel = fakeAppZoomOut.lastTopLevelProgress
@@ -429,7 +431,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() {
            assertThat(vibratorHelper.timesCancelled).isEqualTo(timesCancelledBefore + 1)

            // Complete the cancellation (outward) animation
            animatorTestRule.advanceTimeBy(DEFAULT_OUTWARD_EFFECT_DURATION.toLong())
            animatorTestRule.advanceTimeBy(DEFAULT_OUTWARD_EFFECT_DURATION_MS)
            runCurrent()

            assertThat(fakeAppZoomOut.lastTopLevelProgress).isEqualTo(0f)
@@ -473,9 +475,9 @@ class TopLevelWindowEffectsTest : SysuiTestCase() {
            reset(kosmos.mockTopUiController, kosmos.notificationShadeWindowController)

            // Action: Complete the full animation cycle (inward + outward)
            animatorTestRule.advanceTimeBy(DEFAULT_INWARD_EFFECT_DURATION.toLong() - 1L)
            animatorTestRule.advanceTimeBy(DEFAULT_INWARD_EFFECT_DURATION_MILLIS - 1L)
            runCurrent()
            animatorTestRule.advanceTimeBy(DEFAULT_OUTWARD_EFFECT_DURATION.toLong())
            animatorTestRule.advanceTimeBy(DEFAULT_OUTWARD_EFFECT_DURATION_MS)
            runCurrent()

            // Verification: setRequestTopUi(false) should be called upon completion
@@ -495,7 +497,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() {
            underTest.start()
            advanceTime((initialDelay + 1).milliseconds) // Pass initial delay
            // Progress animation part way
            animatorTestRule.advanceTimeBy(DEFAULT_INWARD_EFFECT_DURATION.toLong() / 2)
            animatorTestRule.advanceTimeBy(DEFAULT_INWARD_EFFECT_DURATION_MILLIS / 2)
            runCurrent()

            // Verification: Ensure TopUI was requested initially
@@ -508,7 +510,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() {
                false
            runCurrent()
            // Allow cancellation animation to complete
            animatorTestRule.advanceTimeBy(DEFAULT_OUTWARD_EFFECT_DURATION.toLong())
            animatorTestRule.advanceTimeBy(DEFAULT_OUTWARD_EFFECT_DURATION_MS)
            runCurrent()

            // Verification: setRequestTopUi(false) should be called upon cancellation
+52 −171
Original line number Diff line number Diff line
@@ -16,16 +16,11 @@

package com.android.systemui.topwindoweffects.data.repository

import android.app.role.OnRoleHoldersChangedListener
import android.app.role.RoleManager
import android.content.pm.UserInfo
import android.hardware.input.InputManager
import android.hardware.input.KeyGestureEvent
import android.os.Bundle
import android.os.UserHandle
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.provider.Settings.Global.POWER_BUTTON_LONG_PRESS
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
@@ -37,10 +32,10 @@ import com.android.systemui.kosmos.testScope
import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.shared.Flags
import com.android.systemui.testKosmos
import com.android.systemui.topwindoweffects.data.repository.SqueezeEffectRepositoryImpl.Companion.IS_INVOCATION_EFFECT_ENABLED_BY_ASSISTANT_DEFAULT_VALUE
import com.android.systemui.topwindoweffects.data.repository.InvocationEffectPreferencesImpl.Companion.INVOCATION_EFFECT_ANIMATION_IN_DURATION_PADDING_MS
import com.android.systemui.topwindoweffects.data.repository.InvocationEffectPreferencesImpl.Companion.INVOCATION_EFFECT_ANIMATION_OUT_DURATION_MS
import com.android.systemui.topwindoweffects.data.repository.SqueezeEffectRepositoryImpl.Companion.IS_INVOCATION_EFFECT_ENABLED_KEY
import com.android.systemui.topwindoweffects.data.repository.SqueezeEffectRepositoryImpl.Companion.SET_INVOCATION_EFFECT_PARAMETERS_ACTION
import com.android.systemui.user.data.repository.FakeUserRepository
import com.android.systemui.util.settings.FakeGlobalSettings
import com.google.common.truth.Truth.assertThat
import java.util.concurrent.Executor
@@ -50,10 +45,8 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.Mock
import org.mockito.Mockito.atLeast
import org.mockito.Mockito.eq
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.MockitoAnnotations

@SmallTest
@@ -63,13 +56,8 @@ class SqueezeEffectRepositoryTest : SysuiTestCase() {
    private val kosmos = testKosmos().useUnconfinedTestDispatcher()
    private val globalSettings = FakeGlobalSettings(StandardTestDispatcher())
    private val mainExecutor = Executor(Runnable::run)
    private val userRepository = FakeUserRepository()

    @Mock private lateinit var inputManager: InputManager
    @Mock private lateinit var roleManager: RoleManager

    private val onRoleHoldersChangedListener =
        ArgumentCaptor.forClass(OnRoleHoldersChangedListener::class.java)

    private val keyGestureEventListenerCaptor =
        ArgumentCaptor.forClass(InputManager.KeyGestureEventListener::class.java)
@@ -78,40 +66,47 @@ class SqueezeEffectRepositoryTest : SysuiTestCase() {
        Kosmos.Fixture {
            SqueezeEffectRepositoryImpl(
                context = context,
                coroutineScope = testScope.backgroundScope,
                globalSettings = globalSettings,
                userRepository = userRepository,
                inputManager = inputManager,
                coroutineContext = testScope.testScheduler,
                roleManager = roleManager,
                executor = mainExecutor,
                preferences = fakeInvocationEffectPreferences,
            )
        }

    @Before
    fun setup() {
        MockitoAnnotations.openMocks(this)
        kosmos.fakeInvocationEffectPreferences.apply {
            clear()
            activeAssistant = "a"
            activeUserId = 0
        }
    }

    @DisableFlags(Flags.FLAG_ENABLE_LPP_ASSIST_INVOCATION_EFFECT)
    @Test
    fun testSqueezeEffectDisabled_FlagDisabled() =
        kosmos.runTest {
            underTest.tryHandleSetUiHints(createAssistantSettingBundle(true))
            fakeInvocationEffectPreferences.setInvocationEffectEnabledByAssistant(false)

            val isEffectEnabledAndPowerButtonPressed by
                collectLastValue(underTest.isEffectEnabledAndPowerButtonPressedAsSingleGesture)

            assertThat(isEffectEnabledAndPowerButtonPressed).isFalse()
        }

    @EnableFlags(Flags.FLAG_ENABLE_LPP_ASSIST_INVOCATION_EFFECT)
    @Test
    fun testSqueezeEffectDisabled_GlobalSettingDisabled() =
    fun testSqueezeEffectEnabled_DisabledFromPhoneWindowManager() =
        kosmos.runTest {
            underTest.tryHandleSetUiHints(createAssistantSettingBundle(true))
            globalSettings.putInt(POWER_BUTTON_LONG_PRESS, 0)
            fakeInvocationEffectPreferences.setInvocationEffectEnabledByAssistant(true)

            val isEffectEnabledAndPowerButtonPressed by
                collectLastValue(underTest.isEffectEnabledAndPowerButtonPressedAsSingleGesture)

            // no events sent from KeyGestureEvent to imitate it was disabled from PWM

            assertThat(isEffectEnabledAndPowerButtonPressed).isFalse()
        }

@@ -119,21 +114,11 @@ class SqueezeEffectRepositoryTest : SysuiTestCase() {
    @Test
    fun testSqueezeEffectDisabled_AssistantSettingDisabled() =
        kosmos.runTest {
            globalSettings.putInt(POWER_BUTTON_LONG_PRESS, 5)
            underTest.tryHandleSetUiHints(createAssistantSettingBundle(false))
            fakeInvocationEffectPreferences.setInvocationEffectEnabledByAssistant(false)

            val isEffectEnabledAndPowerButtonPressed by
                collectLastValue(underTest.isEffectEnabledAndPowerButtonPressedAsSingleGesture)
            assertThat(isEffectEnabledAndPowerButtonPressed).isFalse()
        }

    @EnableFlags(Flags.FLAG_ENABLE_LPP_ASSIST_INVOCATION_EFFECT)
    @Test
    fun testSqueezeEffectEnabled_AllSettingsEnabled() =
        kosmos.runTest {
            underTest.tryHandleSetUiHints(createAssistantSettingBundle(true))
            val isEffectEnabledAndPowerButtonPressed by
                collectLastValue(underTest.isEffectEnabledAndPowerButtonPressedAsSingleGesture)
            verify(inputManager)
                .registerKeyGestureEventListener(
                    eq(mainExecutor),
@@ -145,64 +130,20 @@ class SqueezeEffectRepositoryTest : SysuiTestCase() {
                    .setKeyGestureType(KeyGestureEvent.KEY_GESTURE_TYPE_LAUNCH_ASSISTANT)
                    .build()
            keyGestureEventListenerCaptor.value.onKeyGestureEvent(event)
            assertThat(isEffectEnabledAndPowerButtonPressed).isTrue()
        }

    private suspend fun Kosmos.initUserAndAssistant(
        userInfos: List<UserInfo>,
        userIndex: Int,
        assistantName: String,
    ) {
        collectLastValue(
            underTest.isEffectEnabledAndPowerButtonPressedAsSingleGesture
        ) //  ensure flow is started
        userRepository.setUserInfos(userInfos)
        userRepository.setSelectedUserInfo(userInfos[userIndex])
        verify(roleManager)
            .addOnRoleHoldersChangedListenerAsUser(
                eq(mainExecutor),
                onRoleHoldersChangedListener.capture(),
                eq(UserHandle.ALL),
            )
        `when`(
                roleManager.getRoleHoldersAsUser(
                    eq(RoleManager.ROLE_ASSISTANT),
                    eq(userInfos[userIndex].userHandle),
                )
            )
            .thenReturn(listOf(assistantName))
        onRoleHoldersChangedListener.value.onRoleHoldersChanged(
            RoleManager.ROLE_ASSISTANT,
            userInfos[userIndex].userHandle,
        )
            assertThat(isEffectEnabledAndPowerButtonPressed).isFalse()
        }

    @EnableFlags(Flags.FLAG_ENABLE_LPP_ASSIST_INVOCATION_EFFECT)
    @Test
    fun testAssistantEnabledStatusIsDefault_AssistantSwitched() =
    fun testSqueezeEffectEnabled_AllSettingsEnabled() =
        kosmos.runTest {
            initUserAndAssistant(userInfos, 0, "a")
            underTest.tryHandleSetUiHints(
                createAssistantSettingBundle(
                    !IS_INVOCATION_EFFECT_ENABLED_BY_ASSISTANT_DEFAULT_VALUE
                )
            )

            `when`(
                    roleManager.getRoleHoldersAsUser(
                        eq(RoleManager.ROLE_ASSISTANT),
                        eq(userInfos[0].userHandle),
                    )
                )
                .thenReturn(listOf("b"))
            onRoleHoldersChangedListener.value.onRoleHoldersChanged(
                RoleManager.ROLE_ASSISTANT,
                userInfos[0].userHandle,
            )
            fakeInvocationEffectPreferences.setInvocationEffectEnabledByAssistant(true)

            val isEffectEnabledAndPowerButtonPressed by
                collectLastValue(underTest.isEffectEnabledAndPowerButtonPressedAsSingleGesture)
            verify(inputManager, atLeast(1))

            verify(inputManager)
                .registerKeyGestureEventListener(
                    eq(mainExecutor),
                    keyGestureEventListenerCaptor.capture(),
@@ -214,120 +155,60 @@ class SqueezeEffectRepositoryTest : SysuiTestCase() {
                    .build()
            keyGestureEventListenerCaptor.value.onKeyGestureEvent(event)

            assertThat(isEffectEnabledAndPowerButtonPressed)
                .isEqualTo(IS_INVOCATION_EFFECT_ENABLED_BY_ASSISTANT_DEFAULT_VALUE)
            assertThat(isEffectEnabledAndPowerButtonPressed).isTrue()
        }

    @EnableFlags(Flags.FLAG_ENABLE_LPP_ASSIST_INVOCATION_EFFECT)
    @Test
    fun testAssistantEnabledStatusIsDefault_UserSwitched() =
    fun testInvocationEffectInwardsAnimationDelay() =
        kosmos.runTest {
            initUserAndAssistant(userInfos, 0, "a")
            underTest.tryHandleSetUiHints(
                createAssistantSettingBundle(
                    !IS_INVOCATION_EFFECT_ENABLED_BY_ASSISTANT_DEFAULT_VALUE
                )
            )
            fakeInvocationEffectPreferences.setInwardAnimationPaddingDurationMillis(450)

            userRepository.setSelectedUserInfo(userInfos[1])

            val isEffectEnabledAndPowerButtonPressed by
                collectLastValue(underTest.isEffectEnabledAndPowerButtonPressedAsSingleGesture)
            verify(inputManager, atLeast(1))
                .registerKeyGestureEventListener(
                    eq(mainExecutor),
                    keyGestureEventListenerCaptor.capture(),
                )
            val event =
                KeyGestureEvent.Builder()
                    .setAction(KeyGestureEvent.ACTION_GESTURE_START)
                    .setKeyGestureType(KeyGestureEvent.KEY_GESTURE_TYPE_LAUNCH_ASSISTANT)
                    .build()
            keyGestureEventListenerCaptor.value.onKeyGestureEvent(event)

            assertThat(isEffectEnabledAndPowerButtonPressed)
                .isEqualTo(IS_INVOCATION_EFFECT_ENABLED_BY_ASSISTANT_DEFAULT_VALUE)
            assertThat(underTest.getInvocationEffectInAnimationDurationMillis()).isEqualTo(800)
        }

    @EnableFlags(Flags.FLAG_ENABLE_LPP_ASSIST_INVOCATION_EFFECT)
    @Test
    fun testAssistantEnabledStatusIsRetained_AssistantSwitchedBackAndForth() =
    fun testInvocationEffectOutwardsAnimationDelay() =
        kosmos.runTest {
            initUserAndAssistant(userInfos, 0, "a")
            globalSettings.putInt(POWER_BUTTON_LONG_PRESS, 5)
            underTest.tryHandleSetUiHints(
                createAssistantSettingBundle(
                    !IS_INVOCATION_EFFECT_ENABLED_BY_ASSISTANT_DEFAULT_VALUE
                )
            )
            fakeInvocationEffectPreferences.setOutwardAnimationDurationMillis(400)

            `when`(
                    roleManager.getRoleHoldersAsUser(
                        eq(RoleManager.ROLE_ASSISTANT),
                        eq(UserHandle.CURRENT),
                    )
                )
                .thenReturn(listOf("b"))
            onRoleHoldersChangedListener.value.onRoleHoldersChanged(
                RoleManager.ROLE_ASSISTANT,
                UserHandle.CURRENT,
            )
            `when`(
                    roleManager.getRoleHoldersAsUser(
                        eq(RoleManager.ROLE_ASSISTANT),
                        eq(UserHandle.CURRENT),
                    )
                )
                .thenReturn(listOf("a"))
            onRoleHoldersChangedListener.value.onRoleHoldersChanged(
                RoleManager.ROLE_ASSISTANT,
                UserHandle.CURRENT,
            )

            val isEffectEnabledAndPowerButtonPressed by
                collectLastValue(underTest.isEffectEnabledAndPowerButtonPressedAsSingleGesture)
            assertThat(isEffectEnabledAndPowerButtonPressed)
                .isEqualTo(!IS_INVOCATION_EFFECT_ENABLED_BY_ASSISTANT_DEFAULT_VALUE)
            assertThat(underTest.getInvocationEffectOutAnimationDurationMillis()).isEqualTo(400)
        }

    @EnableFlags(Flags.FLAG_ENABLE_LPP_ASSIST_INVOCATION_EFFECT)
    @Test
    fun testAssistantEnabledStatusIsRetained_UserSwitchedBackAndForth() =
    fun testSetUiHintsShouldUpdatePreferences() =
        kosmos.runTest {
            initUserAndAssistant(userInfos, 0, "a")
            globalSettings.putInt(POWER_BUTTON_LONG_PRESS, 5)
            underTest.tryHandleSetUiHints(
                createAssistantSettingBundle(
                    !IS_INVOCATION_EFFECT_ENABLED_BY_ASSISTANT_DEFAULT_VALUE
                )
            )
            fakeInvocationEffectPreferences.activeUserId = 1
            fakeInvocationEffectPreferences.activeAssistant = "A"

            userRepository.setSelectedUserInfo(userInfos[1])
            userRepository.setSelectedUserInfo(userInfos[0])
            assertThat(fakeInvocationEffectPreferences.isActiveUserAndAssistantPersisted())
                .isFalse()

            val hints = createAssistantSettingBundle(false, 0, 1000)
            underTest.tryHandleSetUiHints(hints)

            val isEffectEnabledAndPowerButtonPressed by
                collectLastValue(underTest.isEffectEnabledAndPowerButtonPressedAsSingleGesture)
            assertThat(isEffectEnabledAndPowerButtonPressed)
                .isEqualTo(!IS_INVOCATION_EFFECT_ENABLED_BY_ASSISTANT_DEFAULT_VALUE)

            assertThat(isEffectEnabledAndPowerButtonPressed).isFalse()
            assertThat(fakeInvocationEffectPreferences.getInwardAnimationPaddingDurationMillis())
                .isEqualTo(0)
            assertThat(fakeInvocationEffectPreferences.getOutwardAnimationDurationMillis())
                .isEqualTo(1000)
            assertThat(fakeInvocationEffectPreferences.isActiveUserAndAssistantPersisted()).isTrue()
        }

    private fun createAssistantSettingBundle(enableAssistantSetting: Boolean) =
    private fun createAssistantSettingBundle(
        enableAssistantSetting: Boolean,
        inwardsPaddingDuration: Long,
        outwardsAnimationDuration: Long,
    ) =
        Bundle().apply {
            putString(AssistManager.ACTION_KEY, SET_INVOCATION_EFFECT_PARAMETERS_ACTION)
            putBoolean(IS_INVOCATION_EFFECT_ENABLED_KEY, enableAssistantSetting)
        }

    companion object {
        private val userInfos =
            listOf(
                UserInfo().apply {
                    id = 0
                    name = "User 0"
                },
                UserInfo().apply {
                    id = 1
                    name = "User 1"
                },
            )
            putLong(INVOCATION_EFFECT_ANIMATION_IN_DURATION_PADDING_MS, inwardsPaddingDuration)
            putLong(INVOCATION_EFFECT_ANIMATION_OUT_DURATION_MS, outwardsAnimationDuration)
        }
}
+8 −6
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.statusbar.NotificationShadeWindowController
import com.android.systemui.topui.TopUiController
import com.android.systemui.topui.TopUiControllerRefactor
import com.android.systemui.topwindoweffects.data.repository.SqueezeEffectRepositoryImpl.Companion.DEFAULT_OUTWARD_EFFECT_DURATION
import com.android.systemui.topwindoweffects.domain.interactor.SqueezeEffectInteractor
import com.android.systemui.topwindoweffects.ui.viewmodel.SqueezeEffectHapticPlayer
import com.android.wm.shell.appzoomout.AppZoomOut
@@ -89,10 +88,12 @@ constructor(
    }

    private suspend fun startSqueeze() {
        delay(squeezeEffectInteractor.getInvocationEffectInitialDelayMs())
        delay(squeezeEffectInteractor.getInvocationEffectInitialDelayMillis())
        setRequestTopUi(true)
        val inwardsAnimationDuration =
            squeezeEffectInteractor.getInvocationEffectInwardsAnimationDurationMs()
            squeezeEffectInteractor.getInvocationEffectInAnimationDurationMillis()
        val outwardsAnimationDuration =
            squeezeEffectInteractor.getInvocationEffectOutAnimationDurationMillis()
        animateSqueezeProgressTo(
            targetProgress = 1f,
            duration = inwardsAnimationDuration,
@@ -100,13 +101,13 @@ constructor(
        ) {
            animateSqueezeProgressTo(
                targetProgress = 0f,
                duration = DEFAULT_OUTWARD_EFFECT_DURATION.toLong(),
                duration = outwardsAnimationDuration,
                interpolator = InterpolatorsAndroidX.LEGACY,
            ) {
                finishAnimation()
            }
        }
        hapticPlayer?.start(inwardsAnimationDuration.toInt() + DEFAULT_OUTWARD_EFFECT_DURATION)
        hapticPlayer?.start(inwardsAnimationDuration.toInt() + outwardsAnimationDuration.toInt())
        squeezeEffectInteractor.isPowerButtonLongPressed.collectLatest { isLongPressed ->
            if (isLongPressed) {
                isAnimationInterruptible = false
@@ -119,7 +120,7 @@ constructor(
            hapticPlayer?.cancel()
            animateSqueezeProgressTo(
                targetProgress = 0f,
                duration = DEFAULT_OUTWARD_EFFECT_DURATION.toLong(),
                duration = squeezeEffectInteractor.getInvocationEffectOutAnimationDurationMillis(),
                interpolator = InterpolatorsAndroidX.LEGACY,
            ) {
                finishAnimation()
@@ -167,6 +168,7 @@ constructor(
        pw.println("$TAG:")
        pw.println("  isAnimationInterruptible=$isAnimationInterruptible")
        pw.println("  squeezeProgress=$squeezeProgress")
        squeezeEffectInteractor.dump(pw, args)
    }

    companion object {
+7 −0

File changed.

Preview size limit exceeded, changes collapsed.

+319 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading