• 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     @SuppressWarnings("Enum")
57     enum CarVersion {
58 
59         TIRAMISU_0(android.car.CarVersion.VERSION_CODES.TIRAMISU_0),
60         TIRAMISU_1(android.car.CarVersion.VERSION_CODES.TIRAMISU_1),
61         TIRAMISU_2(android.car.CarVersion.VERSION_CODES.TIRAMISU_2),
62         TIRAMISU_3(android.car.CarVersion.VERSION_CODES.TIRAMISU_3);
63 
64         private final android.car.CarVersion mVersion;
65 
CarVersion(android.car.CarVersion version)66         CarVersion(android.car.CarVersion version) {
67             mVersion = version;
68         }
69 
70         /**
71          * Gets the {@link CarVersion} associated with it.
72          */
get()73         public android.car.CarVersion get() {
74             return mVersion;
75         }
76     }
77 
78     @SuppressWarnings("Enum")
79     enum PlatformVersion {
80 
81         TIRAMISU_0(android.car.PlatformVersion.VERSION_CODES.TIRAMISU_0),
82         TIRAMISU_1(android.car.PlatformVersion.VERSION_CODES.TIRAMISU_1),
83         TIRAMISU_2(android.car.PlatformVersion.VERSION_CODES.TIRAMISU_2),
84         TIRAMISU_3(android.car.PlatformVersion.VERSION_CODES.TIRAMISU_3);
85 
86         private final android.car.PlatformVersion mVersion;
87 
PlatformVersion(android.car.PlatformVersion version)88         PlatformVersion(android.car.PlatformVersion version) {
89             mVersion = version;
90         }
91 
92         /**
93          * Gets the {@link PlatformVersion} associated with it.
94          */
get()95         public android.car.PlatformVersion get() {
96             return mVersion;
97         }
98     }
99 }
100