Create a new config for attentional haptics OGG resource

Create a new hidden config with the URI of a OGG file that has only the
haptics channels and can be played for attentional haptics when sound is
muted (ringtone, notifications, alarms).

First usage introduced is to the Telecom project to be played on
RINGER_MODE_VIBRATE.

Also update Ringtone class to allow playback of haptic-only ringtones
(i.e. ringtones with unmutted haptic channels and volume set to zero on
devices with audio-coupled haptics support).

Bug: 182157749
Test: manual
Change-Id: Ic64d8d56c6b029e32b3d55389c416cee7679ddc8
This commit is contained in:
Lais Andrade
2021-04-20 18:13:12 +00:00
parent 1eb043a982
commit 852a203646
3 changed files with 10 additions and 3 deletions

View File

@@ -3898,6 +3898,9 @@
<!-- URI for in call notification sound -->
<string translatable="false" name="config_inCallNotificationSound">/product/media/audio/ui/InCallNotification.ogg</string>
<!-- URI for default ringtone sound file to be used for silent ringer vibration -->
<string translatable="false" name="config_defaultRingtoneVibrationSound">/product/media/audio/ui/AttentionalHaptics.ogg</string>
<!-- Default number of notifications from the same app before they are automatically grouped by the OS -->
<integer translatable="false" name="config_autoGroupAtCount">4</integer>

View File

@@ -3230,6 +3230,8 @@
<public name="config_systemCompanionDeviceProvider"/>
<!-- @hide @SystemApi -->
<public name="config_systemUi" />
<!-- @hide For use by platform and tools only. Developers should not specify this value. -->
<public name="config_defaultRingtoneVibrationSound"/>
</staging-public-group>
<staging-public-group type="id" first-id="0x01020055">

View File

@@ -405,9 +405,11 @@ public class Ringtone {
*/
public void play() {
if (mLocalPlayer != null) {
// do not play ringtones if stream volume is 0
// (typically because ringer mode is silent).
if (mAudioManager.getStreamVolume(
// Play ringtones if stream volume is over 0 or if it is a haptic-only ringtone
// (typically because ringer mode is vibrate).
boolean isHapticOnly = AudioManager.hasHapticChannels(mUri)
&& !mAudioAttributes.areHapticChannelsMuted() && mVolume == 0;
if (isHapticOnly || mAudioManager.getStreamVolume(
AudioAttributes.toLegacyStreamType(mAudioAttributes)) != 0) {
startLocalPlayer();
}