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