KernelInfo.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. #pragma once
  17. #include <map>
  18. #include <string>
  19. #include <vector>
  20. #include "MatrixKernel.h"
  21. #include "Version.h"
  22. namespace android {
  23. namespace vintf {
  24. namespace details {
  25. class MockRuntimeInfo;
  26. } // namespace details
  27. // KernelInfo includes kernel-specific information on a device.
  28. class KernelInfo {
  29. public:
  30. KernelInfo() = default;
  31. const KernelVersion& version() const;
  32. const std::map<std::string, std::string>& configs() const;
  33. // mVersion = x'.y'.z', minLts = x.y.z,
  34. // match if x == x' , y == y' , and z <= z'.
  35. bool matchKernelVersion(const KernelVersion& minLts) const;
  36. // return true if all kernel configs in matrixConfigs matches.
  37. bool matchKernelConfigs(const std::vector<KernelConfig>& matrixConfigs,
  38. std::string* error = nullptr) const;
  39. // return true if this matches kernel requirement specified.
  40. bool matchKernelRequirements(const std::vector<MatrixKernel>& kernels,
  41. std::string* error = nullptr) const;
  42. bool operator==(const KernelInfo& other) const;
  43. private:
  44. friend class AssembleVintfImpl;
  45. friend class details::MockRuntimeInfo;
  46. friend struct KernelInfoConverter;
  47. friend struct LibVintfTest;
  48. friend struct RuntimeInfoFetcher;
  49. // x.y.z
  50. KernelVersion mVersion;
  51. // /proc/config.gz
  52. // Key: CONFIG_xxx; Value: the value after = sign.
  53. std::map<std::string, std::string> mConfigs;
  54. };
  55. } // namespace vintf
  56. } // namespace android