1
+ package app.revanced.patches.spotify.misc.fix
2
+
3
+ import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
4
+ import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
5
+ import app.revanced.patcher.patch.bytecodePatch
6
+ import app.revanced.patches.spotify.misc.extension.IS_SPOTIFY_LEGACY_APP_TARGET
7
+ import app.revanced.util.addInstructionsAtControlFlowLabel
8
+ import app.revanced.util.indexOfFirstInstructionOrThrow
9
+ import app.revanced.util.indexOfFirstInstructionReversedOrThrow
10
+ import com.android.tools.smali.dexlib2.Opcode
11
+ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
12
+
13
+ @Suppress(" unused" )
14
+ val spoofPackageInfoPatch = bytecodePatch(
15
+ name = " Spoof package info" ,
16
+ description = " Spoofs the package info of the app to fix various functions of the app." ,
17
+ ) {
18
+ compatibleWith(" com.spotify.music" )
19
+
20
+ execute {
21
+ val getPackageInfoFingerprint = if (IS_SPOTIFY_LEGACY_APP_TARGET ) {
22
+ getPackageInfoLegacyFingerprint
23
+ } else {
24
+ getPackageInfoFingerprint
25
+ }
26
+
27
+ getPackageInfoFingerprint.method.apply {
28
+ val stringMatches = getPackageInfoFingerprint.stringMatches!!
29
+
30
+ // region Spoof signature.
31
+
32
+ val failedToGetSignaturesStringIndex = stringMatches.first().index
33
+
34
+ val concatSignaturesIndex = indexOfFirstInstructionReversedOrThrow(
35
+ failedToGetSignaturesStringIndex,
36
+ Opcode .MOVE_RESULT_OBJECT ,
37
+ )
38
+
39
+ val signatureRegister = getInstruction<OneRegisterInstruction >(concatSignaturesIndex).registerA
40
+ val expectedSignature = " d6a6dced4a85f24204bf9505ccc1fce114cadb32"
41
+
42
+ replaceInstruction(concatSignaturesIndex, " const-string v$signatureRegister , \" $expectedSignature \" " )
43
+
44
+ // endregion
45
+
46
+ // region Spoof installer name.
47
+
48
+ if (IS_SPOTIFY_LEGACY_APP_TARGET ) {
49
+ // Installer name is not used in the legacy app target.
50
+ return @execute
51
+ }
52
+
53
+ val expectedInstallerName = " com.android.vending"
54
+
55
+ val returnInstallerNameIndex = indexOfFirstInstructionOrThrow(
56
+ stringMatches.last().index,
57
+ Opcode .RETURN_OBJECT
58
+ )
59
+
60
+ val installerNameRegister = getInstruction<OneRegisterInstruction >(
61
+ returnInstallerNameIndex
62
+ ).registerA
63
+
64
+ addInstructionsAtControlFlowLabel(
65
+ returnInstallerNameIndex,
66
+ " const-string v$installerNameRegister , \" $expectedInstallerName \" "
67
+ )
68
+
69
+ // endregion
70
+ }
71
+ }
72
+ }
0 commit comments