Add PermissionGrantRequestResultReported atom
Also add a prototype for a future system-api accessible metrics file
that will be auto-generated from atoms.proto
Test: - ./out/host/linux-x86/bin/statsd_testdrive -p com.google.android.permissoncontroller 170
- triggered permission request
Bug: 123594188, 123663448
Change-Id: Icede6ff1f12ca79ebad6267c045a4fb3a9955402
diff --git a/bin/src/atoms.proto b/bin/src/atoms.proto
index 9a6387a..751b3e4 100644
--- a/bin/src/atoms.proto
+++ b/bin/src/atoms.proto
@@ -236,6 +236,7 @@
BluetoothSmpPairingEventReported bluetooth_smp_pairing_event_reported = 167;
ScreenTimeoutExtensionReported screen_timeout_extension_reported = 168;
ProcessStartTime process_start_time = 169;
+ PermissionGrantRequestResultReported permission_grant_request_result_reported = 170;
}
// Pulled events will start at field 10000.
@@ -5097,6 +5098,48 @@
}
/**
+ * Information about a permission grant request
+ */
+message PermissionGrantRequestResultReported {
+ // unique value identifying an API call. A API call might result in multiple of these atoms
+ optional int64 request_id = 1;
+
+ // UID of package requesting the permission grant
+ optional int32 requesting_uid = 2 [(is_uid) = true];
+
+ // Name of package requesting the permission grant
+ optional string requesting_package_name = 3;
+
+ // The permission to be granted
+ optional string permission_name = 4;
+
+ // If the permission was explicitly requested via the API or added by the system
+ optional bool is_implicit = 5;
+
+ enum Result {
+ UNDEFINED = 0;
+ // permission request was ignored
+ IGNORED = 1;
+ // permission request was ignored because it was user fixed
+ IGNORED_USER_FIXED = 2;
+ // permission request was ignored because it was policy fixed
+ IGNORED_POLICY_FIXED = 3;
+ // permission was granted by user action
+ USER_GRANTED = 4;
+ // permission was automatically granted
+ AUTO_GRANTED = 5;
+ // permission was denied by user action
+ USER_DENIED = 6;
+ // permission was denied with prejudice by the user
+ USER_DENIED_WITH_PREJUDICE = 7;
+ // permission was automatically denied
+ AUTO_DENIED = 8;
+ }
+ // The result of the permission grant
+ optional Result result = 6;
+}
+
+/**
* Logs when Omapi API used
* Logged from:
* packages/apps/SecureElement/src/com/android/se/Terminal.java
diff --git a/bin/tools/localtools/src/com/android/statsd/shelltools/testdrive/TestDrive.java b/bin/tools/localtools/src/com/android/statsd/shelltools/testdrive/TestDrive.java
index d9aba61..fc7b778 100644
--- a/bin/tools/localtools/src/com/android/statsd/shelltools/testdrive/TestDrive.java
+++ b/bin/tools/localtools/src/com/android/statsd/shelltools/testdrive/TestDrive.java
@@ -32,7 +32,8 @@
import java.io.File;
import java.io.IOException;
-import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
@@ -60,6 +61,7 @@
};
private static final Logger LOGGER = Logger.getLogger(TestDrive.class.getName());
+ private String mAdditionalAllowedPackage;
private final Set<Long> mTrackedMetrics = new HashSet<>();
public static void main(String[] args) {
@@ -69,11 +71,16 @@
String remoteConfigPath = null;
if (args.length < 1) {
- LOGGER.log(Level.SEVERE, "Usage: ./test_drive <atomId1> <atomId2> ... <atomIdN>");
+ LOGGER.log(Level.SEVERE, "Usage: ./test_drive [-p additional_allowed_package] "
+ + "<atomId1> <atomId2> ... <atomIdN>");
return;
}
- for (int i = 0; i < args.length; i++) {
+ if (args.length >= 3 && args[0].equals("-p")) {
+ testDrive.mAdditionalAllowedPackage = args[1];
+ }
+
+ for (int i = testDrive.mAdditionalAllowedPackage == null ? 0 : 2; i < args.length; i++) {
try {
int atomId = Integer.valueOf(args[i]);
if (Atom.getDescriptor().findFieldByNumber(atomId) == null) {
@@ -137,9 +144,15 @@
long metricId = METRIC_ID_BASE;
long atomMatcherId = ATOM_MATCHER_ID_BASE;
+ ArrayList<String> allowedSources = new ArrayList<>();
+ Collections.addAll(allowedSources, ALLOWED_LOG_SOURCES);
+ if (mAdditionalAllowedPackage != null) {
+ allowedSources.add(mAdditionalAllowedPackage);
+ }
+
StatsdConfig.Builder builder = StatsdConfig.newBuilder();
builder
- .addAllAllowedLogSource(Arrays.asList(ALLOWED_LOG_SOURCES))
+ .addAllAllowedLogSource(allowedSources)
.setHashStringsInMetricReport(false);
for (int atomId : atomIds) {