forked from inotia00/revanced-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(songpal): add
remove-badge-tab
patch
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/app/revanced/patches/songpal/badge/annotations/BadgeCompatibility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package app.revanced.patches.songpal.badge.annotations | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility([Package("com.sony.songpal.mdr")]) | ||
@Target(AnnotationTarget.CLASS) | ||
internal annotation class BadgeCompatibility |
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/app/revanced/patches/songpal/badge/fingerprints/CreateTabsFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package app.revanced.patches.songpal.badge.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import org.jf.dexlib2.AccessFlags | ||
import org.jf.dexlib2.Opcode | ||
|
||
// Located @ ub.i0.h#p (9.5.0) | ||
@FuzzyPatternScanMethod(2) | ||
object CreateTabsFingerprint : MethodFingerprint( | ||
"L", | ||
accessFlags = AccessFlags.PRIVATE.value, | ||
opcodes = listOf( | ||
Opcode.INVOKE_STATIC, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.INVOKE_STATIC, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.SGET_OBJECT, | ||
Opcode.INVOKE_INTERFACE, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.SGET_OBJECT, | ||
Opcode.INVOKE_INTERFACE, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.INVOKE_STATIC, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.INVOKE_INTERFACE, | ||
Opcode.MOVE_RESULT_OBJECT, | ||
Opcode.CHECK_CAST, | ||
Opcode.RETURN_OBJECT | ||
) | ||
) |
66 changes: 66 additions & 0 deletions
66
src/main/kotlin/app/revanced/patches/songpal/badge/patch/BadgeTabPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package app.revanced.patches.songpal.badge.patch | ||
|
||
import app.revanced.extensions.toErrorResult | ||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstructions | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.annotations.Patch | ||
import app.revanced.patches.songpal.badge.annotations.BadgeCompatibility | ||
import app.revanced.patches.songpal.badge.fingerprints.CreateTabsFingerprint | ||
|
||
@Patch | ||
@Name("remove-badge-tab") | ||
@Description("Removes the badge tab from the activity tab.") | ||
@BadgeCompatibility | ||
@Version("0.0.1") | ||
class BadgeTabPatch : BytecodePatch( | ||
listOf(CreateTabsFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext): PatchResult { | ||
CreateTabsFingerprint.result?.mutableMethod?.apply { | ||
removeInstructions(0, 2) | ||
|
||
val arrayRegister = 0 | ||
val indexRegister = 1 | ||
val arrayItemRegister = 2 | ||
|
||
// First insert the array of tabs... | ||
|
||
arrayTabs.withIndex().forEach { (index, tab) -> | ||
addInstructions( | ||
0, | ||
""" | ||
const/4 v$indexRegister, $index | ||
sget-object v$arrayItemRegister, $ACTIVITY_TAB_DESCRIPTOR->$tab:$ACTIVITY_TAB_DESCRIPTOR | ||
aput-object v$arrayItemRegister, v$arrayRegister, v$indexRegister | ||
""" | ||
) | ||
} | ||
|
||
// Then add the instructions to initialize the array. | ||
// This is done so that the order of instructions is correct. | ||
|
||
addInstructions( | ||
0, | ||
""" | ||
const/4 v$arrayRegister, ${arrayTabs.size} | ||
new-array v$arrayRegister, v$arrayRegister, [$ACTIVITY_TAB_DESCRIPTOR | ||
""" | ||
) | ||
|
||
} ?: return CreateTabsFingerprint.toErrorResult() | ||
|
||
return PatchResultSuccess() | ||
} | ||
|
||
companion object { | ||
const val ACTIVITY_TAB_DESCRIPTOR = "Ljp/co/sony/vim/framework/ui/yourheadphones/YhContract\$Tab;" | ||
val arrayTabs = listOf("Log", "HealthCare") | ||
} | ||
} |