[DO NOT MERGE] 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.

Bug: 233580016
Bug: 221041256
Test: Manual test and set work profile sound works.
Change-Id: I7f8fb737a7c6f77a380f3f075a5c89a1970e39ad
Merged-In: I7f8fb737a7c6f77a380f3f075a5c89a1970e39ad
This commit is contained in:
Tsung-Mao Fang
2022-05-27 15:52:30 +08:00
committed by Arc Wang
parent 46e00dc6df
commit 90968c8437
2 changed files with 2 additions and 1 deletions

View File

@@ -51,7 +51,7 @@ public class DefaultRingtonePreference extends RingtonePreference {
return;
}
String mimeType = getContext().getContentResolver().getType(ringtoneUri);
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