| 1 |
/* |
| 2 |
* Copyright (C) 2022 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 |
package com.android.server.art; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.os.Build; |
| 22 |
import android.os.SystemProperties; |
| 23 |
import android.system.Os; |
| 24 |
|
| 25 |
/** |
| 26 |
* A mockable wrapper class for device-specific constants. |
| 27 |
* |
| 28 |
* @hide |
| 29 |
*/ |
| 30 |
public class Constants { |
| 31 |
private Constants() {} |
| 32 |
|
| 33 |
/** Returns the ABI that the device prefers. */ |
| 34 |
@NonNull |
| 35 |
public static String getPreferredAbi() { |
| 36 |
return Build.SUPPORTED_ABIS[0]; |
| 37 |
} |
| 38 |
|
| 39 |
/** Returns the 64 bit ABI that is native to the device. */ |
| 40 |
@Nullable |
| 41 |
public static String getNative64BitAbi() { |
| 42 |
// The value comes from "ro.product.cpu.abilist64" and we assume that the first element is |
| 43 |
// the native one. |
| 44 |
return Build.SUPPORTED_64_BIT_ABIS.length > 0 ? Build.SUPPORTED_64_BIT_ABIS[0] : null; |
| 45 |
} |
| 46 |
|
| 47 |
/** Returns the 32 bit ABI that is native to the device. */ |
| 48 |
@Nullable |
| 49 |
public static String getNative32BitAbi() { |
| 50 |
// The value comes from "ro.product.cpu.abilist32" and we assume that the first element is |
| 51 |
// the native one. |
| 52 |
return Build.SUPPORTED_32_BIT_ABIS.length > 0 ? Build.SUPPORTED_32_BIT_ABIS[0] : null; |
| 53 |
} |
| 54 |
|
| 55 |
@Nullable |
| 56 |
public static String getenv(@NonNull String name) { |
| 57 |
return Os.getenv(name); |
| 58 |
} |
| 59 |
|
| 60 |
public static boolean isBootImageProfilingEnabled() { |
| 61 |
boolean profileBootClassPath = SystemProperties.getBoolean( |
| 62 |
"persist.device_config.runtime_native_boot.profilebootclasspath", |
| 63 |
SystemProperties.getBoolean("dalvik.vm.profilebootclasspath", false /* def */)); |
| 64 |
return Build.isDebuggable() && profileBootClassPath; |
| 65 |
} |
| 66 |
} |