feat(music/settings) when installing for the first time, a reboot dialog is shown

This commit is contained in:
inotia00 2023-09-05 12:26:24 +09:00
parent c5a68bf714
commit 5fda8e2c99
7 changed files with 26 additions and 8 deletions

View File

@ -9,6 +9,7 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patches.music.utils.integrations.patch.IntegrationsPatch
import app.revanced.patches.music.utils.settings.bytecode.fingerprints.PreferenceFingerprint
import app.revanced.patches.music.utils.settings.bytecode.fingerprints.SettingsHeadersFragmentFingerprint
import app.revanced.util.bytecode.BytecodeHelper.injectInit
import app.revanced.util.integrations.Constants.MUSIC_INTEGRATIONS_PATH
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@ -47,6 +48,8 @@ class SettingsBytecodePatch : BytecodePatch(
}
} ?: throw PreferenceFingerprint.exception
context.injectInit("FirstRun", "initializationRVX", false)
}
companion object {

View File

@ -64,7 +64,7 @@ class MicroGBytecodePatch : BytecodePatch(
)
)
context.injectInit("MicroGPatch", "checkAvailability")
context.injectInit("MicroGPatch", "checkAvailability", true)
}
}

View File

@ -79,7 +79,7 @@ class NavBarIndexHookPatch : BytecodePatch(
LithoFilterPatch.addFilter("$PATCHES_PATH/ads/NavBarIndexFilter;")
context.injectInit("NavBarIndexPatch", "initializeIndex")
context.injectInit("NavBarIndexPatch", "initializeIndex", true)
}

View File

@ -43,7 +43,7 @@ class SettingsBytecodePatch : BytecodePatch(
}
} ?: throw ThemeSetterSystemFingerprint.exception
context.injectInit("FirstRun", "initializationRVX")
context.injectInit("FirstRun", "initializationRVX", true)
}

View File

@ -222,7 +222,7 @@ class SponsorBlockBytecodePatch : BytecodePatch(
*/
VideoIdWithoutShortsPatch.injectCall("$INTEGRATIONS_PLAYER_CONTROLLER_CLASS_DESCRIPTOR->setCurrentVideoId(Ljava/lang/String;)V")
context.injectInit("FirstRun", "initializationSB")
context.injectInit("FirstRun", "initializationSB", true)
}

View File

@ -3,23 +3,37 @@ package app.revanced.util.bytecode
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.util.integrations.Constants.MUSIC_UTILS_PATH
import app.revanced.util.integrations.Constants.UTILS_PATH
internal object BytecodeHelper {
internal fun BytecodeContext.injectInit(
methods: String,
descriptor: String
descriptor: String,
isYouTube: Boolean
) {
this.classes.forEach { classDef ->
val activityClass =
if (isYouTube)
"/WatchWhileActivity;"
else
"/MusicActivity;"
val integrationPath =
if (isYouTube)
UTILS_PATH
else
MUSIC_UTILS_PATH
classes.forEach { classDef ->
classDef.methods.forEach { method ->
if (classDef.type.endsWith("/WatchWhileActivity;") && method.name == "onCreate") {
if (classDef.type.endsWith(activityClass) && method.name == "onCreate") {
val hookMethod =
this.proxy(classDef).mutableClass.methods.first { it.name == "onCreate" }
hookMethod.addInstruction(
2,
"invoke-static/range {p0 .. p0}, $UTILS_PATH/$methods;->$descriptor(Landroid/content/Context;)V"
"invoke-static/range {p0 .. p0}, $integrationPath/$methods;->$descriptor(Landroid/content/Context;)V"
)
}
}

View File

@ -91,6 +91,7 @@
<string name="revanced_hide_sample_button_title">Hide sample button</string>
<string name="revanced_hook_button_container_download_summary">Replaces the offline download button in the button container with an external download button.</string>
<string name="revanced_hook_button_container_download_title">Hook download button</string>
<string name="revanced_reboot_first_run">Restart to load the layout normally</string>
<string name="revanced_reboot_message">Refresh and restart</string>
<string name="revanced_reset">Reset</string>
<string name="revanced_ryd_about">About</string>