• 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_COMPATIBILITY_MATRIX_H
18 #define ANDROID_VINTF_COMPATIBILITY_MATRIX_H
19 
20 #include <map>
21 #include <string>
22 
23 #include <utils/Errors.h>
24 
25 #include "HalGroup.h"
26 #include "MapValueIterator.h"
27 #include "MatrixHal.h"
28 #include "MatrixKernel.h"
29 #include "SchemaType.h"
30 #include "Sepolicy.h"
31 #include "Vndk.h"
32 #include "XmlFileGroup.h"
33 
34 namespace android {
35 namespace vintf {
36 
37 // Compatibility matrix defines what hardware does the framework requires.
38 struct CompatibilityMatrix : public HalGroup<MatrixHal>, public XmlFileGroup<MatrixXmlFile> {
39     // Create a framework compatibility matrix.
CompatibilityMatrixCompatibilityMatrix40     CompatibilityMatrix() : mType(SchemaType::FRAMEWORK) {};
41 
42     SchemaType type() const;
43 
44     constexpr static Version kVersion{1, 0};
45 
46     // If the corresponding <xmlfile> with the given version exists, for the first match,
47     // - Return the overridden <path> if it is present,
48     // - otherwise the default value: /{system,vendor}/etc/<name>_V<major>_<minor-max>.<format>
49     // Otherwise if the <xmlfile> entry does not exist, "" is returned.
50     // For example, if the matrix says ["audio@1.0-5" -> "foo.xml", "audio@1.3-7" -> bar.xml]
51     // getXmlSchemaPath("audio", 1.0) -> foo.xml
52     // getXmlSchemaPath("audio", 1.5) -> foo.xml
53     // getXmlSchemaPath("audio", 1.7) -> bar.xml
54     // (Normally, version ranges do not overlap, and the only match is returned.)
55     std::string getXmlSchemaPath(const std::string& xmlFileName, const Version& version) const;
56 
57    private:
58     bool add(MatrixHal &&hal);
59     bool add(MatrixKernel &&kernel);
60 
61     status_t fetchAllInformation(const std::string &path);
62 
63     friend struct HalManifest;
64     friend struct RuntimeInfo;
65     friend struct CompatibilityMatrixConverter;
66     friend struct LibVintfTest;
67     friend class VintfObject;
68     friend class AssembleVintf;
69     friend bool operator==(const CompatibilityMatrix &, const CompatibilityMatrix &);
70 
71     SchemaType mType;
72 
73     // entries only for framework compatibility matrix.
74     struct {
75         std::vector<MatrixKernel> mKernels;
76         Sepolicy mSepolicy;
77         Version mAvbMetaVersion;
78     } framework;
79 
80     // entries only for device compatibility matrix.
81     struct {
82         Vndk mVndk;
83     } device;
84 };
85 
86 } // namespace vintf
87 } // namespace android
88 
89 #endif // ANDROID_VINTF_COMPATIBILITY_MATRIX_H
90