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 // To add new values:
47 // (1) add above this line.
48 // (2) edit array below
49 // (3) edit:
50 // - RuntimeInfo::gkiAndroidReleaseToLevel
51 // - analyze_matrix.cpp, GetDescription()
52 // LINT.ThenChange(/analyze_matrix/analyze_matrix.cpp)
53
54 // For older manifests and compatibility matrices, "level" is not specified.
55 UNSPECIFIED = SIZE_MAX,
56 };
57
IsValid(Level level)58 inline bool IsValid(Level level) {
59 constexpr std::array kValidLevels = {
60 // clang-format off
61 Level::LEGACY,
62 Level::O,
63 Level::O_MR1,
64 Level::P,
65 Level::Q,
66 Level::R,
67 Level::S,
68 Level::T,
69 Level::U,
70 Level::V,
71 Level::UNSPECIFIED,
72 // clang-format on
73 };
74
75 return std::find(kValidLevels.begin(), kValidLevels.end(), level) != kValidLevels.end();
76 }
77
78 std::string GetDescription(Level level);
79
80 } // namespace vintf
81 } // namespace android
82
83 #endif // ANDROID_VINTF_LEVEL_H
84