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