Skip to content

Commit

Permalink
Add more TD patches and fix whitespace error on personal patch
Browse files Browse the repository at this point in the history
  • Loading branch information
cawilliamson committed Jan 31, 2024
1 parent ae87c1f commit 3cb3844
Show file tree
Hide file tree
Showing 5 changed files with 334 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ index 0000000..779c1a9
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -32,7 +32,6 @@ index 0000000..779c1a9
+
+ <string name="voltage_maintainer">chrisaw</string>
+
+</resources>
+</resources>
--
2.39.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
From 7b837155f74e2963175a6148489c9ef40fd8e4d2 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 29 Jan 2024 17:06:34 -0500
Subject: [PATCH 50/53] Try catch the Xiaomi calls

---
.../src/com/android/systemui/biometrics/UdfpsView.kt | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt
index 91053b2c5f8e..d47a7d2068fa 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt
@@ -298,14 +298,16 @@ class UdfpsView(
Log.d("PHH-Enroll", "Xiaomi scenario in UdfpsView reached!")
mySurfaceView.setVisibility(INVISIBLE)

- IXiaomiFingerprint.getService().extCmd(android.os.SystemProperties.getInt("persist.phh.xiaomi.fod.enrollment.id", 4), 1);
- var res = ITouchFeature.getService().setTouchMode(0, 10, 1);
+ try {
+ IXiaomiFingerprint.getService().extCmd(android.os.SystemProperties.getInt("persist.phh.xiaomi.fod.enrollment.id", 4), 1);
+ } catch(t: Throwable) {}
+ var res = try { ITouchFeature.getService().setTouchMode(0, 10, 1) } catch(t: Throwable){ -1 }
if(res != 0){
Log.d("PHH-Enroll", "SetTouchMode 10,1 was NOT executed successfully. Res is " + res)
}

myHandler.postDelayed({
- var ret200 = ITouchFeature.getService().setTouchMode(0, 10, 1);
+ var ret200 = try { ITouchFeature.getService().setTouchMode(0, 10, 1); } catch(t: Throwable) { -1 }

if(ret200 != 0){
Log.d("PHH-Enroll", "myHandler.postDelayed 200ms -SetTouchMode was NOT executed successfully. Ret is " + ret200)
@@ -313,7 +315,7 @@ class UdfpsView(

myHandler.postDelayed({
Log.d("PHH-Enroll", "myHandler.postDelayed 600ms - line prior to setTouchMode 10,0")
- var ret600 = ITouchFeature.getService().setTouchMode(0, 10, 0);
+ var ret600 = try { ITouchFeature.getService().setTouchMode(0, 10, 0); } catch(t: Throwable) { -1 }

if(ret600 != 0){
Log.d("PHH-Enroll", "myHandler.postDelayed 600ms -SetTouchMode 10,0 was NOT executed successfully. Ret is " + ret600)
--
2.25.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
From cb0dae61b4e5ea7647d610fdb50aec324de17d45 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 29 Jan 2024 17:06:45 -0500
Subject: [PATCH 51/53] Typo in observing Samsung brightness

---
.../SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt
index d47a7d2068fa..9f1fde7f2e3f 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt
@@ -353,7 +353,7 @@ class UdfpsView(
};
fodFileObserver?.startWatching();
} else if (hasSamsungMask) {
- fodFileObserver = object: FileObserver(asusGhbmOnAchieved, FileObserver.MODIFY) {
+ fodFileObserver = object: FileObserver(samsungActualMaskBrightness, FileObserver.MODIFY) {
override fun onEvent(event: Int, path: String): Unit {
Log.d("PHH-Enroll", "samsung mask brightness event")
try {
--
2.25.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From 45480ab609ba20cdc45e3b291bd160a06dee680d Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Mon, 29 Jan 2024 17:07:07 -0500
Subject: [PATCH 52/53] Add Samsung sysinput

---
services/core/Android.bp | 1 +
1 file changed, 1 insertion(+)

diff --git a/services/core/Android.bp b/services/core/Android.bp
index 6cba27c50972..0e822cfd5abe 100644
--- a/services/core/Android.bp
+++ b/services/core/Android.bp
@@ -196,6 +196,7 @@ java_library_static {
"vendor.xiaomi.hardware.fingerprintextension-V1.0-java",

//AIDL
+ "vendor.samsung.hardware.sysinput-V1-java",
"vendor.samsung.hardware.biometrics.fingerprint-V1-java",
"vendor.samsung.hardware.light-V1-java",
],
--
2.25.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
From 5a125ad01df3bd0010532499b790e69faf173874 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/53] 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

0 comments on commit 3cb3844

Please sign in to comment.