From bf0b40550bcbaca888e6c63cbf7bd2502ce2f1cb Mon Sep 17 00:00:00 2001 From: Ahaan Ugale Date: Thu, 29 Jul 2021 11:18:34 -0700 Subject: [PATCH] Hotword: Treat preflight soft denial as granted. In preflight we should accept soft denials as they can become grants at the time of delivery. Realigns permissions code in VoiceInteraction with that in SoundTrigger, which was fixed in I4fc3b3e8defed59a900fd156273e9e695a322b0c. Fix: 194137739 Test: manual - no errors for starting recognition when mic access is blocked. data delivery is still blocked Test: atest HotwordDetectionServiceBasicTest Change-Id: I49d504a30b4d04f157990580838757a3f17861cc --- .../SoundTriggerSessionPermissionsDecorator.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/SoundTriggerSessionPermissionsDecorator.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/SoundTriggerSessionPermissionsDecorator.java index b9e1fcd7ffd38..68b2e6168b5c5 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/SoundTriggerSessionPermissionsDecorator.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/SoundTriggerSessionPermissionsDecorator.java @@ -29,7 +29,6 @@ import android.media.permission.Identity; import android.media.permission.PermissionUtil; import android.os.IBinder; import android.os.RemoteException; -import android.os.ServiceSpecificException; import android.text.TextUtils; import android.util.Slog; @@ -117,8 +116,8 @@ final class SoundTriggerSessionPermissionsDecorator implements /** * Throws a {@link SecurityException} if originator permanently doesn't have the given - * permission, or a {@link ServiceSpecificException} with a {@link - * #TEMPORARY_PERMISSION_DENIED} if caller originator doesn't have the given permission. + * permission. + * Soft (temporary) denials are considered OK for preflight purposes. * * @param context A {@link Context}, used for permission checks. * @param identity The identity to check. @@ -130,15 +129,12 @@ final class SoundTriggerSessionPermissionsDecorator implements permission); switch (status) { case PermissionChecker.PERMISSION_GRANTED: + case PermissionChecker.PERMISSION_SOFT_DENIED: return; case PermissionChecker.PERMISSION_HARD_DENIED: throw new SecurityException( TextUtils.formatSimple("Failed to obtain permission %s for identity %s", permission, toString(identity))); - case PermissionChecker.PERMISSION_SOFT_DENIED: - throw new ServiceSpecificException(TEMPORARY_PERMISSION_DENIED, - TextUtils.formatSimple("Failed to obtain permission %s for identity %s", - permission, toString(identity))); default: throw new RuntimeException("Unexpected permission check result."); }