summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author David Krska <krskad@google.com> 2024-07-09 13:14:39 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-07-09 13:14:39 +0000
commitdfe94e4ba578cfd9e6918a94e39f856e20e69d7f (patch)
tree691dcc307aa722cc45a4795bcd3e4a9ecd060e6e
parent0792d0dc0f37fd88ffae7c9d7b3b91e29556115c (diff)
parent280d6f4bf2814daffc48ec769b1a097e6ec72ff4 (diff)
Merge "Add a config allowing to disable notification accessibility events" into main
-rw-r--r--core/res/res/values/config.xml3
-rw-r--r--core/res/res/values/symbols.xml1
-rw-r--r--services/core/java/com/android/server/notification/NotificationAttentionHelper.java6
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/NotificationAttentionHelperTest.java30
4 files changed, 39 insertions, 1 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 4f0a836224f9..dc3d9355f148 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -533,6 +533,9 @@
<!-- If this is true, key chords can be used to take a screenshot on the device. -->
<bool name="config_enableScreenshotChord">true</bool>
+ <!-- If this is true, accessibility events on notifications are sent. -->
+ <bool name="config_enableNotificationAccessibilityEvents">true</bool>
+
<!-- If this is true, allow wake from theater mode when plugged in or unplugged. -->
<bool name="config_allowTheaterModeWakeFromUnplug">false</bool>
<!-- If this is true, allow wake from theater mode from gesture. -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 419a615d92ff..d25f59d7c488 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2006,6 +2006,7 @@
<java-symbol type="array" name="config_notificationFallbackVibeWaveform" />
<java-symbol type="bool" name="config_enableServerNotificationEffectsForAutomotive" />
<java-symbol type="bool" name="config_useAttentionLight" />
+ <java-symbol type="bool" name="config_enableNotificationAccessibilityEvents" />
<java-symbol type="bool" name="config_adaptive_sleep_available" />
<java-symbol type="bool" name="config_camera_autorotate"/>
<java-symbol type="bool" name="config_animateScreenLights" />
diff --git a/services/core/java/com/android/server/notification/NotificationAttentionHelper.java b/services/core/java/com/android/server/notification/NotificationAttentionHelper.java
index 614a0a59c691..5a9cf0326244 100644
--- a/services/core/java/com/android/server/notification/NotificationAttentionHelper.java
+++ b/services/core/java/com/android/server/notification/NotificationAttentionHelper.java
@@ -138,6 +138,7 @@ public final class NotificationAttentionHelper {
private final boolean mUseAttentionLight;
boolean mHasLight;
+ private final boolean mEnableNotificationAccessibilityEvents;
private final SettingsObserver mSettingsObserver;
@@ -190,6 +191,9 @@ public final class NotificationAttentionHelper {
mUseAttentionLight = resources.getBoolean(R.bool.config_useAttentionLight);
mHasLight =
resources.getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed);
+ mEnableNotificationAccessibilityEvents =
+ resources.getBoolean(
+ com.android.internal.R.bool.config_enableNotificationAccessibilityEvents);
// Don't start allowing notifications until the setup wizard has run once.
// After that, including subsequent boots, init with notifications turned on.
@@ -1030,7 +1034,7 @@ public final class NotificationAttentionHelper {
}
void sendAccessibilityEvent(NotificationRecord record) {
- if (!mAccessibilityManager.isEnabled()) {
+ if (!mAccessibilityManager.isEnabled() || !mEnableNotificationAccessibilityEvents) {
return;
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationAttentionHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationAttentionHelperTest.java
index 2233aa2eed0f..28a5db904bd9 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationAttentionHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationAttentionHelperTest.java
@@ -227,6 +227,8 @@ public class NotificationAttentionHelperTest extends UiServiceTestCase {
when(resources.getBoolean(R.bool.config_useAttentionLight)).thenReturn(true);
when(resources.getBoolean(
com.android.internal.R.bool.config_intrusiveNotificationLed)).thenReturn(true);
+ when(resources.getBoolean(R.bool.config_enableNotificationAccessibilityEvents))
+ .thenReturn(true);
when(getContext().getResources()).thenReturn(resources);
// TODO (b/291907312): remove feature flag
@@ -2830,6 +2832,34 @@ public class NotificationAttentionHelperTest extends UiServiceTestCase {
assertThat(r.getRankingTimeMs()).isEqualTo(r.getSbn().getPostTime());
}
+ @Test
+ public void testAccessibilityEventsEnabledInConfig() throws Exception {
+ Resources resources = spy(getContext().getResources());
+ when(resources.getBoolean(R.bool.config_enableNotificationAccessibilityEvents))
+ .thenReturn(true);
+ when(getContext().getResources()).thenReturn(resources);
+ initAttentionHelper(mTestFlagResolver);
+ NotificationRecord r = getBeepyNotification();
+
+ mAttentionHelper.buzzBeepBlinkLocked(r, DEFAULT_SIGNALS);
+
+ verify(mAccessibilityService).sendAccessibilityEvent(any(), anyInt());
+ }
+
+ @Test
+ public void testAccessibilityEventsDisabledInConfig() throws Exception {
+ Resources resources = spy(getContext().getResources());
+ when(resources.getBoolean(R.bool.config_enableNotificationAccessibilityEvents))
+ .thenReturn(false);
+ when(getContext().getResources()).thenReturn(resources);
+ initAttentionHelper(mTestFlagResolver);
+ NotificationRecord r = getBeepyNotification();
+
+ mAttentionHelper.buzzBeepBlinkLocked(r, DEFAULT_SIGNALS);
+
+ verify(mAccessibilityService, never()).sendAccessibilityEvent(any(), anyInt());
+ }
+
static class VibrateRepeatMatcher implements ArgumentMatcher<VibrationEffect> {
private final int mRepeatIndex;