mirror of
https://github.com/revanced/revanced-patches
synced 2024-11-10 09:29:22 +01:00
refactor: apply Kotlin coding conventions
This commit is contained in:
parent
beb8d9cbf2
commit
9d62f7cd6c
@ -1,5 +1,6 @@
|
|||||||
package app.revanced.patches.shared.misc.fix.spoof.patch
|
package app.revanced.patches.shared.misc.fix.spoof.patch
|
||||||
|
|
||||||
|
import app.revanced.extensions.toErrorResult
|
||||||
import app.revanced.patcher.annotation.Description
|
import app.revanced.patcher.annotation.Description
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
@ -23,15 +24,19 @@ class ClientSpoofPatch : BytecodePatch(
|
|||||||
listOf(UserAgentHeaderBuilderFingerprint)
|
listOf(UserAgentHeaderBuilderFingerprint)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
val result = UserAgentHeaderBuilderFingerprint.result!!
|
UserAgentHeaderBuilderFingerprint.result?.let { result ->
|
||||||
val method = result.mutableMethod
|
val insertIndex = result.scanResult.patternScanResult!!.endIndex
|
||||||
|
result.mutableMethod.apply {
|
||||||
|
val packageNameRegister = (instruction(insertIndex) as FiveRegisterInstruction).registerD
|
||||||
|
addInstruction(insertIndex, "const-string v$packageNameRegister, \"$ORIGINAL_PACKAGE_NAME\"")
|
||||||
|
}
|
||||||
|
|
||||||
val insertIndex = result.scanResult.patternScanResult!!.endIndex
|
} ?: return UserAgentHeaderBuilderFingerprint.toErrorResult()
|
||||||
val packageNameRegister = (method.instruction(insertIndex) as FiveRegisterInstruction).registerD
|
|
||||||
|
|
||||||
val originalPackageName = "com.google.android.youtube"
|
|
||||||
method.addInstruction(insertIndex, "const-string v$packageNameRegister, \"$originalPackageName\"")
|
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
private const val ORIGINAL_PACKAGE_NAME = "com.google.android.youtube"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user