From dccdd68c5d7d7161b520cd576d3ba5bad977d9b4 Mon Sep 17 00:00:00 2001 From: Joanne Chung Date: Thu, 14 Jan 2021 19:39:34 +0800 Subject: [PATCH] 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 --- core/java/android/app/AppOpsManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index a23dd35fa55f9..3cb85e8dfbdd5 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -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);