From 62aabe80c16a5316ee05f3127cc2123bc37f83b2 Mon Sep 17 00:00:00 2001 From: Kavish Devar Date: Tue, 3 Jun 2025 20:12:25 +0530 Subject: [PATCH] android: add support for settings hook on A16 --- .../librepods/utils/KotlinModule.kt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/android/app/src/main/java/me/kavishdevar/librepods/utils/KotlinModule.kt b/android/app/src/main/java/me/kavishdevar/librepods/utils/KotlinModule.kt index 78221c3..f32f329 100644 --- a/android/app/src/main/java/me/kavishdevar/librepods/utils/KotlinModule.kt +++ b/android/app/src/main/java/me/kavishdevar/librepods/utils/KotlinModule.kt @@ -52,6 +52,35 @@ class KotlinModule(base: XposedInterface, param: ModuleLoadedParam): XposedModul } } + if (param.packageName == "com.google.android.settings") { + Log.i(TAG, "Settings app detected, hooking Bluetooth icon handling") + try { + val headerControllerClass = param.classLoader.loadClass( + "com.google.android.settings.bluetooth.AdvancedBluetoothDetailsHeaderController") + + val updateIconMethod = headerControllerClass.getDeclaredMethod( + "updateIcon", + android.widget.ImageView::class.java, + String::class.java) + + hook(updateIconMethod, BluetoothIconHooker::class.java) + Log.i(TAG, "Successfully hooked updateIcon method in Bluetooth settings") + + try { + val displayPreferenceMethod = headerControllerClass.getDeclaredMethod( + "displayPreference", + param.classLoader.loadClass("androidx.preference.PreferenceScreen")) + + hook(displayPreferenceMethod, BluetoothSettingsAirPodsHooker::class.java) + Log.i(TAG, "Successfully hooked displayPreference for AirPods button injection") + } catch (e: Exception) { + Log.e(TAG, "Failed to hook displayPreference: ${e.message}", e) + } + } catch (e: Exception) { + Log.e(TAG, "Failed to hook Bluetooth icon handler: ${e.message}", e) + } + } + if (param.packageName == "com.android.settings") { Log.i(TAG, "Settings app detected, hooking Bluetooth icon handling") try {