Fix can't change notification sound for work profile.

Use correct user id context to query the type,
so we won't get empty result unexpectedly.

If we get the null result, then we won't set sound sucessfully.

Fix: 233580016
Test: Manual test and set work profile sound works.
Change-Id: I7f8fb737a7c6f77a380f3f075a5c89a1970e39ad
This commit is contained in:
Tsung-Mao Fang
2022-05-27 15:52:30 +08:00
parent f6ea9c99b3
commit 40fbcf333f
2 changed files with 2 additions and 1 deletions

View File

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

View File

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