Merge changes from topics "presubmit-am-7e93fea7eeca4c76a2b33d5fe115ad40", "presubmit-am-93b3a992dd6c4622a633bca394ada8e5-sc-dev" into sc-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
diff --git a/src/com/android/settings/DefaultRingtonePreference.java b/src/com/android/settings/DefaultRingtonePreference.java
index 914c4b2..9bf626c 100644
--- a/src/com/android/settings/DefaultRingtonePreference.java
+++ b/src/com/android/settings/DefaultRingtonePreference.java
@@ -46,7 +46,12 @@
@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?)");
diff --git a/tests/unit/src/com/android/settings/DefaultRingtonePreferenceTest.java b/tests/unit/src/com/android/settings/DefaultRingtonePreferenceTest.java
index b9dea01..7877684 100644
--- a/tests/unit/src/com/android/settings/DefaultRingtonePreferenceTest.java
+++ b/tests/unit/src/com/android/settings/DefaultRingtonePreferenceTest.java
@@ -59,6 +59,7 @@
when(mDefaultRingtonePreference.getRingtoneType())
.thenReturn(RingtoneManager.TYPE_RINGTONE);
mDefaultRingtonePreference.setUserId(1);
+ mDefaultRingtonePreference.mUserContext = context;
}
@Test