• 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         VANILLA_ICE_CREAM_0(android.car.CarVersion.VERSION_CODES.VANILLA_ICE_CREAM_0);
83 
84         private final android.car.CarVersion mVersion;
85 
CarVersion(android.car.CarVersion version)86         CarVersion(android.car.CarVersion version) {
87             mVersion = version;
88         }
89 
90         /**
91          * Gets the {@link CarVersion} associated with it.
92          */
get()93         public android.car.CarVersion get() {
94             return mVersion;
95         }
96     }
97 
98     @SuppressWarnings("Enum")
99     enum PlatformVersion {
100 
101         TIRAMISU_0(android.car.PlatformVersion.VERSION_CODES.TIRAMISU_0),
102         TIRAMISU_1(android.car.PlatformVersion.VERSION_CODES.TIRAMISU_1),
103         TIRAMISU_2(android.car.PlatformVersion.VERSION_CODES.TIRAMISU_2),
104         TIRAMISU_3(android.car.PlatformVersion.VERSION_CODES.TIRAMISU_3),
105         UPSIDE_DOWN_CAKE_0(android.car.PlatformVersion.VERSION_CODES.UPSIDE_DOWN_CAKE_0),
106         UPSIDE_DOWN_CAKE_1(android.car.PlatformVersion.VERSION_CODES.UPSIDE_DOWN_CAKE_1),
107         VANILLA_ICE_CREAM_0(android.car.PlatformVersion.VERSION_CODES.VANILLA_ICE_CREAM_0);
108 
109         private final android.car.PlatformVersion mVersion;
110 
PlatformVersion(android.car.PlatformVersion version)111         PlatformVersion(android.car.PlatformVersion version) {
112             mVersion = version;
113         }
114 
115         /**
116          * Gets the {@link PlatformVersion} associated with it.
117          */
get()118         public android.car.PlatformVersion get() {
119             return mVersion;
120         }
121     }
122 }
123