Changed VibrationAttributes of Unfold Haptics
There was feedback that the haptic when unfolding was too subtle, so we are increasing the strength to make it more prominent. In this change, USAGE_HARDWARE_FEEDBACK was added as a VibrationAttribute for the unfold haptics. Previously, when no VibrationAttributes were specified, it defaulted to USAGE_UNKNOWN, which meant that the haptics were controlled by the 'Media Vibration' user setting slider. By associating it with USAGE_HARDWARE_FEEDBACK, the haptics will now be controlled by the 'Touch Feedback' user setting slider. Test: UnfoldHapticsPlayerTest Bug: 281642496 Relevant Logs: https://paste.googleplex.com/6294954983817216 Change-Id: I3241a924bf843e590e7d947b5375cd69cda73139
This commit is contained in:
committed by
Shivangi Dubey
parent
7c0f7188a9
commit
7115464557
@@ -1,6 +1,7 @@
|
||||
package com.android.systemui.unfold
|
||||
|
||||
import android.os.SystemProperties
|
||||
import android.os.VibrationAttributes
|
||||
import android.os.VibrationEffect
|
||||
import android.os.Vibrator
|
||||
import com.android.systemui.dagger.qualifiers.Main
|
||||
@@ -22,6 +23,8 @@ constructor(
|
||||
) : TransitionProgressListener {
|
||||
|
||||
private var isFirstAnimationAfterUnfold = false
|
||||
private val touchVibrationAttributes =
|
||||
VibrationAttributes.createForUsage(VibrationAttributes.USAGE_HARDWARE_FEEDBACK)
|
||||
|
||||
init {
|
||||
if (vibrator != null) {
|
||||
@@ -71,7 +74,7 @@ constructor(
|
||||
}
|
||||
|
||||
private fun playHaptics() {
|
||||
vibrator?.vibrate(effect)
|
||||
vibrator?.vibrate(effect, touchVibrationAttributes)
|
||||
}
|
||||
|
||||
private val hapticsScale: Float
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.android.systemui.unfold
|
||||
|
||||
import android.os.VibrationAttributes
|
||||
import android.os.VibrationEffect
|
||||
import android.os.Vibrator
|
||||
import android.testing.AndroidTestingRunner
|
||||
@@ -54,7 +55,7 @@ class UnfoldHapticsPlayerTest : SysuiTestCase() {
|
||||
progressProvider.onTransitionProgress(0.5f)
|
||||
progressProvider.onTransitionFinishing()
|
||||
|
||||
verify(vibrator).vibrate(any<VibrationEffect>())
|
||||
verify(vibrator).vibrate(any<VibrationEffect>(), any<VibrationAttributes>())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,7 +66,7 @@ class UnfoldHapticsPlayerTest : SysuiTestCase() {
|
||||
progressProvider.onTransitionProgress(0.99f)
|
||||
progressProvider.onTransitionFinishing()
|
||||
|
||||
verify(vibrator, never()).vibrate(any<VibrationEffect>())
|
||||
verify(vibrator, never()).vibrate(any<VibrationEffect>(), any<VibrationAttributes>())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,7 +86,7 @@ class UnfoldHapticsPlayerTest : SysuiTestCase() {
|
||||
progressProvider.onTransitionFinished()
|
||||
testFoldProvider.onFoldUpdate(isFolded = true)
|
||||
|
||||
verify(vibrator, never()).vibrate(any<VibrationEffect>())
|
||||
verify(vibrator, never()).vibrate(any<VibrationEffect>(), any<VibrationAttributes>())
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,7 +114,7 @@ class UnfoldHapticsPlayerTest : SysuiTestCase() {
|
||||
progressProvider.onTransitionFinishing()
|
||||
progressProvider.onTransitionFinished()
|
||||
|
||||
verify(vibrator).vibrate(any<VibrationEffect>())
|
||||
verify(vibrator).vibrate(any<VibrationEffect>(), any<VibrationAttributes>())
|
||||
}
|
||||
|
||||
private class TestFoldProvider : FoldProvider {
|
||||
|
||||
Reference in New Issue
Block a user