1 /* 2 * Copyright (C) 2019 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 #pragma once 18 19 #include <map> 20 #include <string> 21 #include <vector> 22 23 #include "MatrixKernel.h" 24 #include "Version.h" 25 26 namespace android { 27 namespace vintf { 28 29 namespace details { 30 class MockRuntimeInfo; 31 struct StaticRuntimeInfo; 32 } // namespace details 33 34 // KernelInfo includes kernel-specific information on a device. 35 class KernelInfo { 36 public: 37 KernelInfo() = default; 38 39 const KernelVersion& version() const; 40 const std::map<std::string, std::string>& configs() const; 41 Level level() const; 42 43 // mVersion = x'.y'.z', minLts = x.y.z, 44 // match if x == x' , y == y' , and z <= z'. 45 bool matchKernelVersion(const KernelVersion& minLts) const; 46 // return true if all kernel configs in matrixConfigs matches. 47 bool matchKernelConfigs(const std::vector<KernelConfig>& matrixConfigs, 48 std::string* error = nullptr) const; 49 // return vector of pointers to elements in "kernels" that this matches 50 // kernel requirement specified. 51 std::vector<const MatrixKernel*> getMatchedKernelRequirements( 52 const std::vector<MatrixKernel>& kernels, Level kernelLevel, 53 std::string* error = nullptr) const; 54 bool operator==(const KernelInfo& other) const; 55 56 // Merge information from "other". 57 bool merge(KernelInfo* other, std::string* error = nullptr); 58 59 private: 60 friend class AssembleVintfImpl; 61 friend class details::MockRuntimeInfo; 62 friend struct details::StaticRuntimeInfo; 63 friend struct KernelInfoConverter; 64 friend struct LibVintfTest; 65 friend struct RuntimeInfoFetcher; 66 friend struct RuntimeInfo; 67 68 std::vector<const MatrixKernel*> getMatchedKernelVersionAndConfigs( 69 const std::vector<const MatrixKernel*>& kernels, std::string* error) const; 70 71 // x.y.z 72 KernelVersion mVersion; 73 // /proc/config.gz 74 // Key: CONFIG_xxx; Value: the value after = sign. 75 std::map<std::string, std::string> mConfigs; 76 // Kernel FCM version 77 Level mLevel = Level::UNSPECIFIED; 78 }; 79 80 } // namespace vintf 81 } // namespace android 82