1 /*
2  * Copyright (C) 2010 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.compatibility.common.util;
18 
19 import android.os.Build;
20 
21 public class CpuFeatures {
22 
23     public static final String ARMEABI_V7 = "armeabi-v7a";
24 
25     public static final String ARMEABI = "armeabi";
26 
27     public static final String MIPSABI = "mips";
28 
29     public static final String X86ABI = "x86";
30 
31     public static class Arm64 {
32         public static final int HWCAP_VFP = (1 << 6);
33 
34         public static final int HWCAP_NEON = (1 << 12);
35 
36         public static final int HWCAP_VFPv3 = (1 << 13);
37 
38         public static final int HWCAP_VFPv4 = (1 << 16);
39 
40         public static final int HWCAP_IDIVA = (1 << 17);
41 
42         public static final int HWCAP_IDIVT = (1 << 18);
43     }
44 
45     static {
46         System.loadLibrary("cts_jni");
47     }
48 
isArmCpu()49     public static native boolean isArmCpu();
50 
isX86Cpu()51     public static native boolean isX86Cpu();
52 
isArm64Cpu()53     public static native boolean isArm64Cpu();
54 
isRiscv64Cpu()55     public static native boolean isRiscv64Cpu();
56 
isX86_64Cpu()57     public static native boolean isX86_64Cpu();
58 
getHwCaps()59     public static native int getHwCaps();
60 
isRiscv64MisalignedFast()61     public static native boolean isRiscv64MisalignedFast();
62 
isNativeBridgedCpu()63     public static native boolean isNativeBridgedCpu();
64 
isArm64CpuIn32BitMode()65     public static boolean isArm64CpuIn32BitMode() {
66         if (!isArmCpu()) {
67             return false;
68         }
69 
70         for (String abi : Build.SUPPORTED_64_BIT_ABIS) {
71             if (abi.equals("arm64-v8a")) {
72                 return true;
73             }
74         }
75 
76         return false;
77     }
78 }
79