summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ahaan Ugale <augale@google.com> 2021-06-07 11:46:47 -0700
committer Ahaan Ugale <augale@google.com> 2021-06-07 11:46:47 -0700
commit45fc633f7b1efc249b712b840d025571527e67cf (patch)
tree68cdd360a1494729b2e7253ba76bbf449e6b7604
parentf3e492125bf0df905e98a138d972c917d8f028db (diff)
Switch media fw hotword permission check to PermissionChecker (native)
PermissionChecker now includes some higher level logic for allowing the HotwordDetectionService to access mic audio and hotword audio. Bug: 190011174 Test: manual - sample app can read audio (with a few other wip changes) Change-Id: I5e624933962ad07ebe4abbde8b884585a052e96b
-rw-r--r--libs/permission/android/permission/PermissionChecker.cpp8
-rw-r--r--libs/permission/include/android/permission/PermissionChecker.h23
2 files changed, 31 insertions, 0 deletions
diff --git a/libs/permission/android/permission/PermissionChecker.cpp b/libs/permission/android/permission/PermissionChecker.cpp
index 008afad607..66526f90ea 100644
--- a/libs/permission/android/permission/PermissionChecker.cpp
+++ b/libs/permission/android/permission/PermissionChecker.cpp
@@ -82,6 +82,14 @@ PermissionChecker::PermissionResult
/*startDataDelivery*/ true, /*fromDatasource*/ true, attributedOpCode);
}
+PermissionChecker::PermissionResult PermissionChecker::checkPermissionForPreflight(
+ const String16& permission, const AttributionSourceState& attributionSource,
+ const String16& message, int32_t attributedOpCode)
+{
+ return checkPermission(permission, attributionSource, message, /*forDataDelivery*/ false,
+ /*startDataDelivery*/ false, /*fromDatasource*/ false, attributedOpCode);
+}
+
PermissionChecker::PermissionResult PermissionChecker::checkPermissionForPreflightFromDatasource(
const String16& permission, const AttributionSourceState& attributionSource,
const String16& message, int32_t attributedOpCode)
diff --git a/libs/permission/include/android/permission/PermissionChecker.h b/libs/permission/include/android/permission/PermissionChecker.h
index 308d7942a4..21515e3bbd 100644
--- a/libs/permission/include/android/permission/PermissionChecker.h
+++ b/libs/permission/include/android/permission/PermissionChecker.h
@@ -101,6 +101,29 @@ public:
* has a given permission and whether the app op that corresponds to this permission
* is allowed. The app ops are not noted/started.
*
+ * NOTE: Use this method only for permission checks at the preflight point where you
+ * will not deliver the permission protected data to clients but schedule permission
+ * data delivery, apps register listeners, etc.
+ *
+ * @param permission The permission to check.
+ * @param attributionSource The attribution chain to check.
+ * @param message A message describing the reason the permission was checked.
+ * @param attributedOpCode The op code towards which to blame the access. If this
+ * is a valid app op the op corresponding to the checked permission (if such)
+ * would only be checked to ensure it is allowed and if that succeeds the
+ * starting would be against the attributed op.
+ * @return The permission check result which is either PERMISSION_GRANTED,
+ * or PERMISSION_SOFT_DENIED or PERMISSION_HARD_DENIED.
+ */
+ PermissionResult checkPermissionForPreflight(
+ const String16& permission, const AttributionSourceState& attributionSource,
+ const String16& message, int32_t attributedOpCode);
+
+ /**
+ * Checks whether a given data access chain described by the given attribution source
+ * has a given permission and whether the app op that corresponds to this permission
+ * is allowed. The app ops are not noted/started.
+ *
* NOTE: The attribution source should be for yourself with its next attribution
* source being the app that would receive the data from you.
*