summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Elliot Sisteron <elliotsisteron@google.com> 2023-09-06 17:02:20 +0000
committer Elliot Sisteron <elliotsisteron@google.com> 2023-09-27 16:49:09 +0000
commit272647d0d993401013eefb8600279d30f5e0261d (patch)
tree4e722f267fee0fe0b29d13e8ced7fd93b03dd725
parente45612fe2fe18edd62c79c36bc82f404fa8ecab5 (diff)
Add "RequiresVanillaIceCreamByDefaultAnnotation".
Will create a ui/tips subpackage for tips and will be using this to mark the whole package as RequiresApi(VANILLA_ICE_CREAM). Test: none Bug: 297029358 Change-Id: I2d050b82687dc02b8de6df83d39f204e6243a08a
-rw-r--r--SafetyCenter/Annotations/java/com/android/safetycenter/annotations/RequiresVanillaIceCreamByDefault.java40
-rw-r--r--SafetyCenter/ConfigLintChecker/java/android/os/Build.java4
-rw-r--r--SafetyCenter/ConfigLintChecker/java/com/android/modules/utils/build/SdkLevel.java6
3 files changed, 50 insertions, 0 deletions
diff --git a/SafetyCenter/Annotations/java/com/android/safetycenter/annotations/RequiresVanillaIceCreamByDefault.java b/SafetyCenter/Annotations/java/com/android/safetycenter/annotations/RequiresVanillaIceCreamByDefault.java
new file mode 100644
index 000000000..bb1c1eb97
--- /dev/null
+++ b/SafetyCenter/Annotations/java/com/android/safetycenter/annotations/RequiresVanillaIceCreamByDefault.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2023 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 com.android.safetycenter.annotations;
+
+import static android.os.Build.VERSION_CODES.VANILLA_ICE_CREAM;
+
+import static java.lang.annotation.ElementType.PACKAGE;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.CLASS;
+
+import androidx.annotation.RequiresApi;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.annotation.meta.TypeQualifierDefault;
+
+/**
+ * Specifies that all types are {@code RequiresApi(VANILLA_ICE_CREAM)} within the annotated package,
+ * unless tagged another {@code @RequiresApi} annotation.
+ */
+@Retention(CLASS)
+@Target(PACKAGE)
+@TypeQualifierDefault({TYPE})
+@RequiresApi(VANILLA_ICE_CREAM)
+public @interface RequiresVanillaIceCreamByDefault {}
diff --git a/SafetyCenter/ConfigLintChecker/java/android/os/Build.java b/SafetyCenter/ConfigLintChecker/java/android/os/Build.java
index 531b6e481..4a58e04fc 100644
--- a/SafetyCenter/ConfigLintChecker/java/android/os/Build.java
+++ b/SafetyCenter/ConfigLintChecker/java/android/os/Build.java
@@ -24,7 +24,11 @@ public final class Build {
public static final class VERSION_CODES {
/** Constant used in the Safety Center config code. */
public static final int TIRAMISU = 33;
+
/** Constant used in the Safety Center config code. */
public static final int UPSIDE_DOWN_CAKE = 34;
+
+ /** Constant used in the Safety Center config code. */
+ public static final int VANILLA_ICE_CREAM = 35;
}
}
diff --git a/SafetyCenter/ConfigLintChecker/java/com/android/modules/utils/build/SdkLevel.java b/SafetyCenter/ConfigLintChecker/java/com/android/modules/utils/build/SdkLevel.java
index dbfaa56b1..cfe99071c 100644
--- a/SafetyCenter/ConfigLintChecker/java/com/android/modules/utils/build/SdkLevel.java
+++ b/SafetyCenter/ConfigLintChecker/java/com/android/modules/utils/build/SdkLevel.java
@@ -18,6 +18,7 @@ package com.android.modules.utils.build;
import static android.os.Build.VERSION_CODES.TIRAMISU;
import static android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
+import static android.os.Build.VERSION_CODES.VANILLA_ICE_CREAM;
/** Stub class to compile the linter for host execution. */
public final class SdkLevel {
@@ -42,4 +43,9 @@ public final class SdkLevel {
public static boolean isAtLeastU() {
return sSdkInt >= UPSIDE_DOWN_CAKE;
}
+
+ /** Method used in the Safety Center config code. */
+ public static boolean isAtLeastV() {
+ return sSdkInt >= VANILLA_ICE_CREAM;
+ }
}