1 /*
2  * Copyright (C) 2023 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.platform.test.annotations;
18 
19 import java.lang.annotation.ElementType;
20 import java.lang.annotation.Retention;
21 import java.lang.annotation.RetentionPolicy;
22 import java.lang.annotation.Target;
23 
24 /**
25  * Indicates that the annotated class uses flags from the provided classes.
26  *
27  * <p>In practice this tells {@code SetFlagsRule.ClassRule} to watch the all flags in the given
28  * classes to ensure they are not read before being set.
29  *
30  * <p>This annotation is redundant if any flag in the provided class is already provided to an
31  * {@link EnableFlags} or {@link DisableFlags} annotation on the same class or any of its tests.
32  *
33  * <p>This annotation is used by {@code SetFlagsRule.ClassRule} to determine which classes will be
34  * watched during class initialization, because only watched classes will be able to be enabled or
35  * disabled. The annotations {@link EnableFlags} or {@link DisableFlags} provide enough information
36  * on their own, but Parameterized tests and tests which imperatively set flags do not provide
37  * enough information via the junit Description to be watched, so this annotation is used to provide
38  * that information.
39  */
40 @Retention(RetentionPolicy.RUNTIME)
41 @Target(ElementType.TYPE)
42 public @interface UsesFlags {
43     /** The list of the `Flags` classes to watch. */
value()44     Class<?>[] value();
45 }
46