feat(Nothing X): Add Show K1 token(s) patch (#6490)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
97e74157fa
commit
421cb2899e
9 changed files with 692 additions and 2 deletions
|
|
@ -0,0 +1,13 @@
|
|||
package app.revanced.patches.nothingx.misc.extension
|
||||
|
||||
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.shared.misc.extension.extensionHook
|
||||
|
||||
val sharedExtensionPatch = sharedExtensionPatch(
|
||||
extensionName = "nothingx",
|
||||
extensionHook {
|
||||
custom { method, classDef ->
|
||||
method.name == "onCreate" && classDef.contains("BaseApplication")
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package app.revanced.patches.nothingx.misc.logk1token
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
|
||||
/**
|
||||
* Fingerprint for the Application onCreate method.
|
||||
* This is used to trigger scanning for existing log files on app startup.
|
||||
*/
|
||||
internal val applicationOnCreateFingerprint = fingerprint {
|
||||
returns("V")
|
||||
parameters()
|
||||
custom { method, classDef ->
|
||||
// Match BaseApplication onCreate specifically
|
||||
method.name == "onCreate" && classDef.endsWith("BaseApplication;")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package app.revanced.patches.nothingx.misc.logk1token
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.nothingx.misc.extension.sharedExtensionPatch
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||
"Lapp/revanced/extension/nothingx/patches/ShowK1TokensPatch;"
|
||||
|
||||
@Suppress("unused")
|
||||
val showK1TokensPatch = bytecodePatch(
|
||||
name = "Show K1 token(s)",
|
||||
description = "Shows the K1 authentication token(s) in a dialog and logs it to logcat " +
|
||||
"for pairing with GadgetBridge without requiring root access. " +
|
||||
"After installing this patch, pair your watch with the Nothing X app and " +
|
||||
"use the token from the dialog or logcat.",
|
||||
) {
|
||||
dependsOn(sharedExtensionPatch)
|
||||
|
||||
compatibleWith("com.nothing.smartcenter"())
|
||||
|
||||
execute {
|
||||
// Hook Application.onCreate to get K1 tokens from database and log files.
|
||||
// This will find K1 tokens that were already written to log files.
|
||||
// p0 is the Application context in onCreate.
|
||||
applicationOnCreateFingerprint.method.addInstruction(
|
||||
0,
|
||||
"invoke-static { p0 }, $EXTENSION_CLASS_DESCRIPTOR->showK1Tokens(Landroid/content/Context;)V",
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue