From f5cabd27ec4545e588e0c73df8fcafd38b47a9d1 Mon Sep 17 00:00:00 2001 From: menghanli Date: Tue, 4 Oct 2022 17:52:16 +0800 Subject: [PATCH] Use default accessibility notification sound be accessibility volume key shortcut ringtone. Root cause: The accessibility volume key shortcut plays notification ringtone would misleading the normal users to check notification list when hear this sound. Solution: Use the default accessibility notification sound instead to avoid users confusing the new notification received. Point to the default notification sound if the sound does not exist. Bug: 175879613 Test: Manual testing Change-Id: I5885dcaa5254b6334a95f756bf53b51186c555f5 --- .../AccessibilityShortcutController.java | 13 +++++++++++-- core/res/res/values/config.xml | 4 +++- core/res/res/values/symbols.xml | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java b/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java index bf55255a7f25a..ef255012b8707 100644 --- a/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java +++ b/core/java/com/android/internal/accessibility/AccessibilityShortcutController.java @@ -438,9 +438,18 @@ public class AccessibilityShortcutController { ? AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY : AudioAttributes.USAGE_NOTIFICATION_EVENT; + // Use the default accessibility notification sound instead to avoid users confusing the new + // notification received. Point to the default notification sound if the sound does not + // exist. + final Uri ringtoneUri = Uri.parse("file://" + + mContext.getString(R.string.config_defaultAccessibilityNotificationSound)); + Ringtone tone = mFrameworkObjectProvider.getRingtone(mContext, ringtoneUri); + if (tone == null) { + tone = mFrameworkObjectProvider.getRingtone(mContext, + Settings.System.DEFAULT_NOTIFICATION_URI); + } + // Play a notification tone - final Ringtone tone = mFrameworkObjectProvider.getRingtone(mContext, - Settings.System.DEFAULT_NOTIFICATION_URI); if (tone != null) { tone.setAudioAttributes(new AudioAttributes.Builder() .setUsage(audioAttributesUsage) diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index a4d6fdd280547..55f52c43ede01 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -4072,7 +4072,9 @@ exists on the device, the accessibility shortcut will be disabled by default. --> - + + +