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.mediapc.cts.common;
18 
19 import java.util.function.BiPredicate;
20 
21 /**
22  * Stores constants used by PerformanceClassEvaluator.  Constants relating to requirement number are
23  * stored in order as they appear in the Android CDD.  Constants relating to measurements are stored
24  * alphabetically.
25  */
26 public class RequirementConstants {
27     private static final String TAG = RequirementConstants.class.getSimpleName();
28 
29     public static final String REPORT_LOG_NAME = "CtsMediaPerformanceClassTestCases";
30     public static final String TN_FIELD_NAME = "test_name";
31     public static final String PC_FIELD_NAME = "performance_class";
32 
33     // Requirement IDs.
34     // keep-sorted start numeric=yes
35 
36     public static final String R5_1__H_1_1 = "r5_1__h_1_1"; // 5.1/H-1-1
37     public static final String R5_1__H_1_2 = "r5_1__h_1_2"; // 5.1/H-1-2
38     public static final String R5_1__H_1_3 = "r5_1__h_1_3"; // 5.1/H-1-3
39     public static final String R5_1__H_1_4 = "r5_1__h_1_4"; // 5.1/H-1-4
40     public static final String R5_1__H_1_5 = "r5_1__h_1_5"; // 5.1/H-1-5
41     public static final String R5_1__H_1_6 = "r5_1__h_1_6"; // 5.1/H-1-6
42     public static final String R5_1__H_1_7 = "r5_1__h_1_7"; // 5.1/H-1-7
43     public static final String R5_1__H_1_8 = "r5_1__h_1_8"; // 5.1/H-1-8
44     public static final String R5_1__H_1_9 = "r5_1__h_1_9"; // 5.1/H-1-9
45     public static final String R5_1__H_1_10 = "r5_1__h_1_10"; // 5.1/H-1-10
46     public static final String R5_1__H_1_11 = "r5_1__h_1_11"; // 5.1/H-1-11
47     public static final String R5_1__H_1_12 = "r5_1__h_1_12"; // 5.1/H-1-12
48     public static final String R5_1__H_1_13 = "r5_1__h_1_13"; // 5.1/H-1-13
49     public static final String R5_1__H_1_14 = "r5_1__h_1_14"; // 5.1/H-1-14
50     public static final String R5_1__H_1_15 = "r5_1__h_1_15"; // 5.1/H-1-16
51     public static final String R5_1__H_1_16 = "r5_1__h_1_16"; // 5.1/H-1-16
52     public static final String R5_1__H_1_17 = "r5_1__h_1_17"; // 5.1/H-1-17
53     public static final String R5_1__H_1_18 = "r5_1__h_1_18"; // 5.1/H-1-18
54     public static final String R5_1__H_1_19 = "r5_1__h_1_19"; // 5.1/H-1-19
55     public static final String R5_1__H_1_20 = "r5_1__h_1_20"; // 5.1/H-1-20
56     public static final String R5_1__H_1_21 = "r5_1__h_1_21"; // 5.1/H-1-21
57     public static final String R5_1__H_1_22 = "r5_1__h_1_22"; // 5.1/H-1-22
58     public static final String R5_3__H_1_1 = "r5_3__h_1_1"; // 5.3/H-1-1
59     public static final String R5_3__H_1_2 = "r5_3__h_1_2"; // 5.3/H-1-2
60     public static final String R5_6__H_1_1 = "r5_6__h_1_1"; // 5.6/H-1-1
61     public static final String R5_7__H_1_1 = "r5_7__h_1_1"; // 5.7/H-1-1
62     public static final String R5_7__H_1_2 = "r5_7__h_1_2"; // 5.7/H-1-2
63     public static final String R5_12__H_1_2 = "r5_12__h_1_2"; // 5.12/H-1-2
64     public static final String R5_12__H_1_3 = "r5_12__h_1_3"; // 5.12/H-1-3
65     public static final String R7_1_1_1__H_1_1 = "r7_1_1_1__h_1_1"; // 7.1.1.1/H-1-1
66     public static final String R7_1_1_1__H_2_1 = "r7_1_1_1__h_2_1"; // 7.1.1.1/H-2-1
67     public static final String R7_1_1_3__H_1_1 = "r7_1_1_3__h_1_1"; // 7.1.1.3/H-1-1
68     public static final String R7_1_1_3__H_2_1 = "r7_1_1_3__h_2_1"; // 7.1.1.3/H-2-1
69     public static final String R7_1_1_3__H_3_1 = "r7_1_1_3__H_3_1"; // 7.1.1.3/H-3-1
70     public static final String R7_1_4_1__H_1_2 = "r7_1_4_1__h_1_2"; // 7.1.4.1/H-1-2
71     public static final String R7_1_4_1__H_1_3 = "r7_1_4_1__h_1_3"; // 7.1.4.1/H-1-3
72     public static final String R7_5__H_1_1 = "r7_5__h_1_1"; // 7.5/H-1-1
73     public static final String R7_5__H_1_2 = "r7_5__h_1_2"; // 7.5/H-1-2
74     public static final String R7_5__H_1_3 = "r7_5__h_1_3"; // 7.5/H-1-3
75     public static final String R7_5__H_1_4 = "r7_5__h_1_4"; // 7.5/H-1-4
76     // includes "its" because the proto in google3 was originally implemented incorrectly
77     public static final String R7_5__H_1_5 = "r7_5__h_1_5__its"; // 7.5/H-1-5
78     // includes "its" because the proto in google3 was originally implemented incorrectly
79     public static final String R7_5__H_1_6 = "r7_5__h_1_6__its"; // 7.5/H-1-6
80     public static final String R7_5__H_1_8 = "r7_5__h_1_8"; // 7.5/H-1-8
81     public static final String R7_5__H_1_9 = "r7_5__h_1_9"; // 7.5/H-1-9
82     public static final String R7_5__H_1_10 = "r7_5__h_1_10"; // 7.5/H-1-10
83     public static final String R7_5__H_1_11 = "r7_5__h_1_11"; // 7.5/H-1-11
84     public static final String R7_5__H_1_12 = "r7_5__h_1_12"; // 7.5/H-1-12
85     public static final String R7_5__H_1_13 = "r7_5__h_1_13"; // 7.5/H-1-13
86     public static final String R7_5__H_1_14 = "r7_5__h_1_14"; // 7.5/H-1-14
87     public static final String R7_5__H_1_15 = "r7_5__h_1_15"; // 7.5/H-1-15
88     public static final String R7_5__H_1_16 = "r7_5__h_1_16"; // 7.5/H-1-16
89     public static final String R7_5__H_1_17 = "r7_5__h_1_17"; // 7.5/H-1-17
90     public static final String R7_5__H_1_18 = "r7_5__h_1_18"; // 7.5/H-1-18
91     public static final String R7_5__H_1_19 = "r7_5__h_1_19"; // 7.5/H-1-19
92     public static final String R7_5__H_1_20 = "r7_5__h_1_20"; // 7.5/H-1-20
93     public static final String R7_6_1__H_1_1 = "r7_6_1__h_1_1"; // 7.6.1/H-1-1
94     public static final String R7_6_1__H_2_1 = "r7_6_1__h_2_1"; // 7.6.1/H-2-1
95     public static final String R7_6_1__H_3_1 = "r7_6_1__h_3_1"; // 7.6.1/H-3-1, currently unused
96     public static final String R8_2__H_1_1 = "r8_2__h_1_1"; // 8.2/H-1-1
97     public static final String R8_2__H_1_2 = "r8_2__h_1_2"; // 8.2/H-1-2
98     public static final String R8_2__H_1_3 = "r8_2__h_1_3"; // 8.2/H-1-3
99     public static final String R8_2__H_1_4 = "r8_2__h_1_4"; // 8.2/H-1-4
100     public static final String R8_2__H_2_1 = "r8_2__h_2_1"; // 8.2/H-2-1
101     public static final String R8_2__H_2_2 = "r8_2__h_2_2"; // 8.2/H-2-2
102     public static final String R8_2__H_2_3 = "r8_2__h_2_3"; // 8.2/H-2-3
103     public static final String R8_2__H_2_4 = "r8_2__h_2_4"; // 8.2/H-2-4
104     public static final String RTBD = "tbd"; // placeholder for requirements without a set id
105 
106     // keep-sorted end
107 
108     // Required measurements. These must be valid proto field names.
109     // keep-sorted start
110 
111     public static final String API_JAVA_LATENCY = "java_latency_ms";
112     public static final String API_NATIVE_LATENCY = "native_latency_ms";
113     public static final String AV1_DEC_REQ = "av1_decoder_requirement_boolean";
114     public static final String AV1_ENC_BITRATE = "av1_encoder_bitrate";
115     public static final String AV1_ENC_FPS = "av1_encoder_fps";
116     public static final String AV1_ENC_RESOLUTION = "av1_encoder_resolution";
117     public static final String AVIF_DEC_REQ = "avif_image_decoder_boolean";
118     public static final String CODEC_INIT_LATENCY = "codec_initialization_latency_ms";
119     public static final String CONCURRENT_FPS = "concurrent_fps";
120     public static final String CONCURRENT_REAR_FRONT_SUPPORTED = "rear_front_concurrent_camera";
121     public static final String CONCURRENT_SESSIONS = "concurrent_sessions";
122     public static final String DISPLAY_DENSITY = "display_density_dpi";
123     public static final String DISPLAY_LUMINANCE_NITS = "display_luminance_nits";
124     public static final String DYNAMIC_COLOR_ASPECTS = "dynamic_color_aspects";
125     public static final String EGL_EXT_PROTECTED_CONTENT = "egl_ext_protected_content";
126     public static final String EGL_IMG_CONTEXT_PRIORITY = "egl_img_context_priority";
127     public static final String EXT_YUV_EXTENSION = "ext_yuv_target_supported";
128     public static final String FILESYSTEM_IO_RATE = "filesystem_io_rate_mbps";
129     public static final String FRAMES_DROPPED = "frame_drops_per_30sec";
130     public static final String FRAMES_DROPPED_PER_SECOND = "frame_drops_per_sec";
131     public static final String FRAME_RATE = "frame_rate";
132     public static final String FRONT_CAMERA2_EXTENSION_NIGHT_SUPPORTED =
133             "front_camera2_extension_night_supported";
134     public static final String FRONT_CAMERAX_EXTENSION_NIGHT_SUPPORTED =
135             "front_camerax_extension_night_supported";
136     public static final String FRONT_CAMERA_DYNAMIC_TENBITS_SUPPORTED =
137             "front_camera_dynamic_tenbits_supported";
138     public static final String FRONT_CAMERA_FACE_DETECTION_SUPPORTED =
139             "front_camera_face_detection_supported";
140     public static final String FRONT_CAMERA_HWL_LEVEL = "front_primary_camera_hwl_level";
141     public static final String FRONT_CAMERA_LATENCY = "front_camera_latency";
142     public static final String FRONT_CAMERA_LOGICAL_MULTI_CAMERA_REQ_MET =
143             "front_camera_logical_multi_camera_req_met";
144     public static final String FRONT_CAMERA_STREAM_USECASE_SUPPORTED =
145             "front_camera_stream_usecase_supported";
146     public static final String FRONT_CAMERA_TIMESTAMP_SOURCE =
147             "front_primary_camera_timestamp_source";
148     public static final String FRONT_CAMERA_ULTRAWIDE_ZOOMRATIO_REQ_MET =
149             "front_camera_ultrawide_zoom_req_met";
150     public static final String FRONT_CAMERA_ULTRA_HDR_SUPPORTED =
151             "front_camera_ultra_hdr_supported";
152     public static final String HLG_EDITING = "hlg_editing";
153     public static final String IS_HDR = "is_hdr";
154     public static final String LONG_RESOLUTION = "long_resolution_pixels";
155     public static final String NUM_4k_HW_DEC = "number_4k_hw_decoders";
156     public static final String NUM_4k_HW_ENC = "number_4k_hw_encoders";
157     public static final String NUM_CRYPTO_HW_SECURE_ALL_SUPPORT =
158             "number_crypto_hw_secure_all_support";
159     public static final String PHYSICAL_MEMORY = "physical_memory_mb";
160     public static final String PORTRAIT_RESOLUTION = "portrait_resolution";
161     public static final String PRIMARY_CAMERA_1080p_VIDEO_FPS =
162             "primary_camera_1080p_video_fps";
163     public static final String PRIMARY_CAMERA_1080p_VIDEO_SIZE_REQ_SATISFIED =
164             "primary_camera_1080p_video_size_req_satisfied";
165     public static final String PRIMARY_CAMERA_720p_VIDEO_FPS =
166             "primary_camera_720p_video_fps";
167     public static final String PRIMARY_CAMERA_720p_VIDEO_SIZE_REQ_SATISFIED =
168             "primary_camera_720p_video_size_req_satisfied";
169     public static final String PRIMARY_CAMERA_AVAILABLE = "primary_camera_available";
170     public static final String PRIMARY_CAMERA_HLG_COMBINATION_SUPPORTED =
171             "primary_camera_hlg_combination_supported";
172     public static final String PRIMARY_CAMERA_RESOLUTION = "primary_camera_resolution";
173     public static final String PRIMARY_CAMERA_VIDEO_FPS = "primary_camera_video_fps";
174     public static final String PRIMARY_CAMERA_VIDEO_SIZE_REQ_SATISFIED =
175             "primary_camera_video_size_req_satisfied";
176     public static final String PRIMARY_FRONT_CAMERA_JPEG_R_SUPPORTED =
177             "primary_front_camera_jpeg_r_supported";
178     public static final String PRIMARY_REAR_CAMERA_JPEG_R_SUPPORTED =
179             "primary_rear_camera_jpeg_r_supported";
180     public static final String REAR_CAMERA2_EXTENSION_NIGHT_SUPPORTED =
181             "rear_camera2_extension_night_supported";
182     public static final String REAR_CAMERAX_EXTENSION_NIGHT_SUPPORTED =
183             "rear_camerax_extension_night_supported";
184     public static final String REAR_CAMERA_240FPS_SUPPORTED = "rear_camera_240fps_supported";
185     public static final String REAR_CAMERA_DYNAMIC_TENBITS_SUPPORTED =
186             "rear_camera_dynamic_tenbits_supported";
187     public static final String REAR_CAMERA_FACE_DETECTION_SUPPORTED =
188             "rear_camera_face_detection_supported";
189     public static final String REAR_CAMERA_HWL_LEVEL = "rear_primary_camera_hwl_level";
190     public static final String REAR_CAMERA_LATENCY = "rear_camera_latency";
191     public static final String REAR_CAMERA_LOGICAL_MULTI_CAMERA_REQ_MET =
192             "rear_camera_logical_multi_camera_req_met";
193     public static final String REAR_CAMERA_PREVIEW_STABILIZATION_SUPPORTED =
194             "rear_camera_preview_stabilization_supported";
195     public static final String REAR_CAMERA_RAW_SUPPORTED = "rear_camera_raw_supported";
196     public static final String REAR_CAMERA_STREAM_USECASE_SUPPORTED =
197             "rear_camera_stream_usecase_supported";
198     public static final String REAR_CAMERA_TIMESTAMP_SOURCE =
199             "rear_primary_camera_timestamp_source";
200     public static final String REAR_CAMERA_ULTRAWIDE_ZOOMRATIO_REQ_MET =
201             "rear_camera_ultrawide_zoom_req_met";
202     public static final String REAR_CAMERA_ULTRA_HDR_SUPPORTED =
203             "rear_camera_ultra_hdr_supported";
204     public static final String RGBA_1010102_COLOR_FORMAT_REQ = "rgba_1010102_color_format";
205     public static final String SECURE_REQ_SATISFIED = "secure_requirement_satisfied_boolean";
206     public static final String SHORT_RESOLUTION = "short_resolution_pixels";
207     public static final String SUPPORTED_PERFORMANCE_POINTS = "supported_performance_points";
208     public static final String TEST_RESOLUTION = "resolution";
209     // keep-sorted end
210 
211     public enum Result {
212         NA, MET, UNMET
213     }
214 
215     public static final BiPredicate<Long, Long> LONG_INFO = RequirementConstants.info();
216     public static final BiPredicate<Long, Long> LONG_GTE = RequirementConstants.gte();
217     public static final BiPredicate<Long, Long> LONG_LTE = RequirementConstants.lte();
218 
219     public static final BiPredicate<Integer, Integer> INTEGER_INFO = RequirementConstants.info();
220     public static final BiPredicate<Integer, Integer> INTEGER_GTE = RequirementConstants.gte();
221     public static final BiPredicate<Integer, Integer> INTEGER_LTE = RequirementConstants.lte();
222     public static final BiPredicate<Integer, Integer> INTEGER_EQ = RequirementConstants.eq();
223 
224     public static final BiPredicate<Double, Double> DOUBLE_INFO = RequirementConstants.info();
225     public static final BiPredicate<Double, Double> DOUBLE_GTE = RequirementConstants.gte();
226     public static final BiPredicate<Double, Double> DOUBLE_LTE = RequirementConstants.lte();
227     public static final BiPredicate<Double, Double> DOUBLE_EQ = RequirementConstants.eq();
228 
229     public static final BiPredicate<Float, Float> FLOAT_INFO = RequirementConstants.info();
230     public static final BiPredicate<Float, Float> FLOAT_GTE = RequirementConstants.gte();
231     public static final BiPredicate<Float, Float> FLOAT_LTE = RequirementConstants.lte();
232 
233     public static final BiPredicate<Boolean, Boolean> BOOLEAN_EQ = RequirementConstants.eq();
234     public static final BiPredicate<Boolean, Boolean> BOOLEAN_INFO = RequirementConstants.info();
235 
236     public static final BiPredicate<String, String> STRING_INFO = RequirementConstants.info();
237 
238     /**
239      * Creates a >= predicate.
240      *
241      * This is convenience method to get the types right.
242      */
gte()243     private static <T, S extends Comparable<T>> BiPredicate<S, T> gte() {
244         return new BiPredicate<S, T>() {
245             @Override
246             public boolean test(S actual, T expected) {
247                 return actual.compareTo(expected) >= 0;
248             }
249 
250             @Override
251             public String toString() {
252                 return "Greater than or equal to";
253             }
254         };
255     }
256 
257 
258     /**
259      * Creates a bi predicate that always returns true because the measurements is for info only.
260      *
261      * <p>
262      * This is convenience method to get the types right.
263      */
264     private static <T> BiPredicate<T, T> info() {
265         return new BiPredicate<T, T>() {
266             @Override
267             public boolean test(T actual, T expected) {
268                 return true;
269             }
270 
271             @Override
272             public String toString() {
273                 return "True. For info only";
274             }
275         };
276     }
277 
278     /**
279      * Creates a <= predicate.
280      */
281     private static <T, S extends Comparable<T>> BiPredicate<S, T> lte() {
282         return new BiPredicate<S, T>() {
283             @Override
284             public boolean test(S actual, T expected) {
285                 return actual.compareTo(expected) <= 0;
286             }
287 
288             @Override
289             public String toString() {
290                 return "Less than or equal to";
291             }
292         };
293     }
294 
295     /**
296      * Creates an == predicate.
297      */
298     private static <T, S extends Comparable<T>> BiPredicate<S, T> eq() {
299         return new BiPredicate<S, T>() {
300             @Override
301             public boolean test(S actual, T expected) {
302                 return actual.compareTo(expected) == 0;
303             }
304 
305             @Override
306             public String toString() {
307                 return "Equal to";
308             }
309         };
310     }
311 
312     private RequirementConstants() {} // class should not be instantiated
313 }
314