feat(Nothing X): Add Show K1 token(s) patch (#6490)

Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
Pa1NarK
2026-01-22 19:17:45 +01:00
committed by GitHub
co-authored by oSumAtrIX
parent 97e74157fa
commit 421cb2899e
9 changed files with 692 additions and 2 deletions
+8 -2
View File
@@ -589,6 +589,14 @@ public final class app/revanced/patches/nfctoolsse/misc/pro/UnlockProPatchKt {
public static final fun getUnlockProPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}
public final class app/revanced/patches/nothingx/misc/extension/SharedExtensionPatchKt {
public static final fun getSharedExtensionPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}
public final class app/revanced/patches/nothingx/misc/logk1token/ShowK1TokenPatchsKt {
public static final fun getShowK1TokensPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}
public final class app/revanced/patches/nunl/ads/HideAdsPatchKt {
public static final fun getHideAdsPatch ()Lapp/revanced/patcher/patch/BytecodePatch;
}
@@ -946,8 +954,6 @@ public final class app/revanced/patches/shared/misc/hex/Replacement {
public final class app/revanced/patches/shared/misc/litho/filter/LithoFilterPatchKt {
public static final fun getAddLithoFilter ()Lkotlin/jvm/functions/Function1;
public static final fun lithoFilterPatch (Lkotlin/jvm/functions/Function1;Lapp/revanced/patcher/Fingerprint;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lapp/revanced/patcher/patch/BytecodePatch;
public static synthetic fun lithoFilterPatch$default (Lkotlin/jvm/functions/Function1;Lapp/revanced/patcher/Fingerprint;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lapp/revanced/patcher/patch/BytecodePatch;
}
public final class app/revanced/patches/shared/misc/mapping/ResourceElement {
@@ -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",
)
}
}