Revert "Relax permission checks in sound trigger middleware"

This is a rollback of ag/10525952, since the underlying issue
is was working around has been addressed.

Bug: 151281856
Test: Some people have reported this to work. I'm still seeing issues
      on Sargo, and want more rigorous testing done by QA, owners of
      Now Playing, and owners of the permission subsystem.
Change-Id: I711470fa4f8478bce74d94ca403b029dd9a1bbd7
This commit is contained in:
Ytai Ben-Tsvi
2020-03-17 13:11:39 -07:00
parent 243c57f079
commit ff7e4f7531

View File

@@ -252,8 +252,21 @@ public class SoundTriggerMiddlewareValidation implements ISoundTriggerMiddleware
* @param permission The permission to check.
*/
void enforcePermission(String permission) {
mContext.enforceCallingOrSelfPermission(permission,
String.format("Caller must have the %s permission.", permission));
final int status = PermissionChecker.checkCallingOrSelfPermissionForPreflight(mContext,
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