mirror of
https://github.com/topjohnwu/Fingerface.git
synced 2024-11-23 03:39:50 +00:00
Final clean ups
This commit is contained in:
parent
36fd0dd896
commit
7dc090de7b
@ -1,25 +0,0 @@
|
||||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package android.hardware.fingerprint
|
||||
|
||||
import android.hardware.biometrics.BiometricPrompt
|
||||
|
||||
class MyAuthenticationCallback(private val callback: FingerprintManager.AuthenticationCallback) :
|
||||
BiometricPrompt.AuthenticationCallback() {
|
||||
|
||||
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
|
||||
callback.onAuthenticationError(errorCode, errString)
|
||||
}
|
||||
|
||||
override fun onAuthenticationHelp(helpCode: Int, helpString: CharSequence) {
|
||||
callback.onAuthenticationHelp(helpCode, helpString)
|
||||
}
|
||||
|
||||
override fun onAuthenticationFailed() {
|
||||
callback.onAuthenticationFailed()
|
||||
}
|
||||
|
||||
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
|
||||
callback.onAuthenticationSucceeded(MyAuthenticationResult(result))
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package android.hardware.fingerprint
|
||||
|
||||
import android.hardware.biometrics.BiometricPrompt
|
||||
|
||||
class MyAuthenticationResult(private val result: BiometricPrompt.AuthenticationResult) :
|
||||
FingerprintManager.AuthenticationResult() {
|
||||
|
||||
private fun BiometricPrompt.CryptoObject.toLegacy() = when {
|
||||
cipher != null -> FingerprintManager.CryptoObject(cipher)
|
||||
mac != null -> FingerprintManager.CryptoObject(mac)
|
||||
signature != null -> FingerprintManager.CryptoObject(signature)
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun getCryptoObject(): FingerprintManager.CryptoObject? {
|
||||
return result.cryptoObject?.toLegacy()
|
||||
}
|
||||
}
|
@ -8,7 +8,6 @@ import android.hardware.biometrics.BiometricManager
|
||||
import android.hardware.biometrics.BiometricPrompt
|
||||
import android.os.CancellationSignal
|
||||
import android.os.Handler
|
||||
import android.util.Log
|
||||
import com.edison.fingerface.HandlerExecutor
|
||||
import com.edison.fingerface.MainActivity
|
||||
import com.edison.fingerface.PreferenceProvider
|
||||
@ -19,7 +18,6 @@ class MyFingerprintManager(private val context: Context) : FingerprintManager()
|
||||
private val prefs = PreferenceProvider.getRemote(context)
|
||||
|
||||
override fun isHardwareDetected(): Boolean {
|
||||
Log.d(TAG, "isHardwareDetected")
|
||||
return when (manager.canAuthenticate()) {
|
||||
BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED,
|
||||
BiometricManager.BIOMETRIC_SUCCESS -> true
|
||||
@ -28,7 +26,6 @@ class MyFingerprintManager(private val context: Context) : FingerprintManager()
|
||||
}
|
||||
|
||||
override fun hasEnrolledFingerprints(): Boolean {
|
||||
Log.d(TAG, "hasEnrolledFingerprints")
|
||||
return when (manager.canAuthenticate()) {
|
||||
BiometricManager.BIOMETRIC_SUCCESS -> true
|
||||
else -> false
|
||||
@ -46,8 +43,6 @@ class MyFingerprintManager(private val context: Context) : FingerprintManager()
|
||||
crypto: CryptoObject?, cancel: CancellationSignal?,
|
||||
flags: Int, legacyCallback: AuthenticationCallback, handler: Handler?
|
||||
) {
|
||||
Log.d(TAG, "authenticate")
|
||||
|
||||
val bioCrypto = crypto?.toBio()
|
||||
val cancelSignal = cancel ?: CancellationSignal()
|
||||
val executor = handler?.let { HandlerExecutor(it) } ?: context.mainExecutor
|
||||
@ -68,7 +63,40 @@ class MyFingerprintManager(private val context: Context) : FingerprintManager()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "Fingerface"
|
||||
class MyAuthenticationCallback(
|
||||
private val callback: AuthenticationCallback
|
||||
) : BiometricPrompt.AuthenticationCallback() {
|
||||
|
||||
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
|
||||
callback.onAuthenticationError(errorCode, errString)
|
||||
}
|
||||
|
||||
override fun onAuthenticationHelp(helpCode: Int, helpString: CharSequence) {
|
||||
callback.onAuthenticationHelp(helpCode, helpString)
|
||||
}
|
||||
|
||||
override fun onAuthenticationFailed() {
|
||||
callback.onAuthenticationFailed()
|
||||
}
|
||||
|
||||
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
|
||||
callback.onAuthenticationSucceeded(MyAuthenticationResult(result))
|
||||
}
|
||||
}
|
||||
|
||||
class MyAuthenticationResult(
|
||||
private val result: BiometricPrompt.AuthenticationResult
|
||||
) : AuthenticationResult() {
|
||||
|
||||
private fun BiometricPrompt.CryptoObject.toLegacy() = when {
|
||||
cipher != null -> CryptoObject(cipher)
|
||||
mac != null -> CryptoObject(mac)
|
||||
signature != null -> CryptoObject(signature)
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun getCryptoObject(): CryptoObject? {
|
||||
return result.cryptoObject?.toLegacy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,23 +2,13 @@ package com.edison.fingerface
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.XModuleResources
|
||||
import android.hardware.fingerprint.MyFingerprintManager
|
||||
import de.robv.android.xposed.*
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage
|
||||
import de.robv.android.xposed.XC_MethodHook
|
||||
import de.robv.android.xposed.XposedHelpers
|
||||
import de.robv.android.xposed.callbacks.XC_LoadPackage
|
||||
|
||||
class XposedHandler : IXposedHookZygoteInit, IXposedHookLoadPackage {
|
||||
|
||||
private lateinit var modulePath: String
|
||||
private lateinit var modRes: XModuleResources
|
||||
private lateinit var prefs: XSharedPreferences
|
||||
|
||||
override fun initZygote(startupParam: IXposedHookZygoteInit.StartupParam) {
|
||||
modulePath = startupParam.modulePath
|
||||
modRes = XModuleResources.createInstance(modulePath, null)
|
||||
prefs = XSharedPreferences(BuildConfig.APPLICATION_ID)
|
||||
|
||||
}
|
||||
class XposedHandler : IXposedHookLoadPackage {
|
||||
|
||||
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
|
||||
if (lpparam.processName != "android" && lpparam.processName != "com.android.systemui") {
|
||||
|
Loading…
Reference in New Issue
Block a user