Merge "KeyguardQuickAffordanceConfig: some renames" into tm-qpr-dev am: 4a3655b2db
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20275188 Change-Id: Ib28f40f9ea7f8bc1d90095d7acccc1db40ea9edd Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -53,19 +53,19 @@ constructor(
|
|||||||
|
|
||||||
override val key: String = BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS
|
override val key: String = BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS
|
||||||
|
|
||||||
override val state: Flow<KeyguardQuickAffordanceConfig.State> =
|
override val lockScreenState: Flow<KeyguardQuickAffordanceConfig.LockScreenState> =
|
||||||
component.canShowWhileLockedSetting.flatMapLatest { canShowWhileLocked ->
|
component.canShowWhileLockedSetting.flatMapLatest { canShowWhileLocked ->
|
||||||
if (canShowWhileLocked) {
|
if (canShowWhileLocked) {
|
||||||
stateInternal(component.getControlsListingController().getOrNull())
|
stateInternal(component.getControlsListingController().getOrNull())
|
||||||
} else {
|
} else {
|
||||||
flowOf(KeyguardQuickAffordanceConfig.State.Hidden)
|
flowOf(KeyguardQuickAffordanceConfig.LockScreenState.Hidden)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onQuickAffordanceClicked(
|
override fun onTriggered(
|
||||||
expandable: Expandable?,
|
expandable: Expandable?,
|
||||||
): KeyguardQuickAffordanceConfig.OnClickedResult {
|
): KeyguardQuickAffordanceConfig.OnTriggeredResult {
|
||||||
return KeyguardQuickAffordanceConfig.OnClickedResult.StartActivity(
|
return KeyguardQuickAffordanceConfig.OnTriggeredResult.StartActivity(
|
||||||
intent =
|
intent =
|
||||||
Intent(appContext, ControlsActivity::class.java)
|
Intent(appContext, ControlsActivity::class.java)
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
@@ -79,9 +79,9 @@ constructor(
|
|||||||
|
|
||||||
private fun stateInternal(
|
private fun stateInternal(
|
||||||
listingController: ControlsListingController?,
|
listingController: ControlsListingController?,
|
||||||
): Flow<KeyguardQuickAffordanceConfig.State> {
|
): Flow<KeyguardQuickAffordanceConfig.LockScreenState> {
|
||||||
if (listingController == null) {
|
if (listingController == null) {
|
||||||
return flowOf(KeyguardQuickAffordanceConfig.State.Hidden)
|
return flowOf(KeyguardQuickAffordanceConfig.LockScreenState.Hidden)
|
||||||
}
|
}
|
||||||
|
|
||||||
return conflatedCallbackFlow {
|
return conflatedCallbackFlow {
|
||||||
@@ -116,7 +116,7 @@ constructor(
|
|||||||
hasServiceInfos: Boolean,
|
hasServiceInfos: Boolean,
|
||||||
visibility: ControlsComponent.Visibility,
|
visibility: ControlsComponent.Visibility,
|
||||||
@DrawableRes iconResourceId: Int?,
|
@DrawableRes iconResourceId: Int?,
|
||||||
): KeyguardQuickAffordanceConfig.State {
|
): KeyguardQuickAffordanceConfig.LockScreenState {
|
||||||
return if (
|
return if (
|
||||||
isFeatureEnabled &&
|
isFeatureEnabled &&
|
||||||
hasFavorites &&
|
hasFavorites &&
|
||||||
@@ -124,7 +124,7 @@ constructor(
|
|||||||
iconResourceId != null &&
|
iconResourceId != null &&
|
||||||
visibility == ControlsComponent.Visibility.AVAILABLE
|
visibility == ControlsComponent.Visibility.AVAILABLE
|
||||||
) {
|
) {
|
||||||
KeyguardQuickAffordanceConfig.State.Visible(
|
KeyguardQuickAffordanceConfig.LockScreenState.Visible(
|
||||||
icon =
|
icon =
|
||||||
Icon.Resource(
|
Icon.Resource(
|
||||||
res = iconResourceId,
|
res = iconResourceId,
|
||||||
@@ -135,7 +135,7 @@ constructor(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
KeyguardQuickAffordanceConfig.State.Hidden
|
KeyguardQuickAffordanceConfig.LockScreenState.Hidden
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package com.android.systemui.keyguard.data.quickaffordance
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import com.android.systemui.animation.Expandable
|
import com.android.systemui.animation.Expandable
|
||||||
import com.android.systemui.common.shared.model.Icon
|
import com.android.systemui.common.shared.model.Icon
|
||||||
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordanceToggleState
|
import com.android.systemui.keyguard.shared.quickaffordance.ActivationState
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
/** Defines interface that can act as data source for a single quick affordance model. */
|
/** Defines interface that can act as data source for a single quick affordance model. */
|
||||||
@@ -29,51 +29,54 @@ interface KeyguardQuickAffordanceConfig {
|
|||||||
/** Unique identifier for this quick affordance. It must be globally unique. */
|
/** Unique identifier for this quick affordance. It must be globally unique. */
|
||||||
val key: String
|
val key: String
|
||||||
|
|
||||||
/** The observable [State] of the affordance. */
|
/**
|
||||||
val state: Flow<State>
|
* The ever-changing state of the affordance.
|
||||||
|
*
|
||||||
|
* Used to populate the lock screen.
|
||||||
|
*/
|
||||||
|
val lockScreenState: Flow<LockScreenState>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies that the affordance was clicked by the user.
|
* Notifies that the affordance was clicked by the user.
|
||||||
*
|
*
|
||||||
* @param expandable An [Expandable] to use when animating dialogs or activities
|
* @param expandable An [Expandable] to use when animating dialogs or activities
|
||||||
* @return An [OnClickedResult] telling the caller what to do next
|
* @return An [OnTriggeredResult] telling the caller what to do next
|
||||||
*/
|
*/
|
||||||
fun onQuickAffordanceClicked(expandable: Expandable?): OnClickedResult
|
fun onTriggered(expandable: Expandable?): OnTriggeredResult
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates the state of a "quick affordance" in the keyguard bottom area (for example, a
|
* Encapsulates the state of a "quick affordance" in the keyguard bottom area (for example, a
|
||||||
* button on the lock-screen).
|
* button on the lock-screen).
|
||||||
*/
|
*/
|
||||||
sealed class State {
|
sealed class LockScreenState {
|
||||||
|
|
||||||
/** No affordance should show up. */
|
/** No affordance should show up. */
|
||||||
object Hidden : State()
|
object Hidden : LockScreenState()
|
||||||
|
|
||||||
/** An affordance is visible. */
|
/** An affordance is visible. */
|
||||||
data class Visible(
|
data class Visible(
|
||||||
/** An icon for the affordance. */
|
/** An icon for the affordance. */
|
||||||
val icon: Icon,
|
val icon: Icon,
|
||||||
/** The toggle state for the affordance. */
|
/** The activation state of the affordance. */
|
||||||
val toggle: KeyguardQuickAffordanceToggleState =
|
val activationState: ActivationState = ActivationState.NotSupported,
|
||||||
KeyguardQuickAffordanceToggleState.NotSupported,
|
) : LockScreenState()
|
||||||
) : State()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class OnClickedResult {
|
sealed class OnTriggeredResult {
|
||||||
/**
|
/**
|
||||||
* Returning this as a result from the [onQuickAffordanceClicked] method means that the
|
* Returning this as a result from the [onTriggered] method means that the implementation
|
||||||
* implementation has taken care of the click, the system will do nothing.
|
* has taken care of the action, the system will do nothing.
|
||||||
*/
|
*/
|
||||||
object Handled : OnClickedResult()
|
object Handled : OnTriggeredResult()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returning this as a result from the [onQuickAffordanceClicked] method means that the
|
* Returning this as a result from the [onTriggered] method means that the implementation
|
||||||
* implementation has _not_ taken care of the click and the system should start an activity
|
* has _not_ taken care of the action and the system should start an activity using the
|
||||||
* using the given [Intent].
|
* given [Intent].
|
||||||
*/
|
*/
|
||||||
data class StartActivity(
|
data class StartActivity(
|
||||||
val intent: Intent,
|
val intent: Intent,
|
||||||
val canShowWhileLocked: Boolean,
|
val canShowWhileLocked: Boolean,
|
||||||
) : OnClickedResult()
|
) : OnTriggeredResult()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,46 +39,47 @@ constructor(
|
|||||||
|
|
||||||
override val key: String = BuiltInKeyguardQuickAffordanceKeys.QR_CODE_SCANNER
|
override val key: String = BuiltInKeyguardQuickAffordanceKeys.QR_CODE_SCANNER
|
||||||
|
|
||||||
override val state: Flow<KeyguardQuickAffordanceConfig.State> = conflatedCallbackFlow {
|
override val lockScreenState: Flow<KeyguardQuickAffordanceConfig.LockScreenState> =
|
||||||
val callback =
|
conflatedCallbackFlow {
|
||||||
object : QRCodeScannerController.Callback {
|
val callback =
|
||||||
override fun onQRCodeScannerActivityChanged() {
|
object : QRCodeScannerController.Callback {
|
||||||
trySendWithFailureLogging(state(), TAG)
|
override fun onQRCodeScannerActivityChanged() {
|
||||||
|
trySendWithFailureLogging(state(), TAG)
|
||||||
|
}
|
||||||
|
override fun onQRCodeScannerPreferenceChanged() {
|
||||||
|
trySendWithFailureLogging(state(), TAG)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
override fun onQRCodeScannerPreferenceChanged() {
|
|
||||||
trySendWithFailureLogging(state(), TAG)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
controller.addCallback(callback)
|
controller.addCallback(callback)
|
||||||
controller.registerQRCodeScannerChangeObservers(
|
controller.registerQRCodeScannerChangeObservers(
|
||||||
QRCodeScannerController.DEFAULT_QR_CODE_SCANNER_CHANGE,
|
|
||||||
QRCodeScannerController.QR_CODE_SCANNER_PREFERENCE_CHANGE
|
|
||||||
)
|
|
||||||
// Registering does not push an initial update.
|
|
||||||
trySendWithFailureLogging(state(), "initial state", TAG)
|
|
||||||
|
|
||||||
awaitClose {
|
|
||||||
controller.unregisterQRCodeScannerChangeObservers(
|
|
||||||
QRCodeScannerController.DEFAULT_QR_CODE_SCANNER_CHANGE,
|
QRCodeScannerController.DEFAULT_QR_CODE_SCANNER_CHANGE,
|
||||||
QRCodeScannerController.QR_CODE_SCANNER_PREFERENCE_CHANGE
|
QRCodeScannerController.QR_CODE_SCANNER_PREFERENCE_CHANGE
|
||||||
)
|
)
|
||||||
controller.removeCallback(callback)
|
// Registering does not push an initial update.
|
||||||
}
|
trySendWithFailureLogging(state(), "initial state", TAG)
|
||||||
}
|
|
||||||
|
|
||||||
override fun onQuickAffordanceClicked(
|
awaitClose {
|
||||||
|
controller.unregisterQRCodeScannerChangeObservers(
|
||||||
|
QRCodeScannerController.DEFAULT_QR_CODE_SCANNER_CHANGE,
|
||||||
|
QRCodeScannerController.QR_CODE_SCANNER_PREFERENCE_CHANGE
|
||||||
|
)
|
||||||
|
controller.removeCallback(callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTriggered(
|
||||||
expandable: Expandable?,
|
expandable: Expandable?,
|
||||||
): KeyguardQuickAffordanceConfig.OnClickedResult {
|
): KeyguardQuickAffordanceConfig.OnTriggeredResult {
|
||||||
return KeyguardQuickAffordanceConfig.OnClickedResult.StartActivity(
|
return KeyguardQuickAffordanceConfig.OnTriggeredResult.StartActivity(
|
||||||
intent = controller.intent,
|
intent = controller.intent,
|
||||||
canShowWhileLocked = true,
|
canShowWhileLocked = true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun state(): KeyguardQuickAffordanceConfig.State {
|
private fun state(): KeyguardQuickAffordanceConfig.LockScreenState {
|
||||||
return if (controller.isEnabledForLockScreenButton) {
|
return if (controller.isEnabledForLockScreenButton) {
|
||||||
KeyguardQuickAffordanceConfig.State.Visible(
|
KeyguardQuickAffordanceConfig.LockScreenState.Visible(
|
||||||
icon =
|
icon =
|
||||||
Icon.Resource(
|
Icon.Resource(
|
||||||
res = R.drawable.ic_qr_code_scanner,
|
res = R.drawable.ic_qr_code_scanner,
|
||||||
@@ -89,7 +90,7 @@ constructor(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
KeyguardQuickAffordanceConfig.State.Hidden
|
KeyguardQuickAffordanceConfig.LockScreenState.Hidden
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,63 +46,64 @@ constructor(
|
|||||||
|
|
||||||
override val key: String = BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET
|
override val key: String = BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET
|
||||||
|
|
||||||
override val state: Flow<KeyguardQuickAffordanceConfig.State> = conflatedCallbackFlow {
|
override val lockScreenState: Flow<KeyguardQuickAffordanceConfig.LockScreenState> =
|
||||||
val callback =
|
conflatedCallbackFlow {
|
||||||
object : QuickAccessWalletClient.OnWalletCardsRetrievedCallback {
|
val callback =
|
||||||
override fun onWalletCardsRetrieved(response: GetWalletCardsResponse?) {
|
object : QuickAccessWalletClient.OnWalletCardsRetrievedCallback {
|
||||||
trySendWithFailureLogging(
|
override fun onWalletCardsRetrieved(response: GetWalletCardsResponse?) {
|
||||||
state(
|
trySendWithFailureLogging(
|
||||||
isFeatureEnabled = walletController.isWalletEnabled,
|
state(
|
||||||
hasCard = response?.walletCards?.isNotEmpty() == true,
|
isFeatureEnabled = walletController.isWalletEnabled,
|
||||||
tileIcon = walletController.walletClient.tileIcon,
|
hasCard = response?.walletCards?.isNotEmpty() == true,
|
||||||
),
|
tileIcon = walletController.walletClient.tileIcon,
|
||||||
TAG,
|
),
|
||||||
)
|
TAG,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onWalletCardRetrievalError(error: GetWalletCardsError?) {
|
||||||
|
Log.e(TAG, "Wallet card retrieval error, message: \"${error?.message}\"")
|
||||||
|
trySendWithFailureLogging(
|
||||||
|
KeyguardQuickAffordanceConfig.LockScreenState.Hidden,
|
||||||
|
TAG,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onWalletCardRetrievalError(error: GetWalletCardsError?) {
|
walletController.setupWalletChangeObservers(
|
||||||
Log.e(TAG, "Wallet card retrieval error, message: \"${error?.message}\"")
|
callback,
|
||||||
trySendWithFailureLogging(
|
|
||||||
KeyguardQuickAffordanceConfig.State.Hidden,
|
|
||||||
TAG,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
walletController.setupWalletChangeObservers(
|
|
||||||
callback,
|
|
||||||
QuickAccessWalletController.WalletChangeEvent.WALLET_PREFERENCE_CHANGE,
|
|
||||||
QuickAccessWalletController.WalletChangeEvent.DEFAULT_PAYMENT_APP_CHANGE
|
|
||||||
)
|
|
||||||
walletController.updateWalletPreference()
|
|
||||||
walletController.queryWalletCards(callback)
|
|
||||||
|
|
||||||
awaitClose {
|
|
||||||
walletController.unregisterWalletChangeObservers(
|
|
||||||
QuickAccessWalletController.WalletChangeEvent.WALLET_PREFERENCE_CHANGE,
|
QuickAccessWalletController.WalletChangeEvent.WALLET_PREFERENCE_CHANGE,
|
||||||
QuickAccessWalletController.WalletChangeEvent.DEFAULT_PAYMENT_APP_CHANGE
|
QuickAccessWalletController.WalletChangeEvent.DEFAULT_PAYMENT_APP_CHANGE
|
||||||
)
|
)
|
||||||
}
|
walletController.updateWalletPreference()
|
||||||
}
|
walletController.queryWalletCards(callback)
|
||||||
|
|
||||||
override fun onQuickAffordanceClicked(
|
awaitClose {
|
||||||
|
walletController.unregisterWalletChangeObservers(
|
||||||
|
QuickAccessWalletController.WalletChangeEvent.WALLET_PREFERENCE_CHANGE,
|
||||||
|
QuickAccessWalletController.WalletChangeEvent.DEFAULT_PAYMENT_APP_CHANGE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onTriggered(
|
||||||
expandable: Expandable?,
|
expandable: Expandable?,
|
||||||
): KeyguardQuickAffordanceConfig.OnClickedResult {
|
): KeyguardQuickAffordanceConfig.OnTriggeredResult {
|
||||||
walletController.startQuickAccessUiIntent(
|
walletController.startQuickAccessUiIntent(
|
||||||
activityStarter,
|
activityStarter,
|
||||||
expandable?.activityLaunchController(),
|
expandable?.activityLaunchController(),
|
||||||
/* hasCard= */ true,
|
/* hasCard= */ true,
|
||||||
)
|
)
|
||||||
return KeyguardQuickAffordanceConfig.OnClickedResult.Handled
|
return KeyguardQuickAffordanceConfig.OnTriggeredResult.Handled
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun state(
|
private fun state(
|
||||||
isFeatureEnabled: Boolean,
|
isFeatureEnabled: Boolean,
|
||||||
hasCard: Boolean,
|
hasCard: Boolean,
|
||||||
tileIcon: Drawable?,
|
tileIcon: Drawable?,
|
||||||
): KeyguardQuickAffordanceConfig.State {
|
): KeyguardQuickAffordanceConfig.LockScreenState {
|
||||||
return if (isFeatureEnabled && hasCard && tileIcon != null) {
|
return if (isFeatureEnabled && hasCard && tileIcon != null) {
|
||||||
KeyguardQuickAffordanceConfig.State.Visible(
|
KeyguardQuickAffordanceConfig.LockScreenState.Visible(
|
||||||
icon =
|
icon =
|
||||||
Icon.Loaded(
|
Icon.Loaded(
|
||||||
drawable = tileIcon,
|
drawable = tileIcon,
|
||||||
@@ -113,7 +114,7 @@ constructor(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
KeyguardQuickAffordanceConfig.State.Hidden
|
KeyguardQuickAffordanceConfig.LockScreenState.Hidden
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,25 +62,25 @@ constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies that a quick affordance has been clicked by the user.
|
* Notifies that a quick affordance has been "triggered" (clicked) by the user.
|
||||||
*
|
*
|
||||||
* @param configKey The configuration key corresponding to the [KeyguardQuickAffordanceModel] of
|
* @param configKey The configuration key corresponding to the [KeyguardQuickAffordanceModel] of
|
||||||
* the affordance that was clicked
|
* the affordance that was clicked
|
||||||
* @param expandable An optional [Expandable] for the activity- or dialog-launch animation
|
* @param expandable An optional [Expandable] for the activity- or dialog-launch animation
|
||||||
*/
|
*/
|
||||||
fun onQuickAffordanceClicked(
|
fun onQuickAffordanceTriggered(
|
||||||
configKey: String,
|
configKey: String,
|
||||||
expandable: Expandable?,
|
expandable: Expandable?,
|
||||||
) {
|
) {
|
||||||
@Suppress("UNCHECKED_CAST") val config = registry.get(configKey)
|
@Suppress("UNCHECKED_CAST") val config = registry.get(configKey)
|
||||||
when (val result = config.onQuickAffordanceClicked(expandable)) {
|
when (val result = config.onTriggered(expandable)) {
|
||||||
is KeyguardQuickAffordanceConfig.OnClickedResult.StartActivity ->
|
is KeyguardQuickAffordanceConfig.OnTriggeredResult.StartActivity ->
|
||||||
launchQuickAffordance(
|
launchQuickAffordance(
|
||||||
intent = result.intent,
|
intent = result.intent,
|
||||||
canShowWhileLocked = result.canShowWhileLocked,
|
canShowWhileLocked = result.canShowWhileLocked,
|
||||||
expandable = expandable,
|
expandable = expandable,
|
||||||
)
|
)
|
||||||
is KeyguardQuickAffordanceConfig.OnClickedResult.Handled -> Unit
|
is KeyguardQuickAffordanceConfig.OnTriggeredResult.Handled -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,16 +94,20 @@ constructor(
|
|||||||
// value and avoid subtle bugs where the downstream isn't receiving any values
|
// value and avoid subtle bugs where the downstream isn't receiving any values
|
||||||
// because one config implementation is not emitting an initial value. For example,
|
// because one config implementation is not emitting an initial value. For example,
|
||||||
// see b/244296596.
|
// see b/244296596.
|
||||||
config.state.onStart { emit(KeyguardQuickAffordanceConfig.State.Hidden) }
|
config.lockScreenState.onStart {
|
||||||
|
emit(KeyguardQuickAffordanceConfig.LockScreenState.Hidden)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
) { states ->
|
) { states ->
|
||||||
val index = states.indexOfFirst { it is KeyguardQuickAffordanceConfig.State.Visible }
|
val index =
|
||||||
|
states.indexOfFirst { it is KeyguardQuickAffordanceConfig.LockScreenState.Visible }
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
val visibleState = states[index] as KeyguardQuickAffordanceConfig.State.Visible
|
val visibleState =
|
||||||
|
states[index] as KeyguardQuickAffordanceConfig.LockScreenState.Visible
|
||||||
KeyguardQuickAffordanceModel.Visible(
|
KeyguardQuickAffordanceModel.Visible(
|
||||||
configKey = configs[index].key,
|
configKey = configs[index].key,
|
||||||
icon = visibleState.icon,
|
icon = visibleState.icon,
|
||||||
toggle = visibleState.toggle,
|
activationState = visibleState.activationState,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
KeyguardQuickAffordanceModel.Hidden
|
KeyguardQuickAffordanceModel.Hidden
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package com.android.systemui.keyguard.domain.model
|
package com.android.systemui.keyguard.domain.model
|
||||||
|
|
||||||
import com.android.systemui.common.shared.model.Icon
|
import com.android.systemui.common.shared.model.Icon
|
||||||
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordanceToggleState
|
import com.android.systemui.keyguard.shared.quickaffordance.ActivationState
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Models a "quick affordance" in the keyguard bottom area (for example, a button on the
|
* Models a "quick affordance" in the keyguard bottom area (for example, a button on the
|
||||||
@@ -34,7 +34,7 @@ sealed class KeyguardQuickAffordanceModel {
|
|||||||
val configKey: String,
|
val configKey: String,
|
||||||
/** An icon for the affordance. */
|
/** An icon for the affordance. */
|
||||||
val icon: Icon,
|
val icon: Icon,
|
||||||
/** The toggle state for the affordance. */
|
/** The activation state of the affordance. */
|
||||||
val toggle: KeyguardQuickAffordanceToggleState,
|
val activationState: ActivationState,
|
||||||
) : KeyguardQuickAffordanceModel()
|
) : KeyguardQuickAffordanceModel()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,12 @@
|
|||||||
|
|
||||||
package com.android.systemui.keyguard.shared.quickaffordance
|
package com.android.systemui.keyguard.shared.quickaffordance
|
||||||
|
|
||||||
/** Enumerates all possible toggle states for a quick affordance on the lock-screen. */
|
/** Enumerates all possible activation states for a quick affordance on the lock-screen. */
|
||||||
sealed class KeyguardQuickAffordanceToggleState {
|
sealed class ActivationState {
|
||||||
/** Toggling is not supported. */
|
/** Activation is not supported. */
|
||||||
object NotSupported : KeyguardQuickAffordanceToggleState()
|
object NotSupported : ActivationState()
|
||||||
/** The quick affordance is on. */
|
/** The quick affordance is on. */
|
||||||
object On : KeyguardQuickAffordanceToggleState()
|
object Active : ActivationState()
|
||||||
/** The quick affordance is off. */
|
/** The quick affordance is off. */
|
||||||
object Off : KeyguardQuickAffordanceToggleState()
|
object Inactive : ActivationState()
|
||||||
}
|
}
|
||||||
@@ -22,8 +22,8 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardBottomAreaInterac
|
|||||||
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
|
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
|
||||||
import com.android.systemui.keyguard.domain.interactor.KeyguardQuickAffordanceInteractor
|
import com.android.systemui.keyguard.domain.interactor.KeyguardQuickAffordanceInteractor
|
||||||
import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordanceModel
|
import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordanceModel
|
||||||
|
import com.android.systemui.keyguard.shared.quickaffordance.ActivationState
|
||||||
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition
|
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition
|
||||||
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordanceToggleState
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
@@ -118,13 +118,13 @@ constructor(
|
|||||||
animateReveal = animateReveal,
|
animateReveal = animateReveal,
|
||||||
icon = icon,
|
icon = icon,
|
||||||
onClicked = { parameters ->
|
onClicked = { parameters ->
|
||||||
quickAffordanceInteractor.onQuickAffordanceClicked(
|
quickAffordanceInteractor.onQuickAffordanceTriggered(
|
||||||
configKey = parameters.configKey,
|
configKey = parameters.configKey,
|
||||||
expandable = parameters.expandable,
|
expandable = parameters.expandable,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
isClickable = isClickable,
|
isClickable = isClickable,
|
||||||
isActivated = toggle is KeyguardQuickAffordanceToggleState.On,
|
isActivated = activationState is ActivationState.Active,
|
||||||
)
|
)
|
||||||
is KeyguardQuickAffordanceModel.Hidden -> KeyguardQuickAffordanceViewModel()
|
is KeyguardQuickAffordanceModel.Hidden -> KeyguardQuickAffordanceViewModel()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
package com.android.systemui.keyguard.data.quickaffordance
|
package com.android.systemui.keyguard.data.quickaffordance
|
||||||
|
|
||||||
import com.android.systemui.animation.Expandable
|
import com.android.systemui.animation.Expandable
|
||||||
import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig.OnClickedResult
|
import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig.OnTriggeredResult
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.yield
|
import kotlinx.coroutines.yield
|
||||||
@@ -33,22 +33,23 @@ abstract class FakeKeyguardQuickAffordanceConfig(
|
|||||||
override val key: String,
|
override val key: String,
|
||||||
) : KeyguardQuickAffordanceConfig {
|
) : KeyguardQuickAffordanceConfig {
|
||||||
|
|
||||||
var onClickedResult: OnClickedResult = OnClickedResult.Handled
|
var onTriggeredResult: OnTriggeredResult = OnTriggeredResult.Handled
|
||||||
|
|
||||||
private val _state =
|
private val _lockScreenState =
|
||||||
MutableStateFlow<KeyguardQuickAffordanceConfig.State>(
|
MutableStateFlow<KeyguardQuickAffordanceConfig.LockScreenState>(
|
||||||
KeyguardQuickAffordanceConfig.State.Hidden
|
KeyguardQuickAffordanceConfig.LockScreenState.Hidden
|
||||||
)
|
)
|
||||||
override val state: Flow<KeyguardQuickAffordanceConfig.State> = _state
|
override val lockScreenState: Flow<KeyguardQuickAffordanceConfig.LockScreenState> =
|
||||||
|
_lockScreenState
|
||||||
|
|
||||||
override fun onQuickAffordanceClicked(
|
override fun onTriggered(
|
||||||
expandable: Expandable?,
|
expandable: Expandable?,
|
||||||
): OnClickedResult {
|
): OnTriggeredResult {
|
||||||
return onClickedResult
|
return onTriggeredResult
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun setState(state: KeyguardQuickAffordanceConfig.State) {
|
suspend fun setState(lockScreenState: KeyguardQuickAffordanceConfig.LockScreenState) {
|
||||||
_state.value = state
|
_lockScreenState.value = lockScreenState
|
||||||
// Yield to allow the test's collection coroutine to "catch up" and collect this value
|
// Yield to allow the test's collection coroutine to "catch up" and collect this value
|
||||||
// before the test continues to the next line.
|
// before the test continues to the next line.
|
||||||
// TODO(b/239834928): once coroutines.test is updated, switch to the approach described in
|
// TODO(b/239834928): once coroutines.test is updated, switch to the approach described in
|
||||||
|
|||||||
@@ -122,8 +122,8 @@ class HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest : SysuiTes
|
|||||||
emptyList()
|
emptyList()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
val values = mutableListOf<KeyguardQuickAffordanceConfig.State>()
|
val values = mutableListOf<KeyguardQuickAffordanceConfig.LockScreenState>()
|
||||||
val job = underTest.state.onEach(values::add).launchIn(this)
|
val job = underTest.lockScreenState.onEach(values::add).launchIn(this)
|
||||||
|
|
||||||
if (canShowWhileLocked) {
|
if (canShowWhileLocked) {
|
||||||
verify(controlsListingController).addCallback(callbackCaptor.capture())
|
verify(controlsListingController).addCallback(callbackCaptor.capture())
|
||||||
@@ -139,9 +139,9 @@ class HomeControlsKeyguardQuickAffordanceConfigParameterizedStateTest : SysuiTes
|
|||||||
assertThat(values.last())
|
assertThat(values.last())
|
||||||
.isInstanceOf(
|
.isInstanceOf(
|
||||||
if (isVisibleExpected) {
|
if (isVisibleExpected) {
|
||||||
KeyguardQuickAffordanceConfig.State.Visible::class.java
|
KeyguardQuickAffordanceConfig.LockScreenState.Visible::class.java
|
||||||
} else {
|
} else {
|
||||||
KeyguardQuickAffordanceConfig.State.Hidden::class.java
|
KeyguardQuickAffordanceConfig.LockScreenState.Hidden::class.java
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
job.cancel()
|
job.cancel()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import com.android.systemui.SysuiTestCase
|
|||||||
import com.android.systemui.animation.Expandable
|
import com.android.systemui.animation.Expandable
|
||||||
import com.android.systemui.controls.controller.ControlsController
|
import com.android.systemui.controls.controller.ControlsController
|
||||||
import com.android.systemui.controls.dagger.ControlsComponent
|
import com.android.systemui.controls.dagger.ControlsComponent
|
||||||
import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig.OnClickedResult
|
import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig.OnTriggeredResult
|
||||||
import com.android.systemui.util.mockito.mock
|
import com.android.systemui.util.mockito.mock
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import java.util.Optional
|
import java.util.Optional
|
||||||
@@ -72,11 +72,11 @@ class HomeControlsKeyguardQuickAffordanceConfigTest : SysuiTestCase() {
|
|||||||
whenever(component.getVisibility()).thenReturn(ControlsComponent.Visibility.AVAILABLE)
|
whenever(component.getVisibility()).thenReturn(ControlsComponent.Visibility.AVAILABLE)
|
||||||
whenever(controlsController.getFavorites()).thenReturn(listOf(mock()))
|
whenever(controlsController.getFavorites()).thenReturn(listOf(mock()))
|
||||||
|
|
||||||
val values = mutableListOf<KeyguardQuickAffordanceConfig.State>()
|
val values = mutableListOf<KeyguardQuickAffordanceConfig.LockScreenState>()
|
||||||
val job = underTest.state.onEach(values::add).launchIn(this)
|
val job = underTest.lockScreenState.onEach(values::add).launchIn(this)
|
||||||
|
|
||||||
assertThat(values.last())
|
assertThat(values.last())
|
||||||
.isInstanceOf(KeyguardQuickAffordanceConfig.State.Hidden::class.java)
|
.isInstanceOf(KeyguardQuickAffordanceConfig.LockScreenState.Hidden::class.java)
|
||||||
job.cancel()
|
job.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,31 +91,32 @@ class HomeControlsKeyguardQuickAffordanceConfigTest : SysuiTestCase() {
|
|||||||
whenever(component.getVisibility()).thenReturn(ControlsComponent.Visibility.AVAILABLE)
|
whenever(component.getVisibility()).thenReturn(ControlsComponent.Visibility.AVAILABLE)
|
||||||
whenever(controlsController.getFavorites()).thenReturn(listOf(mock()))
|
whenever(controlsController.getFavorites()).thenReturn(listOf(mock()))
|
||||||
|
|
||||||
val values = mutableListOf<KeyguardQuickAffordanceConfig.State>()
|
val values = mutableListOf<KeyguardQuickAffordanceConfig.LockScreenState>()
|
||||||
val job = underTest.state.onEach(values::add).launchIn(this)
|
val job = underTest.lockScreenState.onEach(values::add).launchIn(this)
|
||||||
|
|
||||||
assertThat(values.last())
|
assertThat(values.last())
|
||||||
.isInstanceOf(KeyguardQuickAffordanceConfig.State.Hidden::class.java)
|
.isInstanceOf(KeyguardQuickAffordanceConfig.LockScreenState.Hidden::class.java)
|
||||||
job.cancel()
|
job.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `onQuickAffordanceClicked - canShowWhileLockedSetting is true`() = runBlockingTest {
|
fun `onQuickAffordanceTriggered - canShowWhileLockedSetting is true`() = runBlockingTest {
|
||||||
whenever(component.canShowWhileLockedSetting).thenReturn(MutableStateFlow(true))
|
whenever(component.canShowWhileLockedSetting).thenReturn(MutableStateFlow(true))
|
||||||
|
|
||||||
val onClickedResult = underTest.onQuickAffordanceClicked(expandable)
|
val onClickedResult = underTest.onTriggered(expandable)
|
||||||
|
|
||||||
assertThat(onClickedResult).isInstanceOf(OnClickedResult.StartActivity::class.java)
|
assertThat(onClickedResult).isInstanceOf(OnTriggeredResult.StartActivity::class.java)
|
||||||
assertThat((onClickedResult as OnClickedResult.StartActivity).canShowWhileLocked).isTrue()
|
assertThat((onClickedResult as OnTriggeredResult.StartActivity).canShowWhileLocked).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `onQuickAffordanceClicked - canShowWhileLockedSetting is false`() = runBlockingTest {
|
fun `onQuickAffordanceTriggered - canShowWhileLockedSetting is false`() = runBlockingTest {
|
||||||
whenever(component.canShowWhileLockedSetting).thenReturn(MutableStateFlow(false))
|
whenever(component.canShowWhileLockedSetting).thenReturn(MutableStateFlow(false))
|
||||||
|
|
||||||
val onClickedResult = underTest.onQuickAffordanceClicked(expandable)
|
val onClickedResult = underTest.onTriggered(expandable)
|
||||||
|
|
||||||
assertThat(onClickedResult).isInstanceOf(OnClickedResult.StartActivity::class.java)
|
assertThat(onClickedResult).isInstanceOf(OnTriggeredResult.StartActivity::class.java)
|
||||||
assertThat((onClickedResult as OnClickedResult.StartActivity).canShowWhileLocked).isFalse()
|
assertThat((onClickedResult as OnTriggeredResult.StartActivity).canShowWhileLocked)
|
||||||
|
.isFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ package com.android.systemui.keyguard.data.quickaffordance
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
import com.android.systemui.SysuiTestCase
|
import com.android.systemui.SysuiTestCase
|
||||||
import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig.OnClickedResult
|
import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceConfig.OnTriggeredResult
|
||||||
import com.android.systemui.qrcodescanner.controller.QRCodeScannerController
|
import com.android.systemui.qrcodescanner.controller.QRCodeScannerController
|
||||||
import com.android.systemui.util.mockito.argumentCaptor
|
import com.android.systemui.util.mockito.argumentCaptor
|
||||||
import com.android.systemui.util.mockito.mock
|
import com.android.systemui.util.mockito.mock
|
||||||
@@ -56,9 +56,9 @@ class QrCodeScannerKeyguardQuickAffordanceConfigTest : SysuiTestCase() {
|
|||||||
@Test
|
@Test
|
||||||
fun `affordance - sets up registration and delivers initial model`() = runBlockingTest {
|
fun `affordance - sets up registration and delivers initial model`() = runBlockingTest {
|
||||||
whenever(controller.isEnabledForLockScreenButton).thenReturn(true)
|
whenever(controller.isEnabledForLockScreenButton).thenReturn(true)
|
||||||
var latest: KeyguardQuickAffordanceConfig.State? = null
|
var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null
|
||||||
|
|
||||||
val job = underTest.state.onEach { latest = it }.launchIn(this)
|
val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this)
|
||||||
|
|
||||||
val callbackCaptor = argumentCaptor<QRCodeScannerController.Callback>()
|
val callbackCaptor = argumentCaptor<QRCodeScannerController.Callback>()
|
||||||
verify(controller).addCallback(callbackCaptor.capture())
|
verify(controller).addCallback(callbackCaptor.capture())
|
||||||
@@ -77,8 +77,8 @@ class QrCodeScannerKeyguardQuickAffordanceConfigTest : SysuiTestCase() {
|
|||||||
fun `affordance - scanner activity changed - delivers model with updated intent`() =
|
fun `affordance - scanner activity changed - delivers model with updated intent`() =
|
||||||
runBlockingTest {
|
runBlockingTest {
|
||||||
whenever(controller.isEnabledForLockScreenButton).thenReturn(true)
|
whenever(controller.isEnabledForLockScreenButton).thenReturn(true)
|
||||||
var latest: KeyguardQuickAffordanceConfig.State? = null
|
var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null
|
||||||
val job = underTest.state.onEach { latest = it }.launchIn(this)
|
val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this)
|
||||||
val callbackCaptor = argumentCaptor<QRCodeScannerController.Callback>()
|
val callbackCaptor = argumentCaptor<QRCodeScannerController.Callback>()
|
||||||
verify(controller).addCallback(callbackCaptor.capture())
|
verify(controller).addCallback(callbackCaptor.capture())
|
||||||
|
|
||||||
@@ -93,8 +93,8 @@ class QrCodeScannerKeyguardQuickAffordanceConfigTest : SysuiTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `affordance - scanner preference changed - delivers visible model`() = runBlockingTest {
|
fun `affordance - scanner preference changed - delivers visible model`() = runBlockingTest {
|
||||||
var latest: KeyguardQuickAffordanceConfig.State? = null
|
var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null
|
||||||
val job = underTest.state.onEach { latest = it }.launchIn(this)
|
val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this)
|
||||||
val callbackCaptor = argumentCaptor<QRCodeScannerController.Callback>()
|
val callbackCaptor = argumentCaptor<QRCodeScannerController.Callback>()
|
||||||
verify(controller).addCallback(callbackCaptor.capture())
|
verify(controller).addCallback(callbackCaptor.capture())
|
||||||
|
|
||||||
@@ -109,34 +109,35 @@ class QrCodeScannerKeyguardQuickAffordanceConfigTest : SysuiTestCase() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `affordance - scanner preference changed - delivers none`() = runBlockingTest {
|
fun `affordance - scanner preference changed - delivers none`() = runBlockingTest {
|
||||||
var latest: KeyguardQuickAffordanceConfig.State? = null
|
var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null
|
||||||
val job = underTest.state.onEach { latest = it }.launchIn(this)
|
val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this)
|
||||||
val callbackCaptor = argumentCaptor<QRCodeScannerController.Callback>()
|
val callbackCaptor = argumentCaptor<QRCodeScannerController.Callback>()
|
||||||
verify(controller).addCallback(callbackCaptor.capture())
|
verify(controller).addCallback(callbackCaptor.capture())
|
||||||
|
|
||||||
whenever(controller.isEnabledForLockScreenButton).thenReturn(false)
|
whenever(controller.isEnabledForLockScreenButton).thenReturn(false)
|
||||||
callbackCaptor.value.onQRCodeScannerPreferenceChanged()
|
callbackCaptor.value.onQRCodeScannerPreferenceChanged()
|
||||||
|
|
||||||
assertThat(latest).isEqualTo(KeyguardQuickAffordanceConfig.State.Hidden)
|
assertThat(latest).isEqualTo(KeyguardQuickAffordanceConfig.LockScreenState.Hidden)
|
||||||
|
|
||||||
job.cancel()
|
job.cancel()
|
||||||
verify(controller).removeCallback(callbackCaptor.value)
|
verify(controller).removeCallback(callbackCaptor.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onQuickAffordanceClicked() {
|
fun onQuickAffordanceTriggered() {
|
||||||
assertThat(underTest.onQuickAffordanceClicked(mock()))
|
assertThat(underTest.onTriggered(mock()))
|
||||||
.isEqualTo(
|
.isEqualTo(
|
||||||
OnClickedResult.StartActivity(
|
OnTriggeredResult.StartActivity(
|
||||||
intent = INTENT_1,
|
intent = INTENT_1,
|
||||||
canShowWhileLocked = true,
|
canShowWhileLocked = true,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun assertVisibleState(latest: KeyguardQuickAffordanceConfig.State?) {
|
private fun assertVisibleState(latest: KeyguardQuickAffordanceConfig.LockScreenState?) {
|
||||||
assertThat(latest).isInstanceOf(KeyguardQuickAffordanceConfig.State.Visible::class.java)
|
assertThat(latest)
|
||||||
val visibleState = latest as KeyguardQuickAffordanceConfig.State.Visible
|
.isInstanceOf(KeyguardQuickAffordanceConfig.LockScreenState.Visible::class.java)
|
||||||
|
val visibleState = latest as KeyguardQuickAffordanceConfig.LockScreenState.Visible
|
||||||
assertThat(visibleState.icon).isNotNull()
|
assertThat(visibleState.icon).isNotNull()
|
||||||
assertThat(visibleState.icon.contentDescription).isNotNull()
|
assertThat(visibleState.icon.contentDescription).isNotNull()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,11 +67,11 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() {
|
|||||||
@Test
|
@Test
|
||||||
fun `affordance - keyguard showing - has wallet card - visible model`() = runBlockingTest {
|
fun `affordance - keyguard showing - has wallet card - visible model`() = runBlockingTest {
|
||||||
setUpState()
|
setUpState()
|
||||||
var latest: KeyguardQuickAffordanceConfig.State? = null
|
var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null
|
||||||
|
|
||||||
val job = underTest.state.onEach { latest = it }.launchIn(this)
|
val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this)
|
||||||
|
|
||||||
val visibleModel = latest as KeyguardQuickAffordanceConfig.State.Visible
|
val visibleModel = latest as KeyguardQuickAffordanceConfig.LockScreenState.Visible
|
||||||
assertThat(visibleModel.icon)
|
assertThat(visibleModel.icon)
|
||||||
.isEqualTo(
|
.isEqualTo(
|
||||||
Icon.Loaded(
|
Icon.Loaded(
|
||||||
@@ -88,11 +88,11 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() {
|
|||||||
@Test
|
@Test
|
||||||
fun `affordance - wallet not enabled - model is none`() = runBlockingTest {
|
fun `affordance - wallet not enabled - model is none`() = runBlockingTest {
|
||||||
setUpState(isWalletEnabled = false)
|
setUpState(isWalletEnabled = false)
|
||||||
var latest: KeyguardQuickAffordanceConfig.State? = null
|
var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null
|
||||||
|
|
||||||
val job = underTest.state.onEach { latest = it }.launchIn(this)
|
val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this)
|
||||||
|
|
||||||
assertThat(latest).isEqualTo(KeyguardQuickAffordanceConfig.State.Hidden)
|
assertThat(latest).isEqualTo(KeyguardQuickAffordanceConfig.LockScreenState.Hidden)
|
||||||
|
|
||||||
job.cancel()
|
job.cancel()
|
||||||
}
|
}
|
||||||
@@ -100,11 +100,11 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() {
|
|||||||
@Test
|
@Test
|
||||||
fun `affordance - query not successful - model is none`() = runBlockingTest {
|
fun `affordance - query not successful - model is none`() = runBlockingTest {
|
||||||
setUpState(isWalletQuerySuccessful = false)
|
setUpState(isWalletQuerySuccessful = false)
|
||||||
var latest: KeyguardQuickAffordanceConfig.State? = null
|
var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null
|
||||||
|
|
||||||
val job = underTest.state.onEach { latest = it }.launchIn(this)
|
val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this)
|
||||||
|
|
||||||
assertThat(latest).isEqualTo(KeyguardQuickAffordanceConfig.State.Hidden)
|
assertThat(latest).isEqualTo(KeyguardQuickAffordanceConfig.LockScreenState.Hidden)
|
||||||
|
|
||||||
job.cancel()
|
job.cancel()
|
||||||
}
|
}
|
||||||
@@ -112,11 +112,11 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() {
|
|||||||
@Test
|
@Test
|
||||||
fun `affordance - missing icon - model is none`() = runBlockingTest {
|
fun `affordance - missing icon - model is none`() = runBlockingTest {
|
||||||
setUpState(hasWalletIcon = false)
|
setUpState(hasWalletIcon = false)
|
||||||
var latest: KeyguardQuickAffordanceConfig.State? = null
|
var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null
|
||||||
|
|
||||||
val job = underTest.state.onEach { latest = it }.launchIn(this)
|
val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this)
|
||||||
|
|
||||||
assertThat(latest).isEqualTo(KeyguardQuickAffordanceConfig.State.Hidden)
|
assertThat(latest).isEqualTo(KeyguardQuickAffordanceConfig.LockScreenState.Hidden)
|
||||||
|
|
||||||
job.cancel()
|
job.cancel()
|
||||||
}
|
}
|
||||||
@@ -124,24 +124,24 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() {
|
|||||||
@Test
|
@Test
|
||||||
fun `affordance - no selected card - model is none`() = runBlockingTest {
|
fun `affordance - no selected card - model is none`() = runBlockingTest {
|
||||||
setUpState(hasWalletIcon = false)
|
setUpState(hasWalletIcon = false)
|
||||||
var latest: KeyguardQuickAffordanceConfig.State? = null
|
var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null
|
||||||
|
|
||||||
val job = underTest.state.onEach { latest = it }.launchIn(this)
|
val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this)
|
||||||
|
|
||||||
assertThat(latest).isEqualTo(KeyguardQuickAffordanceConfig.State.Hidden)
|
assertThat(latest).isEqualTo(KeyguardQuickAffordanceConfig.LockScreenState.Hidden)
|
||||||
|
|
||||||
job.cancel()
|
job.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onQuickAffordanceClicked() {
|
fun onQuickAffordanceTriggered() {
|
||||||
val animationController: ActivityLaunchAnimator.Controller = mock()
|
val animationController: ActivityLaunchAnimator.Controller = mock()
|
||||||
val expandable: Expandable = mock {
|
val expandable: Expandable = mock {
|
||||||
whenever(this.activityLaunchController()).thenReturn(animationController)
|
whenever(this.activityLaunchController()).thenReturn(animationController)
|
||||||
}
|
}
|
||||||
|
|
||||||
assertThat(underTest.onQuickAffordanceClicked(expandable))
|
assertThat(underTest.onTriggered(expandable))
|
||||||
.isEqualTo(KeyguardQuickAffordanceConfig.OnClickedResult.Handled)
|
.isEqualTo(KeyguardQuickAffordanceConfig.OnTriggeredResult.Handled)
|
||||||
verify(walletController)
|
verify(walletController)
|
||||||
.startQuickAccessUiIntent(
|
.startQuickAccessUiIntent(
|
||||||
activityStarter,
|
activityStarter,
|
||||||
|
|||||||
@@ -248,29 +248,29 @@ class KeyguardQuickAffordanceInteractorParameterizedTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun onQuickAffordanceClicked() = runBlockingTest {
|
fun onQuickAffordanceTriggered() = runBlockingTest {
|
||||||
setUpMocks(
|
setUpMocks(
|
||||||
needStrongAuthAfterBoot = needStrongAuthAfterBoot,
|
needStrongAuthAfterBoot = needStrongAuthAfterBoot,
|
||||||
keyguardIsUnlocked = keyguardIsUnlocked,
|
keyguardIsUnlocked = keyguardIsUnlocked,
|
||||||
)
|
)
|
||||||
|
|
||||||
homeControls.setState(
|
homeControls.setState(
|
||||||
state =
|
lockScreenState =
|
||||||
KeyguardQuickAffordanceConfig.State.Visible(
|
KeyguardQuickAffordanceConfig.LockScreenState.Visible(
|
||||||
icon = DRAWABLE,
|
icon = DRAWABLE,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
homeControls.onClickedResult =
|
homeControls.onTriggeredResult =
|
||||||
if (startActivity) {
|
if (startActivity) {
|
||||||
KeyguardQuickAffordanceConfig.OnClickedResult.StartActivity(
|
KeyguardQuickAffordanceConfig.OnTriggeredResult.StartActivity(
|
||||||
intent = INTENT,
|
intent = INTENT,
|
||||||
canShowWhileLocked = canShowWhileLocked,
|
canShowWhileLocked = canShowWhileLocked,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
KeyguardQuickAffordanceConfig.OnClickedResult.Handled
|
KeyguardQuickAffordanceConfig.OnTriggeredResult.Handled
|
||||||
}
|
}
|
||||||
|
|
||||||
underTest.onQuickAffordanceClicked(
|
underTest.onQuickAffordanceTriggered(
|
||||||
configKey = BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS,
|
configKey = BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS,
|
||||||
expandable = expandable,
|
expandable = expandable,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanc
|
|||||||
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
|
import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository
|
||||||
import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordanceModel
|
import com.android.systemui.keyguard.domain.model.KeyguardQuickAffordanceModel
|
||||||
import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceRegistry
|
import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceRegistry
|
||||||
|
import com.android.systemui.keyguard.shared.quickaffordance.ActivationState
|
||||||
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition
|
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition
|
||||||
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordanceToggleState
|
|
||||||
import com.android.systemui.plugins.ActivityStarter
|
import com.android.systemui.plugins.ActivityStarter
|
||||||
import com.android.systemui.settings.UserTracker
|
import com.android.systemui.settings.UserTracker
|
||||||
import com.android.systemui.statusbar.policy.KeyguardStateController
|
import com.android.systemui.statusbar.policy.KeyguardStateController
|
||||||
@@ -114,9 +114,9 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
|
|||||||
fun `quickAffordance - bottom start affordance is visible`() = runBlockingTest {
|
fun `quickAffordance - bottom start affordance is visible`() = runBlockingTest {
|
||||||
val configKey = BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS
|
val configKey = BuiltInKeyguardQuickAffordanceKeys.HOME_CONTROLS
|
||||||
homeControls.setState(
|
homeControls.setState(
|
||||||
KeyguardQuickAffordanceConfig.State.Visible(
|
KeyguardQuickAffordanceConfig.LockScreenState.Visible(
|
||||||
icon = ICON,
|
icon = ICON,
|
||||||
toggle = KeyguardQuickAffordanceToggleState.On,
|
activationState = ActivationState.Active,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
|
|||||||
assertThat(visibleModel.icon).isEqualTo(ICON)
|
assertThat(visibleModel.icon).isEqualTo(ICON)
|
||||||
assertThat(visibleModel.icon.contentDescription)
|
assertThat(visibleModel.icon.contentDescription)
|
||||||
.isEqualTo(ContentDescription.Resource(res = CONTENT_DESCRIPTION_RESOURCE_ID))
|
.isEqualTo(ContentDescription.Resource(res = CONTENT_DESCRIPTION_RESOURCE_ID))
|
||||||
assertThat(visibleModel.toggle).isEqualTo(KeyguardQuickAffordanceToggleState.On)
|
assertThat(visibleModel.activationState).isEqualTo(ActivationState.Active)
|
||||||
job.cancel()
|
job.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
|
|||||||
fun `quickAffordance - bottom end affordance is visible`() = runBlockingTest {
|
fun `quickAffordance - bottom end affordance is visible`() = runBlockingTest {
|
||||||
val configKey = BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET
|
val configKey = BuiltInKeyguardQuickAffordanceKeys.QUICK_ACCESS_WALLET
|
||||||
quickAccessWallet.setState(
|
quickAccessWallet.setState(
|
||||||
KeyguardQuickAffordanceConfig.State.Visible(
|
KeyguardQuickAffordanceConfig.LockScreenState.Visible(
|
||||||
icon = ICON,
|
icon = ICON,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -167,7 +167,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
|
|||||||
assertThat(visibleModel.icon).isEqualTo(ICON)
|
assertThat(visibleModel.icon).isEqualTo(ICON)
|
||||||
assertThat(visibleModel.icon.contentDescription)
|
assertThat(visibleModel.icon.contentDescription)
|
||||||
.isEqualTo(ContentDescription.Resource(res = CONTENT_DESCRIPTION_RESOURCE_ID))
|
.isEqualTo(ContentDescription.Resource(res = CONTENT_DESCRIPTION_RESOURCE_ID))
|
||||||
assertThat(visibleModel.toggle).isEqualTo(KeyguardQuickAffordanceToggleState.NotSupported)
|
assertThat(visibleModel.activationState).isEqualTo(ActivationState.NotSupported)
|
||||||
job.cancel()
|
job.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
|
|||||||
fun `quickAffordance - bottom start affordance hidden while dozing`() = runBlockingTest {
|
fun `quickAffordance - bottom start affordance hidden while dozing`() = runBlockingTest {
|
||||||
repository.setDozing(true)
|
repository.setDozing(true)
|
||||||
homeControls.setState(
|
homeControls.setState(
|
||||||
KeyguardQuickAffordanceConfig.State.Visible(
|
KeyguardQuickAffordanceConfig.LockScreenState.Visible(
|
||||||
icon = ICON,
|
icon = ICON,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -195,7 +195,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
|
|||||||
runBlockingTest {
|
runBlockingTest {
|
||||||
repository.setKeyguardShowing(false)
|
repository.setKeyguardShowing(false)
|
||||||
homeControls.setState(
|
homeControls.setState(
|
||||||
KeyguardQuickAffordanceConfig.State.Visible(
|
KeyguardQuickAffordanceConfig.LockScreenState.Visible(
|
||||||
icon = ICON,
|
icon = ICON,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardBottomAreaInterac
|
|||||||
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
|
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
|
||||||
import com.android.systemui.keyguard.domain.interactor.KeyguardQuickAffordanceInteractor
|
import com.android.systemui.keyguard.domain.interactor.KeyguardQuickAffordanceInteractor
|
||||||
import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceRegistry
|
import com.android.systemui.keyguard.domain.quickaffordance.FakeKeyguardQuickAffordanceRegistry
|
||||||
|
import com.android.systemui.keyguard.shared.quickaffordance.ActivationState
|
||||||
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition
|
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition
|
||||||
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordanceToggleState
|
|
||||||
import com.android.systemui.plugins.ActivityStarter
|
import com.android.systemui.plugins.ActivityStarter
|
||||||
import com.android.systemui.settings.UserTracker
|
import com.android.systemui.settings.UserTracker
|
||||||
import com.android.systemui.statusbar.policy.KeyguardStateController
|
import com.android.systemui.statusbar.policy.KeyguardStateController
|
||||||
@@ -508,28 +508,28 @@ class KeyguardBottomAreaViewModelTest : SysuiTestCase() {
|
|||||||
KeyguardQuickAffordancePosition.BOTTOM_END -> quickAccessWalletAffordanceConfig
|
KeyguardQuickAffordancePosition.BOTTOM_END -> quickAccessWalletAffordanceConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
val state =
|
val lockScreenState =
|
||||||
if (testConfig.isVisible) {
|
if (testConfig.isVisible) {
|
||||||
if (testConfig.intent != null) {
|
if (testConfig.intent != null) {
|
||||||
config.onClickedResult =
|
config.onTriggeredResult =
|
||||||
KeyguardQuickAffordanceConfig.OnClickedResult.StartActivity(
|
KeyguardQuickAffordanceConfig.OnTriggeredResult.StartActivity(
|
||||||
intent = testConfig.intent,
|
intent = testConfig.intent,
|
||||||
canShowWhileLocked = testConfig.canShowWhileLocked,
|
canShowWhileLocked = testConfig.canShowWhileLocked,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
KeyguardQuickAffordanceConfig.State.Visible(
|
KeyguardQuickAffordanceConfig.LockScreenState.Visible(
|
||||||
icon = testConfig.icon ?: error("Icon is unexpectedly null!"),
|
icon = testConfig.icon ?: error("Icon is unexpectedly null!"),
|
||||||
toggle =
|
activationState =
|
||||||
when (testConfig.isActivated) {
|
when (testConfig.isActivated) {
|
||||||
true -> KeyguardQuickAffordanceToggleState.On
|
true -> ActivationState.Active
|
||||||
false -> KeyguardQuickAffordanceToggleState.Off
|
false -> ActivationState.Inactive
|
||||||
null -> KeyguardQuickAffordanceToggleState.NotSupported
|
null -> ActivationState.NotSupported
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
KeyguardQuickAffordanceConfig.State.Hidden
|
KeyguardQuickAffordanceConfig.LockScreenState.Hidden
|
||||||
}
|
}
|
||||||
config.setState(state)
|
config.setState(lockScreenState)
|
||||||
return config.key
|
return config.key
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user