Loading packages/SystemUI/multivalentTests/src/com/android/systemui/haptics/qs/QSLongPressEffectTest.kt +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.haptics.vibratorHelper import com.android.systemui.kosmos.testScope import com.android.systemui.log.core.FakeLogBuffer import com.android.systemui.qs.qsTileFactory import com.android.systemui.statusbar.policy.keyguardStateController import com.android.systemui.testKosmos Loading Loading @@ -72,6 +73,7 @@ class QSLongPressEffectTest : SysuiTestCase() { QSLongPressEffect( vibratorHelper, kosmos.keyguardStateController, FakeLogBuffer.Factory.create(), ) longPressEffect.callback = callback longPressEffect.qsTile = qsTile Loading packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt +30 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,9 @@ import com.android.systemui.animation.DelegateTransitionAnimatorController import com.android.systemui.animation.DialogCuj import com.android.systemui.animation.DialogTransitionAnimator import com.android.systemui.animation.Expandable import com.android.systemui.log.LogBuffer import com.android.systemui.log.core.LogLevel import com.android.systemui.log.dagger.QSLog import com.android.systemui.plugins.qs.QSTile import com.android.systemui.statusbar.VibratorHelper import com.android.systemui.statusbar.policy.KeyguardStateController Loading @@ -47,6 +50,7 @@ class QSLongPressEffect constructor( private val vibratorHelper: VibratorHelper?, private val keyguardStateController: KeyguardStateController, @QSLog private val logBuffer: LogBuffer, ) { var effectDuration = 0 Loading Loading @@ -101,6 +105,7 @@ constructor( } fun handleActionDown() { logEvent(qsTile?.tileSpec, state, "action down received") when (state) { State.IDLE -> { setState(State.TIMEOUT_WAIT) Loading @@ -112,6 +117,7 @@ constructor( } fun handleActionUp() { logEvent(qsTile?.tileSpec, state, "action up received") if (state == State.RUNNING_FORWARD) { setState(State.RUNNING_BACKWARDS_FROM_UP) callback?.onReverseAnimator() Loading @@ -130,6 +136,7 @@ constructor( } fun handleAnimationStart() { logEvent(qsTile?.tileSpec, state, "animation started") if (state == State.TIMEOUT_WAIT) { vibrate(longPressHint) setState(State.RUNNING_FORWARD) Loading @@ -138,6 +145,7 @@ constructor( /** This function is called both when an animator completes or gets cancelled */ fun handleAnimationComplete() { logEvent(qsTile?.tileSpec, state, "animation completed") when (state) { State.RUNNING_FORWARD -> { vibrate(snapEffect) Loading @@ -147,11 +155,13 @@ constructor( callback?.onResetProperties() setState(State.IDLE) } logEvent(qsTile?.tileSpec, state, "long click action triggered") qsTile?.longClick(expandable) } State.RUNNING_BACKWARDS_FROM_UP -> { callback?.onEffectFinishedReversing() setState(getStateForClick()) logEvent(qsTile?.tileSpec, state, "click action triggered") qsTile?.click(expandable) } State.RUNNING_BACKWARDS_FROM_CANCEL -> { Loading Loading @@ -179,6 +189,7 @@ constructor( if (keyguardStateController.isPrimaryBouncerShowing || !isStateClickable) return false setState(getStateForClick()) logEvent(qsTile?.tileSpec, state, "click action triggered") qsTile?.click(expandable) return true } Loading Loading @@ -273,6 +284,20 @@ constructor( return delegated } private fun logEvent(tileSpec: String?, state: State, event: String) { if (!DEBUG) return logBuffer.log( TAG, LogLevel.DEBUG, { str1 = tileSpec str2 = event str3 = state.name }, { "[long-press effect on $str1 tile] $str2 on state: $str3" } ) } enum class State { IDLE, /* The effect is idle waiting for touch input */ TIMEOUT_WAIT, /* The effect is waiting for a tap timeout period */ Loading Loading @@ -304,4 +329,9 @@ constructor( /** Cancel the effect animator */ fun onCancelAnimator() } companion object { private const val TAG = "QSLongPressEffect" private const val DEBUG = true } } packages/SystemUI/tests/utils/src/com/android/systemui/haptics/qs/QSLongPressEffectKosmos.kt +8 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,14 @@ package com.android.systemui.haptics.qs import com.android.systemui.haptics.vibratorHelper import com.android.systemui.kosmos.Kosmos import com.android.systemui.log.core.FakeLogBuffer import com.android.systemui.statusbar.policy.keyguardStateController val Kosmos.qsLongPressEffect by Kosmos.Fixture { QSLongPressEffect(vibratorHelper, keyguardStateController) } Kosmos.Fixture { QSLongPressEffect( vibratorHelper, keyguardStateController, FakeLogBuffer.Factory.create(), ) } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/haptics/qs/QSLongPressEffectTest.kt +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.haptics.vibratorHelper import com.android.systemui.kosmos.testScope import com.android.systemui.log.core.FakeLogBuffer import com.android.systemui.qs.qsTileFactory import com.android.systemui.statusbar.policy.keyguardStateController import com.android.systemui.testKosmos Loading Loading @@ -72,6 +73,7 @@ class QSLongPressEffectTest : SysuiTestCase() { QSLongPressEffect( vibratorHelper, kosmos.keyguardStateController, FakeLogBuffer.Factory.create(), ) longPressEffect.callback = callback longPressEffect.qsTile = qsTile Loading
packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt +30 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,9 @@ import com.android.systemui.animation.DelegateTransitionAnimatorController import com.android.systemui.animation.DialogCuj import com.android.systemui.animation.DialogTransitionAnimator import com.android.systemui.animation.Expandable import com.android.systemui.log.LogBuffer import com.android.systemui.log.core.LogLevel import com.android.systemui.log.dagger.QSLog import com.android.systemui.plugins.qs.QSTile import com.android.systemui.statusbar.VibratorHelper import com.android.systemui.statusbar.policy.KeyguardStateController Loading @@ -47,6 +50,7 @@ class QSLongPressEffect constructor( private val vibratorHelper: VibratorHelper?, private val keyguardStateController: KeyguardStateController, @QSLog private val logBuffer: LogBuffer, ) { var effectDuration = 0 Loading Loading @@ -101,6 +105,7 @@ constructor( } fun handleActionDown() { logEvent(qsTile?.tileSpec, state, "action down received") when (state) { State.IDLE -> { setState(State.TIMEOUT_WAIT) Loading @@ -112,6 +117,7 @@ constructor( } fun handleActionUp() { logEvent(qsTile?.tileSpec, state, "action up received") if (state == State.RUNNING_FORWARD) { setState(State.RUNNING_BACKWARDS_FROM_UP) callback?.onReverseAnimator() Loading @@ -130,6 +136,7 @@ constructor( } fun handleAnimationStart() { logEvent(qsTile?.tileSpec, state, "animation started") if (state == State.TIMEOUT_WAIT) { vibrate(longPressHint) setState(State.RUNNING_FORWARD) Loading @@ -138,6 +145,7 @@ constructor( /** This function is called both when an animator completes or gets cancelled */ fun handleAnimationComplete() { logEvent(qsTile?.tileSpec, state, "animation completed") when (state) { State.RUNNING_FORWARD -> { vibrate(snapEffect) Loading @@ -147,11 +155,13 @@ constructor( callback?.onResetProperties() setState(State.IDLE) } logEvent(qsTile?.tileSpec, state, "long click action triggered") qsTile?.longClick(expandable) } State.RUNNING_BACKWARDS_FROM_UP -> { callback?.onEffectFinishedReversing() setState(getStateForClick()) logEvent(qsTile?.tileSpec, state, "click action triggered") qsTile?.click(expandable) } State.RUNNING_BACKWARDS_FROM_CANCEL -> { Loading Loading @@ -179,6 +189,7 @@ constructor( if (keyguardStateController.isPrimaryBouncerShowing || !isStateClickable) return false setState(getStateForClick()) logEvent(qsTile?.tileSpec, state, "click action triggered") qsTile?.click(expandable) return true } Loading Loading @@ -273,6 +284,20 @@ constructor( return delegated } private fun logEvent(tileSpec: String?, state: State, event: String) { if (!DEBUG) return logBuffer.log( TAG, LogLevel.DEBUG, { str1 = tileSpec str2 = event str3 = state.name }, { "[long-press effect on $str1 tile] $str2 on state: $str3" } ) } enum class State { IDLE, /* The effect is idle waiting for touch input */ TIMEOUT_WAIT, /* The effect is waiting for a tap timeout period */ Loading Loading @@ -304,4 +329,9 @@ constructor( /** Cancel the effect animator */ fun onCancelAnimator() } companion object { private const val TAG = "QSLongPressEffect" private const val DEBUG = true } }
packages/SystemUI/tests/utils/src/com/android/systemui/haptics/qs/QSLongPressEffectKosmos.kt +8 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,14 @@ package com.android.systemui.haptics.qs import com.android.systemui.haptics.vibratorHelper import com.android.systemui.kosmos.Kosmos import com.android.systemui.log.core.FakeLogBuffer import com.android.systemui.statusbar.policy.keyguardStateController val Kosmos.qsLongPressEffect by Kosmos.Fixture { QSLongPressEffect(vibratorHelper, keyguardStateController) } Kosmos.Fixture { QSLongPressEffect( vibratorHelper, keyguardStateController, FakeLogBuffer.Factory.create(), ) }