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 final int HWCAP_VFP = (1 << 6); 32 33 public static final int HWCAP_NEON = (1 << 12); 34 35 public static final int HWCAP_VFPv3 = (1 << 13); 36 37 public static final int HWCAP_VFPv4 = (1 << 16); 38 39 public static final int HWCAP_IDIVA = (1 << 17); 40 41 public static final int HWCAP_IDIVT = (1 << 18); 42 43 static { 44 System.loadLibrary("cts_jni"); 45 } 46 isArmCpu()47 public static native boolean isArmCpu(); 48 isArm7Compatible()49 public static native boolean isArm7Compatible(); 50 isMipsCpu()51 public static native boolean isMipsCpu(); 52 isX86Cpu()53 public static native boolean isX86Cpu(); 54 isArm64Cpu()55 public static native boolean isArm64Cpu(); 56 isMips64Cpu()57 public static native boolean isMips64Cpu(); 58 isX86_64Cpu()59 public static native boolean isX86_64Cpu(); 60 getHwCaps()61 public static native int getHwCaps(); 62 isArm64CpuIn32BitMode()63 public static boolean isArm64CpuIn32BitMode() { 64 if (!isArmCpu()) { 65 return false; 66 } 67 68 for (String abi : Build.SUPPORTED_64_BIT_ABIS) { 69 if (abi.equals("arm64-v8a")) { 70 return true; 71 } 72 } 73 74 return false; 75 } 76 } 77