模拟器检验

  1. 属性检测
    1.  //判断当前设备是否是模拟器。如果返回TRUE,则当前是模拟器,不是返回FALSE
          public static boolean isEmulator(Context context){
              try{
                  TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
                  String imei = tm.getDeviceId();
                  if (imei != null && imei.equals("000000000000000")){
                      return true;
                  }
                  return  (Build.MODEL.equals("sdk")) || (Build.MODEL.equals("google_sdk"));//系统全局属性判断
              }catch (Exception ioe) {

              }
              return false;
          } 
                   其次,android各个os版本都有code name,模拟器中,属性 BRAND和DEVICE都是“generic”,Landroid/os/Build:->BRAND的值可以判断是否为模拟器;
          绕过方法:修改系统源码相应属性,重新编译;将判断模拟器的逻辑代码重新设计;
       2. 检测IMEI和IMSI,默认值分别为000000000000000(15个)和310260000000000
          需要申请android.permission.READ_PHONE_STATE权限
           TelephoneManager Tm=(TelephoneyManager)getSystemService(TELEPHONY_SERVICE);
          String imsi=Tm.getSubscriberId();
          String imei=Tm.getDeviceId();
          绕过方法:修改Android SDK下/tools/emulator-arm.exe文件,修改后保存

     


2.     虚拟文件检测
     模拟器中存在特殊文件或目录,如/system/bin/qemu-props(在模拟器中设置系统属性),/system/lib/libc_malloc_debug_qemu.so文件,/sys/qemu_trace目录等。

     private static String[] knwon_files={"/system/bin/qemu-props","/system/lib/libc_malloc_debug_qemu.so","/sys/qemu_trace"};
     
     public static boolean hasQEmuFiles(){
          for(String pipe: known_files){
               File qemu_file=new File(pipe);
               if(qemu_file.exists()){
                    return true;
         }
          return false;
     }
     参考资料: https://github.com/strazzere



3.     基于Cache行为的模拟器检测

转载于:https://www.cnblogs.com/littlefishxu/p/3969200.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值