diff options
| author | Nate Myren <ntmyren@google.com> | 2020-11-09 13:50:25 -0800 |
|---|---|---|
| committer | Nate Myren <ntmyren@google.com> | 2020-11-10 09:10:53 -0800 |
| commit | ecb07b0c0f0b060ecf5decc9ce0356fae3c8e41f (patch) | |
| tree | 7bbe5b82a7def4313c8e5afff32c9773d7dc8df1 /core/java/android/app/AppOpsManager.java | |
| parent | 6465c1ea0d383a26158aa40e94c75c7fa5f733c0 (diff) | |
More robust null check in isTrustedVoiceServiceProxy
Ensure that the component name unflattening does not result in a null
value before getting the package name.
Fixes: 172854122
Test: Manual
Change-Id: Icbcacc87308bdb87fd45e055240fd72458e478f5
Diffstat (limited to 'core/java/android/app/AppOpsManager.java')
| -rw-r--r-- | core/java/android/app/AppOpsManager.java | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 26b4234fd14b..d6cf8fffe586 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -7618,16 +7618,18 @@ public class AppOpsManager { mContext.getContentResolver(), Settings.Secure.VOICE_INTERACTION_SERVICE); final String voiceRecognitionServicePackageName = - voiceRecognitionComponent != null ? ComponentName.unflattenFromString( - voiceRecognitionComponent).getPackageName() : ""; + getComponentPackageNameFromString(voiceRecognitionComponent); final String voiceInteractionServicePackageName = - voiceInteractionComponent != null ? ComponentName.unflattenFromString( - voiceInteractionComponent).getPackageName() : ""; - + getComponentPackageNameFromString(voiceInteractionComponent); return Objects.equals(packageName, voiceRecognitionServicePackageName) && Objects.equals( voiceRecognitionServicePackageName, voiceInteractionServicePackageName); } + private String getComponentPackageNameFromString(String from) { + ComponentName componentName = from != null ? ComponentName.unflattenFromString(from) : null; + return componentName != null ? componentName.getPackageName() : ""; + } + /** * Do a quick check for whether an application might be able to perform an operation. * This is <em>not</em> a security check; you must use {@link #noteOp(String, int, String, |
