Merge "Hotword: Treat preflight soft denial as granted." into sc-dev am: a13d80321e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15421452

Change-Id: I978e7bd2c6124f4d613848051aa0db3ef04e50b5
This commit is contained in:
Ahaan Ugale
2021-07-30 22:49:36 +00:00
committed by Automerger Merge Worker

View File

@@ -29,7 +29,6 @@ import android.media.permission.Identity;
import android.media.permission.PermissionUtil; import android.media.permission.PermissionUtil;
import android.os.IBinder; import android.os.IBinder;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceSpecificException;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Slog; import android.util.Slog;
@@ -117,8 +116,8 @@ final class SoundTriggerSessionPermissionsDecorator implements
/** /**
* Throws a {@link SecurityException} if originator permanently doesn't have the given * Throws a {@link SecurityException} if originator permanently doesn't have the given
* permission, or a {@link ServiceSpecificException} with a {@link * permission.
* #TEMPORARY_PERMISSION_DENIED} if caller originator doesn't have the given permission. * Soft (temporary) denials are considered OK for preflight purposes.
* *
* @param context A {@link Context}, used for permission checks. * @param context A {@link Context}, used for permission checks.
* @param identity The identity to check. * @param identity The identity to check.
@@ -130,15 +129,12 @@ final class SoundTriggerSessionPermissionsDecorator implements
permission); permission);
switch (status) { switch (status) {
case PermissionChecker.PERMISSION_GRANTED: case PermissionChecker.PERMISSION_GRANTED:
case PermissionChecker.PERMISSION_SOFT_DENIED:
return; return;
case PermissionChecker.PERMISSION_HARD_DENIED: case PermissionChecker.PERMISSION_HARD_DENIED:
throw new SecurityException( throw new SecurityException(
TextUtils.formatSimple("Failed to obtain permission %s for identity %s", TextUtils.formatSimple("Failed to obtain permission %s for identity %s",
permission, toString(identity))); 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: default:
throw new RuntimeException("Unexpected permission check result."); throw new RuntimeException("Unexpected permission check result.");
} }