Merge changes from topic "presubmit-am-93b3a992dd6c4622a633bca394ada8e5-qt-dev" into qt-dev

* changes:
  [DO NOT MERGE] Fix can't change notification sound for work profile.
  [DO NOT MERGE] Fix Settings crash when setting a null ringtone
This commit is contained in:
Arc Wang
2022-06-03 23:27:16 +00:00
committed by Android (Google) Code Review
2 changed files with 7 additions and 1 deletions

View File

@@ -46,7 +46,12 @@ public class DefaultRingtonePreference extends RingtonePreference {
@Override
protected void onSaveRingtone(Uri ringtoneUri) {
String mimeType = getContext().getContentResolver().getType(ringtoneUri);
if (ringtoneUri == null) {
setActualDefaultRingtoneUri(ringtoneUri);
return;
}
String mimeType = mUserContext.getContentResolver().getType(ringtoneUri);
if (mimeType == null) {
Log.e(TAG, "onSaveRingtone for URI:" + ringtoneUri
+ " ignored: failure to find mimeType (no access from this context?)");

View File

@@ -59,6 +59,7 @@ public class DefaultRingtonePreferenceTest {
when(mDefaultRingtonePreference.getRingtoneType())
.thenReturn(RingtoneManager.TYPE_RINGTONE);
mDefaultRingtonePreference.setUserId(1);
mDefaultRingtonePreference.mUserContext = context;
}
@Test