mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-04-29 22:24:27 +02:00
refactor(Spotify - Spoof package info): Replace installer package name of legacy target (#4797)
This commit is contained in:
parent
c5d1702411
commit
ffc74be822
@ -3,15 +3,7 @@ package app.revanced.patches.spotify.misc.fix
|
|||||||
import app.revanced.patcher.fingerprint
|
import app.revanced.patcher.fingerprint
|
||||||
|
|
||||||
internal val getPackageInfoFingerprint = fingerprint {
|
internal val getPackageInfoFingerprint = fingerprint {
|
||||||
strings(
|
|
||||||
"Failed to get the application signatures",
|
|
||||||
"Failed to get installer package"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
internal val getPackageInfoLegacyFingerprint = fingerprint {
|
|
||||||
strings(
|
strings(
|
||||||
"Failed to get the application signatures"
|
"Failed to get the application signatures"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
package app.revanced.patches.spotify.misc.fix
|
package app.revanced.patches.spotify.misc.fix
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
import app.revanced.patcher.patch.bytecodePatch
|
import app.revanced.patcher.patch.bytecodePatch
|
||||||
import app.revanced.patches.spotify.misc.extension.IS_SPOTIFY_LEGACY_APP_TARGET
|
import app.revanced.util.findInstructionIndicesReversedOrThrow
|
||||||
import app.revanced.util.addInstructionsAtControlFlowLabel
|
import app.revanced.util.getReference
|
||||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
|
||||||
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
import app.revanced.util.indexOfFirstInstructionReversedOrThrow
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||||
|
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
val spoofPackageInfoPatch = bytecodePatch(
|
val spoofPackageInfoPatch = bytecodePatch(
|
||||||
@ -18,18 +19,11 @@ val spoofPackageInfoPatch = bytecodePatch(
|
|||||||
compatibleWith("com.spotify.music")
|
compatibleWith("com.spotify.music")
|
||||||
|
|
||||||
execute {
|
execute {
|
||||||
val getPackageInfoFingerprint = if (IS_SPOTIFY_LEGACY_APP_TARGET) {
|
|
||||||
getPackageInfoLegacyFingerprint
|
|
||||||
} else {
|
|
||||||
getPackageInfoFingerprint
|
|
||||||
}
|
|
||||||
|
|
||||||
getPackageInfoFingerprint.method.apply {
|
getPackageInfoFingerprint.method.apply {
|
||||||
val stringMatches = getPackageInfoFingerprint.stringMatches!!
|
|
||||||
|
|
||||||
// region Spoof signature.
|
// region Spoof signature.
|
||||||
|
|
||||||
val failedToGetSignaturesStringIndex = stringMatches.first().index
|
val failedToGetSignaturesStringIndex =
|
||||||
|
getPackageInfoFingerprint.stringMatches!!.first().index
|
||||||
|
|
||||||
val concatSignaturesIndex = indexOfFirstInstructionReversedOrThrow(
|
val concatSignaturesIndex = indexOfFirstInstructionReversedOrThrow(
|
||||||
failedToGetSignaturesStringIndex,
|
failedToGetSignaturesStringIndex,
|
||||||
@ -45,26 +39,23 @@ val spoofPackageInfoPatch = bytecodePatch(
|
|||||||
|
|
||||||
// region Spoof installer name.
|
// region Spoof installer name.
|
||||||
|
|
||||||
if (IS_SPOTIFY_LEGACY_APP_TARGET) {
|
|
||||||
// Installer name is not used in the legacy app target.
|
|
||||||
return@execute
|
|
||||||
}
|
|
||||||
|
|
||||||
val expectedInstallerName = "com.android.vending"
|
val expectedInstallerName = "com.android.vending"
|
||||||
|
|
||||||
val returnInstallerNameIndex = indexOfFirstInstructionOrThrow(
|
findInstructionIndicesReversedOrThrow {
|
||||||
stringMatches.last().index,
|
val reference = getReference<MethodReference>()
|
||||||
Opcode.RETURN_OBJECT
|
reference?.name == "getInstallerPackageName" || reference?.name == "getInstallingPackageName"
|
||||||
)
|
}.forEach { index ->
|
||||||
|
val returnObjectIndex = index + 1
|
||||||
|
|
||||||
val installerNameRegister = getInstruction<OneRegisterInstruction>(
|
val installerPackageNameRegister = getInstruction<OneRegisterInstruction>(
|
||||||
returnInstallerNameIndex
|
returnObjectIndex
|
||||||
).registerA
|
).registerA
|
||||||
|
|
||||||
addInstructionsAtControlFlowLabel(
|
addInstruction(
|
||||||
returnInstallerNameIndex,
|
returnObjectIndex + 1,
|
||||||
"const-string v$installerNameRegister, \"$expectedInstallerName\""
|
"const-string v$installerPackageNameRegister, \"$expectedInstallerName\""
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user