fix(RVX Manager): WARNING and INFO are not printed https://github.com/inotia00/ReVanced_Extended/issues/2590

This commit is contained in:
inotia00 2024-12-22 16:15:24 +09:00
parent b92b79e96c
commit 74ba042a7d
15 changed files with 39 additions and 17 deletions

View File

@ -17,6 +17,7 @@ import app.revanced.patches.music.utils.settings.addPreferenceWithIntent
import app.revanced.patches.music.utils.settings.addSwitchPreference
import app.revanced.patches.music.utils.settings.settingsPatch
import app.revanced.patches.shared.spoof.appversion.baseSpoofAppVersionPatch
import app.revanced.util.Utils.printWarn
import app.revanced.util.appendAppVersion
import app.revanced.util.findMethodOrThrow
@ -64,7 +65,6 @@ val spoofAppVersionPatch = resourcePatch(
"6.29.59",
"6.42.55",
"6.51.53",
"7.06.54",
"7.16.53",
),
)
@ -78,7 +78,7 @@ val spoofAppVersionPatch = resourcePatch(
execute {
if (is_7_25_or_greater) {
println("WARNING: \"${SPOOF_APP_VERSION.title}\" is not supported in this version. Use YouTube Music 7.24.51 or earlier.")
printWarn("\"${SPOOF_APP_VERSION.title}\" is not supported in this version. Use YouTube Music 7.24.51 or earlier.")
return@execute
}
if (is_7_17_or_greater) {

View File

@ -9,6 +9,7 @@ import app.revanced.patches.music.utils.settings.ResourceUtils.getIconType
import app.revanced.patches.music.utils.settings.ResourceUtils.updatePatchStatus
import app.revanced.patches.music.utils.settings.settingsPatch
import app.revanced.util.ResourceGroup
import app.revanced.util.Utils.printWarn
import app.revanced.util.Utils.trimIndentMultiline
import app.revanced.util.copyFile
import app.revanced.util.copyResources
@ -154,7 +155,7 @@ val changeHeaderPatch = resourcePatch(
val customBrandingIconIncluded = customBrandingIconType != "default"
customHeader = customHeaderOption.valueOrThrow()
val warnings = "WARNING: Invalid header path: $customHeader. Does not apply patches."
val warnings = "Invalid header path: $customHeader. Does not apply patches."
if (isPath) {
copyFile(
@ -169,7 +170,7 @@ val changeHeaderPatch = resourcePatch(
}
}
} else {
println(warnings)
printWarn(warnings)
}
updatePatchStatus(CUSTOM_HEADER_FOR_YOUTUBE_MUSIC)

View File

@ -16,6 +16,7 @@ import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.ResourceUtils.updatePatchStatus
import app.revanced.patches.music.utils.settings.addSwitchPreference
import app.revanced.patches.music.utils.settings.settingsPatch
import app.revanced.util.Utils.printWarn
import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall
import app.revanced.util.fingerprint.methodOrThrow
import app.revanced.util.getReference
@ -50,7 +51,7 @@ val cairoSplashAnimationPatch = bytecodePatch(
execute {
if (!is_7_06_or_greater) {
println("WARNING: \"${DISABLE_CAIRO_SPLASH_ANIMATION.title}\" is not supported in this version. Use YouTube Music 7.06.54 or later.")
printWarn("\"${DISABLE_CAIRO_SPLASH_ANIMATION.title}\" is not supported in this version. Use YouTube Music 7.06.54 or later.")
return@execute
} else if (!is_7_20_or_greater) {
cairoSplashAnimationConfigFingerprint.injectLiteralInstructionBooleanCall(

View File

@ -5,6 +5,7 @@ import app.revanced.patcher.patch.stringOption
import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.reddit.utils.patch.PatchList.CUSTOM_BRANDING_NAME_FOR_REDDIT
import app.revanced.patches.reddit.utils.settings.updatePatchStatus
import app.revanced.util.Utils.printInfo
import app.revanced.util.valueOrThrow
import java.io.FileWriter
import java.nio.file.Files
@ -37,7 +38,7 @@ val customBrandingNamePatch = resourcePatch(
.valueOrThrow()
if (appName == ORIGINAL_APP_NAME) {
println("INFO: App name will remain unchanged as it matches the original.")
printInfo("App name will remain unchanged as it matches the original.")
return@execute
}

View File

@ -5,6 +5,7 @@ import app.revanced.patcher.patch.stringOption
import app.revanced.patches.reddit.utils.compatibility.Constants.COMPATIBLE_PACKAGE
import app.revanced.patches.reddit.utils.patch.PatchList.CHANGE_PACKAGE_NAME
import app.revanced.patches.reddit.utils.settings.updatePatchStatus
import app.revanced.util.Utils.printInfo
import app.revanced.util.valueOrThrow
import org.w3c.dom.Element
@ -71,7 +72,7 @@ val changePackageNamePatch = resourcePatch(
.valueOrThrow()
if (redditPackageName == PACKAGE_NAME_REDDIT) {
println("INFO: Package name will remain unchanged as it matches the original.")
printInfo("Package name will remain unchanged as it matches the original.")
return@execute
}

View File

@ -10,6 +10,7 @@ import app.revanced.patches.reddit.utils.patch.PatchList.HIDE_NAVIGATION_BUTTONS
import app.revanced.patches.reddit.utils.settings.is_2024_18_or_greater
import app.revanced.patches.reddit.utils.settings.settingsPatch
import app.revanced.patches.reddit.utils.settings.updatePatchStatus
import app.revanced.util.Utils.printWarn
import app.revanced.util.fingerprint.methodOrThrow
import app.revanced.util.fingerprint.resolvable
import app.revanced.util.indexOfFirstInstructionOrThrow
@ -34,7 +35,7 @@ val navigationButtonsPatch = bytecodePatch(
execute {
if (is_2024_18_or_greater) {
println("WARNING: \"Hide navigation buttons\" patch is not supported in this version. Use Reddit 2024.17.0 or earlier.")
printWarn("\"Hide navigation buttons\" patch is not supported in this version. Use Reddit 2024.17.0 or earlier.")
return@execute
}

View File

@ -9,6 +9,7 @@ import app.revanced.patches.youtube.utils.playservice.versionCheckPatch
import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference
import app.revanced.patches.youtube.utils.settings.settingsPatch
import app.revanced.util.ResourceGroup
import app.revanced.util.Utils.printInfo
import app.revanced.util.copyResources
import app.revanced.util.inputStreamFromBundledResourceOrThrow
import app.revanced.util.lowerCaseOrThrow
@ -63,7 +64,7 @@ val shortsActionButtonsPatch = resourcePatch(
.lowerCaseOrThrow()
if (iconType == YOUTUBE_ICON) {
println("INFO: Shorts action buttons will remain unchanged as it matches the original.")
printInfo("Shorts action buttons will remain unchanged as it matches the original.")
addPreference(CUSTOM_SHORTS_ACTION_BUTTONS)
return@execute
}

View File

@ -147,7 +147,7 @@ val customBrandingIconPatch = resourcePatch(
val copiedFiles = copyFile(
launcherIconResourceGroups,
appIcon,
"WARNING: Invalid app icon path: $appIcon. Does not apply patches."
"Invalid app icon path: $appIcon. Does not apply patches."
)
if (copiedFiles)
updatePatchStatusIcon("custom")

View File

@ -7,6 +7,7 @@ import app.revanced.patches.youtube.utils.patch.PatchList.CUSTOM_HEADER_FOR_YOUT
import app.revanced.patches.youtube.utils.settings.ResourceUtils.getIconType
import app.revanced.patches.youtube.utils.settings.settingsPatch
import app.revanced.util.ResourceGroup
import app.revanced.util.Utils.printWarn
import app.revanced.util.Utils.trimIndentMultiline
import app.revanced.util.copyFile
import app.revanced.util.copyResources
@ -125,7 +126,7 @@ val changeHeaderPatch = resourcePatch(
customBrandingIconType != "default" && customBrandingIconType != "custom"
customHeader = customHeaderOption.valueOrThrow()
val warnings = "WARNING: Invalid header path: $customHeader. Does not apply patches."
val warnings = "Invalid header path: $customHeader. Does not apply patches."
if (isPath) {
copyFile(
@ -140,7 +141,7 @@ val changeHeaderPatch = resourcePatch(
}
}
} else {
println(warnings)
printWarn(warnings)
return@execute
}

View File

@ -35,6 +35,7 @@ import app.revanced.patches.youtube.utils.youtubeControlsOverlayFingerprint
import app.revanced.patches.youtube.video.information.hookVideoInformation
import app.revanced.patches.youtube.video.information.videoInformationPatch
import app.revanced.util.REGISTER_TEMPLATE_REPLACEMENT
import app.revanced.util.Utils.printWarn
import app.revanced.util.findMethodOrThrow
import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall
import app.revanced.util.fingerprint.injectLiteralInstructionViewCall
@ -382,7 +383,7 @@ val playerComponentsPatch = bytecodePatch(
name == "onClick"
}.hookInitVideoPanel(0)
} else {
println("WARNING: target Opcode not found in ${fingerprint.first}")
printWarn("target Opcode not found in ${fingerprint.first}")
}
}
}

View File

@ -28,6 +28,7 @@ import app.revanced.patches.youtube.utils.resourceid.sharedResourceIdPatch
import app.revanced.patches.youtube.utils.settings.ResourceUtils.addPreference
import app.revanced.patches.youtube.utils.settings.settingsPatch
import app.revanced.patches.youtube.utils.youtubeControlsOverlayFingerprint
import app.revanced.util.Utils.printWarn
import app.revanced.util.findMethodOrThrow
import app.revanced.util.fingerprint.methodOrThrow
import app.revanced.util.fingerprint.mutableClassOrThrow
@ -321,7 +322,7 @@ val fullscreenComponentsPatch = bytecodePatch(
settingArray += "SETTINGS: KEEP_LANDSCAPE_MODE"
} else {
println("WARNING: \"Keep landscape mode\" is not supported in this version. Use YouTube 19.16.39 or earlier.")
printWarn("\"Keep landscape mode\" is not supported in this version. Use YouTube 19.16.39 or earlier.")
}
// endregion

View File

@ -35,6 +35,7 @@ import app.revanced.patches.youtube.utils.settings.ResourceUtils.getContext
import app.revanced.patches.youtube.utils.settings.settingsPatch
import app.revanced.patches.youtube.utils.totalTimeFingerprint
import app.revanced.patches.youtube.video.information.videoInformationPatch
import app.revanced.util.Utils.printWarn
import app.revanced.util.copyXmlNode
import app.revanced.util.findElementByAttributeValueOrThrow
import app.revanced.util.findMethodsOrThrow
@ -468,7 +469,7 @@ val seekbarComponentsPatch = bytecodePatch(
updatePatchStatus(PATCH_STATUS_CLASS_DESCRIPTOR, "OldSeekbarThumbnailsDefaultBoolean")
} else {
println("WARNING: \"Restore old seekbar thumbnails\" is not supported in this version. Use YouTube 19.16.39 or earlier.")
printWarn("\"Restore old seekbar thumbnails\" is not supported in this version. Use YouTube 19.16.39 or earlier.")
}
// endregion

View File

@ -20,6 +20,7 @@ import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMu
import app.revanced.patches.shared.mapping.get
import app.revanced.patches.shared.mapping.resourceMappingPatch
import app.revanced.patches.shared.mapping.resourceMappings
import app.revanced.util.Utils.printWarn
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.Method
@ -135,7 +136,7 @@ internal fun MutableMethod.addInstructionsAtControlFlowLabel(
fun Method.indexOfFirstResourceId(resourceName: String): Int {
val resourceId = resourceMappings["id", resourceName]
if (resourceId == -1L) {
println("WARNING: Could not find resource type: id name: $name")
printWarn("Could not find resource type: id name: $name")
return -1
}
return indexOfFirstLiteralInstruction(resourceId)

View File

@ -5,6 +5,7 @@ import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.ResourcePatchContext
import app.revanced.patcher.util.Document
import app.revanced.util.Utils.printWarn
import org.w3c.dom.Element
import org.w3c.dom.Node
import org.w3c.dom.NodeList
@ -202,7 +203,7 @@ fun ResourcePatchContext.copyFile(
return true
} catch (_: Exception) {
println(warning)
printWarn(warning)
}
}
return false

View File

@ -1,8 +1,18 @@
package app.revanced.util
import java.util.logging.Logger
internal object Utils {
internal fun String.trimIndentMultiline() =
this.split("\n")
.joinToString("\n") { it.trimIndent() } // Remove the leading whitespace from each line.
.trimIndent() // Remove the leading newline.
private val logger = Logger.getLogger(this::class.java.name)
internal fun printInfo(msg: String) =
logger.info(msg)
internal fun printWarn(msg: String) =
logger.warning(msg)
}