Loading media/java/android/media/RingtoneManager.java +17 −3 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; import java.util.Objects; /** * RingtoneManager provides access to ringtones, notification, and other types Loading Loading @@ -810,9 +811,7 @@ public class RingtoneManager { // Don't set the stream type Ringtone ringtone = getRingtone(context, ringtoneUri, -1 /* streamType */, volumeShaperConfig, false); if (Flags.enableRingtoneHapticsCustomization() && Utils.isRingtoneVibrationSettingsSupported(context) && Utils.hasVibration(ringtoneUri) && hasHapticChannels(ringtoneUri)) { if (muteHapticChannelForVibration(context, ringtoneUri)) { audioAttributes = new AudioAttributes.Builder( audioAttributes).setHapticChannelsMuted(true).build(); } Loading Loading @@ -1305,4 +1304,19 @@ public class RingtoneManager { default: throw new IllegalArgumentException(); } } private static boolean muteHapticChannelForVibration(Context context, Uri ringtoneUri) { final Uri vibrationUri = Utils.getVibrationUri(ringtoneUri); // No vibration is specified if (vibrationUri == null) { return false; } // The user specified the synchronized pattern if (Objects.equals(vibrationUri.toString(), Utils.SYNCHRONIZED_VIBRATION)) { return false; } return Flags.enableRingtoneHapticsCustomization() && Utils.isRingtoneVibrationSettingsSupported(context) && hasHapticChannels(ringtoneUri); } } media/java/android/media/Utils.java +4 −2 Original line number Diff line number Diff line Loading @@ -66,6 +66,8 @@ public class Utils { public static final String VIBRATION_URI_PARAM = "vibration_uri"; public static final String SYNCHRONIZED_VIBRATION = "synchronized"; /** * Sorts distinct (non-intersecting) range array in ascending order. * @throws java.lang.IllegalArgumentException if ranges are not distinct Loading Loading @@ -757,8 +759,8 @@ public class Utils { return null; } String filePath = vibrationUri.getPath(); if (filePath == null) { Log.w(TAG, "The file path is null."); if (filePath == null || filePath.equals(Utils.SYNCHRONIZED_VIBRATION)) { Log.w(TAG, "Ignore the vibration parsing for file:" + filePath); return null; } File vibrationFile = new File(filePath); Loading Loading
media/java/android/media/RingtoneManager.java +17 −3 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; import java.util.Objects; /** * RingtoneManager provides access to ringtones, notification, and other types Loading Loading @@ -810,9 +811,7 @@ public class RingtoneManager { // Don't set the stream type Ringtone ringtone = getRingtone(context, ringtoneUri, -1 /* streamType */, volumeShaperConfig, false); if (Flags.enableRingtoneHapticsCustomization() && Utils.isRingtoneVibrationSettingsSupported(context) && Utils.hasVibration(ringtoneUri) && hasHapticChannels(ringtoneUri)) { if (muteHapticChannelForVibration(context, ringtoneUri)) { audioAttributes = new AudioAttributes.Builder( audioAttributes).setHapticChannelsMuted(true).build(); } Loading Loading @@ -1305,4 +1304,19 @@ public class RingtoneManager { default: throw new IllegalArgumentException(); } } private static boolean muteHapticChannelForVibration(Context context, Uri ringtoneUri) { final Uri vibrationUri = Utils.getVibrationUri(ringtoneUri); // No vibration is specified if (vibrationUri == null) { return false; } // The user specified the synchronized pattern if (Objects.equals(vibrationUri.toString(), Utils.SYNCHRONIZED_VIBRATION)) { return false; } return Flags.enableRingtoneHapticsCustomization() && Utils.isRingtoneVibrationSettingsSupported(context) && hasHapticChannels(ringtoneUri); } }
media/java/android/media/Utils.java +4 −2 Original line number Diff line number Diff line Loading @@ -66,6 +66,8 @@ public class Utils { public static final String VIBRATION_URI_PARAM = "vibration_uri"; public static final String SYNCHRONIZED_VIBRATION = "synchronized"; /** * Sorts distinct (non-intersecting) range array in ascending order. * @throws java.lang.IllegalArgumentException if ranges are not distinct Loading Loading @@ -757,8 +759,8 @@ public class Utils { return null; } String filePath = vibrationUri.getPath(); if (filePath == null) { Log.w(TAG, "The file path is null."); if (filePath == null || filePath.equals(Utils.SYNCHRONIZED_VIBRATION)) { Log.w(TAG, "Ignore the vibration parsing for file:" + filePath); return null; } File vibrationFile = new File(filePath); Loading