Get value from setting provider using user id.

If the API calls from system server, we will get the value of user 0,
we should get the value for correct user.

Bug: 177628417
Test: manual. Switch user and check the value is correct.
Test: atest RecognitionServiceMicIndicatorTest#\
testRecognitionServiceNoteProxyOpNoExceptionThrown \
--user-type secondary_user

Change-Id: Ie100613d360b93c99de134c566990c73a80156d8
This commit is contained in:
Joanne Chung
2021-01-14 19:39:34 +08:00
parent c91a0f9491
commit dccdd68c5d

View File

@@ -7689,8 +7689,8 @@ public class AppOpsManager {
if (code != OP_RECORD_AUDIO) {
return false;
}
final String voiceRecognitionComponent = Settings.Secure.getString(
context.getContentResolver(), Settings.Secure.VOICE_RECOGNITION_SERVICE);
final String voiceRecognitionComponent = Settings.Secure.getStringForUser(
context.getContentResolver(), Settings.Secure.VOICE_RECOGNITION_SERVICE, userId);
final String voiceRecognitionServicePackageName =
getComponentPackageNameFromString(voiceRecognitionComponent);