Skip to content

Commit 6bdf3f8

Browse files
committed
add debug logging to track hook initialization timing
1 parent c6d7066 commit 6bdf3f8

6 files changed

Lines changed: 19 additions & 1 deletion

File tree

app/src/main/java/ru/hepolise/volumekeytrackcontrol/module/VolumeControlModule.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam
99
import ru.hepolise.volumekeytrackcontrol.module.VolumeKeyControlModuleHandlers.handleConstructPhoneWindowManager
1010
import ru.hepolise.volumekeytrackcontrol.module.VolumeKeyControlModuleHandlers.handleInterceptKeyBeforeQueueing
1111
import ru.hepolise.volumekeytrackcontrol.module.util.LogHelper
12+
import ru.hepolise.volumekeytrackcontrolmodule.BuildConfig
1213
import java.io.Serializable
1314

1415
@Keep
@@ -57,6 +58,7 @@ class VolumeControlModule : IXposedHookLoadPackage {
5758
if (lpparam.packageName != "android") {
5859
return
5960
}
61+
log("ApplicationID: ${BuildConfig.APPLICATION_ID}")
6062
init(lpparam.classLoader)
6163
}
6264

app/src/main/java/ru/hepolise/volumekeytrackcontrol/module/VolumeKeyControlModuleHandlers.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ object VolumeKeyControlModuleHandlers {
8282
val filter = IntentFilter(Intent.ACTION_USER_UNLOCKED)
8383
context.registerReceiver(object : BroadcastReceiver() {
8484
override fun onReceive(ctx: Context, intent: Intent) {
85+
log("handleConstructPhoneWindowManager: user unlocked")
8586
HookNotifier.notifyHooked(context)
8687
ctx.unregisterReceiver(this)
8788
}

app/src/main/java/ru/hepolise/volumekeytrackcontrol/module/util/HookNotifier.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ import ru.hepolise.volumekeytrackcontrolmodule.BuildConfig
77

88
object HookNotifier {
99

10+
private fun log(text: String) = LogHelper.log(HookNotifier::class.java.simpleName, text)
11+
1012
private val authorityUri = "content://${BuildConfig.APPLICATION_ID}.hookstatusprovider".toUri()
1113

1214
fun notifyHooked(context: Context) {
1315
runCatching {
16+
log("notifyHooked")
1417
context.contentResolver.call(authorityUri, Constants.SET_HOOKED, null, null)
1518
}
1619
}
1720

1821
fun incrementLaunchCount(context: Context) {
1922
runCatching {
23+
log("incrementLaunchCount")
2024
context.contentResolver.call(authorityUri, Constants.INCREMENT_LAUNCH_COUNT, null, null)
2125
}
2226
}

app/src/main/java/ru/hepolise/volumekeytrackcontrol/provider/HookStatusProvider.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.content.Context
66
import android.database.Cursor
77
import android.net.Uri
88
import android.os.Bundle
9+
import android.util.Log
910
import androidx.core.content.edit
1011
import ru.hepolise.volumekeytrackcontrol.util.Constants
1112
import ru.hepolise.volumekeytrackcontrol.util.SharedPreferencesUtil.HOOK_PREFS_NAME
@@ -21,6 +22,8 @@ class HookStatusProvider : ContentProvider() {
2122
val context = context ?: return null
2223
val prefs = context.getSharedPreferences(HOOK_PREFS_NAME, Context.MODE_PRIVATE)
2324

25+
Log.d(Constants.LOG_TAG, "call: $method")
26+
2427
prefs.edit {
2528
when (method) {
2629
Constants.SET_HOOKED -> {

app/src/main/java/ru/hepolise/volumekeytrackcontrol/util/Constants.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ object Constants {
99

1010
const val SET_HOOKED = "set_hooked"
1111
const val INCREMENT_LAUNCH_COUNT = "increment_launch_count"
12+
13+
const val LOG_TAG = "LSPosed-Bridge"
1214
}

app/src/main/java/ru/hepolise/volumekeytrackcontrol/util/SharedPreferencesUtil.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ru.hepolise.volumekeytrackcontrol.util
33
import android.content.SharedPreferences
44
import android.os.Build
55
import android.os.SystemClock
6+
import android.util.Log
67
import android.view.ViewConfiguration
78
import de.robv.android.xposed.XSharedPreferences
89
import ru.hepolise.volumekeytrackcontrolmodule.BuildConfig
@@ -79,7 +80,12 @@ object SharedPreferencesUtil {
7980
getLong(
8081
LAST_INIT_HOOK_TIME,
8182
0L
82-
) >= (System.currentTimeMillis() - SystemClock.elapsedRealtime())
83+
).also {
84+
Log.d(
85+
Constants.LOG_TAG,
86+
"Last init hook time: $it, comparing to ${System.currentTimeMillis() - SystemClock.elapsedRealtime()}"
87+
)
88+
} >= (System.currentTimeMillis() - SystemClock.elapsedRealtime())
8389

8490
fun SharedPreferences.getLaunchedCount(): Int =
8591
this.getInt(LAUNCHED_COUNT, LAUNCHED_COUNT_DEFAULT_VALUE)

0 commit comments

Comments
 (0)