Merge "Move permission enforcement to onCommand" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-06-14 20:37:42 +00:00
committed by Android (Google) Code Review

View File

@@ -32,16 +32,18 @@ public class ContextHubShellCommand extends ShellCommand {
// Internal service impl -- must perform security checks before touching. // Internal service impl -- must perform security checks before touching.
private final ContextHubService mInternal; private final ContextHubService mInternal;
private final Context mContext;
public ContextHubShellCommand(Context context, ContextHubService service) { public ContextHubShellCommand(Context context, ContextHubService service) {
mInternal = service; mInternal = service;
mContext = context;
context.enforceCallingOrSelfPermission(
android.Manifest.permission.ACCESS_CONTEXT_HUB, "ContextHubShellCommand");
} }
@Override @Override
public int onCommand(String cmd) { public int onCommand(String cmd) {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.ACCESS_CONTEXT_HUB, "ContextHubShellCommand");
if ("deny".equals(cmd)) { if ("deny".equals(cmd)) {
return runDisableAuth(); return runDisableAuth();
} }