feat(YouTube Music - Change start page): Add more start pages (#135)

* feat(YouTube Music - Change start page): Add more start pages

* Add more start pages

* feat: Switch to `EnumSetting`, Add `Default`, `Samples` and `Search`, Remove `Home`

---------

Co-authored-by: ILoveOpenSourceApplications <ILoveOpenSourceApplications@users.noreply.github.com>
Co-authored-by: inotia00 <108592928+inotia00@users.noreply.github.com>
This commit is contained in:
ILoveOpenSourceApplications
2025-01-27 15:23:27 +05:30
committed by GitHub
parent eb24578186
commit f7109f9815
8 changed files with 175 additions and 30 deletions

View File

@ -1,10 +1,11 @@
package app.revanced.patches.music.general.startpage
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.music.utils.extension.Constants.GENERAL_CLASS_DESCRIPTOR
import app.revanced.patches.music.utils.extension.Constants.GENERAL_PATH
import app.revanced.patches.music.utils.patch.PatchList.CHANGE_START_PAGE
import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.ResourceUtils.updatePatchStatus
@ -18,6 +19,9 @@ import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
private const val EXTENSION_CLASS_DESCRIPTOR =
"$GENERAL_PATH/ChangeStartPagePatch;"
@Suppress("unused")
val changeStartPagePatch = bytecodePatch(
CHANGE_START_PAGE.title,
@ -29,6 +33,11 @@ val changeStartPagePatch = bytecodePatch(
execute {
coldStartIntentFingerprint.methodOrThrow().addInstruction(
0,
"invoke-static {p1}, $EXTENSION_CLASS_DESCRIPTOR->overrideIntent(Landroid/content/Intent;)V"
)
coldStartUpFingerprint.methodOrThrow().apply {
val defaultBrowseIdIndex = indexOfFirstStringInstructionOrThrow(DEFAULT_BROWSE_ID)
val browseIdIndex = indexOfFirstInstructionReversedOrThrow(defaultBrowseIdIndex) {
@ -39,7 +48,7 @@ val changeStartPagePatch = bytecodePatch(
addInstructions(
browseIdIndex + 1, """
invoke-static {v$browseIdRegister}, $GENERAL_CLASS_DESCRIPTOR->changeStartPage(Ljava/lang/String;)Ljava/lang/String;
invoke-static {v$browseIdRegister}, $EXTENSION_CLASS_DESCRIPTOR->overrideBrowseId(Ljava/lang/String;)Ljava/lang/String;
move-result-object v$browseIdRegister
"""
)

View File

@ -7,6 +7,17 @@ import com.android.tools.smali.dexlib2.Opcode
const val DEFAULT_BROWSE_ID = "FEmusic_home"
internal val coldStartIntentFingerprint = legacyFingerprint(
name = "coldStartIntentFingerprint",
returnType = "L",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
parameters = listOf("Landroid/content/Intent;"),
strings = listOf(
"android.intent.action.SEARCH",
"com.google.android.youtube.music.action.shortcut_type",
)
)
internal val coldStartUpFingerprint = legacyFingerprint(
name = "coldStartUpFingerprint",
returnType = "Ljava/lang/String;",
@ -16,6 +27,9 @@ internal val coldStartUpFingerprint = legacyFingerprint(
Opcode.CONST_STRING,
Opcode.RETURN_OBJECT
),
strings = listOf("FEmusic_library_sideloaded_tracks", DEFAULT_BROWSE_ID)
strings = listOf(
"FEmusic_library_sideloaded_tracks",
DEFAULT_BROWSE_ID
)
)