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 } // namespace details 32 33 // KernelInfo includes kernel-specific information on a device. 34 class KernelInfo { 35 public: 36 KernelInfo() = default; 37 38 const KernelVersion& version() const; 39 const std::map<std::string, std::string>& configs() const; 40 41 // mVersion = x'.y'.z', minLts = x.y.z, 42 // match if x == x' , y == y' , and z <= z'. 43 bool matchKernelVersion(const KernelVersion& minLts) const; 44 // return true if all kernel configs in matrixConfigs matches. 45 bool matchKernelConfigs(const std::vector<KernelConfig>& matrixConfigs, 46 std::string* error = nullptr) const; 47 // return true if this matches kernel requirement specified. 48 bool matchKernelRequirements(const std::vector<MatrixKernel>& kernels, 49 std::string* error = nullptr) const; 50 51 bool operator==(const KernelInfo& other) const; 52 53 private: 54 friend class AssembleVintfImpl; 55 friend class details::MockRuntimeInfo; 56 friend struct KernelInfoConverter; 57 friend struct LibVintfTest; 58 friend struct RuntimeInfoFetcher; 59 // x.y.z 60 KernelVersion mVersion; 61 // /proc/config.gz 62 // Key: CONFIG_xxx; Value: the value after = sign. 63 std::map<std::string, std::string> mConfigs; 64 }; 65 66 } // namespace vintf 67 } // namespace android 68