闲着没事下载6.0的源码看下指纹模块是怎么写,记录一下学习过程。
本篇主要是介绍如何用虚拟机进行指纹相关的操作。以及修改HAL层,提供未实现的功能。
编译成功后,使用emulator打开虚拟机。emulator在这个目录:
prebuilts/android-emulator/linux-x86_64/emulator
emulator -selinux disabled -sysdir out/target/product/generic/
注意把selinux关了,不然要去配置selinux,否则各种权限问题。
进入设置->安全->指纹。
ok,一直next到指纹录入的界面。输入:
adb emu finger touch 1
模拟手去点击传感器。输入一次就录入成功了。此时按power键进入待机再按亮屏,就可以看见keyguard上有一个指纹标志了。再输入adb emu finger touch 1就可以解锁了。
这个命令找了好久,从hal层看到是通过qemu通信的,一直在代码里搜,结果没搜到。后来才发现下载的源码没有qemu,去github里下了一份就能搜到相关的了。最后是google到的。这里有一篇介绍6.0API的也有提及。
http://blog.csdn.net/yuzepeng997/article/details/50477091
1.Install Android SDK Tools Revision 24.3, if you have not done so. 2.Enroll a new fingerprint in the emulator by going to Settings > Security > Fingerprint, then follow the enrollment instructions. 3.Use an emulator to emulate fingerprint touch events with the following command. Use the same command to emulate fingerprint touch events on the lockscreen or in your app. adb -e emu finger touch <finger_id> On Windows, you may have to run telnet 127.0.0.1 <emulator-id> followed by finger touch <finger_id>.
也可以通过telnet去执行命令。还有help可以看,不像emu命令,输入错了也没反应。
telnet 127.0.0.1 5554
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
OK
KO: unknown command, try 'help'
help
Android console command help:
help|h|? print a list of commands
event simulate hardware events
geo Geo-location commands
gsm GSM related commands
cdma CDMA related commands
kill kill the emulator instance
network manage network settings
power power related commands
quit|exit quit control session
redir manage port redirections
sms SMS related commands
avd control virtual device execution
window manage emulator window
qemu QEMU-specific commands
sensor manage emulator sensors
finger manage emulator finger print
help finger
allows you to touch the emulator finger print sensor
av