From e3edd0a3c31f47a25a60a433d531c51ed90c41c8 Mon Sep 17 00:00:00 2001 From: Shuo Qian Date: Fri, 23 Oct 2020 12:12:28 -0700 Subject: [PATCH] Try to add AppOps Keys into Proto to unblock my project My code https://googleplex-android-review.git.corp.google.com/q/topic:%223rd-incall%22+(status:open%20OR%20status:merged), which is adding a proto enum for a new AppOps, is causing presubmit failure (https://android-build.googleplex.com/builds/tests/view?invocationId=I62800006309385464&redirect=http%3A%2F%2Fsponge2%2F8a607de5-e0c3-4349-b3c4-0ee397685e18&testResultId=TR55614315792892488). I cannot check in my code because of this failure. To solve this failure, one of the next step is: adding AppOps 100-102 there Test: Treehugger Bug: 169595473 Change-Id: Ibd0f85575c9bc3d7aca9d5b011f1e5f0cbf960c1 Merged-In: Ibd0f85575c9bc3d7aca9d5b011f1e5f0cbf960c1 (cherry picked from commit 503ee6ad3be976c3a436a783cb4ee65169d92c16) --- core/java/android/app/AppOpsManager.java | 68 +++++++++++++++++++++++- core/proto/android/app/enums.proto | 3 ++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index 69b77a9b4c591..0d5bb115db915 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -1111,9 +1111,30 @@ public class AppOpsManager { /** @hide */ public static final int OP_NO_ISOLATED_STORAGE = AppProtoEnums.APP_OP_NO_ISOLATED_STORAGE; + /** + * Reserved key for 100 + * + * @hide + */ + public static final int OP_RESERVED_100 = 100; + + /** + * Reserved key for 101 + * + * @hide + */ + public static final int OP_RESERVED_101 = 101; + + /** + * Reserved key for 102 + * + * @hide + */ + public static final int OP_RESERVED_102 = 102; + /** @hide */ @UnsupportedAppUsage - public static final int _NUM_OP = 100; + public static final int _NUM_OP = 103; /** Access to coarse location information. */ public static final String OPSTR_COARSE_LOCATION = "android:coarse_location"; @@ -1430,6 +1451,27 @@ public class AppOpsManager { */ public static final String OPSTR_NO_ISOLATED_STORAGE = "android:no_isolated_storage"; + /** + * Reserved for 100 + * + * @hide + */ + public static final String OPSTR_RESERVED_100 = "android:opstr_reserved_100"; + + /** + * Reserved for 101 + * + * @hide + */ + public static final String OPSTR_RESERVED_101 = "android:opstr_reserved_101"; + + /** + * Reserved for 102 + * + * @hide + */ + public static final String OPSTR_RESERVED_102 = "android:opstr_reserved_102"; + /** {@link #sAppOpsToNote} not initialized yet for this op */ private static final byte SHOULD_COLLECT_NOTE_OP_NOT_INITIALIZED = 0; /** Should not collect noting of this app-op in {@link #sAppOpsToNote} */ @@ -1619,6 +1661,9 @@ public class AppOpsManager { OP_AUTO_REVOKE_PERMISSIONS_IF_UNUSED, //AUTO_REVOKE_PERMISSIONS_IF_UNUSED OP_AUTO_REVOKE_MANAGED_BY_INSTALLER, //OP_AUTO_REVOKE_MANAGED_BY_INSTALLER OP_NO_ISOLATED_STORAGE, // NO_ISOLATED_STORAGE + OP_RESERVED_100, // OP_RESERVED_100 + OP_RESERVED_101, // OP_RESERVED_101 + OP_RESERVED_102, // OP_RESERVED_102 }; /** @@ -1725,6 +1770,9 @@ public class AppOpsManager { OPSTR_AUTO_REVOKE_PERMISSIONS_IF_UNUSED, OPSTR_AUTO_REVOKE_MANAGED_BY_INSTALLER, OPSTR_NO_ISOLATED_STORAGE, + OPSTR_RESERVED_100, + OPSTR_RESERVED_101, + OPSTR_RESERVED_102, }; /** @@ -1832,6 +1880,9 @@ public class AppOpsManager { "AUTO_REVOKE_PERMISSIONS_IF_UNUSED", "AUTO_REVOKE_MANAGED_BY_INSTALLER", "NO_ISOLATED_STORAGE", + "RESERVED_100", + "RESERVED_101", + "RESERVED_102", }; /** @@ -1940,6 +1991,9 @@ public class AppOpsManager { null, // no permission for OP_AUTO_REVOKE_PERMISSIONS_IF_UNUSED null, // no permission for OP_AUTO_REVOKE_MANAGED_BY_INSTALLER null, // no permission for OP_NO_ISOLATED_STORAGE + null, // OP_RESERVED_100 + null, // OP_RESERVED_101 + null, // OP_RESERVED_102 }; /** @@ -2048,6 +2102,9 @@ public class AppOpsManager { null, // AUTO_REVOKE_PERMISSIONS_IF_UNUSED null, // AUTO_REVOKE_MANAGED_BY_INSTALLER null, // NO_ISOLATED_STORAGE + null, // OP_RESERVED_100 + null, // OP_RESERVED_101 + null, // OP_RESERVED_102 }; /** @@ -2155,6 +2212,9 @@ public class AppOpsManager { null, // AUTO_REVOKE_PERMISSIONS_IF_UNUSED null, // AUTO_REVOKE_MANAGED_BY_INSTALLER null, // NO_ISOLATED_STORAGE + null, // OP_RESERVED_100 + null, // OP_RESERVED_101 + null, // OP_RESERVED_102 }; /** @@ -2261,6 +2321,9 @@ public class AppOpsManager { AppOpsManager.MODE_DEFAULT, // OP_AUTO_REVOKE_PERMISSIONS_IF_UNUSED AppOpsManager.MODE_ALLOWED, // OP_AUTO_REVOKE_MANAGED_BY_INSTALLER AppOpsManager.MODE_ERRORED, // OP_NO_ISOLATED_STORAGE + AppOpsManager.MODE_ERRORED, // OP_RESERVED_100 + AppOpsManager.MODE_ERRORED, // OP_RESERVED_101 + AppOpsManager.MODE_ERRORED, // OP_RESERVED_102 }; /** @@ -2371,6 +2434,9 @@ public class AppOpsManager { false, // AUTO_REVOKE_PERMISSIONS_IF_UNUSED false, // AUTO_REVOKE_MANAGED_BY_INSTALLER true, // NO_ISOLATED_STORAGE + false, // OP_RESERVED_100 + false, // OP_RESERVED_101 + false, // OP_RESERVED_102 }; /** diff --git a/core/proto/android/app/enums.proto b/core/proto/android/app/enums.proto index bd5cb62f7fdec..98ba029236e68 100644 --- a/core/proto/android/app/enums.proto +++ b/core/proto/android/app/enums.proto @@ -207,4 +207,7 @@ enum AppOpEnum { APP_OP_AUTO_REVOKE_PERMISSIONS_IF_UNUSED = 97; APP_OP_AUTO_REVOKE_MANAGED_BY_INSTALLER = 98; APP_OP_NO_ISOLATED_STORAGE = 99; + APP_OP_RESERVED_100 = 100; + APP_OP_RESERVED_101 = 101; + APP_OP_RESERVED_102 = 102; }