Home | History | Annotate | Download | only in vintf
      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_RUNTIME_INFO_H
     18 #define ANDROID_VINTF_RUNTIME_INFO_H
     19 
     20 #include "Version.h"
     21 
     22 #include <map>
     23 #include <string>
     24 #include <vector>
     25 
     26 #include <utils/Errors.h>
     27 
     28 namespace android {
     29 namespace vintf {
     30 
     31 struct CompatibilityMatrix;
     32 
     33 // Runtime Info sent to OTA server
     34 struct RuntimeInfo {
     35 
     36     RuntimeInfo() {}
     37 
     38     // /proc/version
     39     // utsname.sysname
     40     const std::string &osName() const;
     41     // utsname.nodename
     42     const std::string &nodeName() const;
     43     // utsname.release
     44     const std::string &osRelease() const;
     45     // utsname.version
     46     const std::string &osVersion() const;
     47     // utsname.machine
     48     const std::string &hardwareId() const;
     49     // extract from utsname.release
     50     const KernelVersion &kernelVersion() const;
     51 
     52     const std::map<std::string, std::string> &kernelConfigs() const;
     53 
     54     const Version &bootVbmetaAvbVersion() const;
     55     const Version &bootAvbVersion() const;
     56 
     57     // /proc/cpuinfo
     58     const std::string &cpuInfo() const;
     59 
     60     // /sys/fs/selinux/policyvers
     61     size_t kernelSepolicyVersion() const;
     62 
     63     // Return whether this RuntimeInfo works with the given compatibility matrix. Return true if:
     64     // - mat is a framework compat-mat
     65     // - sepolicy.kernel-sepolicy-version == kernelSepolicyVersion()
     66     // - /proc/config.gz matches the requirements. Note that /proc/config.gz is read when the
     67     //   RuntimeInfo object is created (the first time VintfObject::GetRuntimeInfo is called),
     68     //   not when RuntimeInfo::checkCompatibility is called.
     69     // - avb-vbmetaversion matches related sysprops
     70     bool checkCompatibility(const CompatibilityMatrix &mat,
     71             std::string *error = nullptr) const;
     72 
     73 private:
     74 
     75     friend struct RuntimeInfoFetcher;
     76     friend class VintfObject;
     77     friend struct LibVintfTest;
     78     friend std::string dump(const RuntimeInfo &ki);
     79 
     80     status_t fetchAllInformation();
     81 
     82     // /proc/config.gz
     83     // Key: CONFIG_xxx; Value: the value after = sign.
     84     std::map<std::string, std::string> mKernelConfigs;
     85     std::string mOsName;
     86     std::string mNodeName;
     87     std::string mOsRelease;
     88     std::string mOsVersion;
     89     std::string mHardwareId;
     90     KernelVersion mKernelVersion;
     91 
     92     std::vector<std::string> mSepolicyFilePaths;
     93     std::string mCpuInfo;
     94     Version mBootVbmetaAvbVersion;
     95     Version mBootAvbVersion;
     96 
     97     size_t mKernelSepolicyVersion;
     98 
     99 };
    100 
    101 } // namespace vintf
    102 } // namespace android
    103 
    104 #endif // ANDROID_VINTF_RUNTIME_INFO_H
    105