From c470570f310bdcc7a9a1360f3e9407b8cd30af09 Mon Sep 17 00:00:00 2001 From: naz664 Date: Sun, 15 Oct 2023 12:21:11 +0000 Subject: [PATCH] feat: Sync with Sep source of Spark * Synced with latest td source Signed-off-by: naz664 --- .../03-remove-su-from-no-su-builds.patch | 31 +++++ ...ort-for-Asus-ZF8-and-Samsung-devices.patch | 63 +++++---- ...nt-alternate-brightness-path-for-FOD.patch | 4 +- ...34-Add-Mediatek-power-hints-on-touch.patch | 12 +- ...mi-FOD-implementation-for-recent-Xia.patch | 83 +++++++---- ...UI-Add-MTK-s-brightness-path-for-FOD.patch | 67 +++++++++ .../0038-udfps-fixup.patch | 53 +++++++ ...-Fix-light-sensor-crash-on-Xiaomi-13.patch | 36 +++++ .../03-Optionally-use-sysbta-HAL.patch | 104 ++++++++++++++ ...-to-change-eSCO-Transport-Unit-Size.patch} | 4 +- ...n-failing-to-get-real-time-priority.patch} | 13 +- ...re-running-narrow-band-or-wide-band.patch} | 8 +- ...o-disable-some-features-commands-sta.patch | 129 ++++++++++++++++++ ...-cap-declared-le-vendor-version.-Fo.patch} | 0 14 files changed, 535 insertions(+), 72 deletions(-) create mode 100644 patches/personal/platform_build_make/03-remove-su-from-no-su-builds.patch create mode 100644 patches/trebledroid/platform_frameworks_base/0037-SystemUI-Add-MTK-s-brightness-path-for-FOD.patch create mode 100644 patches/trebledroid/platform_frameworks_base/0038-udfps-fixup.patch create mode 100644 patches/trebledroid/platform_frameworks_native/0010-Fix-light-sensor-crash-on-Xiaomi-13.patch create mode 100644 patches/trebledroid/platform_packages_modules_Bluetooth/03-Optionally-use-sysbta-HAL.patch rename patches/trebledroid/platform_packages_modules_Bluetooth/{0004-Add-option-to-change-eSCO-Transport-Unit-Size.patch => 04-Add-option-to-change-eSCO-Transport-Unit-Size.patch} (92%) rename patches/trebledroid/platform_packages_modules_Bluetooth/{0005-Don-t-abort-when-failing-to-get-real-time-priority.patch => 05-Don-t-abort-when-failing-to-get-real-time-priority.patch} (90%) rename patches/trebledroid/platform_packages_modules_Bluetooth/{0006-On-Samsung-devices-we-need-to-tell-Audio-HAL-if-we-r.patch => 06-On-Samsung-devices-we-need-to-tell-Audio-HAL-if-we-re-running-narrow-band-or-wide-band.patch} (93%) create mode 100644 patches/trebledroid/platform_packages_modules_Bluetooth/07-Add-properties-to-disable-some-features-commands-sta.patch rename patches/trebledroid/platform_packages_modules_Bluetooth/{0008-Add-a-property-to-cap-declared-le-vendor-version.-Fo.patch => 08-Add-a-property-to-cap-declared-le-vendor-version.-Fo.patch} (100%) diff --git a/patches/personal/platform_build_make/03-remove-su-from-no-su-builds.patch b/patches/personal/platform_build_make/03-remove-su-from-no-su-builds.patch new file mode 100644 index 0000000..a733559 --- /dev/null +++ b/patches/personal/platform_build_make/03-remove-su-from-no-su-builds.patch @@ -0,0 +1,31 @@ +From 513f08dade75dce317b22ef09d67f988c81838f5 Mon Sep 17 00:00:00 2001 +From: naz664 +Date: Mon, 26 Dec 2022 11:54:04 +0000 +Subject: [PATCH] remove su from no-su builds + +--- + target/product/base_system.mk | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/target/product/base_system.mk b/target/product/base_system.mk +index 9935ffe8b..5095760ab 100644 +--- a/target/product/base_system.mk ++++ b/target/product/base_system.mk +@@ -397,10 +397,10 @@ PRODUCT_PACKAGES_DEBUG := \ + unwind_reg_info \ + unwind_symbols \ + +-ifeq ($(SPARK_BUILD),) +-PRODUCT_PACKAGES_DEBUG += \ +- su +-endif ++#ifeq ($(SPARK_BUILD),) ++#PRODUCT_PACKAGES_DEBUG += \ ++# su ++#endif + + # The set of packages whose code can be loaded by the system server. + PRODUCT_SYSTEM_SERVER_APPS += \ +-- +2.34.1 + diff --git a/patches/trebledroid/platform_frameworks_base/0029-FOD-support-for-Asus-ZF8-and-Samsung-devices.patch b/patches/trebledroid/platform_frameworks_base/0029-FOD-support-for-Asus-ZF8-and-Samsung-devices.patch index ba0ec90..1b607af 100644 --- a/patches/trebledroid/platform_frameworks_base/0029-FOD-support-for-Asus-ZF8-and-Samsung-devices.patch +++ b/patches/trebledroid/platform_frameworks_base/0029-FOD-support-for-Asus-ZF8-and-Samsung-devices.patch @@ -1,19 +1,18 @@ -From 1bd35f696ab783fcbe7ecddee76549584a11a5e4 Mon Sep 17 00:00:00 2001 -From: Pierre-Hugues Husson -Date: Sun, 18 Dec 2022 18:20:40 -0500 -Subject: [PATCH 29/36] FOD support for Asus ZF8 and Samsung devices +From b260611700022db35eb02b29101ac35a8f378a0a Mon Sep 17 00:00:00 2001 +From: naz664 +Date: Sun, 15 Oct 2023 06:08:20 +0000 +Subject: [PATCH 1/7] FOD support for Asus ZF8 and Samsung devices Thanks Asus + for providing a free device to make this support And thanks @davigamer987 for + donating enough to get a Samsung FOD device to make this -Thanks Asus for providing a free device to make this support -And thanks @davigamer987 for donating enough to get a Samsung FOD device -to make this --- packages/SystemUI/Android.bp | 1 + packages/SystemUI/res/values/config.xml | 2 +- - .../biometrics/UdfpsControllerOverlay.kt | 7 +- + .../biometrics/UdfpsControllerOverlay.kt | 9 +- .../android/systemui/biometrics/UdfpsView.kt | 161 ++++++++++-- services/core/Android.bp | 7 +- - .../server/biometrics/AuthService.java | 236 +++++++++++++++++- - 6 files changed, 383 insertions(+), 31 deletions(-) + .../server/biometrics/AuthService.java | 240 +++++++++++++++++- + 6 files changed, 385 insertions(+), 35 deletions(-) diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp index 7ac7a2fc7880..e039b9eb8a5f 100644 @@ -28,10 +27,10 @@ index 7ac7a2fc7880..e039b9eb8a5f 100644 manifest: "AndroidManifest.xml", additional_manifests: ["LineageManifest.xml"], diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml -index ab6bd7abcaae..818cd0fd69b5 100644 +index 7bd3cc7f22ad..adc96e701031 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml -@@ -591,7 +591,7 @@ +@@ -592,7 +592,7 @@ @@ -41,21 +40,24 @@ index ab6bd7abcaae..818cd0fd69b5 100644 diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt -index baa46e875529..fdbdf90f03e8 100644 +index 277cde1efd5e..8d2cb39c6e98 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt -@@ -120,7 +120,9 @@ class UdfpsControllerOverlay @JvmOverloads constructor( +@@ -120,10 +120,10 @@ class UdfpsControllerOverlay @JvmOverloads constructor( gravity = android.view.Gravity.TOP or android.view.Gravity.LEFT layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS flags = (Utils.FINGERPRINT_OVERLAY_LAYOUT_PARAM_FLAGS or +- WindowManager.LayoutParams.FLAG_DIM_BEHIND or - WindowManager.LayoutParams.FLAG_SPLIT_TOUCH) +- privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY + WindowManager.LayoutParams.FLAG_SPLIT_TOUCH) or + WindowManager.LayoutParams.FLAG_DIM_BEHIND -+ dimAmount = 0.0f - privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY + dimAmount = 0.0f ++ privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY + // Avoid announcing window title. accessibilityTitle = " " -@@ -189,6 +191,9 @@ class UdfpsControllerOverlay @JvmOverloads constructor( +@@ -198,6 +198,9 @@ class UdfpsControllerOverlay @JvmOverloads constructor( windowManager.addView(this, coreLayoutParams.updateDimensions(animation)) sensorRect = sensorBounds touchExplorationEnabled = accessibilityManager.isTouchExplorationEnabled @@ -296,7 +298,7 @@ index 1e2e6c8bb253..cdaad81b9222 100644 } } diff --git a/services/core/Android.bp b/services/core/Android.bp -index f4d582b5f1a1..03055e2855b6 100644 +index f4d582b5f1a1..68ac3911ffdd 100644 --- a/services/core/Android.bp +++ b/services/core/Android.bp @@ -181,7 +181,12 @@ java_library_static { @@ -304,7 +306,7 @@ index f4d582b5f1a1..03055e2855b6 100644 "kotlinx_coroutines_android", "kotlinx_coroutines", - "vendor.samsung.hardware.sysinput-V1.2-java", // HIDL -+ // HIDL ++ // HIDL + "vendor.samsung.hardware.sysinput-V1.2-java", + "vendor.goodix.hardware.biometrics.fingerprint-V2.1-java", + "vendor.samsung.hardware.biometrics.fingerprint-V3.0-java", @@ -314,7 +316,7 @@ index f4d582b5f1a1..03055e2855b6 100644 javac_shard_size: 50, } diff --git a/services/core/java/com/android/server/biometrics/AuthService.java b/services/core/java/com/android/server/biometrics/AuthService.java -index 7e6f35acc398..e3d951648432 100644 +index 7e6f35acc398..dad82e5264e4 100644 --- a/services/core/java/com/android/server/biometrics/AuthService.java +++ b/services/core/java/com/android/server/biometrics/AuthService.java @@ -77,6 +77,22 @@ import java.util.ArrayList; @@ -422,8 +424,12 @@ index 7e6f35acc398..e3d951648432 100644 } /** -@@ -775,18 +859,104 @@ public class AuthService extends SystemService { - ? modality : (modality & ~BiometricAuthenticator.TYPE_CREDENTIAL); +@@ -772,21 +856,107 @@ public class AuthService extends SystemService { + @BiometricAuthenticator.Modality + private static int getCredentialBackupModality(@BiometricAuthenticator.Modality int modality) { + return modality == BiometricAuthenticator.TYPE_CREDENTIAL +- ? modality : (modality & ~BiometricAuthenticator.TYPE_CREDENTIAL); ++ ? modality : (modality & ~BiometricAuthenticator.TYPE_CREDENTIAL); } + private int[] dynamicUdfpsProps() { @@ -511,7 +517,7 @@ index 7e6f35acc398..e3d951648432 100644 @BiometricManager.Authenticators.Types int strength) { // The existence of config_udfps_sensor_props indicates that the sensor is UDFPS. - final int[] udfpsProps = getContext().getResources().getIntArray( -+ int[] udfpsProps = getContext().getResources().getIntArray( ++ int[] udfpsProps = getContext().getResources().getIntArray( com.android.internal.R.array.config_udfps_sensor_props); // Non-empty workaroundLocations indicates that the sensor is SFPS. @@ -529,10 +535,13 @@ index 7e6f35acc398..e3d951648432 100644 // config_is_powerbutton_fps indicates whether device has a power button fingerprint sensor. final boolean isPowerbuttonFps = getContext().getResources().getBoolean( -@@ -854,4 +1024,66 @@ public class AuthService extends SystemService { +@@ -852,6 +1022,68 @@ public class AuthService extends SystemService { + return new SensorPropertiesInternal(sensorId, + Utils.authenticatorStrengthToPropertyStrength(strength), maxEnrollmentsPerUser, componentInfo, resetLockoutRequiresHardwareAuthToken, - resetLockoutRequiresChallenge); - } +- resetLockoutRequiresChallenge); ++ resetLockoutRequiresChallenge); ++ } + + private static boolean samsungHasCmd(String cmd) { + try { @@ -574,7 +583,7 @@ index 7e6f35acc398..e3d951648432 100644 + } catch(Exception e) { + android.util.Log.d("PHH", "Failed writing to " + path + ": " + value); + } -+ } + } + + private static void writeFile(File file, String value) { + try { diff --git a/patches/trebledroid/platform_frameworks_base/0031-SystemUI-Implement-alternate-brightness-path-for-FOD.patch b/patches/trebledroid/platform_frameworks_base/0031-SystemUI-Implement-alternate-brightness-path-for-FOD.patch index a3bdabc..4cafdc3 100644 --- a/patches/trebledroid/platform_frameworks_base/0031-SystemUI-Implement-alternate-brightness-path-for-FOD.patch +++ b/patches/trebledroid/platform_frameworks_base/0031-SystemUI-Implement-alternate-brightness-path-for-FOD.patch @@ -1,7 +1,7 @@ -From cf6479c7dba53ea522a7282e397a697bc5418bbb Mon Sep 17 00:00:00 2001 +From d42f7b533ecf304a08f7c86bcebe0f927bbf9c36 Mon Sep 17 00:00:00 2001 From: ItsLynix <71310187+ItsLynix@users.noreply.github.com> Date: Sat, 28 Jan 2023 10:25:16 +0100 -Subject: [PATCH 31/36] SystemUI: Implement alternate brightness path for FOD +Subject: [PATCH 2/7] SystemUI: Implement alternate brightness path for FOD --- .../com/android/systemui/biometrics/UdfpsView.kt | 15 +++++++++++++-- diff --git a/patches/trebledroid/platform_frameworks_base/0034-Add-Mediatek-power-hints-on-touch.patch b/patches/trebledroid/platform_frameworks_base/0034-Add-Mediatek-power-hints-on-touch.patch index cf6272d..a1b21ce 100644 --- a/patches/trebledroid/platform_frameworks_base/0034-Add-Mediatek-power-hints-on-touch.patch +++ b/patches/trebledroid/platform_frameworks_base/0034-Add-Mediatek-power-hints-on-touch.patch @@ -1,7 +1,7 @@ -From 8e60f55ce0b0768c25a6e0b8d4ff31449aa1924f Mon Sep 17 00:00:00 2001 +From ebaf78e343c4ac85703dcea181279d4627dc0eaf Mon Sep 17 00:00:00 2001 From: Pierre-Hugues Husson Date: Sat, 17 Jun 2023 08:31:55 -0400 -Subject: [PATCH 34/36] Add Mediatek power hints on touch +Subject: [PATCH 3/7] Add Mediatek power hints on touch Mediatek has multiple HALs (which existed concurrently), so it is a bit of a mess. @@ -25,19 +25,19 @@ smoother. 2 files changed, 52 insertions(+) diff --git a/services/core/Android.bp b/services/core/Android.bp -index 03055e2855b6..2386b54abf7f 100644 +index 68ac3911ffdd..363d1fe02a20 100644 --- a/services/core/Android.bp +++ b/services/core/Android.bp @@ -182,6 +182,7 @@ java_library_static { "kotlinx_coroutines_android", "kotlinx_coroutines", - // HIDL + // HIDL + "vendor.mediatek.hardware.mtkpower-V1.1-java", "vendor.samsung.hardware.sysinput-V1.2-java", "vendor.goodix.hardware.biometrics.fingerprint-V2.1-java", "vendor.samsung.hardware.biometrics.fingerprint-V3.0-java", diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java -index 489fdc44555c..8d3708d8e0f3 100644 +index 2f32d61805f9..b88c912de288 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -224,6 +224,9 @@ public class DisplayPolicy { @@ -76,7 +76,7 @@ index 489fdc44555c..8d3708d8e0f3 100644 Boost.INTERACTION, duration); } + -+ if(mOldMtkPerf != null) { ++ if(mOldMtkPerf != null) { + try { + android.util.Log.d("PHH-Power", "mtk1 fling power hint"); + int hint = 36; // MTKPOWER_HINT_APP_TOUCH diff --git a/patches/trebledroid/platform_frameworks_base/0036-Add-initial-Xiaomi-FOD-implementation-for-recent-Xia.patch b/patches/trebledroid/platform_frameworks_base/0036-Add-initial-Xiaomi-FOD-implementation-for-recent-Xia.patch index 1cea08c..ab00966 100644 --- a/patches/trebledroid/platform_frameworks_base/0036-Add-initial-Xiaomi-FOD-implementation-for-recent-Xia.patch +++ b/patches/trebledroid/platform_frameworks_base/0036-Add-initial-Xiaomi-FOD-implementation-for-recent-Xia.patch @@ -1,16 +1,16 @@ -From 16d13c8c2c2a4451f118fef963eb50c07c26fd60 Mon Sep 17 00:00:00 2001 +From ce69b8d632ad5841565bee9cec0e0de593394eb1 Mon Sep 17 00:00:00 2001 From: jgudec Date: Fri, 18 Aug 2023 08:41:49 +0100 -Subject: [PATCH 36/36] Add initial Xiaomi FOD implementation for recent Xiaomi +Subject: [PATCH 4/7] Add initial Xiaomi FOD implementation for recent Xiaomi devices Huge thanks to phhusson for the help and guidance. --- packages/SystemUI/Android.bp | 2 + - .../android/systemui/biometrics/UdfpsView.kt | 43 +++++++++++++++++ + .../android/systemui/biometrics/UdfpsView.kt | 43 +++++++++++ services/core/Android.bp | 1 + - .../server/biometrics/AuthService.java | 48 +++++++++++++++++++ - 4 files changed, 94 insertions(+) + .../server/biometrics/AuthService.java | 73 +++++++++++++++++++ + 4 files changed, 119 insertions(+) diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp index e039b9eb8a5f..8fa42863f7a3 100644 @@ -26,7 +26,7 @@ index e039b9eb8a5f..8fa42863f7a3 100644 manifest: "AndroidManifest.xml", additional_manifests: ["LineageManifest.xml"], diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt -index 6cc9ab3da570..583fd7cfab2a 100644 +index 6cc9ab3da570..8ab00fc34f0d 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt @@ -37,6 +37,12 @@ import java.io.File @@ -59,7 +59,7 @@ index 6cc9ab3da570..583fd7cfab2a 100644 if(android.os.SystemProperties.get("ro.vendor.build.fingerprint").contains("ASUS")) { goodixCmd(200001) } -+ ++ + if(hasXiaomiLhbm){ + Log.d("PHH-Enroll", "Xiaomi scenario in UdfpsView reached!") + mySurfaceView.setVisibility(INVISIBLE) @@ -90,18 +90,18 @@ index 6cc9ab3da570..583fd7cfab2a 100644 } fun unconfigureDisplay() { -@@ -279,6 +319,9 @@ Log.d("PHH", "Surface destroyed!") +@@ -296,6 +336,9 @@ Log.d("PHH", "Surface destroyed!") } }; fodFileObserver?.startWatching(); + } else if(hasXiaomiLhbm) { + IXiaomiFingerprint.getService().extCmd(android.os.SystemProperties.getInt("persist.phh.xiaomi.fod.enrollment.id", 4), 0); + ITouchFeature.getService().setTouchMode(0, 10, 0); - } else if (hasSamsungMask) { - fodFileObserver = object: FileObserver(asusGhbmOnAchieved, FileObserver.MODIFY) { - override fun onEvent(event: Int, path: String): Unit { + } else { + dimUpdate(0.0f) + } diff --git a/services/core/Android.bp b/services/core/Android.bp -index 2386b54abf7f..ca0b437286fd 100644 +index 363d1fe02a20..fdc91aa0cc7c 100644 --- a/services/core/Android.bp +++ b/services/core/Android.bp @@ -188,6 +188,7 @@ java_library_static { @@ -113,10 +113,18 @@ index 2386b54abf7f..ca0b437286fd 100644 javac_shard_size: 50, } diff --git a/services/core/java/com/android/server/biometrics/AuthService.java b/services/core/java/com/android/server/biometrics/AuthService.java -index 35ff1ff0ba7a..30e1349c9562 100644 +index dad82e5264e4..b9555b0f226b 100644 --- a/services/core/java/com/android/server/biometrics/AuthService.java +++ b/services/core/java/com/android/server/biometrics/AuthService.java -@@ -93,6 +93,8 @@ import vendor.samsung.hardware.biometrics.fingerprint.V3_0.ISehBiometricsFingerp +@@ -66,6 +66,7 @@ import android.os.ServiceManager; + import android.os.SystemProperties; + import android.os.UserHandle; + import android.provider.Settings; ++import android.text.TextUtils; + import android.util.Slog; + + import com.android.internal.R; +@@ -93,6 +94,8 @@ import vendor.samsung.hardware.biometrics.fingerprint.V3_0.ISehBiometricsFingerp import vendor.goodix.hardware.biometrics.fingerprint.V2_1.IGoodixFingerprintDaemon; import vendor.samsung.hardware.sysinput.V1_0.ISehSysInputDev; @@ -125,7 +133,7 @@ index 35ff1ff0ba7a..30e1349c9562 100644 /** * System service that provides an interface for authenticating with biometrics and * PIN/pattern/password to BiometricPrompt and lock screen. -@@ -114,6 +116,8 @@ public class AuthService extends SystemService { +@@ -114,6 +117,8 @@ public class AuthService extends SystemService { private FileObserver fodFileObserver = null; private ISehBiometricsFingerprint mSamsungFingerprint = null; @@ -134,7 +142,7 @@ index 35ff1ff0ba7a..30e1349c9562 100644 /** * Class for injecting dependencies into AuthService. * TODO(b/141025588): Replace with a dependency injection framework (e.g. Guice, Dagger). -@@ -677,6 +681,12 @@ public class AuthService extends SystemService { +@@ -677,6 +682,12 @@ public class AuthService extends SystemService { } catch(Exception e) { android.util.Log.e("PHH", "Failed getting Samsung fingerprint HAL", e); } @@ -147,7 +155,39 @@ index 35ff1ff0ba7a..30e1349c9562 100644 if(samsungHasCmd("fod_enable") && mSamsungFingerprint != null) { samsungCmd("fod_enable,1,1,0"); String actualMaskBrightnessPath = "/sys/class/lcd/panel/actual_mask_brightness"; -@@ -736,6 +746,31 @@ public class AuthService extends SystemService { +@@ -708,6 +719,31 @@ public class AuthService extends SystemService { + fodFileObserver.startWatching(); + } + ++ String xiaomiFodPressedStatusPath = "/sys/class/touch/touch_dev/fod_press_status"; ++ if(new File(xiaomiFodPressedStatusPath).exists() && mXiaomiFingerprint != null) { ++ fodFileObserver = new FileObserver(xiaomiFodPressedStatusPath, FileObserver.MODIFY) { ++ @Override ++ public void onEvent(int event, String path) { ++ String isFodPressed = readFile(xiaomiFodPressedStatusPath); ++ Slog.d("PHH-Enroll", "Fod pressed status: " + isFodPressed); ++ Slog.d("PHH-Enroll", "Within xiaomi scenario for FOD"); ++ ++ try { ++ if("0".equals(isFodPressed)) { ++ Slog.d("PHH-Enroll", "Fod un-pressed!"); ++ mXiaomiFingerprint.extCmd(android.os.SystemProperties.getInt("phh.xiaomi.fod.enrollment.id", 4), 0); ++ } else if("1".equals(isFodPressed)) { ++ Slog.d("PHH-Enroll", "Fod pressed!"); ++ mXiaomiFingerprint.extCmd(android.os.SystemProperties.getInt("phh.xiaomi.fod.enrollment.id", 4), 1); ++ } ++ } catch(Exception e) { ++ Slog.d("PHH-Enroll", "Failed Xiaomi async extcmd", e); ++ } ++ } ++ }; ++ fodFileObserver.startWatching(); ++ } ++ + String asusGhbmOnAchieved = "/sys/class/drm/ghbm_on_achieved"; + if( (new File(asusGhbmOnAchieved)).exists()) { + fodFileObserver = new FileObserver(asusGhbmOnAchieved, FileObserver.MODIFY) { +@@ -736,6 +772,31 @@ public class AuthService extends SystemService { }; fodFileObserver.startWatching(); } @@ -179,11 +219,11 @@ index 35ff1ff0ba7a..30e1349c9562 100644 } /** -@@ -937,6 +972,18 @@ public class AuthService extends SystemService { +@@ -937,6 +998,18 @@ public class AuthService extends SystemService { return udfpsProps; } -+ if(android.os.SystemProperties.get("persist.vendor.sys.fp.fod.location.X_Y") != null) { ++ if(!TextUtils.isEmpty(android.os.SystemProperties.get("persist.vendor.sys.fp.fod.location.X_Y"))) { + int[] udfpsProps = new int[3]; + String[] coordinates = android.os.SystemProperties.get("persist.vendor.sys.fp.fod.location.X_Y").split(","); + udfpsProps[0] = displayRealSize.x/2; @@ -198,11 +238,6 @@ index 35ff1ff0ba7a..30e1349c9562 100644 return new int[0]; } -@@ -1087,3 +1134,4 @@ public class AuthService extends SystemService { - return null; - } - } -+} -- 2.34.1 diff --git a/patches/trebledroid/platform_frameworks_base/0037-SystemUI-Add-MTK-s-brightness-path-for-FOD.patch b/patches/trebledroid/platform_frameworks_base/0037-SystemUI-Add-MTK-s-brightness-path-for-FOD.patch new file mode 100644 index 0000000..497dcf6 --- /dev/null +++ b/patches/trebledroid/platform_frameworks_base/0037-SystemUI-Add-MTK-s-brightness-path-for-FOD.patch @@ -0,0 +1,67 @@ +From 01218280a29858aaa25fcee33cc825785fde1056 Mon Sep 17 00:00:00 2001 +From: Andy CrossGate Yan +Date: Sun, 15 Oct 2023 11:21:58 +0800 +Subject: [PATCH 5/7] SystemUI: Add MTK's brightness path for FOD + +Rewrote the part for easier extension + +Change-Id: Ifec88c625210301b5d1146bba0275cd9699243e8 +--- + .../android/systemui/biometrics/UdfpsView.kt | 30 ++++++++++++++----- + 1 file changed, 22 insertions(+), 8 deletions(-) + +diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt +index 8ab00fc34f0d..e43650d9d3f9 100644 +--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt ++++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt +@@ -34,6 +34,7 @@ import android.widget.FrameLayout + import com.android.systemui.R + import com.android.systemui.doze.DozeReceiver + import java.io.File ++import java.io.FileNotFoundException + + import vendor.goodix.hardware.biometrics.fingerprint.V2_1.IGoodixFingerprintDaemon + +@@ -240,18 +241,31 @@ Log.d("PHH", "Surface destroyed!") + mySurfaceView.setVisibility(VISIBLE) + Log.d("PHH", "setting surface visible!") + +- val brightnessFile = File("/sys/class/backlight/panel/brightness") +- val maxBrightnessFile = File("/sys/class/backlight/panel/max_brightness") ++ val brightnessFiles = listOf( ++ File("/sys/class/backlight/panel/brightness"), ++ File("/sys/class/backlight/panel0-backlight/brightness"), ++ File("/sys/devices/platform/soc/soc:mtk_leds/leds/lcd-backlight/brightness") ++ ) ++ val maxBrightnessFiles = listOf( ++ File("/sys/class/backlight/panel/max_brightness"), ++ File("/sys/class/backlight/panel0-backlight/max_brightness"), ++ File("/sys/devices/platform/soc/soc:mtk_leds/leds/lcd-backlight/max_brightness") ++ ) + + var brightness: Double = 0.0 + var maxBrightness: Double = 0.0 ++ var bmFilesExist: Boolean = false + +- if (brightnessFile.exists() && maxBrightnessFile.exists()) { +- brightness = brightnessFile.readText().toDouble() +- maxBrightness = maxBrightnessFile.readText().toDouble() +- } else { +- brightness = File("/sys/class/backlight/panel0-backlight/brightness").readText().toDouble() +- maxBrightness = File("/sys/class/backlight/panel0-backlight/max_brightness").readText().toDouble() ++ brightnessFiles.zip(maxBrightnessFiles) {bFile, mFile -> ++ if (bFile.exists() && mFile.exists()) { ++ bmFilesExist = true ++ brightness = bFile.readText().toDouble() ++ maxBrightness = mFile.readText().toDouble() ++ } ++ } ++ ++ if (!bmFilesExist) { ++ throw FileNotFoundException("No brightness files under expected paths") + } + + // Assume HBM is max brightness +-- +2.34.1 + diff --git a/patches/trebledroid/platform_frameworks_base/0038-udfps-fixup.patch b/patches/trebledroid/platform_frameworks_base/0038-udfps-fixup.patch new file mode 100644 index 0000000..5251240 --- /dev/null +++ b/patches/trebledroid/platform_frameworks_base/0038-udfps-fixup.patch @@ -0,0 +1,53 @@ +From a1ec30c16dc3979a3476b1ccc2c03020c7423d6a Mon Sep 17 00:00:00 2001 +From: naz664 +Date: Sun, 15 Oct 2023 12:10:21 +0000 +Subject: [PATCH 7/7] udfps: fixup! + +--- + .../server/biometrics/AuthService.java | 26 +------------------ + 1 file changed, 1 insertion(+), 25 deletions(-) + +diff --git a/services/core/java/com/android/server/biometrics/AuthService.java b/services/core/java/com/android/server/biometrics/AuthService.java +index b9555b0f226b..a08375fb5dda 100644 +--- a/services/core/java/com/android/server/biometrics/AuthService.java ++++ b/services/core/java/com/android/server/biometrics/AuthService.java +@@ -719,31 +719,6 @@ public class AuthService extends SystemService { + fodFileObserver.startWatching(); + } + +- String xiaomiFodPressedStatusPath = "/sys/class/touch/touch_dev/fod_press_status"; +- if(new File(xiaomiFodPressedStatusPath).exists() && mXiaomiFingerprint != null) { +- fodFileObserver = new FileObserver(xiaomiFodPressedStatusPath, FileObserver.MODIFY) { +- @Override +- public void onEvent(int event, String path) { +- String isFodPressed = readFile(xiaomiFodPressedStatusPath); +- Slog.d("PHH-Enroll", "Fod pressed status: " + isFodPressed); +- Slog.d("PHH-Enroll", "Within xiaomi scenario for FOD"); +- +- try { +- if("0".equals(isFodPressed)) { +- Slog.d("PHH-Enroll", "Fod un-pressed!"); +- mXiaomiFingerprint.extCmd(android.os.SystemProperties.getInt("phh.xiaomi.fod.enrollment.id", 4), 0); +- } else if("1".equals(isFodPressed)) { +- Slog.d("PHH-Enroll", "Fod pressed!"); +- mXiaomiFingerprint.extCmd(android.os.SystemProperties.getInt("phh.xiaomi.fod.enrollment.id", 4), 1); +- } +- } catch(Exception e) { +- Slog.d("PHH-Enroll", "Failed Xiaomi async extcmd", e); +- } +- } +- }; +- fodFileObserver.startWatching(); +- } +- + String asusGhbmOnAchieved = "/sys/class/drm/ghbm_on_achieved"; + if( (new File(asusGhbmOnAchieved)).exists()) { + fodFileObserver = new FileObserver(asusGhbmOnAchieved, FileObserver.MODIFY) { +@@ -1160,3 +1135,4 @@ public class AuthService extends SystemService { + return null; + } + } ++} +-- +2.34.1 + diff --git a/patches/trebledroid/platform_frameworks_native/0010-Fix-light-sensor-crash-on-Xiaomi-13.patch b/patches/trebledroid/platform_frameworks_native/0010-Fix-light-sensor-crash-on-Xiaomi-13.patch new file mode 100644 index 0000000..b7fa839 --- /dev/null +++ b/patches/trebledroid/platform_frameworks_native/0010-Fix-light-sensor-crash-on-Xiaomi-13.patch @@ -0,0 +1,36 @@ +From 559e6fb609765373655f42181232a962767d65d4 Mon Sep 17 00:00:00 2001 +From: Andy CrossGate Yan +Date: Tue, 18 Apr 2023 23:48:15 +0000 +Subject: [PATCH] Fix light sensor crash on Xiaomi 13 + +SensorService expects a scalar, but Xiaomi HAL returns a pose6DOF vector encapsulation +Thanks @phhusson for the analysis + +Change-Id: Ie358321d5328d01541f455d6af86944ff413c9c9 +--- + services/sensorservice/AidlSensorHalWrapper.cpp | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/services/sensorservice/AidlSensorHalWrapper.cpp b/services/sensorservice/AidlSensorHalWrapper.cpp +index f67c610550..32fd9240b3 100644 +--- a/services/sensorservice/AidlSensorHalWrapper.cpp ++++ b/services/sensorservice/AidlSensorHalWrapper.cpp +@@ -171,7 +171,14 @@ void convertToSensorEvent(const Event &src, sensors_event_t *dst) { + case SensorType::MOTION_DETECT: + case SensorType::HEART_BEAT: + case SensorType::LOW_LATENCY_OFFBODY_DETECT: { +- dst->data[0] = src.payload.get(); ++ if (src.payload.getTag() == Event::EventPayload::pose6DOF) { ++ auto d = src.payload.get(); ++ auto dstr = ::android::internal::ToString(d); ++ // ALOGE("Received 6DOF for expected scalar %s", dstr.c_str()); ++ dst->data[0] = d.values[0]; ++ } else { ++ dst->data[0] = src.payload.get(); ++ } + break; + } + +-- +2.34.1 + diff --git a/patches/trebledroid/platform_packages_modules_Bluetooth/03-Optionally-use-sysbta-HAL.patch b/patches/trebledroid/platform_packages_modules_Bluetooth/03-Optionally-use-sysbta-HAL.patch new file mode 100644 index 0000000..061160c --- /dev/null +++ b/patches/trebledroid/platform_packages_modules_Bluetooth/03-Optionally-use-sysbta-HAL.patch @@ -0,0 +1,104 @@ +From f33456723161bd07c435c62a16d3ae19c499c5c7 Mon Sep 17 00:00:00 2001 +From: Peter Cai +Date: Wed, 24 Aug 2022 15:45:18 -0400 +Subject: [PATCH] audio_hal_interface: Optionally use sysbta HAL + +Required to support sysbta, our system-side bt audio implementation. + +Change-Id: I59973e6ec84c5923be8a7c67b36b2e237f000860 +--- + system/audio_hal_interface/aidl/client_interface_aidl.cc | 6 +++--- + system/audio_hal_interface/aidl/client_interface_aidl.h | 7 +++++++ + system/audio_hal_interface/hal_version_manager.cc | 9 ++++++++- + 3 files changed, 18 insertions(+), 4 deletions(-) + +diff --git a/system/audio_hal_interface/aidl/client_interface_aidl.cc b/system/audio_hal_interface/aidl/client_interface_aidl.cc +index 9af28031f7..5a9dbbccad 100644 +--- a/system/audio_hal_interface/aidl/client_interface_aidl.cc ++++ b/system/audio_hal_interface/aidl/client_interface_aidl.cc +@@ -56,7 +56,7 @@ BluetoothAudioClientInterface::BluetoothAudioClientInterface( + + bool BluetoothAudioClientInterface::is_aidl_available() { + return AServiceManager_isDeclared( +- kDefaultAudioProviderFactoryInterface.c_str()); ++ audioProviderFactoryInterface().c_str()); + } + + std::vector +@@ -72,7 +72,7 @@ BluetoothAudioClientInterface::GetAudioCapabilities(SessionType session_type) { + } + auto provider_factory = IBluetoothAudioProviderFactory::fromBinder( + ::ndk::SpAIBinder(AServiceManager_waitForService( +- kDefaultAudioProviderFactoryInterface.c_str()))); ++ audioProviderFactoryInterface().c_str()))); + + if (provider_factory == nullptr) { + LOG(ERROR) << __func__ << ", can't get capability from unknown factory"; +@@ -99,7 +99,7 @@ void BluetoothAudioClientInterface::FetchAudioProvider() { + } + auto provider_factory = IBluetoothAudioProviderFactory::fromBinder( + ::ndk::SpAIBinder(AServiceManager_waitForService( +- kDefaultAudioProviderFactoryInterface.c_str()))); ++ audioProviderFactoryInterface().c_str()))); + + if (provider_factory == nullptr) { + LOG(ERROR) << __func__ << ", can't get capability from unknown factory"; +diff --git a/system/audio_hal_interface/aidl/client_interface_aidl.h b/system/audio_hal_interface/aidl/client_interface_aidl.h +index 87dd450997..36d5fa5e86 100644 +--- a/system/audio_hal_interface/aidl/client_interface_aidl.h ++++ b/system/audio_hal_interface/aidl/client_interface_aidl.h +@@ -28,6 +28,7 @@ + #include "bluetooth_audio_port_impl.h" + #include "common/message_loop_thread.h" + #include "transport_instance.h" ++#include "osi/include/properties.h" + + #define BLUETOOTH_AUDIO_HAL_PROP_DISABLED \ + "persist.bluetooth.bluetooth_audio_hal.disabled" +@@ -115,6 +116,12 @@ class BluetoothAudioClientInterface { + // "android.hardware.bluetooth.audio.IBluetoothAudioProviderFactory/default"; + static inline const std::string kDefaultAudioProviderFactoryInterface = + std::string() + IBluetoothAudioProviderFactory::descriptor + "/default"; ++ static inline const std::string kSystemAudioProviderFactoryInterface = ++ std::string() + IBluetoothAudioProviderFactory::descriptor + "/sysbta"; ++ static inline const std::string audioProviderFactoryInterface() { ++ return osi_property_get_bool("persist.bluetooth.system_audio_hal.enabled", false) ++ ? kSystemAudioProviderFactoryInterface : kDefaultAudioProviderFactoryInterface; ++ } + + private: + IBluetoothTransportInstance* transport_; +diff --git a/system/audio_hal_interface/hal_version_manager.cc b/system/audio_hal_interface/hal_version_manager.cc +index a2c192f37d..c3d1cf35c2 100644 +--- a/system/audio_hal_interface/hal_version_manager.cc ++++ b/system/audio_hal_interface/hal_version_manager.cc +@@ -24,6 +24,7 @@ + #include + + #include "aidl/audio_aidl_interfaces.h" ++#include "osi/include/properties.h" + + namespace bluetooth { + namespace audio { +@@ -33,6 +34,12 @@ using ::aidl::android::hardware::bluetooth::audio:: + + static const std::string kDefaultAudioProviderFactoryInterface = + std::string() + IBluetoothAudioProviderFactory::descriptor + "/default"; ++static const std::string kSystemAudioProviderFactoryInterface = ++ std::string() + IBluetoothAudioProviderFactory::descriptor + "/sysbta"; ++static inline const std::string audioProviderFactoryInterface() { ++ return osi_property_get_bool("persist.bluetooth.system_audio_hal.enabled", false) ++ ? kSystemAudioProviderFactoryInterface : kDefaultAudioProviderFactoryInterface; ++} + + std::unique_ptr HalVersionManager::instance_ptr = + std::make_unique(); +@@ -92,7 +99,7 @@ HalVersionManager::GetProvidersFactory_2_0() { + + HalVersionManager::HalVersionManager() { + if (AServiceManager_checkService( +- kDefaultAudioProviderFactoryInterface.c_str()) != nullptr) { ++ audioProviderFactoryInterface().c_str()) != nullptr) { + hal_version_ = BluetoothAudioHalVersion::VERSION_AIDL_V1; + return; + } diff --git a/patches/trebledroid/platform_packages_modules_Bluetooth/0004-Add-option-to-change-eSCO-Transport-Unit-Size.patch b/patches/trebledroid/platform_packages_modules_Bluetooth/04-Add-option-to-change-eSCO-Transport-Unit-Size.patch similarity index 92% rename from patches/trebledroid/platform_packages_modules_Bluetooth/0004-Add-option-to-change-eSCO-Transport-Unit-Size.patch rename to patches/trebledroid/platform_packages_modules_Bluetooth/04-Add-option-to-change-eSCO-Transport-Unit-Size.patch index 4bfe66a..20c6113 100644 --- a/patches/trebledroid/platform_packages_modules_Bluetooth/0004-Add-option-to-change-eSCO-Transport-Unit-Size.patch +++ b/patches/trebledroid/platform_packages_modules_Bluetooth/04-Add-option-to-change-eSCO-Transport-Unit-Size.patch @@ -1,7 +1,7 @@ -From b26567424687e4e644d9bc9ac657935e0bbe5a73 Mon Sep 17 00:00:00 2001 +From 3a2980c46c7acbaa1464a832ec61f80bea0f5e5e Mon Sep 17 00:00:00 2001 From: Alberto Ponces Date: Thu, 17 Jun 2021 15:48:53 +0100 -Subject: [PATCH 4/8] Add option to change eSCO Transport Unit Size +Subject: [PATCH 4/5] Add option to change eSCO Transport Unit Size Fixes Bluetooth calls on some Samsung devices if set to 16. diff --git a/patches/trebledroid/platform_packages_modules_Bluetooth/0005-Don-t-abort-when-failing-to-get-real-time-priority.patch b/patches/trebledroid/platform_packages_modules_Bluetooth/05-Don-t-abort-when-failing-to-get-real-time-priority.patch similarity index 90% rename from patches/trebledroid/platform_packages_modules_Bluetooth/0005-Don-t-abort-when-failing-to-get-real-time-priority.patch rename to patches/trebledroid/platform_packages_modules_Bluetooth/05-Don-t-abort-when-failing-to-get-real-time-priority.patch index facefd5..4793361 100644 --- a/patches/trebledroid/platform_packages_modules_Bluetooth/0005-Don-t-abort-when-failing-to-get-real-time-priority.patch +++ b/patches/trebledroid/platform_packages_modules_Bluetooth/05-Don-t-abort-when-failing-to-get-real-time-priority.patch @@ -1,7 +1,7 @@ -From a4582bfe878d6889f426974346ccd85ac1e1453a Mon Sep 17 00:00:00 2001 +From d608ee09645c451a17ac5956dbf5cd3a4f853558 Mon Sep 17 00:00:00 2001 From: Pierre-Hugues Husson Date: Sun, 17 Oct 2021 17:17:13 -0400 -Subject: [PATCH 5/8] Don't abort when failing to get real-time priority +Subject: [PATCH 5/5] Don't abort when failing to get real-time priority On some devices (like OP6), for unknown reason, trying to go to realtime fails with EPERM. @@ -14,12 +14,13 @@ Change-Id: Id25dac186628e933185bdfd640498004459b375a --- system/btif/src/btif_a2dp_sink.cc | 2 +- system/btif/src/btif_a2dp_source.cc | 2 +- + system/hci/src/hci_layer.cc | 1 - system/osi/src/alarm.cc | 12 +++++++++++- system/stack/btu/btu_task.cc | 2 +- - 4 files changed, 14 insertions(+), 4 deletions(-) + 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/system/btif/src/btif_a2dp_sink.cc b/system/btif/src/btif_a2dp_sink.cc -index 9d52524b4b..95a129d2b5 100644 +index 665965a3cb..d1f00ceed1 100644 --- a/system/btif/src/btif_a2dp_sink.cc +++ b/system/btif/src/btif_a2dp_sink.cc @@ -197,7 +197,7 @@ bool btif_a2dp_sink_init() { @@ -32,10 +33,10 @@ index 9d52524b4b..95a129d2b5 100644 #endif } diff --git a/system/btif/src/btif_a2dp_source.cc b/system/btif/src/btif_a2dp_source.cc -index 4ca2c8c265..db5ff20444 100644 +index f13abac71a..a6a84b519e 100644 --- a/system/btif/src/btif_a2dp_source.cc +++ b/system/btif/src/btif_a2dp_source.cc -@@ -365,7 +365,7 @@ static void btif_a2dp_source_startup_delayed() { +@@ -364,7 +364,7 @@ static void btif_a2dp_source_startup_delayed() { LOG_INFO("%s: state=%s", __func__, btif_a2dp_source_cb.StateStr().c_str()); if (!btif_a2dp_source_thread.EnableRealTimeScheduling()) { #if defined(OS_ANDROID) diff --git a/patches/trebledroid/platform_packages_modules_Bluetooth/0006-On-Samsung-devices-we-need-to-tell-Audio-HAL-if-we-r.patch b/patches/trebledroid/platform_packages_modules_Bluetooth/06-On-Samsung-devices-we-need-to-tell-Audio-HAL-if-we-re-running-narrow-band-or-wide-band.patch similarity index 93% rename from patches/trebledroid/platform_packages_modules_Bluetooth/0006-On-Samsung-devices-we-need-to-tell-Audio-HAL-if-we-r.patch rename to patches/trebledroid/platform_packages_modules_Bluetooth/06-On-Samsung-devices-we-need-to-tell-Audio-HAL-if-we-re-running-narrow-band-or-wide-band.patch index c99a372..710b911 100644 --- a/patches/trebledroid/platform_packages_modules_Bluetooth/0006-On-Samsung-devices-we-need-to-tell-Audio-HAL-if-we-r.patch +++ b/patches/trebledroid/platform_packages_modules_Bluetooth/06-On-Samsung-devices-we-need-to-tell-Audio-HAL-if-we-re-running-narrow-band-or-wide-band.patch @@ -1,11 +1,9 @@ -From e201cbdc5562ac6475a0fe51f9eefa75eea5384b Mon Sep 17 00:00:00 2001 +From d331112c5305bcfa8c47e0b5c4a5bad7b905a0ed Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sat, 12 Nov 2022 00:35:46 +0000 -Subject: [PATCH 6/8] On Samsung devices, we need to tell Audio HAL if we're +Subject: [PATCH] On Samsung devices, we need to tell Audio HAL if we're running narrow band or wide band -Ported to Android 13. - Change-Id: I7802b7a29c017a2cd7018e82772183df1dfa0b89 --- .../com/android/bluetooth/hfp/HeadsetStateMachine.java | 8 ++++++++ @@ -63,5 +61,5 @@ index 52f2949d4d..4e46f47eab 100644 default: Log.e(TAG, "processWBSEvent: unknown wbsConfig " + wbsConfig); -- -2.25.1 +2.34.1 diff --git a/patches/trebledroid/platform_packages_modules_Bluetooth/07-Add-properties-to-disable-some-features-commands-sta.patch b/patches/trebledroid/platform_packages_modules_Bluetooth/07-Add-properties-to-disable-some-features-commands-sta.patch new file mode 100644 index 0000000..f414de6 --- /dev/null +++ b/patches/trebledroid/platform_packages_modules_Bluetooth/07-Add-properties-to-disable-some-features-commands-sta.patch @@ -0,0 +1,129 @@ +From fa15428213f8f4ab3901f77642b69715e08eeb51 Mon Sep 17 00:00:00 2001 +From: Pierre-Hugues Husson +Date: Sat, 27 May 2023 06:41:32 -0400 +Subject: [PATCH] Add properties to disable some features/commands/states that + the ble chip declared but doesnt actually support + +--- + system/gd/hci/controller.cc | 70 ++++++++++++++++++++++++++++++++++--- + 1 file changed, 66 insertions(+), 4 deletions(-) + +diff --git a/system/gd/hci/controller.cc b/system/gd/hci/controller.cc +index 41cc75b5d8..7a52277d3f 100644 +--- a/system/gd/hci/controller.cc ++++ b/system/gd/hci/controller.cc +@@ -16,6 +16,7 @@ + + #include "hci/controller.h" + ++#include + #include + #include + #include +@@ -27,6 +28,8 @@ + #include "hci_controller_generated.h" + #include "os/metrics.h" + #include "os/system_properties.h" ++#include "os/system_properties.h" ++using bluetooth::os::GetSystemProperty; + + namespace bluetooth { + namespace hci { +@@ -264,7 +267,23 @@ struct Controller::impl { + ASSERT(complete_view.IsValid()); + ErrorCode status = complete_view.GetStatus(); + ASSERT_LOG(status == ErrorCode::SUCCESS, "Status 0x%02hhx, %s", status, ErrorCodeText(status).c_str()); +- local_supported_commands_ = complete_view.GetSupportedCommands(); ++ //local_supported_commands_ = complete_view.GetSupportedCommands(); ++ ++ auto local_commands = complete_view.GetSupportedCommands(); ++ std::string ignored_commands = GetSystemProperty("persist.sys.bt.unsupported.commands").value_or(""); ++ ++ if (ignored_commands != "") { ++ auto s = base::SplitString(ignored_commands, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); ++ for(auto command: s) { ++ int index = std::stoi(command); ++ LOG_WARN("Ignoring local supported command %d", index); ++ uint16_t byte_index = index / 10; ++ uint16_t bit_index = index % 10; ++ local_commands[byte_index] &= ~(1 << bit_index); ++ } ++ } ++ ++ local_supported_commands_ = local_commands; + + if (auto disabledCommands = os::GetSystemProperty(kPropertyDisabledCommands)) { + for (const auto& command : android::base::Split(*disabledCommands, ",")) { +@@ -282,7 +301,23 @@ struct Controller::impl { + ErrorCode status = complete_view.GetStatus(); + ASSERT_LOG(status == ErrorCode::SUCCESS, "Status 0x%02hhx, %s", status, ErrorCodeText(status).c_str()); + uint8_t page_number = complete_view.GetPageNumber(); +- extended_lmp_features_array_.push_back(complete_view.GetExtendedLmpFeatures()); ++ //extended_lmp_features_array_.push_back(complete_view.GetExtendedLmpFeatures()); ++ auto lmp_features = complete_view.GetExtendedLmpFeatures(); ++ ++ std::string ignored_features = GetSystemProperty("persist.sys.bt.unsupported.ogfeatures").value_or(""); ++ ++ if (ignored_features != "") { ++ auto s = base::SplitString(ignored_features, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); ++ int offset = page_number * 64; ++ for(auto feature: s) { ++ int index = std::stoi(feature) - offset; ++ if(index >= 0 && index < 64) { ++ LOG_WARN("Ignoring local supported feature %d", index); ++ lmp_features &= ~(1ULL << index); ++ } ++ } ++ } ++ extended_lmp_features_array_.push_back(lmp_features); + bluetooth::os::LogMetricBluetoothLocalSupportedFeatures(page_number, complete_view.GetExtendedLmpFeatures()); + // Query all extended features + if (page_number < complete_view.GetMaximumPageNumber()) { +@@ -362,7 +397,20 @@ struct Controller::impl { + ASSERT(complete_view.IsValid()); + ErrorCode status = complete_view.GetStatus(); + ASSERT_LOG(status == ErrorCode::SUCCESS, "Status 0x%02hhx, %s", status, ErrorCodeText(status).c_str()); +- le_local_supported_features_ = complete_view.GetLeFeatures(); ++ //le_local_supported_features_ = complete_view.GetLeFeatures(); ++ auto local_features = complete_view.GetLeFeatures(); ++ std::string ignored_features = GetSystemProperty("persist.sys.bt.unsupported.lefeatures").value_or(""); ++ ++ if (ignored_features != "") { ++ auto s = base::SplitString(ignored_features, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); ++ for(auto feature: s) { ++ int index = std::stoi(feature); ++ LOG_WARN("Ignoring local supported feature %d", index); ++ local_features &= ~(1ULL << index); ++ } ++ } ++ ++ le_local_supported_features_ = local_features; + } + + void le_read_supported_states_handler(CommandCompleteView view) { +@@ -370,7 +418,21 @@ struct Controller::impl { + ASSERT(complete_view.IsValid()); + ErrorCode status = complete_view.GetStatus(); + ASSERT_LOG(status == ErrorCode::SUCCESS, "Status 0x%02hhx, %s", status, ErrorCodeText(status).c_str()); +- le_supported_states_ = complete_view.GetLeStates(); ++ //le_supported_states_ = complete_view.GetLeStates(); ++ ++ auto local_states = complete_view.GetLeStates(); ++ std::string ignored_states = GetSystemProperty("persist.sys.bt.unsupported.states").value_or(""); ++ ++ if (ignored_states != "") { ++ auto s = base::SplitString(ignored_states, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); ++ for(auto state: s) { ++ int index = std::stoi(state); ++ LOG_WARN("Ignoring local supported state %d", index); ++ local_states &= ~(1ULL << index); ++ } ++ } ++ ++ le_supported_states_ = local_states; + } + + void le_read_connect_list_size_handler(CommandCompleteView view) { +-- +2.34.1 + diff --git a/patches/trebledroid/platform_packages_modules_Bluetooth/0008-Add-a-property-to-cap-declared-le-vendor-version.-Fo.patch b/patches/trebledroid/platform_packages_modules_Bluetooth/08-Add-a-property-to-cap-declared-le-vendor-version.-Fo.patch similarity index 100% rename from patches/trebledroid/platform_packages_modules_Bluetooth/0008-Add-a-property-to-cap-declared-le-vendor-version.-Fo.patch rename to patches/trebledroid/platform_packages_modules_Bluetooth/08-Add-a-property-to-cap-declared-le-vendor-version.-Fo.patch