summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ahmad Khalil <khalilahmad@google.com> 2023-04-13 16:11:44 +0000
committer Ahmad Khalil <khalilahmad@google.com> 2023-04-14 11:16:44 +0000
commit8718a48f25f1fd3b52775faa95ecc65c7eeeab2b (patch)
tree7f7482a52d9c7bdb34123aa12b7bbccc1e11649a
parent1e5933c1befabb4b18cb8dec8ff9f9ab74027239 (diff)
Add accessibility usage to screen OFF usage allowlist.
Fix: 277959670 Test: com.android.server.vibrator.VibrationSettingsTest Change-Id: I2134dd54dd5f3a2d8fb3097af87b67aff32a858b
-rw-r--r--services/core/java/com/android/server/vibrator/VibrationSettings.java1
-rw-r--r--services/tests/servicestests/src/com/android/server/vibrator/VibrationSettingsTest.java36
2 files changed, 28 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/vibrator/VibrationSettings.java b/services/core/java/com/android/server/vibrator/VibrationSettings.java
index 1ab7f362808a..9cf08340f613 100644
--- a/services/core/java/com/android/server/vibrator/VibrationSettings.java
+++ b/services/core/java/com/android/server/vibrator/VibrationSettings.java
@@ -124,6 +124,7 @@ final class VibrationSettings {
private static final Set<Integer> SYSTEM_VIBRATION_SCREEN_OFF_USAGE_ALLOWLIST = new HashSet<>(
Arrays.asList(
USAGE_TOUCH,
+ USAGE_ACCESSIBILITY,
USAGE_PHYSICAL_EMULATION,
USAGE_HARDWARE_FEEDBACK));
diff --git a/services/tests/servicestests/src/com/android/server/vibrator/VibrationSettingsTest.java b/services/tests/servicestests/src/com/android/server/vibrator/VibrationSettingsTest.java
index d50aca94e06b..2efd9fcf5f9c 100644
--- a/services/tests/servicestests/src/com/android/server/vibrator/VibrationSettingsTest.java
+++ b/services/tests/servicestests/src/com/android/server/vibrator/VibrationSettingsTest.java
@@ -618,13 +618,19 @@ public class VibrationSettingsTest {
}
@Test
- public void shouldCancelVibrationOnScreenOff_withUidZero_returnsFalseForTouchAndHardware() {
+ public void shouldCancelVibrationOnScreenOff_withUidZero_returnsFalseForUsagesInAllowlist() {
long vibrateStartTime = 100;
mockGoToSleep(vibrateStartTime + 10, PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN);
+ Set<Integer> expectedAllowedVibrations = new HashSet<>(Arrays.asList(
+ USAGE_TOUCH,
+ USAGE_ACCESSIBILITY,
+ USAGE_PHYSICAL_EMULATION,
+ USAGE_HARDWARE_FEEDBACK
+ ));
+
for (int usage : ALL_USAGES) {
- if (usage == USAGE_TOUCH || usage == USAGE_HARDWARE_FEEDBACK
- || usage == USAGE_PHYSICAL_EMULATION) {
+ if (expectedAllowedVibrations.contains(usage)) {
assertFalse(mVibrationSettings.shouldCancelVibrationOnScreenOff(
createCallerInfo(/* uid= */ 0, "", usage), vibrateStartTime));
} else {
@@ -635,13 +641,19 @@ public class VibrationSettingsTest {
}
@Test
- public void shouldCancelVibrationOnScreenOff_withSystemUid_returnsFalseForTouchAndHardware() {
+ public void shouldCancelVibrationOnScreenOff_withSystemUid__returnsFalseForUsagesInAllowlist() {
long vibrateStartTime = 100;
mockGoToSleep(vibrateStartTime + 10, PowerManager.GO_TO_SLEEP_REASON_DEVICE_FOLD);
+ Set<Integer> expectedAllowedVibrations = new HashSet<>(Arrays.asList(
+ USAGE_TOUCH,
+ USAGE_ACCESSIBILITY,
+ USAGE_PHYSICAL_EMULATION,
+ USAGE_HARDWARE_FEEDBACK
+ ));
+
for (int usage : ALL_USAGES) {
- if (usage == USAGE_TOUCH || usage == USAGE_HARDWARE_FEEDBACK
- || usage == USAGE_PHYSICAL_EMULATION) {
+ if (expectedAllowedVibrations.contains(usage)) {
assertFalse(mVibrationSettings.shouldCancelVibrationOnScreenOff(
createCallerInfo(Process.SYSTEM_UID, "", usage), vibrateStartTime));
} else {
@@ -652,13 +664,19 @@ public class VibrationSettingsTest {
}
@Test
- public void shouldCancelVibrationOnScreenOff_withSysUiPkg_returnsFalseForTouchAndHardware() {
+ public void shouldCancelVibrationOnScreenOff_withSysUiPkg_returnsFalseForUsagesInAllowlist() {
long vibrateStartTime = 100;
mockGoToSleep(vibrateStartTime + 10, PowerManager.GO_TO_SLEEP_REASON_HDMI);
+ Set<Integer> expectedAllowedVibrations = new HashSet<>(Arrays.asList(
+ USAGE_TOUCH,
+ USAGE_ACCESSIBILITY,
+ USAGE_PHYSICAL_EMULATION,
+ USAGE_HARDWARE_FEEDBACK
+ ));
+
for (int usage : ALL_USAGES) {
- if (usage == USAGE_TOUCH || usage == USAGE_HARDWARE_FEEDBACK
- || usage == USAGE_PHYSICAL_EMULATION) {
+ if (expectedAllowedVibrations.contains(usage)) {
assertFalse(mVibrationSettings.shouldCancelVibrationOnScreenOff(
createCallerInfo(UID, SYSUI_PACKAGE_NAME, usage), vibrateStartTime));
} else {