Create Camera Prebuilt quick affordance
Bug: 254333599 Test: New Unit test, verified manually via toggling flag and activating camera quick affordance Change-Id: I957a504c2694051f44b4aae6280945f6ce640682
This commit is contained in:
@@ -158,9 +158,9 @@ object Flags {
|
||||
/**
|
||||
* Whether to enable the code powering customizable lock screen quick affordances.
|
||||
*
|
||||
* Note that this flag does not enable individual implementations of quick affordances like the
|
||||
* new camera quick affordance. Look for individual flags for those.
|
||||
* This flag enables any new prebuilt quick affordances as well.
|
||||
*/
|
||||
// TODO(b/255618149): Tracking Bug
|
||||
@JvmField
|
||||
val CUSTOMIZABLE_LOCK_SCREEN_QUICK_AFFORDANCES =
|
||||
unreleasedFlag(216, "customizable_lock_screen_quick_affordances", teamfood = false)
|
||||
|
||||
@@ -24,6 +24,7 @@ package com.android.systemui.keyguard.data.quickaffordance
|
||||
*/
|
||||
object BuiltInKeyguardQuickAffordanceKeys {
|
||||
// Please keep alphabetical order of const names to simplify future maintenance.
|
||||
const val CAMERA = "camera"
|
||||
const val HOME_CONTROLS = "home"
|
||||
const val QR_CODE_SCANNER = "qr_code_scanner"
|
||||
const val QUICK_ACCESS_WALLET = "wallet"
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.data.quickaffordance
|
||||
|
||||
import android.app.StatusBarManager
|
||||
import android.content.Context
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.animation.Expandable
|
||||
import com.android.systemui.camera.CameraGestureHelper
|
||||
import com.android.systemui.common.shared.model.ContentDescription
|
||||
import com.android.systemui.common.shared.model.Icon
|
||||
import com.android.systemui.dagger.SysUISingleton
|
||||
import com.android.systemui.dagger.qualifiers.Application
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import javax.inject.Inject
|
||||
|
||||
@SysUISingleton
|
||||
class CameraQuickAffordanceConfig @Inject constructor(
|
||||
@Application private val context: Context,
|
||||
private val cameraGestureHelper: CameraGestureHelper,
|
||||
) : KeyguardQuickAffordanceConfig {
|
||||
|
||||
override val key: String
|
||||
get() = BuiltInKeyguardQuickAffordanceKeys.CAMERA
|
||||
|
||||
override val pickerName: String
|
||||
get() = context.getString(R.string.accessibility_camera_button)
|
||||
|
||||
override val pickerIconResourceId: Int
|
||||
get() = com.android.internal.R.drawable.perm_group_camera
|
||||
|
||||
override val lockScreenState: Flow<KeyguardQuickAffordanceConfig.LockScreenState>
|
||||
get() = flowOf(
|
||||
KeyguardQuickAffordanceConfig.LockScreenState.Visible(
|
||||
icon = Icon.Resource(
|
||||
com.android.internal.R.drawable.perm_group_camera,
|
||||
ContentDescription.Resource(R.string.accessibility_camera_button)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
override fun onTriggered(expandable: Expandable?): KeyguardQuickAffordanceConfig.OnTriggeredResult {
|
||||
cameraGestureHelper.launchCamera(StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP)
|
||||
return KeyguardQuickAffordanceConfig.OnTriggeredResult.Handled
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,10 @@ object KeyguardDataQuickAffordanceModule {
|
||||
home: HomeControlsKeyguardQuickAffordanceConfig,
|
||||
quickAccessWallet: QuickAccessWalletKeyguardQuickAffordanceConfig,
|
||||
qrCodeScanner: QrCodeScannerKeyguardQuickAffordanceConfig,
|
||||
camera: CameraQuickAffordanceConfig,
|
||||
): Set<KeyguardQuickAffordanceConfig> {
|
||||
return setOf(
|
||||
camera,
|
||||
home,
|
||||
quickAccessWallet,
|
||||
qrCodeScanner,
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.data.quickaffordance
|
||||
|
||||
import android.app.StatusBarManager
|
||||
import android.content.Context
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.systemui.SysuiTestCase
|
||||
import com.android.systemui.camera.CameraGestureHelper
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.JUnit4
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
@SmallTest
|
||||
@RunWith(JUnit4::class)
|
||||
class CameraQuickAffordanceConfigTest : SysuiTestCase() {
|
||||
|
||||
@Mock private lateinit var cameraGestureHelper: CameraGestureHelper
|
||||
@Mock private lateinit var context: Context
|
||||
private lateinit var underTest: CameraQuickAffordanceConfig
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
underTest = CameraQuickAffordanceConfig(
|
||||
context,
|
||||
cameraGestureHelper,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `affordance triggered -- camera launch called`() {
|
||||
//when
|
||||
val result = underTest.onTriggered(null)
|
||||
|
||||
//then
|
||||
verify(cameraGestureHelper)
|
||||
.launchCamera(StatusBarManager.CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP)
|
||||
assertEquals(KeyguardQuickAffordanceConfig.OnTriggeredResult.Handled, result)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user