1 /* 2 * Copyright (C) 2021 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 package com.android.modules.annotation; 17 18 import static java.lang.annotation.ElementType.CONSTRUCTOR; 19 import static java.lang.annotation.ElementType.FIELD; 20 import static java.lang.annotation.ElementType.METHOD; 21 import static java.lang.annotation.ElementType.TYPE; 22 import static java.lang.annotation.RetentionPolicy.CLASS; 23 24 import java.lang.annotation.Repeatable; 25 import java.lang.annotation.Retention; 26 import java.lang.annotation.Target; 27 28 /** 29 * Indicates than an API is only supported on platform versions of at least the given value and 30 * later. 31 * 32 * Currently, this annotations is purely informational. The exact meaning of this annotation depends 33 * on it's context: 34 * <ul> 35 * <li>On a public SDK method, it means that the member should only be included in the SDK of 36 * the given version or later</li> 37 * <li>On a module API, it will mean that it should only be called when running on a device with 38 * the given SDK or later</li> 39 * </ul> 40 * 41 * In future, the annotation will acquire further semantics: 42 * <ul> 43 * <li>Classes annotated with this will only be classloaded on devices running the given SDK 44 * version or later.</li> 45 * <li>It will be used to ensure API safety at build time in the context of a codebase with 46 * different parts having different min SDK versions.</li> 47 * </ul> 48 * 49 * This annotation should only be used on code that exports an API (either public SDK or 50 * {@code @SystemApi}. For code that just calls APIs that only exist on newer platform versions 51 * use {@code androidx.annotation.RequiresApi} instead. 52 */ 53 @Retention(CLASS) 54 @Target({CONSTRUCTOR, METHOD, FIELD, TYPE}) 55 public @interface MinSdk { value()56 int value(); 57 }