Sepolicy.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #ifndef ANDROID_VINTF_SEPOLICY_H
  17. #define ANDROID_VINTF_SEPOLICY_H
  18. namespace android {
  19. namespace vintf {
  20. struct KernelSepolicyVersion {
  21. size_t value;
  22. inline KernelSepolicyVersion() : KernelSepolicyVersion(0u) {}
  23. inline KernelSepolicyVersion(size_t v) : value(v) {}
  24. inline operator size_t() const {
  25. return value;
  26. }
  27. };
  28. // Sepolicy section in compatibility matrix.
  29. struct Sepolicy {
  30. Sepolicy() : Sepolicy(0u, {}) {}
  31. Sepolicy(KernelSepolicyVersion kernelSepolicyVersion,
  32. std::vector<VersionRange> &&sepolicyVersions) :
  33. mKernelSepolicyVersion(kernelSepolicyVersion),
  34. mSepolicyVersionRanges(std::move(sepolicyVersions)) {}
  35. inline size_t kernelSepolicyVersion() const { return mKernelSepolicyVersion.value; }
  36. inline const std::vector<VersionRange> &sepolicyVersions() const {
  37. return mSepolicyVersionRanges;
  38. }
  39. private:
  40. friend class AssembleVintfImpl;
  41. friend struct SepolicyConverter;
  42. KernelSepolicyVersion mKernelSepolicyVersion;
  43. std::vector<VersionRange> mSepolicyVersionRanges;
  44. };
  45. inline bool operator==(const Sepolicy &lft, const Sepolicy &rgt) {
  46. return lft.kernelSepolicyVersion() == rgt.kernelSepolicyVersion() &&
  47. lft.sepolicyVersions() == rgt.sepolicyVersions();
  48. }
  49. } // namespace vintf
  50. } // namespace android
  51. #endif // ANDROID_VINTF_SEPOLICY_H