fix(YouTube Music - GmsCore support): Handle sharing links to certain apps such as Instagram (#6026)

This commit is contained in:
LisoUseInAIKyrios
2025-09-28 14:31:40 +04:00
committed by GitHub
parent 326953cfc3
commit 328234f39a
4 changed files with 63 additions and 2 deletions

View File

@@ -0,0 +1,44 @@
package app.revanced.patches.music.misc.fileprovider
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.all.misc.packagename.setOrGetFallbackPackageName
import app.revanced.patches.music.utils.fix.fileprovider.fileProviderResolverFingerprint
internal fun fileProviderPatch(
youtubePackageName: String,
musicPackageName: String
) = bytecodePatch(
description = "Fixes broken YouTube Music file provider that prevents sharing with specific apps such as Instagram."
) {
finalize {
// Must do modification last, so change package name value is correctly set.
val musicChangedPackageName = setOrGetFallbackPackageName(musicPackageName)
// For some reason, if the app gets "android.support.FILE_PROVIDER_PATHS",
// the package name of YouTube is used, not the package name of the YT Music.
//
// There is no issue in the stock YT Music, but this is an issue in the GmsCore Build.
// https://github.com/ReVanced/revanced-patches/issues/55
//
// To solve this issue, replace the package name of YouTube with YT Music's package name.
fileProviderResolverFingerprint.method.addInstructionsWithLabels(
0,
"""
const-string v0, "com.google.android.youtube.fileprovider"
invoke-static { p1, v0 }, Ljava/util/Objects;->equals(Ljava/lang/Object;Ljava/lang/Object;)Z
move-result v0
if-nez v0, :fix
const-string v0, "$youtubePackageName.fileprovider"
invoke-static { p1, v0 }, Ljava/util/Objects;->equals(Ljava/lang/Object;Ljava/lang/Object;)Z
move-result v0
if-nez v0, :fix
goto :ignore
:fix
const-string p1, "$musicChangedPackageName.fileprovider"
:ignore
nop
"""
)
}
}

View File

@@ -0,0 +1,11 @@
package app.revanced.patches.music.utils.fix.fileprovider
import app.revanced.patcher.fingerprint
internal val fileProviderResolverFingerprint = fingerprint {
returns("L")
strings(
"android.support.FILE_PROVIDER_PATHS",
"Name must not be empty"
)
}

View File

@@ -9,6 +9,7 @@ import app.revanced.patches.music.misc.gms.Constants.REVANCED_MUSIC_PACKAGE_NAME
import app.revanced.patches.music.misc.settings.PreferenceScreen
import app.revanced.patches.music.misc.settings.settingsPatch
import app.revanced.patches.music.misc.spoof.spoofVideoStreamsPatch
import app.revanced.patches.music.misc.fileprovider.fileProviderPatch
import app.revanced.patches.shared.castContextFetchFingerprint
import app.revanced.patches.shared.misc.gms.gmsCoreSupportPatch
import app.revanced.patches.shared.misc.settings.preference.IntentPreference
@@ -60,6 +61,10 @@ private fun gmsCoreSupportResourcePatch(
) {
dependsOn(
addResourcesPatch,
settingsPatch
settingsPatch,
fileProviderPatch(
MUSIC_PACKAGE_NAME,
REVANCED_MUSIC_PACKAGE_NAME
)
)
}

View File

@@ -6,6 +6,7 @@ import app.revanced.patches.all.misc.packagename.setOrGetFallbackPackageName
import app.revanced.patches.all.misc.resources.addResources
import app.revanced.patches.all.misc.resources.addResourcesPatch
import app.revanced.patches.music.misc.extension.sharedExtensionPatch
import app.revanced.patches.music.misc.gms.Constants.MUSIC_PACKAGE_NAME
import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
import app.revanced.patches.shared.misc.settings.preference.BasePreference
import app.revanced.patches.shared.misc.settings.preference.BasePreferenceScreen
@@ -126,7 +127,7 @@ fun newIntent(settingsName: String) = IntentPreference.Intent(
targetClass = "com.google.android.gms.common.api.GoogleApiActivity"
) {
// The package name change has to be reflected in the intent.
setOrGetFallbackPackageName("com.google.android.apps.youtube.music")
setOrGetFallbackPackageName(MUSIC_PACKAGE_NAME)
}
object PreferenceScreen : BasePreferenceScreen() {