xref: /aosp_15_r20/system/libvintf/include/vintf/Level.h (revision 70a7ec852fcefd15a4fb57f8f183a8b1c3aacb08)
1 /*
2  * Copyright (C) 2017 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 #ifndef ANDROID_VINTF_LEVEL_H
18 #define ANDROID_VINTF_LEVEL_H
19 
20 #include <stddef.h>
21 #include <stdint.h>
22 #include <array>
23 #include <string>
24 
25 namespace android {
26 namespace vintf {
27 
28 // Manifest and Compatibility Matrix Level, a.k.a FCM Version, is a number assigned to each
29 // manifest / matrix.
30 // - For manifest, the FCM Version that it implements
31 // - For matrix, the single FCM Version that this matrix file details.
32 enum class Level : size_t {
33     // LINT.IfChange
34     // Non-Treble devices.
35     LEGACY = 0,
36     // Actual values starts from 1.
37     O = 1,
38     O_MR1 = 2,
39     P = 3,
40     Q = 4,
41     R = 5,
42     S = 6,
43     T = 7,
44     U = 8,
45     V = 202404,
46     W = 202504,  // TODO(346861728) placeholder letter/number.
47     // To add new values:
48     // (1) add above this line.
49     // (2) edit array below
50     // (3) edit:
51     // - RuntimeInfo::gkiAndroidReleaseToLevel
52     // - analyze_matrix.cpp, GetDescription()
53     // LINT.ThenChange(/analyze_matrix/analyze_matrix.cpp)
54 
55     // For older manifests and compatibility matrices, "level" is not specified.
56     UNSPECIFIED = SIZE_MAX,
57 };
58 
IsValid(Level level)59 inline bool IsValid(Level level) {
60     constexpr std::array kValidLevels = {
61         // clang-format off
62         Level::LEGACY,
63         Level::O,
64         Level::O_MR1,
65         Level::P,
66         Level::Q,
67         Level::R,
68         Level::S,
69         Level::T,
70         Level::U,
71         Level::V,
72         Level::W,
73         Level::UNSPECIFIED,
74         // clang-format on
75     };
76 
77     return std::find(kValidLevels.begin(), kValidLevels.end(), level) != kValidLevels.end();
78 }
79 
80 std::string GetDescription(Level level);
81 
82 }  // namespace vintf
83 }  // namespace android
84 
85 #endif  // ANDROID_VINTF_LEVEL_H
86