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 #include "utils-fake.h" 18 19 namespace android { 20 namespace vintf { 21 namespace details { 22 23 MockRuntimeInfo::MockRuntimeInfo() { 24 kernel_info_.mVersion = {3, 18, 31}; 25 kernel_info_.mConfigs = {{"CONFIG_64BIT", "y"}, 26 {"CONFIG_ANDROID_BINDER_DEVICES", "\"binder,hwbinder\""}, 27 {"CONFIG_ARCH_MMAP_RND_BITS", "24"}, 28 {"CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES", "\"\""}, 29 {"CONFIG_ILLEGAL_POINTER_VALUE", "0xdead000000000000"}}; 30 ON_CALL(*this, fetchAllInformation(_)).WillByDefault(Invoke(this, &MockRuntimeInfo::doFetch)); 31 } 32 33 status_t MockRuntimeInfo::doFetch(RuntimeInfo::FetchFlags flags) { 34 if (failNextFetch_) { 35 failNextFetch_ = false; 36 return android::UNKNOWN_ERROR; 37 } 38 39 if (flags & RuntimeInfo::FetchFlag::CPU_VERSION) { 40 mOsName = "Linux"; 41 mNodeName = "localhost"; 42 mOsRelease = "3.18.31-g936f9a479d0f"; 43 mOsVersion = "#4 SMP PREEMPT Wed Feb 1 18:10:52 PST 2017"; 44 mHardwareId = "aarch64"; 45 mKernel.mVersion = kernel_info_.mVersion; 46 } 47 48 if (flags & RuntimeInfo::FetchFlag::POLICYVERS) { 49 mKernelSepolicyVersion = 30; 50 } 51 52 if (flags & RuntimeInfo::FetchFlag::CONFIG_GZ) { 53 mKernel.mConfigs = kernel_info_.mConfigs; 54 } 55 // fetchAllInformtion does not fetch kernel FCM version 56 return OK; 57 } 58 void MockRuntimeInfo::setNextFetchKernelInfo(KernelVersion&& v, 59 std::map<std::string, std::string>&& configs) { 60 kernel_info_.mVersion = std::move(v); 61 kernel_info_.mConfigs = std::move(configs); 62 } 63 void MockRuntimeInfo::setNextFetchKernelInfo(const KernelVersion& v, 64 const std::map<std::string, std::string>& configs) { 65 kernel_info_.mVersion = v; 66 kernel_info_.mConfigs = configs; 67 } 68 69 } // namespace details 70 } // namespace vintf 71 } // namespace android 72