• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.car.annotation;
18 
19 import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
20 import static java.lang.annotation.ElementType.FIELD;
21 import static java.lang.annotation.ElementType.METHOD;
22 import static java.lang.annotation.ElementType.TYPE;
23 import static java.lang.annotation.RetentionPolicy.RUNTIME;
24 
25 import android.annotation.TestApi;
26 
27 import java.lang.annotation.Retention;
28 import java.lang.annotation.Target;
29 
30 /**
31  * Defines in which version of Car and platform SDK the annotated API is supported.
32  *
33  * @hide
34  */
35 @Retention(RUNTIME)
36 @Target({ANNOTATION_TYPE, FIELD, TYPE, METHOD})
37 @TestApi
38 public @interface ApiRequirements {
39 
40     /**
41      * Indicates the minimum Car SDK version required for the annotated API.
42      *
43      * <p>Clients can check it calling {@code Car.getCarApiVersion.isAtLeast(
44      * CarApiVersion.VERSION_CODES.VERSION_DEFINED_IN_THIS_ANNOTATION)}.
45      */
minCarVersion()46     CarVersion minCarVersion();
47 
48     /**
49      * Indicates the minimum Platform SDK version required for the annotated API.
50      *
51      * <p>Clients can check it calling {@code Car.getPlatformApiVersion.isAtLeast(
52      * PlatformApiVersion.VERSION_CODES.VERSION_DEFINED_IN_THIS_ANNOTATION)}.
53      */
minPlatformVersion()54     PlatformVersion minPlatformVersion();
55 
56     /**
57      * Indicates the Android version in which this deprecated annotated API will be soft removed.
58      * <p>Soft removal means the API will now be marked as {@code @Removed} but its
59      * implementation remains.
60      *
61      * <p>Only used for APIs that have been marked for removal.
62      */
softRemovalVersion()63     int softRemovalVersion() default -1;
64 
65     /**
66      * Indicates the Android version in which this deprecated annotated API will be hard removed.
67      * <p>Hard removal means removing the entire implementation of the API.
68      *
69      * <p>Only used for APIs that have been marked for removal.
70      */
hardRemovalVersion()71     int hardRemovalVersion() default -1;
72 
73     @SuppressWarnings("Enum")
74     enum CarVersion {
75 
76         TIRAMISU_0(android.car.CarVersion.VERSION_CODES.TIRAMISU_0),
77         TIRAMISU_1(android.car.CarVersion.VERSION_CODES.TIRAMISU_1),
78         TIRAMISU_2(android.car.CarVersion.VERSION_CODES.TIRAMISU_2),
79         TIRAMISU_3(android.car.CarVersion.VERSION_CODES.TIRAMISU_3),
80         UPSIDE_DOWN_CAKE_0(android.car.CarVersion.VERSION_CODES.UPSIDE_DOWN_CAKE_0),
81         UPSIDE_DOWN_CAKE_1(android.car.CarVersion.VERSION_CODES.UPSIDE_DOWN_CAKE_1);
82 
83         private final android.car.CarVersion mVersion;
84 
CarVersion(android.car.CarVersion version)85         CarVersion(android.car.CarVersion version) {
86             mVersion = version;
87         }
88 
89         /**
90          * Gets the {@link CarVersion} associated with it.
91          */
get()92         public android.car.CarVersion get() {
93             return mVersion;
94         }
95     }
96 
97     @SuppressWarnings("Enum")
98     enum PlatformVersion {
99 
100         TIRAMISU_0(android.car.PlatformVersion.VERSION_CODES.TIRAMISU_0),
101         TIRAMISU_1(android.car.PlatformVersion.VERSION_CODES.TIRAMISU_1),
102         TIRAMISU_2(android.car.PlatformVersion.VERSION_CODES.TIRAMISU_2),
103         TIRAMISU_3(android.car.PlatformVersion.VERSION_CODES.TIRAMISU_3),
104         UPSIDE_DOWN_CAKE_0(android.car.PlatformVersion.VERSION_CODES.UPSIDE_DOWN_CAKE_0),
105         UPSIDE_DOWN_CAKE_1(android.car.PlatformVersion.VERSION_CODES.UPSIDE_DOWN_CAKE_1);
106 
107         private final android.car.PlatformVersion mVersion;
108 
PlatformVersion(android.car.PlatformVersion version)109         PlatformVersion(android.car.PlatformVersion version) {
110             mVersion = version;
111         }
112 
113         /**
114          * Gets the {@link PlatformVersion} associated with it.
115          */
get()116         public android.car.PlatformVersion get() {
117             return mVersion;
118         }
119     }
120 }
121