Merge "Revert "Relax permission checks in sound trigger middleware"" into rvc-dev am: a08e8e075d am: e0a738ad6b
Change-Id: I0de05428a050c0a3ebd347586521d96eaaa28520
This commit is contained in:
@@ -252,8 +252,21 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
|
|||||||
* @param permission The permission to check.
|
* @param permission The permission to check.
|
||||||
*/
|
*/
|
||||||
void enforcePermission(String permission) {
|
void enforcePermission(String permission) {
|
||||||
mContext.enforceCallingOrSelfPermission(permission,
|
final int status = PermissionChecker.checkCallingOrSelfPermissionForPreflight(mContext,
|
||||||
String.format("Caller must have the %s permission.", permission));
|
permission);
|
||||||
|
switch (status) {
|
||||||
|
case PermissionChecker.PERMISSION_GRANTED:
|
||||||
|
return;
|
||||||
|
case PermissionChecker.PERMISSION_HARD_DENIED:
|
||||||
|
throw new SecurityException(
|
||||||
|
String.format("Caller must have the %s permission.", permission));
|
||||||
|
case PermissionChecker.PERMISSION_SOFT_DENIED:
|
||||||
|
throw new ServiceSpecificException(Status.TEMPORARY_PERMISSION_DENIED,
|
||||||
|
String.format("Caller must have the %s permission.", permission));
|
||||||
|
default:
|
||||||
|
throw new InternalServerError(
|
||||||
|
new RuntimeException("Unexpected perimission check result."));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user