Launch correct tone picker for audio attributes

Test: robotests
Fixes: 129353516
Change-Id: Iacbf5008f186e59377e534da747544d33a20f81f
This commit is contained in:
Julia Reynolds
2019-03-27 11:09:11 -04:00
parent dd295676c6
commit ca974ae0f4
3 changed files with 81 additions and 2 deletions

View File

@@ -16,10 +16,14 @@
package com.android.settings.notification;
import static android.media.AudioAttributes.USAGE_ALARM;
import static android.media.AudioAttributes.USAGE_NOTIFICATION_RINGTONE;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.preference.PreferenceManager;
@@ -91,6 +95,16 @@ public class SoundPreferenceController extends NotificationPreferenceController
public boolean handlePreferenceTreeClick(Preference preference) {
if (KEY_SOUND.equals(preference.getKey()) && mFragment != null) {
NotificationSoundPreference pref = (NotificationSoundPreference) preference;
if (mChannel != null && mChannel.getAudioAttributes() != null) {
if (USAGE_ALARM == mChannel.getAudioAttributes().getUsage()) {
pref.setRingtoneType(RingtoneManager.TYPE_ALARM);
} else if (USAGE_NOTIFICATION_RINGTONE
== mChannel.getAudioAttributes().getUsage()) {
pref.setRingtoneType(RingtoneManager.TYPE_RINGTONE);
} else {
pref.setRingtoneType(RingtoneManager.TYPE_NOTIFICATION);
}
}
pref.onPrepareRingtonePickerIntent(pref.getIntent());
mFragment.startActivityForResult(preference.getIntent(), CODE);
return true;