aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-01-12 19:29:15 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-01-12 19:29:15 +0000
commit9baa1d5c665c1e68a47fd55fc911a4a6f2766eba (patch)
tree4160b0661426ab450459b10d32997648e7d26ebd
parentf2ecced6cda9b6d27813b62d7d1d5c8f3b1914d9 (diff)
parent2ac3022f6ce60bfc0e9a4557f937e8fe84db289d (diff)
downloadmodules-utils-9baa1d5c665c1e68a47fd55fc911a4a6f2766eba.tar.gz
Snap for 9484466 from 2ac3022f6ce60bfc0e9a4557f937e8fe84db289d to mainline-adbd-release
Change-Id: I79e468450508c49e86e8c9bcaedea6970f2e21a7
-rw-r--r--java/android/annotation/PermissionMethod.java52
-rw-r--r--java/android/annotation/PermissionName.java35
2 files changed, 87 insertions, 0 deletions
diff --git a/java/android/annotation/PermissionMethod.java b/java/android/annotation/PermissionMethod.java
new file mode 100644
index 0000000..91fafcc
--- /dev/null
+++ b/java/android/annotation/PermissionMethod.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.annotation;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.CLASS;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Documents that the subject method's job is to look
+ * up whether the provided or calling uid/pid has the requested permission.
+ *
+ * <p>Methods should either return `void`, but potentially throw {@link SecurityException},
+ * or return {@link android.content.pm.PackageManager.PermissionResult} `int`.
+ *
+ * @hide
+ */
+@Retention(CLASS)
+@Target({METHOD})
+public @interface PermissionMethod {
+ /**
+ * Hard-coded list of permissions checked by this method
+ */
+ @PermissionName String[] value() default {};
+ /**
+ * If true, the check passes if the caller
+ * has any ONE of the supplied permissions
+ */
+ boolean anyOf() default false;
+ /**
+ * Signifies that the permission check passes if
+ * the calling process OR the current process has
+ * the permission
+ */
+ boolean orSelf() default false;
+}
diff --git a/java/android/annotation/PermissionName.java b/java/android/annotation/PermissionName.java
new file mode 100644
index 0000000..2b9f525
--- /dev/null
+++ b/java/android/annotation/PermissionName.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.CLASS;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Denotes that the annotated {@link String} represents a permission name.
+ *
+ * @hide
+ */
+@Retention(CLASS)
+@Target({PARAMETER, METHOD, LOCAL_VARIABLE, FIELD})
+public @interface PermissionName {}