diff --git a/udfps/UdfpsHandler.cpp b/udfps/UdfpsHandler.cpp index 788631e..8a5215c 100644 --- a/udfps/UdfpsHandler.cpp +++ b/udfps/UdfpsHandler.cpp @@ -77,10 +77,6 @@ class XiaomiUdfpsHander : public UdfpsHandler { mDevice->extCmd(mDevice, COMMAND_NIT, readBool(fd) ? PARAM_NIT_UDFPS : PARAM_NIT_NONE); - - int arg[2] = {TOUCH_UDFPS_ENABLE, - readBool(fd) ? UDFPS_STATUS_ON : UDFPS_STATUS_OFF}; - ioctl(touch_fd_.get(), TOUCH_IOC_SETMODE, &arg); } }).detach(); } @@ -93,6 +89,25 @@ class XiaomiUdfpsHander : public UdfpsHandler { // nothing } + void onAcquired(int32_t result, int32_t vendorCode) { + if (result == FINGERPRINT_ACQUIRED_GOOD) { + int arg[2] = {TOUCH_UDFPS_ENABLE, UDFPS_STATUS_OFF}; + ioctl(touch_fd_.get(), TOUCH_IOC_SETMODE, &arg); + } else if (vendorCode == 21 || vendorCode == 23) { + /* + * vendorCode = 21 waiting for fingerprint authentication + * vendorCode = 23 waiting for fingerprint enroll + */ + int arg[2] = {TOUCH_UDFPS_ENABLE, UDFPS_STATUS_ON}; + ioctl(touch_fd_.get(), TOUCH_IOC_SETMODE, &arg); + } + } + + void cancel() { + int arg[2] = {TOUCH_UDFPS_ENABLE, UDFPS_STATUS_OFF}; + ioctl(touch_fd_.get(), TOUCH_IOC_SETMODE, &arg); + } + private: fingerprint_device_t* mDevice; android::base::unique_fd touch_fd_;