diff options
27 files changed, 365 insertions, 276 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsControllerTest.java index 54e0725957e6..949886cb9eb2 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/UdfpsControllerTest.java @@ -87,6 +87,7 @@ import com.android.systemui.biometrics.ui.viewmodel.DefaultUdfpsTouchOverlayView import com.android.systemui.biometrics.ui.viewmodel.DeviceEntryUdfpsTouchOverlayViewModel; import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor; import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor; +import com.android.systemui.camera.CameraGestureHelper; import com.android.systemui.classifier.FalsingCollector; import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFaceAuthInteractor; import com.android.systemui.dump.DumpManager; @@ -118,6 +119,8 @@ import com.android.systemui.util.time.SystemClock; import dagger.Lazy; +import javax.inject.Provider; + import kotlinx.coroutines.CoroutineScope; import org.junit.Before; @@ -261,6 +264,8 @@ public class UdfpsControllerTest extends SysuiTestCase { private Lazy<DeviceEntryUdfpsTouchOverlayViewModel> mDeviceEntryUdfpsTouchOverlayViewModel; @Mock private Lazy<DefaultUdfpsTouchOverlayViewModel> mDefaultUdfpsTouchOverlayViewModel; + @Mock + private Provider<CameraGestureHelper> mCameraGestureHelper; @Before public void setUp() { @@ -269,7 +274,8 @@ public class UdfpsControllerTest extends SysuiTestCase { mPowerRepository, mock(FalsingCollector.class), mock(ScreenOffAnimationController.class), - mStatusBarStateController + mStatusBarStateController, + mCameraGestureHelper ); mPowerRepository.updateWakefulness( WakefulnessState.AWAKE, diff --git a/packages/SystemUI/tests/src/com/android/systemui/camera/CameraGestureHelperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/CameraGestureHelperTest.kt index bea0db66555d..a0928ad6dd63 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/camera/CameraGestureHelperTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/camera/CameraGestureHelperTest.kt @@ -18,6 +18,7 @@ package com.android.systemui.camera import android.app.ActivityManager import android.app.IActivityTaskManager +import android.app.admin.DevicePolicyManager import android.content.ComponentName import android.content.ContentResolver import android.content.Intent @@ -29,82 +30,73 @@ import androidx.test.filters.SmallTest import com.android.systemui.ActivityIntentHelper import com.android.systemui.SysuiTestCase import com.android.systemui.plugins.ActivityStarter +import com.android.systemui.statusbar.NotificationLockscreenUserManager import com.android.systemui.statusbar.StatusBarState -import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.user.domain.interactor.SelectedUserInteractor import com.android.systemui.util.mockito.KotlinArgumentCaptor +import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.eq import com.android.systemui.util.mockito.mock +import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat import com.google.common.util.concurrent.MoreExecutors import org.junit.Before import org.junit.Test import org.junit.runner.RunWith +import org.mockito.ArgumentMatchers.isNull import org.mockito.Mock -import org.mockito.Mockito.any import org.mockito.Mockito.anyInt import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations -import org.mockito.Mockito.`when` as whenever @SmallTest @RunWith(AndroidJUnit4::class) class CameraGestureHelperTest : SysuiTestCase() { - @Mock - lateinit var centralSurfaces: CentralSurfaces - @Mock - lateinit var statusBarKeyguardViewManager: StatusBarKeyguardViewManager - @Mock - lateinit var keyguardStateController: KeyguardStateController - @Mock - lateinit var packageManager: PackageManager - @Mock - lateinit var activityManager: ActivityManager - @Mock - lateinit var activityStarter: ActivityStarter - @Mock - lateinit var activityIntentHelper: ActivityIntentHelper - @Mock - lateinit var activityTaskManager: IActivityTaskManager - @Mock - lateinit var cameraIntents: CameraIntentsWrapper - @Mock - lateinit var contentResolver: ContentResolver - @Mock - lateinit var mSelectedUserInteractor: SelectedUserInteractor + @Mock lateinit var statusBarKeyguardViewManager: StatusBarKeyguardViewManager + @Mock lateinit var keyguardStateController: KeyguardStateController + @Mock lateinit var packageManager: PackageManager + @Mock lateinit var activityManager: ActivityManager + @Mock lateinit var activityStarter: ActivityStarter + @Mock lateinit var activityIntentHelper: ActivityIntentHelper + @Mock lateinit var activityTaskManager: IActivityTaskManager + @Mock lateinit var cameraIntents: CameraIntentsWrapper + @Mock lateinit var contentResolver: ContentResolver + @Mock lateinit var mSelectedUserInteractor: SelectedUserInteractor + @Mock lateinit var devicePolicyManager: DevicePolicyManager + @Mock lateinit var lockscreenUserManager: NotificationLockscreenUserManager private lateinit var underTest: CameraGestureHelper @Before fun setUp() { MockitoAnnotations.initMocks(this) - whenever(cameraIntents.getSecureCameraIntent(anyInt())).thenReturn( - Intent(CameraIntents.DEFAULT_SECURE_CAMERA_INTENT_ACTION) - ) - whenever(cameraIntents.getInsecureCameraIntent(anyInt())).thenReturn( - Intent(CameraIntents.DEFAULT_INSECURE_CAMERA_INTENT_ACTION) - ) + whenever(cameraIntents.getSecureCameraIntent(any())) + .thenReturn(Intent(CameraIntents.DEFAULT_SECURE_CAMERA_INTENT_ACTION)) + whenever(cameraIntents.getInsecureCameraIntent(any())) + .thenReturn(Intent(CameraIntents.DEFAULT_INSECURE_CAMERA_INTENT_ACTION)) prepare() - underTest = CameraGestureHelper( - context = mock(), - centralSurfaces = centralSurfaces, - keyguardStateController = keyguardStateController, - statusBarKeyguardViewManager = statusBarKeyguardViewManager, - packageManager = packageManager, - activityManager = activityManager, - activityStarter = activityStarter, - activityIntentHelper = activityIntentHelper, - activityTaskManager = activityTaskManager, - cameraIntents = cameraIntents, - contentResolver = contentResolver, - uiExecutor = MoreExecutors.directExecutor(), - selectedUserInteractor = mSelectedUserInteractor, - ) + underTest = + CameraGestureHelper( + context = mock(), + keyguardStateController = keyguardStateController, + statusBarKeyguardViewManager = statusBarKeyguardViewManager, + packageManager = packageManager, + activityManager = activityManager, + activityStarter = activityStarter, + activityIntentHelper = activityIntentHelper, + activityTaskManager = activityTaskManager, + cameraIntents = cameraIntents, + contentResolver = contentResolver, + uiExecutor = MoreExecutors.directExecutor(), + selectedUserInteractor = mSelectedUserInteractor, + devicePolicyManager = devicePolicyManager, + lockscreenUserManager = lockscreenUserManager, + ) } /** @@ -116,13 +108,13 @@ class CameraGestureHelperTest : SysuiTestCase() { * @param isCameraAllowedByAdmin Whether the device administrator allows use of the camera app * @param installedCameraAppCount The number of installed camera apps on the device * @param isUsingSecureScreenLockOption Whether the user-controlled setting for Screen Lock is - * set with a "secure" option that requires the user to provide some secret/credentials to be - * able to unlock the device, for example "Face Unlock", "PIN", or "Password". Examples of - * non-secure options are "None" and "Swipe" + * set with a "secure" option that requires the user to provide some secret/credentials to be + * able to unlock the device, for example "Face Unlock", "PIN", or "Password". Examples of + * non-secure options are "None" and "Swipe" * @param isCameraActivityRunningOnTop Whether the camera activity is running at the top of the - * most recent/current task of activities + * most recent/current task of activities * @param isTaskListEmpty Whether there are no active activity tasks at all. Note that this is - * treated as `false` if [isCameraActivityRunningOnTop] is set to `true` + * treated as `false` if [isCameraActivityRunningOnTop] is set to `true` */ private fun prepare( isCameraAllowedByAdmin: Boolean = true, @@ -131,7 +123,13 @@ class CameraGestureHelperTest : SysuiTestCase() { isCameraActivityRunningOnTop: Boolean = false, isTaskListEmpty: Boolean = false, ) { - whenever(centralSurfaces.isCameraAllowedByAdmin).thenReturn(isCameraAllowedByAdmin) + whenever(lockscreenUserManager.getCurrentUserId()).thenReturn(1) + if (isCameraAllowedByAdmin) { + whenever(devicePolicyManager.getCameraDisabled(isNull(), any())).thenReturn(false) + whenever(keyguardStateController.isMethodSecure).thenReturn(false) + } else { + whenever(devicePolicyManager.getCameraDisabled(isNull(), any())).thenReturn(true) + } whenever(activityIntentHelper.wouldLaunchResolverActivity(any(), anyInt())) .thenReturn(installedCameraAppCount > 1) @@ -141,30 +139,26 @@ class CameraGestureHelperTest : SysuiTestCase() { .thenReturn(!isUsingSecureScreenLockOption) if (installedCameraAppCount >= 1) { - val resolveInfo = ResolveInfo().apply { - this.activityInfo = ActivityInfo().apply { - packageName = CAMERA_APP_PACKAGE_NAME + val resolveInfo = + ResolveInfo().apply { + this.activityInfo = + ActivityInfo().apply { packageName = CAMERA_APP_PACKAGE_NAME } } - } - whenever(packageManager.resolveActivityAsUser(any(), anyInt(), anyInt())).thenReturn( - resolveInfo - ) + whenever(packageManager.resolveActivityAsUser(any(), anyInt(), anyInt())) + .thenReturn(resolveInfo) } else { - whenever(packageManager.resolveActivityAsUser(any(), anyInt(), anyInt())).thenReturn( - null - ) + whenever(packageManager.resolveActivityAsUser(any(), anyInt(), anyInt())) + .thenReturn(null) } when { isCameraActivityRunningOnTop -> { - val runningTaskInfo = ActivityManager.RunningTaskInfo().apply { - topActivity = ComponentName(CAMERA_APP_PACKAGE_NAME, "cameraActivity") - } - whenever(activityManager.getRunningTasks(anyInt())).thenReturn( - listOf( - runningTaskInfo - ) - ) + val runningTaskInfo = + ActivityManager.RunningTaskInfo().apply { + topActivity = ComponentName(CAMERA_APP_PACKAGE_NAME, "cameraActivity") + } + whenever(activityManager.getRunningTasks(anyInt())) + .thenReturn(listOf(runningTaskInfo)) } isTaskListEmpty -> { whenever(activityManager.getRunningTasks(anyInt())).thenReturn(emptyList()) @@ -289,28 +283,28 @@ class CameraGestureHelperTest : SysuiTestCase() { ) { val intentCaptor = KotlinArgumentCaptor(Intent::class.java) if (isSecure && !moreThanOneCameraAppInstalled) { - verify(activityTaskManager).startActivityAsUser( - any(), - any(), - any(), - intentCaptor.capture(), - any(), - any(), - any(), - anyInt(), - anyInt(), - any(), - any(), - anyInt() - ) + verify(activityTaskManager) + .startActivityAsUser( + isNull(), + isNull(), + isNull(), + intentCaptor.capture(), + isNull(), + isNull(), + isNull(), + anyInt(), + anyInt(), + isNull(), + any(), + anyInt() + ) } else { verify(activityStarter).startActivity(intentCaptor.capture(), eq(false)) } val intent = intentCaptor.value assertThat(CameraIntents.isSecureCameraIntent(intent)).isEqualTo(isSecure) - assertThat(intent.getIntExtra(CameraIntents.EXTRA_LAUNCH_SOURCE, -1)) - .isEqualTo(source) + assertThat(intent.getIntExtra(CameraIntents.EXTRA_LAUNCH_SOURCE, -1)).isEqualTo(source) } companion object { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepositoryTest.kt index 2bf50b3daa2f..91259a65eff9 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepositoryTest.kt @@ -58,7 +58,6 @@ import com.android.systemui.dump.DumpManager import com.android.systemui.flags.FakeFeatureFlags import com.android.systemui.keyguard.data.repository.BiometricType import com.android.systemui.keyguard.data.repository.fakeBiometricSettingsRepository -import com.android.systemui.keyguard.data.repository.fakeCommandQueue import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFingerprintAuthRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository @@ -78,7 +77,6 @@ import com.android.systemui.log.table.TableLogBuffer import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest import com.android.systemui.power.domain.interactor.powerInteractor -import com.android.systemui.statusbar.commandQueue import com.android.systemui.statusbar.phone.KeyguardBypassController import com.android.systemui.testKosmos import com.android.systemui.user.data.model.SelectionStatus @@ -116,7 +114,7 @@ import org.mockito.MockitoAnnotations @SmallTest @RunWith(AndroidJUnit4::class) class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { - private val kosmos = testKosmos().apply { this.commandQueue = this.fakeCommandQueue } + private val kosmos = testKosmos() private lateinit var underTest: DeviceEntryFaceAuthRepositoryImpl @Mock private lateinit var faceManager: FaceManager @@ -162,7 +160,6 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { private val displayStateInteractor = kosmos.displayStateInteractor private val bouncerRepository = kosmos.fakeKeyguardBouncerRepository private val displayRepository = kosmos.displayRepository - private val fakeCommandQueue = kosmos.fakeCommandQueue private val keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor private lateinit var featureFlags: FakeFeatureFlags @@ -572,9 +569,7 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { bouncerRepository.setAlternateVisible(false) // Keyguard is occluded when secure camera is active. keyguardRepository.setKeyguardOccluded(true) - fakeCommandQueue.doForEachCallback { - it.onCameraLaunchGestureDetected(CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) - } + keyguardInteractor.onCameraLaunchDetected(CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) } } @@ -589,9 +584,7 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { assertThat(canFaceAuthRun()).isTrue() // launch secure camera - fakeCommandQueue.doForEachCallback { - it.onCameraLaunchGestureDetected(CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) - } + keyguardInteractor.onCameraLaunchDetected(CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) keyguardRepository.setKeyguardOccluded(true) runCurrent() assertThat(canFaceAuthRun()).isFalse() @@ -870,9 +863,7 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { bouncerRepository.setAlternateVisible(false) // Keyguard is occluded when secure camera is active. keyguardRepository.setKeyguardOccluded(true) - fakeCommandQueue.doForEachCallback { - it.onCameraLaunchGestureDetected(CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) - } + keyguardInteractor.onCameraLaunchDetected(CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt index 7906a8244c5d..fc827a1478c7 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorTest.kt @@ -32,7 +32,7 @@ import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.keyguard.data.repository.fakeCommandQueue import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository -import com.android.systemui.keyguard.shared.model.CameraLaunchSourceModel +import com.android.systemui.keyguard.shared.model.CameraLaunchType import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.StatusBarState import com.android.systemui.keyguard.shared.model.TransitionState @@ -47,7 +47,6 @@ import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flowOf -import kotlinx.coroutines.flow.onCompletion import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.Before @@ -87,31 +86,17 @@ class KeyguardInteractorTest : SysuiTestCase() { val cameraLaunchSource = collectLastValue(flow) runCurrent() - commandQueue.doForEachCallback { - it.onCameraLaunchGestureDetected(StatusBarManager.CAMERA_LAUNCH_SOURCE_WIGGLE) - } - assertThat(cameraLaunchSource()).isEqualTo(CameraLaunchSourceModel.WIGGLE) + underTest.onCameraLaunchDetected(StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) + assertThat(cameraLaunchSource()!!.type).isEqualTo(CameraLaunchType.POWER_DOUBLE_TAP) - commandQueue.doForEachCallback { - it.onCameraLaunchGestureDetected( - StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP - ) - } - assertThat(cameraLaunchSource()).isEqualTo(CameraLaunchSourceModel.POWER_DOUBLE_TAP) - - commandQueue.doForEachCallback { - it.onCameraLaunchGestureDetected(StatusBarManager.CAMERA_LAUNCH_SOURCE_LIFT_TRIGGER) - } - assertThat(cameraLaunchSource()).isEqualTo(CameraLaunchSourceModel.LIFT_TRIGGER) + underTest.onCameraLaunchDetected(StatusBarManager.CAMERA_LAUNCH_SOURCE_WIGGLE) + assertThat(cameraLaunchSource()!!.type).isEqualTo(CameraLaunchType.WIGGLE) - commandQueue.doForEachCallback { - it.onCameraLaunchGestureDetected( - StatusBarManager.CAMERA_LAUNCH_SOURCE_QUICK_AFFORDANCE - ) - } - assertThat(cameraLaunchSource()).isEqualTo(CameraLaunchSourceModel.QUICK_AFFORDANCE) + underTest.onCameraLaunchDetected(StatusBarManager.CAMERA_LAUNCH_SOURCE_LIFT_TRIGGER) + assertThat(cameraLaunchSource()!!.type).isEqualTo(CameraLaunchType.LIFT_TRIGGER) - flow.onCompletion { assertThat(commandQueue.callbackCount()).isEqualTo(0) } + underTest.onCameraLaunchDetected(StatusBarManager.CAMERA_LAUNCH_SOURCE_QUICK_AFFORDANCE) + assertThat(cameraLaunchSource()!!.type).isEqualTo(CameraLaunchType.QUICK_AFFORDANCE) } @Test @@ -121,11 +106,7 @@ class KeyguardInteractorTest : SysuiTestCase() { val secureCameraActive = collectLastValue(underTest.isSecureCameraActive) runCurrent() - commandQueue.doForEachCallback { - it.onCameraLaunchGestureDetected( - StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP - ) - } + underTest.onCameraLaunchDetected(StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) assertThat(secureCameraActive()).isTrue() @@ -146,11 +127,7 @@ class KeyguardInteractorTest : SysuiTestCase() { val secureCameraActive = collectLastValue(underTest.isSecureCameraActive) runCurrent() - commandQueue.doForEachCallback { - it.onCameraLaunchGestureDetected( - StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP - ) - } + underTest.onCameraLaunchDetected(StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) assertThat(secureCameraActive()).isTrue() // Keyguard is showing and not occluded diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt index d9708a4f5506..9762fd8e2158 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardTransitionScenariosTest.kt @@ -16,7 +16,7 @@ package com.android.systemui.keyguard.domain.interactor -import android.app.StatusBarManager +import android.app.StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.FlagsParameterization @@ -42,7 +42,6 @@ import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED import com.android.systemui.flags.andSceneContainer import com.android.systemui.flags.fakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository -import com.android.systemui.keyguard.data.repository.fakeCommandQueue import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.BiometricUnlockMode @@ -59,7 +58,6 @@ import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.se import com.android.systemui.power.domain.interactor.powerInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.shade.shadeTestUtil -import com.android.systemui.statusbar.commandQueue import com.android.systemui.testKosmos import com.android.systemui.util.mockito.whenever import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -93,13 +91,12 @@ class KeyguardTransitionScenariosTest(flags: FlagsParameterization?) : SysuiTest private val kosmos = testKosmos().apply { fakeKeyguardTransitionRepository = spy(FakeKeyguardTransitionRepository()) - this.commandQueue = fakeCommandQueue } private val testScope = kosmos.testScope private val keyguardRepository by lazy { kosmos.fakeKeyguardRepository } + private val keyguardInteractor by lazy { kosmos.keyguardInteractor } private val bouncerRepository by lazy { kosmos.fakeKeyguardBouncerRepository } - private var commandQueue = kosmos.fakeCommandQueue private val shadeTestUtil by lazy { kosmos.shadeTestUtil } private val transitionRepository by lazy { kosmos.fakeKeyguardTransitionRepository } private lateinit var featureFlags: FakeFeatureFlags @@ -1724,11 +1721,7 @@ class KeyguardTransitionScenariosTest(flags: FlagsParameterization?) : SysuiTest reset(transitionRepository) // ...AND WHEN the camera gesture is detected quickly afterwards - commandQueue.doForEachCallback { - it.onCameraLaunchGestureDetected( - StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP - ) - } + keyguardInteractor.onCameraLaunchDetected(CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP) runCurrent() // THEN a transition from DOZING => OCCLUDED should occur diff --git a/packages/SystemUI/tests/src/com/android/systemui/power/domain/interactor/PowerInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/power/domain/interactor/PowerInteractorTest.kt index 12c9eb900ee1..53dec696004d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/power/domain/interactor/PowerInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/power/domain/interactor/PowerInteractorTest.kt @@ -21,22 +21,23 @@ import android.os.PowerManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase +import com.android.systemui.camera.cameraGestureHelper import com.android.systemui.classifier.FalsingCollector +import com.android.systemui.coroutines.collectLastValue import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository -import com.android.systemui.power.shared.model.WakeSleepReason -import com.android.systemui.power.shared.model.WakefulnessState +import com.android.systemui.kosmos.testScope import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.power.data.repository.FakePowerRepository +import com.android.systemui.power.shared.model.WakeSleepReason +import com.android.systemui.power.shared.model.WakefulnessState import com.android.systemui.statusbar.phone.ScreenOffAnimationController +import com.android.systemui.testKosmos +import com.android.systemui.util.mockito.any import com.android.systemui.util.mockito.whenever import com.google.common.truth.Truth.assertThat import junit.framework.Assert.assertFalse import junit.framework.Assert.assertTrue -import kotlin.test.assertEquals -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach -import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -47,6 +48,9 @@ import org.mockito.MockitoAnnotations @SmallTest @RunWith(AndroidJUnit4::class) class PowerInteractorTest : SysuiTestCase() { + private val kosmos = testKosmos() + private val testScope = kosmos.testScope + private val cameraGestureHelper = kosmos.cameraGestureHelper private lateinit var underTest: PowerInteractor private lateinit var repository: FakePowerRepository @@ -66,33 +70,30 @@ class PowerInteractorTest : SysuiTestCase() { falsingCollector, screenOffAnimationController, statusBarStateController, + { cameraGestureHelper }, ) + + whenever(cameraGestureHelper.canCameraGestureBeLaunched(any())).thenReturn(true) } @Test fun isInteractive_screenTurnsOff() = - runBlocking(IMMEDIATE) { + testScope.runTest { repository.setInteractive(true) - var value: Boolean? = null - val job = underTest.isInteractive.onEach { value = it }.launchIn(this) + val isInteractive by collectLastValue(underTest.isInteractive) repository.setInteractive(false) - - assertThat(value).isFalse() - job.cancel() + assertThat(isInteractive).isFalse() } @Test fun isInteractive_becomesInteractive() = - runBlocking(IMMEDIATE) { + testScope.runTest { repository.setInteractive(false) - var value: Boolean? = null - val job = underTest.isInteractive.onEach { value = it }.launchIn(this) + val isInteractive by collectLastValue(underTest.isInteractive) repository.setInteractive(true) - - assertThat(value).isTrue() - job.cancel() + assertThat(isInteractive).isTrue() } @Test @@ -203,6 +204,23 @@ class PowerInteractorTest : SysuiTestCase() { } @Test + fun onCameraLaunchGestureDetected_isNotTrueWhenCannotLaunch() { + whenever(cameraGestureHelper.canCameraGestureBeLaunched(any())).thenReturn(false) + underTest.onStartedWakingUp( + PowerManager.WAKE_REASON_POWER_BUTTON, + /*powerButtonLaunchGestureTriggeredDuringSleep= */ false + ) + underTest.onFinishedWakingUp() + underTest.onCameraLaunchGestureDetected() + + assertThat(repository.wakefulness.value.internalWakefulnessState) + .isEqualTo(WakefulnessState.AWAKE) + assertThat(repository.wakefulness.value.lastWakeReason) + .isEqualTo(WakeSleepReason.POWER_BUTTON) + assertFalse(repository.wakefulness.value.powerButtonLaunchGestureTriggered) + } + + @Test fun onCameraLaunchGestureDetected_maintainsAllOtherState() { underTest.onStartedWakingUp( PowerManager.WAKE_REASON_POWER_BUTTON, @@ -211,8 +229,10 @@ class PowerInteractorTest : SysuiTestCase() { underTest.onFinishedWakingUp() underTest.onCameraLaunchGestureDetected() - assertEquals(WakefulnessState.AWAKE, repository.wakefulness.value.internalWakefulnessState) - assertEquals(WakeSleepReason.POWER_BUTTON, repository.wakefulness.value.lastWakeReason) + assertThat(repository.wakefulness.value.internalWakefulnessState) + .isEqualTo(WakefulnessState.AWAKE) + assertThat(repository.wakefulness.value.lastWakeReason) + .isEqualTo(WakeSleepReason.POWER_BUTTON) assertTrue(repository.wakefulness.value.powerButtonLaunchGestureTriggered) } @@ -221,21 +241,23 @@ class PowerInteractorTest : SysuiTestCase() { underTest.onCameraLaunchGestureDetected() // Ensure that the 'false' here does not clear the direct launch detection call earlier. // This state should only be reset onStartedGoingToSleep. - underTest.onFinishedGoingToSleep(/*powerButtonLaunchGestureTriggeredDuringSleep= */ false) + underTest.onFinishedGoingToSleep(/* powerButtonLaunchGestureTriggeredDuringSleep= */ false) underTest.onStartedWakingUp( PowerManager.WAKE_REASON_POWER_BUTTON, /*powerButtonLaunchGestureTriggeredDuringSleep= */ false ) underTest.onFinishedWakingUp() - assertEquals(WakefulnessState.AWAKE, repository.wakefulness.value.internalWakefulnessState) - assertEquals(WakeSleepReason.POWER_BUTTON, repository.wakefulness.value.lastWakeReason) + assertThat(repository.wakefulness.value.internalWakefulnessState) + .isEqualTo(WakefulnessState.AWAKE) + assertThat(repository.wakefulness.value.lastWakeReason) + .isEqualTo(WakeSleepReason.POWER_BUTTON) assertTrue(repository.wakefulness.value.powerButtonLaunchGestureTriggered) } @Test fun cameraLaunchDetectedOnGoingToSleep_stillTrue_ifGestureNotDetectedOnWakingUp() { - underTest.onFinishedGoingToSleep(/*powerButtonLaunchGestureTriggeredDuringSleep= */ true) + underTest.onFinishedGoingToSleep(/* powerButtonLaunchGestureTriggeredDuringSleep= */ true) // Ensure that the 'false' here does not clear the direct launch detection call earlier. // This state should only be reset onStartedGoingToSleep. underTest.onStartedWakingUp( @@ -244,12 +266,10 @@ class PowerInteractorTest : SysuiTestCase() { ) underTest.onFinishedWakingUp() - assertEquals(WakefulnessState.AWAKE, repository.wakefulness.value.internalWakefulnessState) - assertEquals(WakeSleepReason.POWER_BUTTON, repository.wakefulness.value.lastWakeReason) + assertThat(repository.wakefulness.value.internalWakefulnessState) + .isEqualTo(WakefulnessState.AWAKE) + assertThat(repository.wakefulness.value.lastWakeReason) + .isEqualTo(WakeSleepReason.POWER_BUTTON) assertTrue(repository.wakefulness.value.powerButtonLaunchGestureTriggered) } - - companion object { - private val IMMEDIATE = Dispatchers.Main.immediate - } } diff --git a/packages/SystemUI/src/com/android/systemui/camera/CameraGestureHelper.kt b/packages/SystemUI/src/com/android/systemui/camera/CameraGestureHelper.kt index ecbd3f97f4e5..6757edba8ac3 100644 --- a/packages/SystemUI/src/com/android/systemui/camera/CameraGestureHelper.kt +++ b/packages/SystemUI/src/com/android/systemui/camera/CameraGestureHelper.kt @@ -19,6 +19,7 @@ package com.android.systemui.camera import android.app.ActivityManager import android.app.ActivityOptions import android.app.IActivityTaskManager +import android.app.admin.DevicePolicyManager import android.content.ContentResolver import android.content.Context import android.content.Intent @@ -32,8 +33,8 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.plugins.ActivityStarter import com.android.systemui.shared.system.ActivityManagerKt.isInForeground +import com.android.systemui.statusbar.NotificationLockscreenUserManager import com.android.systemui.statusbar.StatusBarState -import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.user.domain.interactor.SelectedUserInteractor @@ -45,9 +46,10 @@ import javax.inject.Inject * the camera). */ @SysUISingleton -class CameraGestureHelper @Inject constructor( +class CameraGestureHelper +@Inject +constructor( private val context: Context, - private val centralSurfaces: CentralSurfaces, private val keyguardStateController: KeyguardStateController, private val statusBarKeyguardViewManager: StatusBarKeyguardViewManager, private val packageManager: PackageManager, @@ -59,24 +61,25 @@ class CameraGestureHelper @Inject constructor( private val contentResolver: ContentResolver, @Main private val uiExecutor: Executor, private val selectedUserInteractor: SelectedUserInteractor, + private val devicePolicyManager: DevicePolicyManager, + private val lockscreenUserManager: NotificationLockscreenUserManager, ) { - /** - * Whether the camera application can be launched for the camera launch gesture. - */ + /** Whether the camera application can be launched for the camera launch gesture. */ fun canCameraGestureBeLaunched(statusBarState: Int): Boolean { - if (!centralSurfaces.isCameraAllowedByAdmin) { + if (!isCameraAllowedByAdmin()) { return false } - val resolveInfo: ResolveInfo? = packageManager.resolveActivityAsUser( - getStartCameraIntent(selectedUserInteractor.getSelectedUserId()), - PackageManager.MATCH_DEFAULT_ONLY, - selectedUserInteractor.getSelectedUserId() - ) + val resolveInfo: ResolveInfo? = + packageManager.resolveActivityAsUser( + getStartCameraIntent(selectedUserInteractor.getSelectedUserId()), + PackageManager.MATCH_DEFAULT_ONLY, + selectedUserInteractor.getSelectedUserId() + ) val resolvedPackage = resolveInfo?.activityInfo?.packageName return (resolvedPackage != null && - (statusBarState != StatusBarState.SHADE || - !activityManager.isInForeground(resolvedPackage))) + (statusBarState != StatusBarState.SHADE || + !activityManager.isInForeground(resolvedPackage))) } /** @@ -87,9 +90,11 @@ class CameraGestureHelper @Inject constructor( fun launchCamera(source: Int) { val intent: Intent = getStartCameraIntent(selectedUserInteractor.getSelectedUserId()) intent.putExtra(CameraIntents.EXTRA_LAUNCH_SOURCE, source) - val wouldLaunchResolverActivity = activityIntentHelper.wouldLaunchResolverActivity( - intent, selectedUserInteractor.getSelectedUserId() - ) + val wouldLaunchResolverActivity = + activityIntentHelper.wouldLaunchResolverActivity( + intent, + selectedUserInteractor.getSelectedUserId() + ) if (CameraIntents.isSecureCameraIntent(intent) && !wouldLaunchResolverActivity) { uiExecutor.execute { // Normally an activity will set its requested rotation animation on its window. @@ -101,7 +106,7 @@ class CameraGestureHelper @Inject constructor( val activityOptions = ActivityOptions.makeBasic() activityOptions.setDisallowEnterPictureInPictureWhileLaunching(true) activityOptions.rotationAnimationHint = - WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS + WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS try { activityTaskManager.startActivityAsUser( null, @@ -118,11 +123,7 @@ class CameraGestureHelper @Inject constructor( selectedUserInteractor.getSelectedUserId(true), ) } catch (e: RemoteException) { - Log.w( - "CameraGestureHelper", - "Unable to start camera activity", - e - ) + Log.w("CameraGestureHelper", "Unable to start camera activity", e) } } } else { @@ -131,9 +132,6 @@ class CameraGestureHelper @Inject constructor( activityStarter.startActivity(intent, false /* dismissShade */) } - // Call this to make sure that the keyguard returns if the app that is being launched - // crashes after a timeout. - centralSurfaces.startLaunchTransitionTimeout() // Call this to make sure the keyguard is ready to be dismissed once the next intent is // handled by the OS (in our case it is the activity we started right above) statusBarKeyguardViewManager.readyForKeyguardDone() @@ -152,4 +150,17 @@ class CameraGestureHelper @Inject constructor( cameraIntents.getInsecureCameraIntent(userId) } } + + private fun isCameraAllowedByAdmin(): Boolean { + if (devicePolicyManager.getCameraDisabled(null, lockscreenUserManager.getCurrentUserId())) { + return false + } else if (keyguardStateController.isShowing() && statusBarKeyguardViewManager.isSecure()) { + // Check if the admin has disabled the camera specifically for the keyguard + return (devicePolicyManager.getKeyguardDisabledFeatures( + null, + lockscreenUserManager.getCurrentUserId() + ) and DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) == 0 + } + return true + } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt index ae751dbacd68..edf17c1e9e80 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt @@ -34,6 +34,7 @@ import com.android.systemui.dreams.DreamOverlayCallbackController import com.android.systemui.keyguard.shared.model.BiometricUnlockMode import com.android.systemui.keyguard.shared.model.BiometricUnlockModel import com.android.systemui.keyguard.shared.model.BiometricUnlockSource +import com.android.systemui.keyguard.shared.model.CameraLaunchSourceModel import com.android.systemui.keyguard.shared.model.DismissAction import com.android.systemui.keyguard.shared.model.DozeStateModel import com.android.systemui.keyguard.shared.model.DozeTransitionModel @@ -237,6 +238,9 @@ interface KeyguardRepository { /** Observable updated when keyguardDone should be called either now or soon. */ val keyguardDone: Flow<KeyguardDone> + /** Last camera launch detection event */ + val onCameraLaunchDetected: MutableStateFlow<CameraLaunchSourceModel> + /** * Emits after the keyguard is done animating away. * @@ -380,6 +384,8 @@ constructor( private val _keyguardAlpha = MutableStateFlow(1f) override val keyguardAlpha = _keyguardAlpha.asStateFlow() + override val onCameraLaunchDetected = MutableStateFlow(CameraLaunchSourceModel()) + override val panelAlpha: MutableStateFlow<Float> = MutableStateFlow(1f) private val _clockShouldBeCentered = MutableStateFlow(true) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt index 046e79cd04c4..f109fd6e97f6 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt @@ -23,10 +23,7 @@ import android.app.StatusBarManager import android.graphics.Point import android.util.MathUtils import com.android.app.animation.Interpolators -import com.android.app.tracing.FlowTracing.tracedAwaitClose -import com.android.app.tracing.FlowTracing.tracedConflatedCallbackFlow import com.android.systemui.bouncer.data.repository.KeyguardBouncerRepository -import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging import com.android.systemui.common.shared.model.NotificationContainerBounds import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor import com.android.systemui.dagger.SysUISingleton @@ -35,6 +32,7 @@ import com.android.systemui.keyguard.MigrateClocksToBlueprint import com.android.systemui.keyguard.data.repository.KeyguardRepository import com.android.systemui.keyguard.shared.model.BiometricUnlockModel import com.android.systemui.keyguard.shared.model.CameraLaunchSourceModel +import com.android.systemui.keyguard.shared.model.CameraLaunchType import com.android.systemui.keyguard.shared.model.DozeStateModel import com.android.systemui.keyguard.shared.model.DozeStateModel.Companion.isDozeOff import com.android.systemui.keyguard.shared.model.DozeTransitionModel @@ -48,7 +46,6 @@ import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.shade.data.repository.ShadeRepository -import com.android.systemui.statusbar.CommandQueue import com.android.systemui.statusbar.notification.NotificationUtils.interpolate import com.android.systemui.statusbar.notification.stack.domain.interactor.SharedNotificationContainerInteractor import com.android.systemui.util.kotlin.Utils.Companion.sample as sampleCombine @@ -87,7 +84,6 @@ class KeyguardInteractor @Inject constructor( private val repository: KeyguardRepository, - private val commandQueue: CommandQueue, powerInteractor: PowerInteractor, bouncerRepository: KeyguardBouncerRepository, configurationInteractor: ConfigurationInteractor, @@ -198,22 +194,7 @@ constructor( /** Event for when the camera gesture is detected */ val onCameraLaunchDetected: Flow<CameraLaunchSourceModel> = - tracedConflatedCallbackFlow("KeyguardInteractor#onCameraLaunchDetected") { - val callback = - object : CommandQueue.Callbacks { - override fun onCameraLaunchGestureDetected(source: Int) { - trySendWithFailureLogging( - cameraLaunchSourceIntToModel(source), - TAG, - "updated onCameraLaunchGestureDetected" - ) - } - } - - commandQueue.addCallback(callback) - - tracedAwaitClose("onCameraLaunchDetected") { commandQueue.removeCallback(callback) } - } + repository.onCameraLaunchDetected.filter { it.type != CameraLaunchType.IGNORE } /** * Dozing and dreaming have overlapping events. If the doze state remains in FINISH, it means @@ -310,7 +291,7 @@ constructor( when { isKeyguardVisible -> false isPrimaryBouncerShowing -> false - else -> cameraLaunchEvent == CameraLaunchSourceModel.POWER_DOUBLE_TAP + else -> cameraLaunchEvent.type == CameraLaunchType.POWER_DOUBLE_TAP } } .onStart { emit(false) } @@ -440,16 +421,15 @@ constructor( return repository.isKeyguardShowing() } - private fun cameraLaunchSourceIntToModel(value: Int): CameraLaunchSourceModel { + private fun cameraLaunchSourceIntToType(value: Int): CameraLaunchType { return when (value) { - StatusBarManager.CAMERA_LAUNCH_SOURCE_WIGGLE -> CameraLaunchSourceModel.WIGGLE + StatusBarManager.CAMERA_LAUNCH_SOURCE_WIGGLE -> CameraLaunchType.WIGGLE StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP -> - CameraLaunchSourceModel.POWER_DOUBLE_TAP - StatusBarManager.CAMERA_LAUNCH_SOURCE_LIFT_TRIGGER -> - CameraLaunchSourceModel.LIFT_TRIGGER + CameraLaunchType.POWER_DOUBLE_TAP + StatusBarManager.CAMERA_LAUNCH_SOURCE_LIFT_TRIGGER -> CameraLaunchType.LIFT_TRIGGER StatusBarManager.CAMERA_LAUNCH_SOURCE_QUICK_AFFORDANCE -> - CameraLaunchSourceModel.QUICK_AFFORDANCE - else -> throw IllegalArgumentException("Invalid CameraLaunchSourceModel value: $value") + CameraLaunchType.QUICK_AFFORDANCE + else -> throw IllegalArgumentException("Invalid CameraLaunchType value: $value") } } @@ -508,6 +488,11 @@ constructor( fromLockscreenTransitionInteractor.get().dismissKeyguard() } + fun onCameraLaunchDetected(source: Int) { + repository.onCameraLaunchDetected.value = + CameraLaunchSourceModel(type = cameraLaunchSourceIntToType(source)) + } + companion object { private const val TAG = "KeyguardInteractor" } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/CameraLaunchSourceModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/CameraLaunchSourceModel.kt index 19baf7705546..c01765146ed0 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/CameraLaunchSourceModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/CameraLaunchSourceModel.kt @@ -15,14 +15,8 @@ */ package com.android.systemui.keyguard.shared.model -/** Camera launch sources */ -enum class CameraLaunchSourceModel { - /** Device is wiggled */ - WIGGLE, - /** Power button has been double tapped */ - POWER_DOUBLE_TAP, - /** Device has been lifted */ - LIFT_TRIGGER, - /** Quick affordance button has been pressed */ - QUICK_AFFORDANCE, -} +/** Camera launch source, with type and time detected */ +data class CameraLaunchSourceModel( + val type: CameraLaunchType = CameraLaunchType.IGNORE, + val detectedTime: Long = System.currentTimeMillis(), +) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/CameraLaunchType.kt b/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/CameraLaunchType.kt new file mode 100644 index 000000000000..984abbbdb955 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/CameraLaunchType.kt @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2024 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.systemui.keyguard.shared.model + +/** Camera launch sources */ +enum class CameraLaunchType { + /** Models no value */ + IGNORE, + /** Device is wiggled */ + WIGGLE, + /** Power button has been double tapped */ + POWER_DOUBLE_TAP, + /** Device has been lifted */ + LIFT_TRIGGER, + /** Quick affordance button has been pressed */ + QUICK_AFFORDANCE, +} diff --git a/packages/SystemUI/src/com/android/systemui/power/domain/interactor/PowerInteractor.kt b/packages/SystemUI/src/com/android/systemui/power/domain/interactor/PowerInteractor.kt index 9380d44dc27f..8d48c1d1d23f 100644 --- a/packages/SystemUI/src/com/android/systemui/power/domain/interactor/PowerInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/power/domain/interactor/PowerInteractor.kt @@ -18,6 +18,7 @@ package com.android.systemui.power.domain.interactor import android.os.PowerManager +import com.android.systemui.camera.CameraGestureHelper import com.android.systemui.classifier.FalsingCollector import com.android.systemui.classifier.FalsingCollectorActual import com.android.systemui.dagger.SysUISingleton @@ -28,6 +29,7 @@ import com.android.systemui.power.shared.model.WakeSleepReason import com.android.systemui.power.shared.model.WakefulnessState import com.android.systemui.statusbar.phone.ScreenOffAnimationController import javax.inject.Inject +import javax.inject.Provider import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.map @@ -41,6 +43,7 @@ constructor( @FalsingCollectorActual private val falsingCollector: FalsingCollector, private val screenOffAnimationController: ScreenOffAnimationController, private val statusBarStateController: StatusBarStateController, + private val cameraGestureHelper: Provider<CameraGestureHelper>, ) { /** Whether the screen is on or off. */ val isInteractive: Flow<Boolean> = repository.isInteractive @@ -206,7 +209,13 @@ constructor( } fun onCameraLaunchGestureDetected() { - repository.updateWakefulness(powerButtonLaunchGestureTriggered = true) + if ( + cameraGestureHelper + .get() + .canCameraGestureBeLaunched(statusBarStateController.getState()) + ) { + repository.updateWakefulness(powerButtonLaunchGestureTriggered = true) + } } companion object { diff --git a/packages/SystemUI/src/com/android/systemui/power/shared/model/WakefulnessModel.kt b/packages/SystemUI/src/com/android/systemui/power/shared/model/WakefulnessModel.kt index 5432793d8117..0f49c94c3195 100644 --- a/packages/SystemUI/src/com/android/systemui/power/shared/model/WakefulnessModel.kt +++ b/packages/SystemUI/src/com/android/systemui/power/shared/model/WakefulnessModel.kt @@ -19,7 +19,7 @@ data class WakefulnessModel( * all use cases. If you need more granular information about a waking/sleeping transition, use * the [KeyguardTransitionInteractor]. */ - internal val internalWakefulnessState: WakefulnessState = WakefulnessState.AWAKE, + val internalWakefulnessState: WakefulnessState = WakefulnessState.AWAKE, val lastWakeReason: WakeSleepReason = WakeSleepReason.OTHER, val lastSleepReason: WakeSleepReason = WakeSleepReason.OTHER, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java index a0d4ca268e8c..ae311512db01 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java @@ -261,8 +261,6 @@ public interface CentralSurfaces extends Dumpable, LifecycleOwner, CoreStartable boolean isScreenFullyOff(); - boolean isCameraAllowedByAdmin(); - boolean isGoingToSleep(); void notifyBiometricAuthModeChanged(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java index c8a445033b0d..5209d0f1551e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java @@ -49,6 +49,7 @@ import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.emergency.EmergencyGesture; import com.android.systemui.emergency.EmergencyGestureModule.EmergencyGestureIntentFactory; import com.android.systemui.keyguard.WakefulnessLifecycle; +import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.qs.QSHost; import com.android.systemui.qs.QSPanelController; @@ -109,6 +110,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba private final Lazy<CameraLauncher> mCameraLauncherLazy; private final QuickSettingsController mQsController; private final QSHost mQSHost; + private final KeyguardInteractor mKeyguardInteractor; private static final VibrationAttributes HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES = VibrationAttributes.createForUsage(VibrationAttributes.USAGE_HARDWARE_FEEDBACK); @@ -148,6 +150,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba UserTracker userTracker, QSHost qsHost, ActivityStarter activityStarter, + KeyguardInteractor keyguardInteractor, EmergencyGestureIntentFactory emergencyGestureIntentFactory) { mCentralSurfaces = centralSurfaces; mQsController = quickSettingsController; @@ -176,7 +179,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba mCameraLauncherLazy = cameraLauncherLazy; mUserTracker = userTracker; mQSHost = qsHost; - + mKeyguardInteractor = keyguardInteractor; mVibrateOnOpening = resources.getBoolean(R.bool.config_vibrateOnIconAnimation); mCameraLaunchGestureVibrationEffect = getCameraGestureVibrationEffect( mVibratorOptional, resources); @@ -351,6 +354,8 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba } return; } + mKeyguardInteractor.onCameraLaunchDetected(source); + if (!mCentralSurfaces.isDeviceInteractive()) { mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_CAMERA_LAUNCH, "com.android.systemui:CAMERA_GESTURE"); @@ -383,6 +388,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba if (mStatusBarKeyguardViewManager.isBouncerShowing()) { mStatusBarKeyguardViewManager.reset(true /* hide */); } + mCentralSurfaces.startLaunchTransitionTimeout(); mCameraLauncherLazy.get().launchCamera(source, mPanelExpansionInteractor.isFullyCollapsed()); mCentralSurfaces.updateScrimController(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesEmptyImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesEmptyImpl.kt index 88d3e0718fa6..d4f2a93c025b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesEmptyImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesEmptyImpl.kt @@ -34,72 +34,127 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow */ abstract class CentralSurfacesEmptyImpl : CentralSurfaces { override val lifecycle = LifecycleRegistry(this) + override fun updateIsKeyguard() = false + override fun updateIsKeyguard(forceStateChange: Boolean) = false + override fun getKeyguardMessageArea(): AuthKeyguardMessageArea? = null + override fun isLaunchingActivityOverLockscreen() = false + override fun isDismissingShadeForActivityLaunch() = false + override fun onKeyguardViewManagerStatesUpdated() {} + override fun getCommandQueuePanelsEnabled() = false + override fun showWirelessChargingAnimation(batteryLevel: Int) {} + override fun checkBarModes() {} + override fun updateBubblesVisibility() {} + override fun setInteracting(barWindow: Int, interacting: Boolean) {} + override fun getDisplayWidth() = 0f + override fun getDisplayHeight() = 0f + override fun showKeyguard() {} + override fun hideKeyguard() = false + override fun showKeyguardImpl() {} + override fun fadeKeyguardAfterLaunchTransition( beforeFading: Runnable?, endRunnable: Runnable?, cancelRunnable: Runnable?, ) {} + override fun startLaunchTransitionTimeout() {} + override fun hideKeyguardImpl(forceStateChange: Boolean) = false + override fun keyguardGoingAway() {} + override fun setKeyguardFadingAway(startTime: Long, delay: Long, fadeoutDuration: Long) {} + override fun finishKeyguardFadingAway() {} + override fun userActivity() {} + override fun endAffordanceLaunch() {} + override fun shouldKeyguardHideImmediately() = false + override fun showBouncerWithDimissAndCancelIfKeyguard( performAction: OnDismissAction?, cancelAction: Runnable?, ) {} + override fun getNavigationBarView(): NavigationBarView? = null + override fun setBouncerShowing(bouncerShowing: Boolean) {} + override fun isScreenFullyOff() = false - override fun isCameraAllowedByAdmin() = false + override fun isGoingToSleep() = false + override fun notifyBiometricAuthModeChanged() {} + override fun setTransitionToFullShadeProgress(transitionToFullShadeProgress: Float) {} + override fun setPrimaryBouncerHiddenFraction(expansion: Float) {} + override fun updateScrimController() {} + override fun shouldIgnoreTouch() = false + override fun isDeviceInteractive() = false + override fun handleExternalShadeWindowTouch(event: MotionEvent?) {} + override fun handleCommunalHubTouch(event: MotionEvent?) {} + override fun awakenDreams() {} + override fun isBouncerShowing() = false + override fun isBouncerShowingScrimmed() = false + override fun updateNotificationPanelTouchState() {} + override fun getRotation() = 0 + override fun setBarStateForTest(state: Int) {} + override fun acquireGestureWakeLock(time: Long) {} + override fun resendMessage(msg: Int) {} + override fun resendMessage(msg: Any?) {} + override fun setLastCameraLaunchSource(source: Int) {} + override fun setLaunchCameraOnFinishedGoingToSleep(launch: Boolean) {} + override fun setLaunchCameraOnFinishedWaking(launch: Boolean) {} + override fun setLaunchEmergencyActionOnFinishedGoingToSleep(launch: Boolean) {} + override fun setLaunchEmergencyActionOnFinishedWaking(launch: Boolean) {} + override fun getQSPanelController(): QSPanelController? = null + override fun getDisplayDensity() = 0f + override fun setIsLaunchingActivityOverLockscreen( isLaunchingActivityOverLockscreen: Boolean, dismissShade: Boolean, ) {} + override fun getAnimatorControllerFromNotification( associatedView: ExpandableNotificationRow?, ): ActivityTransitionAnimator.Controller? = null diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 462ae7ab39cb..461a38df797f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -47,7 +47,6 @@ import android.app.StatusBarManager; import android.app.TaskInfo; import android.app.UiModeManager; import android.app.WallpaperManager; -import android.app.admin.DevicePolicyManager; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; @@ -883,8 +882,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { // start old BaseStatusBar.start(). mWindowManagerService = WindowManagerGlobal.getWindowManagerService(); - mDevicePolicyManager = (DevicePolicyManager) mContext.getSystemService( - Context.DEVICE_POLICY_SERVICE); mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); @@ -2627,6 +2624,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mStackScrollerController.updateSensitivenessForOccludedWakeup(); } if (mLaunchCameraWhenFinishedWaking) { + startLaunchTransitionTimeout(); mCameraLauncherLazy.get().launchCamera(mLastCameraLaunchSource, mShadeSurface.isFullyCollapsed()); mLaunchCameraWhenFinishedWaking = false; @@ -2701,21 +2699,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { } @Override - public boolean isCameraAllowedByAdmin() { - if (mDevicePolicyManager.getCameraDisabled(null, - mLockscreenUserManager.getCurrentUserId())) { - return false; - } else if (mKeyguardStateController.isShowing() - && mStatusBarKeyguardViewManager.isSecure()) { - // Check if the admin has disabled the camera specifically for the keyguard - return (mDevicePolicyManager.getKeyguardDisabledFeatures(null, - mLockscreenUserManager.getCurrentUserId()) - & DevicePolicyManager.KEYGUARD_DISABLE_SECURE_CAMERA) == 0; - } - return true; - } - - @Override public boolean isGoingToSleep() { return mWakefulnessLifecycle.getWakefulness() == WakefulnessLifecycle.WAKEFULNESS_GOING_TO_SLEEP; @@ -2864,7 +2847,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { protected boolean mDeviceInteractive; - protected DevicePolicyManager mDevicePolicyManager; private final PowerManager mPowerManager; protected StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java index 06a883c02ac0..b7ce33671492 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java @@ -44,7 +44,6 @@ import com.android.systemui.deviceentry.domain.interactor.DeviceEntryUdfpsIntera import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.fragments.FragmentHostManager; -import com.android.systemui.keyguard.data.repository.FakeCommandQueue; import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor; @@ -190,7 +189,6 @@ public class QuickSettingsControllerImplBaseTest extends SysuiTestCase { mKosmos.getKeyguardTransitionInteractor(); KeyguardInteractor keyguardInteractor = new KeyguardInteractor( mKeyguardRepository, - new FakeCommandQueue(), powerInteractor, new FakeKeyguardBouncerRepository(), new ConfigurationInteractor(configurationRepository), diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/domain/interactor/HideNotificationsInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/domain/interactor/HideNotificationsInteractorTest.kt index e46906fb5192..476252737454 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/domain/interactor/HideNotificationsInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/domain/interactor/HideNotificationsInteractorTest.kt @@ -66,7 +66,8 @@ open class HideNotificationsInteractorTest : SysuiTestCase() { repository = powerRepository, falsingCollector = mock(), screenOffAnimationController = mock(), - statusBarStateController = mock() + statusBarStateController = mock(), + cameraGestureHelper = mock(), ) private val configurationRepository = diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java index 5e5586d0f94f..d9e94953e757 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java @@ -42,6 +42,7 @@ import com.android.systemui.SysuiTestCase; import com.android.systemui.assist.AssistManager; import com.android.systemui.emergency.EmergencyGestureModule.EmergencyGestureIntentFactory; import com.android.systemui.keyguard.WakefulnessLifecycle; +import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.qs.QSHost; import com.android.systemui.recents.ScreenPinningRequest; @@ -103,6 +104,7 @@ public class CentralSurfacesCommandQueueCallbacksTest extends SysuiTestCase { @Mock private QSHost mQSHost; @Mock private ActivityStarter mActivityStarter; @Mock private EmergencyGestureIntentFactory mEmergencyGestureIntentFactory; + @Mock private KeyguardInteractor mKeyguardInteractor; CentralSurfacesCommandQueueCallbacks mSbcqCallbacks; @@ -140,6 +142,7 @@ public class CentralSurfacesCommandQueueCallbacksTest extends SysuiTestCase { mUserTracker, mQSHost, mActivityStarter, + mKeyguardInteractor, mEmergencyGestureIntentFactory); when(mUserTracker.getUserHandle()).thenReturn( diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/TestMocksModule.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/TestMocksModule.kt index 0b6b816e589f..50631409308c 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/TestMocksModule.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/TestMocksModule.kt @@ -33,6 +33,7 @@ import com.android.keyguard.KeyguardViewController import com.android.systemui.animation.DialogTransitionAnimator import com.android.systemui.biometrics.AuthController import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor +import com.android.systemui.camera.CameraGestureHelper import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor @@ -143,6 +144,7 @@ data class TestMocksModule( @get:Provides val primaryBouncerInteractor: PrimaryBouncerInteractor = mock(), @get:Provides val keyguardStateController: KeyguardStateController = mock(), @get:Provides val globalSettings: GlobalSettings = mock(), + @get:Provides val cameraGestureHelper: CameraGestureHelper = mock(), // log buffers @get:[Provides BroadcastDispatcherLog] diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/camera/CameraGestureHelperKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/camera/CameraGestureHelperKosmos.kt new file mode 100644 index 000000000000..931567e4be78 --- /dev/null +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/camera/CameraGestureHelperKosmos.kt @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2024 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.systemui.camera + +import com.android.systemui.kosmos.Kosmos +import com.android.systemui.util.mockito.any +import com.android.systemui.util.mockito.whenever +import org.mockito.Mockito.mock + +val Kosmos.cameraGestureHelper: CameraGestureHelper by + Kosmos.Fixture<CameraGestureHelper> { + mock(CameraGestureHelper::class.java).also { helper -> + whenever(helper.canCameraGestureBeLaunched(any())).thenReturn(true) + } + } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt index 87143efb7f3c..727de9e95872 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt @@ -22,6 +22,7 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.shared.model.BiometricUnlockMode import com.android.systemui.keyguard.shared.model.BiometricUnlockModel import com.android.systemui.keyguard.shared.model.BiometricUnlockSource +import com.android.systemui.keyguard.shared.model.CameraLaunchSourceModel import com.android.systemui.keyguard.shared.model.DismissAction import com.android.systemui.keyguard.shared.model.DozeTransitionModel import com.android.systemui.keyguard.shared.model.KeyguardDone @@ -138,6 +139,8 @@ class FakeKeyguardRepository @Inject constructor() : KeyguardRepository { private val _canIgnoreAuthAndReturnToGone = MutableStateFlow(false) override val canIgnoreAuthAndReturnToGone = _canIgnoreAuthAndReturnToGone.asStateFlow() + override val onCameraLaunchDetected = MutableStateFlow(CameraLaunchSourceModel()) + override fun setQuickSettingsVisible(isVisible: Boolean) { _isQuickSettingsVisible.value = isVisible } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorFactory.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorFactory.kt index b5ca964d6968..a95609efc16f 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorFactory.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorFactory.kt @@ -21,7 +21,6 @@ import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepositor import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor import com.android.systemui.flags.FakeFeatureFlags -import com.android.systemui.keyguard.data.repository.FakeCommandQueue import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.TransitionStep @@ -49,7 +48,6 @@ object KeyguardInteractorFactory { fun create( featureFlags: FakeFeatureFlags = FakeFeatureFlags(), repository: FakeKeyguardRepository = FakeKeyguardRepository(), - commandQueue: FakeCommandQueue = FakeCommandQueue(), bouncerRepository: FakeKeyguardBouncerRepository = FakeKeyguardBouncerRepository(), configurationRepository: FakeConfigurationRepository = FakeConfigurationRepository(), shadeRepository: FakeShadeRepository = FakeShadeRepository(), @@ -87,7 +85,6 @@ object KeyguardInteractorFactory { } return WithDependencies( repository = repository, - commandQueue = commandQueue, featureFlags = featureFlags, bouncerRepository = bouncerRepository, configurationRepository = configurationRepository, @@ -95,7 +92,6 @@ object KeyguardInteractorFactory { powerInteractor = powerInteractor, KeyguardInteractor( repository = repository, - commandQueue = commandQueue, powerInteractor = powerInteractor, bouncerRepository = bouncerRepository, configurationInteractor = ConfigurationInteractor(configurationRepository), @@ -112,7 +108,6 @@ object KeyguardInteractorFactory { data class WithDependencies( val repository: FakeKeyguardRepository, - val commandQueue: FakeCommandQueue, val featureFlags: FakeFeatureFlags, val bouncerRepository: FakeKeyguardBouncerRepository, val configurationRepository: FakeConfigurationRepository, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorKosmos.kt index 81d8f0b4ca53..5ab56e931175 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractorKosmos.kt @@ -18,7 +18,6 @@ package com.android.systemui.keyguard.domain.interactor import com.android.systemui.bouncer.data.repository.keyguardBouncerRepository import com.android.systemui.common.ui.domain.interactor.configurationInteractor -import com.android.systemui.keyguard.data.repository.fakeCommandQueue import com.android.systemui.keyguard.data.repository.keyguardRepository import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testScope @@ -31,7 +30,6 @@ val Kosmos.keyguardInteractor: KeyguardInteractor by Kosmos.Fixture { KeyguardInteractor( repository = keyguardRepository, - commandQueue = fakeCommandQueue, powerInteractor = powerInteractor, bouncerRepository = keyguardBouncerRepository, configurationInteractor = configurationInteractor, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/power/domain/interactor/PowerInteractorFactory.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/power/domain/interactor/PowerInteractorFactory.kt index d92ace945b18..9a07c4e94276 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/power/domain/interactor/PowerInteractorFactory.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/power/domain/interactor/PowerInteractorFactory.kt @@ -42,6 +42,7 @@ object PowerInteractorFactory { falsingCollector, screenOffAnimationController, statusBarStateController, + mock(), ) ) } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/power/domain/interactor/PowerInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/power/domain/interactor/PowerInteractorKosmos.kt index 8486691a7b95..d50091e1447c 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/power/domain/interactor/PowerInteractorKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/power/domain/interactor/PowerInteractorKosmos.kt @@ -16,6 +16,7 @@ package com.android.systemui.power.domain.interactor +import com.android.systemui.camera.cameraGestureHelper import com.android.systemui.classifier.falsingCollector import com.android.systemui.kosmos.Kosmos import com.android.systemui.plugins.statusbar.statusBarStateController @@ -29,5 +30,6 @@ val Kosmos.powerInteractor by falsingCollector = falsingCollector, screenOffAnimationController = screenOffAnimationController, statusBarStateController = statusBarStateController, + cameraGestureHelper = { cameraGestureHelper }, ) } |