Kiyoung Kim | 6d7cb59 | 2019-03-13 15:07:57 +0900 | [diff] [blame] | 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 | */ |
Kiyoung Kim | 6d7cb59 | 2019-03-13 15:07:57 +0900 | [diff] [blame] | 16 | |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 17 | #include "linkerconfig/environment.h" |
Kiyoung Kim | 09cbb08 | 2019-12-05 16:44:34 +0900 | [diff] [blame] | 18 | |
| 19 | #include <unistd.h> |
| 20 | |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 21 | #include "linkerconfig/variables.h" |
Kiyoung Kim | 6d7cb59 | 2019-03-13 15:07:57 +0900 | [diff] [blame] | 22 | |
| 23 | namespace android { |
| 24 | namespace linkerconfig { |
| 25 | namespace modules { |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 26 | bool IsLegacyDevice() { |
Daichi Hirono | 33648de | 2019-10-31 01:49:23 +0000 | [diff] [blame] | 27 | return (!Variables::GetValue("ro.vndk.version").has_value() && |
| 28 | !Variables::GetValue("ro.vndk.lite").has_value()) || |
| 29 | Variables::GetValue("ro.treble.enabled") == "false"; |
Kiyoung Kim | e655807 | 2019-09-30 16:58:39 +0900 | [diff] [blame] | 30 | } |
Kiyoung Kim | 6d7cb59 | 2019-03-13 15:07:57 +0900 | [diff] [blame] | 31 | |
Kiyoung Kim | e655807 | 2019-09-30 16:58:39 +0900 | [diff] [blame] | 32 | bool IsVndkLiteDevice() { |
| 33 | return Variables::GetValue("ro.vndk.lite").value_or("") == "true"; |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 34 | } |
Kiyoung Kim | 6d7cb59 | 2019-03-13 15:07:57 +0900 | [diff] [blame] | 35 | |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 36 | bool IsVndkInSystemNamespace() { |
Kiyoung Kim | e9a77fe | 2019-05-23 11:04:20 +0900 | [diff] [blame] | 37 | return Variables::GetValue("VNDK_USING_CORE_VARIANT_LIBRARIES").has_value(); |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 38 | } |
Kiyoung Kim | 6d7cb59 | 2019-03-13 15:07:57 +0900 | [diff] [blame] | 39 | |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 40 | std::string GetVendorVndkVersion() { |
| 41 | return Variables::GetValue("ro.vndk.version").value_or(""); |
| 42 | } |
Kiyoung Kim | 09cbb08 | 2019-12-05 16:44:34 +0900 | [diff] [blame] | 43 | |
Justin Yun | 2a07d26 | 2019-12-16 17:47:02 +0900 | [diff] [blame] | 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 | |
Kiyoung Kim | 09cbb08 | 2019-12-05 16:44:34 +0900 | [diff] [blame] | 52 | bool IsRecoveryMode() { |
| 53 | return access("/system/bin/recovery", F_OK) == 0; |
| 54 | } |
Kiyoung Kim | 6d7cb59 | 2019-03-13 15:07:57 +0900 | [diff] [blame] | 55 | } // namespace modules |
| 56 | } // namespace linkerconfig |
Justin Yun | 2a07d26 | 2019-12-16 17:47:02 +0900 | [diff] [blame] | 57 | } // namespace android |