summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Anthony Stange <stange@google.com> 2021-06-14 17:31:13 +0000
committer Anthony Stange <stange@google.com> 2021-06-14 19:10:45 +0000
commit7986c7365e8ad18e2dad4a36a99dee9b04413337 (patch)
tree0f21a95524b44894274241df91d55e2d2671c6c6
parent10a6b054ff3df9dff0040462e2b1bb490cfe480a (diff)
Move permission enforcement to onCommand
Calling enforceCallingOrSelfPermission in the shell command constructor causes a hang when running GTS if the permission isn't granted. Bug: 191043641 Test: Run "cmd contexthub deny" and verify error is printed if not rooted Change-Id: I807adee4382310a201c34e31cd53fbb37574e851
-rw-r--r--services/core/java/com/android/server/location/contexthub/ContextHubShellCommand.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/location/contexthub/ContextHubShellCommand.java b/services/core/java/com/android/server/location/contexthub/ContextHubShellCommand.java
index 5ec85e661b98..6931baa948a1 100644
--- a/services/core/java/com/android/server/location/contexthub/ContextHubShellCommand.java
+++ b/services/core/java/com/android/server/location/contexthub/ContextHubShellCommand.java
@@ -32,16 +32,18 @@ public class ContextHubShellCommand extends ShellCommand {
// Internal service impl -- must perform security checks before touching.
private final ContextHubService mInternal;
+ private final Context mContext;
public ContextHubShellCommand(Context context, ContextHubService service) {
mInternal = service;
-
- context.enforceCallingOrSelfPermission(
- android.Manifest.permission.ACCESS_CONTEXT_HUB, "ContextHubShellCommand");
+ mContext = context;
}
@Override
public int onCommand(String cmd) {
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.ACCESS_CONTEXT_HUB, "ContextHubShellCommand");
+
if ("deny".equals(cmd)) {
return runDisableAuth();
}