Skip to content

Commit 62aabe8

Browse files
committed
android: add support for settings hook on A16
1 parent dc0b06a commit 62aabe8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

android/app/src/main/java/me/kavishdevar/librepods/utils/KotlinModule.kt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,35 @@ class KotlinModule(base: XposedInterface, param: ModuleLoadedParam): XposedModul
5252
}
5353
}
5454

55+
if (param.packageName == "com.google.android.settings") {
56+
Log.i(TAG, "Settings app detected, hooking Bluetooth icon handling")
57+
try {
58+
val headerControllerClass = param.classLoader.loadClass(
59+
"com.google.android.settings.bluetooth.AdvancedBluetoothDetailsHeaderController")
60+
61+
val updateIconMethod = headerControllerClass.getDeclaredMethod(
62+
"updateIcon",
63+
android.widget.ImageView::class.java,
64+
String::class.java)
65+
66+
hook(updateIconMethod, BluetoothIconHooker::class.java)
67+
Log.i(TAG, "Successfully hooked updateIcon method in Bluetooth settings")
68+
69+
try {
70+
val displayPreferenceMethod = headerControllerClass.getDeclaredMethod(
71+
"displayPreference",
72+
param.classLoader.loadClass("androidx.preference.PreferenceScreen"))
73+
74+
hook(displayPreferenceMethod, BluetoothSettingsAirPodsHooker::class.java)
75+
Log.i(TAG, "Successfully hooked displayPreference for AirPods button injection")
76+
} catch (e: Exception) {
77+
Log.e(TAG, "Failed to hook displayPreference: ${e.message}", e)
78+
}
79+
} catch (e: Exception) {
80+
Log.e(TAG, "Failed to hook Bluetooth icon handler: ${e.message}", e)
81+
}
82+
}
83+
5584
if (param.packageName == "com.android.settings") {
5685
Log.i(TAG, "Settings app detected, hooking Bluetooth icon handling")
5786
try {

0 commit comments

Comments
 (0)