mirror of
https://github.com/yurisieucuti/treble_evolution.git
synced 2024-11-24 12:06:19 +00:00
238 lines
12 KiB
Diff
238 lines
12 KiB
Diff
From e8e05327aaaa48fe50d461ffd4503c7955ed3ad1 Mon Sep 17 00:00:00 2001
|
|
From: Pierre-Hugues Husson <phh@phh.me>
|
|
Date: Mon, 29 Jan 2024 17:15:38 -0500
|
|
Subject: [PATCH 53/56] Bunch of FOD stuff -- commonize refreshing the
|
|
services, start supporting AIDL Samsung
|
|
|
|
---
|
|
.../server/biometrics/AuthService.java | 157 +++++++++++++++---
|
|
1 file changed, 138 insertions(+), 19 deletions(-)
|
|
|
|
diff --git a/services/core/java/com/android/server/biometrics/AuthService.java b/services/core/java/com/android/server/biometrics/AuthService.java
|
|
index dfc268c07d76..b13b8ec9c581 100644
|
|
--- a/services/core/java/com/android/server/biometrics/AuthService.java
|
|
+++ b/services/core/java/com/android/server/biometrics/AuthService.java
|
|
@@ -43,6 +43,7 @@ import android.hardware.biometrics.IAuthService;
|
|
import android.hardware.biometrics.IBiometricEnabledOnKeyguardCallback;
|
|
import android.hardware.biometrics.IBiometricService;
|
|
import android.hardware.biometrics.IBiometricServiceReceiver;
|
|
+import android.hardware.biometrics.fingerprint.IFingerprint;
|
|
import android.hardware.biometrics.IInvalidationCallback;
|
|
import android.hardware.biometrics.ITestSession;
|
|
import android.hardware.biometrics.ITestSessionCallback;
|
|
@@ -92,6 +93,7 @@ import android.os.Build;
|
|
import vendor.samsung.hardware.biometrics.fingerprint.V3_0.ISehBiometricsFingerprint;
|
|
import vendor.goodix.hardware.biometrics.fingerprint.V2_1.IGoodixFingerprintDaemon;
|
|
import vendor.samsung.hardware.sysinput.V1_0.ISehSysInputDev;
|
|
+import vendor.samsung.hardware.biometrics.fingerprint.ISehFingerprint;
|
|
|
|
import vendor.xiaomi.hardware.fingerprintextension.V1_0.IXiaomiFingerprint;
|
|
|
|
@@ -115,6 +117,8 @@ public class AuthService extends SystemService {
|
|
|
|
private FileObserver fodFileObserver = null;
|
|
private ISehBiometricsFingerprint mSamsungFingerprint = null;
|
|
+ private ISehFingerprint mSamsungFingerprintAidl = null;
|
|
+ private vendor.samsung.hardware.sysinput.ISehSysInputDev mSamsungSysinputAidl = null;
|
|
|
|
private IXiaomiFingerprint mXiaomiFingerprint = null;
|
|
|
|
@@ -668,6 +672,101 @@ public class AuthService extends SystemService {
|
|
* └── for (s : p.sensors)
|
|
* └── BiometricService.registerAuthenticator(s)
|
|
*/
|
|
+
|
|
+ private static void samsungSysinputCommand(String arg) {
|
|
+ try {
|
|
+ android.util.Log.e("PHH-Enroll", "SysinputCommand " + arg);
|
|
+ var name = "default";
|
|
+ var fqName = vendor.samsung.hardware.sysinput.ISehSysInputDev.DESCRIPTOR + "/" + name;
|
|
+ var b = android.os.Binder.allowBlocking(android.os.ServiceManager.waitForDeclaredService(fqName));
|
|
+ var samsungSysinputAidl = vendor.samsung.hardware.sysinput.ISehSysInputDev.Stub.asInterface(b);
|
|
+ Thread.sleep(100);
|
|
+ samsungSysinputAidl.setProperty(1 /*DEFAULT_TSP*/, 18, arg);
|
|
+ android.util.Log.e("PHH-Enroll", "Done SysinputCommand");
|
|
+ } catch(Throwable t) {
|
|
+ android.util.Log.e("PHH-Enroll", "SysinputCommand", t);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private void refreshVendorServices() {
|
|
+ try {
|
|
+ mSamsungFingerprint = ISehBiometricsFingerprint.getService();
|
|
+ android.util.Log.e("PHH", "Got samsung fingerprint HAL");
|
|
+ } catch(Exception e) {
|
|
+ if (e instanceof java.util.NoSuchElementException) {
|
|
+ android.util.Log.e("PHH", "Failed getting Samsung fingerprint HAL, doesn't exist");
|
|
+ } else {
|
|
+ android.util.Log.e("PHH", "Failed getting Samsung fingerprint HAL", e);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ try {
|
|
+ final String name = "default";
|
|
+ final String fqName = IFingerprint.DESCRIPTOR + "/" + name;
|
|
+ final IBinder fpBinder = Binder.allowBlocking(ServiceManager.waitForDeclaredService(fqName));
|
|
+ //final IFingerprint fp = IFingerprint.Stub.asInterface(fpBinder);
|
|
+ mSamsungFingerprintAidl = ISehFingerprint.Stub.asInterface(fpBinder.getExtension());
|
|
+ } catch(Exception e) {
|
|
+ android.util.Log.e("PHH", "Failed getting Samsung fingerprint AIDL HAL", e);
|
|
+ }
|
|
+
|
|
+ try {
|
|
+ final String name = "default";
|
|
+ final String fqName = vendor.samsung.hardware.sysinput.ISehSysInputDev.DESCRIPTOR + "/" + name;
|
|
+ final IBinder b = Binder.allowBlocking(ServiceManager.waitForDeclaredService(fqName));
|
|
+ mSamsungSysinputAidl = vendor.samsung.hardware.sysinput.ISehSysInputDev.Stub.asInterface(b);
|
|
+ mSamsungSysinputAidl.registerCallback(new vendor.samsung.hardware.sysinput.ISehSysInputCallback.Stub() {
|
|
+ @Override
|
|
+ public void onReportInformation(int type, String data) {
|
|
+ android.util.Log.e("PHH", "Received Sysinput Report Information " +type + ", " + data);
|
|
+ }
|
|
+ @Override
|
|
+ public void onReportRawData(int type, int count, int[] data) {
|
|
+ android.util.Log.e("PHH", "Received Sysinput Report RawData " + type + ", " + count);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int getInterfaceVersion() {
|
|
+ return this.VERSION;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getInterfaceHash() {
|
|
+ return this.HASH;
|
|
+ }
|
|
+ });
|
|
+ String res;
|
|
+ res = mSamsungSysinputAidl.getProperty(1, 1);
|
|
+ Thread.sleep(100);
|
|
+ android.util.Log.e("PHH", "Got Samsung sysinput aidl feature " + res);
|
|
+ res = mSamsungSysinputAidl.getProperty(1, 2);
|
|
+ Thread.sleep(100);
|
|
+ android.util.Log.e("PHH", "Got Samsung sysinput aidl cmd_list " + res);
|
|
+ res = mSamsungSysinputAidl.getProperty(1, 3);
|
|
+ Thread.sleep(100);
|
|
+ android.util.Log.e("PHH", "Got Samsung sysinput aidl scrub_pos " + res);
|
|
+ res = mSamsungSysinputAidl.getProperty(1, 4);
|
|
+ Thread.sleep(100);
|
|
+ android.util.Log.e("PHH", "Got Samsung sysinput aidl fod_info " + res);
|
|
+ res = mSamsungSysinputAidl.getProperty(1, 5);
|
|
+ Thread.sleep(100);
|
|
+ android.util.Log.e("PHH", "Got Samsung sysinput aidl fod_pos " + res);
|
|
+ } catch(Exception e) {
|
|
+ android.util.Log.e("PHH", "Failed getting Samsung fingerprint AIDL HAL", e);
|
|
+ }
|
|
+
|
|
+ try {
|
|
+ mXiaomiFingerprint = IXiaomiFingerprint.getService();
|
|
+ android.util.Log.e("PHH", "Got xiaomi fingerprint HAL");
|
|
+ } catch(Exception e) {
|
|
+ if (e instanceof java.util.NoSuchElementException) {
|
|
+ android.util.Log.e("PHH", "Failed getting xiaomi fingerprint HAL, doesn't exist");
|
|
+ } else {
|
|
+ android.util.Log.e("PHH", "Failed getting xiaomi fingerprint HAL", e);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
@Override
|
|
public void onStart() {
|
|
mBiometricService = mInjector.getBiometricService();
|
|
@@ -695,20 +794,11 @@ public class AuthService extends SystemService {
|
|
// Registers HIDL and AIDL authenticators, but only HIDL configs need to be provided.
|
|
registerAuthenticators(hidlConfigs);
|
|
|
|
+ refreshVendorServices();
|
|
+
|
|
mInjector.publishBinderService(this, mImpl);
|
|
- try {
|
|
- mSamsungFingerprint = ISehBiometricsFingerprint.getService();
|
|
- android.util.Log.e("PHH", "Got samsung fingerprint HAL");
|
|
- } catch(Exception e) {
|
|
- android.util.Log.e("PHH", "Failed getting Samsung fingerprint HAL", e);
|
|
- }
|
|
- try {
|
|
- mXiaomiFingerprint = IXiaomiFingerprint.getService();
|
|
- android.util.Log.e("PHH", "Got xiaomi fingerprint HAL");
|
|
- } catch(Exception e) {
|
|
- android.util.Log.e("PHH", "Failed getting xiaomi fingerprint HAL", e);
|
|
- }
|
|
- if(samsungHasCmd("fod_enable") && mSamsungFingerprint != null) {
|
|
+ //samsungSysinputCommand("fod_icon_visible,1");
|
|
+ if(samsungHasCmd("fod_enable") && (mSamsungFingerprint != null || mSamsungFingerprintAidl != null)) {
|
|
samsungCmd("fod_enable,1,1,0");
|
|
String actualMaskBrightnessPath = "/sys/class/lcd/panel/actual_mask_brightness";
|
|
android.util.Log.e("PHH-Enroll", "Reading actual brightness file gives " + readFile(actualMaskBrightnessPath));
|
|
@@ -716,9 +806,7 @@ public class AuthService extends SystemService {
|
|
@Override
|
|
public void onEvent(int event, String path) {
|
|
String actualMask = readFile(actualMaskBrightnessPath);
|
|
- try {
|
|
- mSamsungFingerprint = ISehBiometricsFingerprint.getService();
|
|
- } catch(Exception e) {}
|
|
+ refreshVendorServices();
|
|
Slog.d("PHH-Enroll", "New actual mask brightness is " + actualMask);
|
|
try {
|
|
int eventReq = 0;
|
|
@@ -963,22 +1051,53 @@ public class AuthService extends SystemService {
|
|
udfpsProps[2] = (int)mW;
|
|
|
|
try {
|
|
- mSamsungFingerprint = ISehBiometricsFingerprint.getService();
|
|
+ ISehBiometricsFingerprint samsungFingerprint = null;
|
|
+ samsungFingerprint = ISehBiometricsFingerprint.getService();
|
|
Slog.d("PHH-Enroll", "Samsung ask for sensor status");
|
|
- mSamsungFingerprint.sehRequest(6, 0, new java.util.ArrayList(), (int retval, java.util.ArrayList<Byte> out) -> {
|
|
+ samsungFingerprint.sehRequest(6, 0, new java.util.ArrayList(), (int retval, java.util.ArrayList<Byte> out) -> {
|
|
Slog.d("PHH-Enroll", "Result is " + retval);
|
|
for(int i=0; i<out.size(); i++) {
|
|
Slog.d("PHH-Enroll", "\t" + i + ":" + out.get(i));
|
|
}
|
|
} );
|
|
Slog.d("PHH-Enroll", "Samsung ask for sensor brightness value");
|
|
- mSamsungFingerprint.sehRequest(32, 0, new java.util.ArrayList(), (int retval, java.util.ArrayList<Byte> out) -> {
|
|
+ samsungFingerprint.sehRequest(32, 0, new java.util.ArrayList(), (int retval, java.util.ArrayList<Byte> out) -> {
|
|
Slog.d("PHH-Enroll", "Result is " + retval);
|
|
for(int i=0; i<out.size(); i++) {
|
|
Slog.d("PHH-Enroll", "\t" + i + ":" + out.get(i));
|
|
}
|
|
} );
|
|
|
|
+ } catch(Exception e) {
|
|
+ if (e instanceof java.util.NoSuchElementException) {
|
|
+ Slog.d("PHH-Enroll", "Failed setting samsung3.0 fingerprint recognition, doesn't exist");
|
|
+ } else {
|
|
+ Slog.d("PHH-Enroll", "Failed setting samsung3.0 fingerprint recognition", e);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ try {
|
|
+ final String name = "default";
|
|
+ final String fqName = IFingerprint.DESCRIPTOR + "/" + name;
|
|
+ final IBinder fpBinder = Binder.allowBlocking(ServiceManager.waitForDeclaredService(fqName));
|
|
+ final IFingerprint fp = IFingerprint.Stub.asInterface(fpBinder);
|
|
+ final ISehFingerprint fpaidl = ISehFingerprint.Stub.asInterface(fpBinder.getExtension());
|
|
+
|
|
+ Slog.d("PHH-Enroll", "Samsung ask for sensor status");
|
|
+ vendor.samsung.hardware.biometrics.fingerprint.SehResult sehres = fpaidl.sehRequest(0, 6, 0, new byte[0]);
|
|
+
|
|
+ Slog.d("PHH-Enroll", "Result is " + sehres.retValue);
|
|
+ for(int i=0; i<sehres.data.length; i++) {
|
|
+ Slog.d("PHH-Enroll", "\t" + i + ":" + sehres.data[i]);
|
|
+ }
|
|
+
|
|
+ Slog.d("PHH-Enroll", "Samsung ask for sensor brightness value");
|
|
+ sehres = fpaidl.sehRequest(0, 32, 0, new byte[0]);
|
|
+
|
|
+ Slog.d("PHH-Enroll", "Result is " + sehres.retValue);
|
|
+ for(int i=0; i<sehres.data.length; i++) {
|
|
+ Slog.d("PHH-Enroll", "\t" + i + ":" + sehres.data[i]);
|
|
+ }
|
|
} catch(Exception e) {
|
|
Slog.d("PHH-Enroll", "Failed setting samsung3.0 fingerprint recognition", e);
|
|
}
|
|
--
|
|
2.25.1
|
|
|