blob: e63be71c51bb4e392e9e46f47350c17486a89f48 [file] [log] [blame]
Kiyoung Kim6d7cb592019-03-13 15:07:57 +09001/*
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 */
Kiyoung Kim6d7cb592019-03-13 15:07:57 +090016
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090017#include "linkerconfig/environment.h"
Kiyoung Kim09cbb082019-12-05 16:44:34 +090018
19#include <unistd.h>
20
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090021#include "linkerconfig/variables.h"
Kiyoung Kim6d7cb592019-03-13 15:07:57 +090022
23namespace android {
24namespace linkerconfig {
25namespace modules {
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090026bool IsLegacyDevice() {
Daichi Hirono33648de2019-10-31 01:49:23 +000027 return (!Variables::GetValue("ro.vndk.version").has_value() &&
28 !Variables::GetValue("ro.vndk.lite").has_value()) ||
29 Variables::GetValue("ro.treble.enabled") == "false";
Kiyoung Kime6558072019-09-30 16:58:39 +090030}
Kiyoung Kim6d7cb592019-03-13 15:07:57 +090031
Kiyoung Kime6558072019-09-30 16:58:39 +090032bool IsVndkLiteDevice() {
33 return Variables::GetValue("ro.vndk.lite").value_or("") == "true";
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090034}
Kiyoung Kim6d7cb592019-03-13 15:07:57 +090035
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090036bool IsVndkInSystemNamespace() {
Kiyoung Kime9a77fe2019-05-23 11:04:20 +090037 return Variables::GetValue("VNDK_USING_CORE_VARIANT_LIBRARIES").has_value();
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090038}
Kiyoung Kim6d7cb592019-03-13 15:07:57 +090039
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090040std::string GetVendorVndkVersion() {
41 return Variables::GetValue("ro.vndk.version").value_or("");
42}
Kiyoung Kim09cbb082019-12-05 16:44:34 +090043
Justin Yun2a07d262019-12-16 17:47:02 +090044std::string GetProductVndkVersion() {
45 return Variables::GetValue("ro.product.vndk.version").value_or("");
46}
47
48bool IsProductVndkVersionDefined() {
49 return Variables::GetValue("ro.product.vndk.version").has_value();
50}
51
Kiyoung Kim09cbb082019-12-05 16:44:34 +090052bool IsRecoveryMode() {
53 return access("/system/bin/recovery", F_OK) == 0;
54}
Kiyoung Kim6d7cb592019-03-13 15:07:57 +090055} // namespace modules
56} // namespace linkerconfig
Justin Yun2a07d262019-12-16 17:47:02 +090057} // namespace android