小米9屏下指纹判断

最近有个需求,需要指纹验证,但是在小米9上,会默认显示指纹图标,跟我们的就重复了,所以会显示两个图标在屏幕上。

查了miui的适配文档,可以通过一个参数“ro.hardware.fp.fod”来判断当前设备是否是屏下指纹,如果有这个变量且返回的值是“true”,则当前设备为屏下指纹。

文档地址:https://dev.mi.com/console/doc/detail?pId=1294

怎么读取变量ro.hardware.fp.fod:

手机接上电脑,直接执行adb shell getprop,可以得到所有的手机系统变量。每行都是key:value对应。ro.hardware.fp.fod就包含在其中,前提是你的设备支持屏下指纹,不支持就看不到这个变量。

android 代码:

  //propName:参数名称,直接传入"ro.hardware.fp.fod"
public static String getSystemProperty(String propName) { String line = ""; BufferedReader input = null; try { Process p = Runtime.getRuntime().exec("getprop " + propName); InputStreamReader streamReader = new InputStreamReader(p.getInputStream()); input = new BufferedReader(streamReader); String result = input.readLine(); if (result != null) { line += result; } input.close(); } catch (IOException ex) { Log.d("==========ex",""+ex); return null; } finally { if (input != null) { try { input.close(); } catch (IOException e) { } } } return line; }

  

原文地址:https://www.cnblogs.com/wangyuehome/p/11737802.html