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 #include "linkerconfig/environment.h" 18 19 #include <unistd.h> 20 21 #include "linkerconfig/variables.h" 22 23 namespace android { 24 namespace linkerconfig { 25 namespace modules { IsTreblelizedDevice()26bool IsTreblelizedDevice() { 27 return Variables::GetValue("ro.treble.enabled").value_or("false") == "true"; 28 } 29 IsVndkLiteDevice()30bool IsVndkLiteDevice() { 31 return Variables::GetValue("ro.vndk.lite").value_or("") == "true"; 32 } 33 IsVndkInSystemNamespace()34bool IsVndkInSystemNamespace() { 35 return Variables::GetValue("VNDK_USING_CORE_VARIANT_LIBRARIES").has_value(); 36 } 37 GetVendorVndkVersion()38std::string GetVendorVndkVersion() { 39 return Variables::GetValue("ro.vndk.version").value_or(""); 40 } 41 GetProductVndkVersion()42std::string GetProductVndkVersion() { 43 return Variables::GetValue("ro.product.vndk.version").value_or(""); 44 } 45 IsVendorVndkVersionDefined()46bool IsVendorVndkVersionDefined() { 47 return Variables::GetValue("ro.vndk.version").has_value(); 48 } 49 IsProductVndkVersionDefined()50bool IsProductVndkVersionDefined() { 51 return Variables::GetValue("ro.product.vndk.version").has_value(); 52 } 53 IsRecoveryMode()54bool IsRecoveryMode() { 55 return access("/system/bin/recovery", F_OK) == 0; 56 } 57 } // namespace modules 58 } // namespace linkerconfig 59 } // namespace android 60