fix(YouTube Music/MicroG support): can't share the stories to Facebook, Instagram and Snapchat

This commit is contained in:
inotia00 2023-12-17 21:25:11 +09:00
parent d701a9acb6
commit 09ee27646c
3 changed files with 64 additions and 1 deletions

View File

@ -0,0 +1,50 @@
package app.revanced.patches.music.utils.fix.fileprovider
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.music.utils.fix.fileprovider.fingerprints.FileProviderResolverFingerprint
import app.revanced.patches.shared.patch.packagename.PackageNamePatch
import app.revanced.util.exception
@Patch(dependencies = [PackageNamePatch::class])
object FileProviderPatch : BytecodePatch(
setOf(FileProviderResolverFingerprint)
) {
override fun execute(context: BytecodeContext) {
val youtubePackageName = PackageNamePatch.PackageNameYouTube
?: throw PatchException("Invalid package name.")
val musicPackageName = PackageNamePatch.PackageNameYouTubeMusic
?: throw PatchException("Invalid package name.")
/**
* 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 MicroG Build.
* https://github.com/inotia00/ReVanced_Extended/issues/1830
*
* To solve this issue, replace the package name of YouTube with YT Music's package name.
*/
FileProviderResolverFingerprint.result?.let {
it.mutableMethod.apply {
addInstructionsWithLabels(
0, """
const-string v0, "$youtubePackageName.fileprovider"
invoke-static {p1, v0}, Ljava/util/Objects;->equals(Ljava/lang/Object;Ljava/lang/Object;)Z
move-result v0
if-eqz v0, :ignore
const-string p1, "$musicPackageName.fileprovider"
""", ExternalLabel("ignore", getInstruction(0))
)
}
} ?: throw FileProviderResolverFingerprint.exception
}
}

View File

@ -0,0 +1,11 @@
package app.revanced.patches.music.utils.fix.fileprovider.fingerprints
import app.revanced.patcher.fingerprint.MethodFingerprint
object FileProviderResolverFingerprint : MethodFingerprint(
returnType = "L",
strings = listOf(
"android.support.FILE_PROVIDER_PATHS",
"Name must not be empty"
)
)

View File

@ -6,6 +6,7 @@ import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.annotation.CompatiblePackage import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.music.utils.fix.clientspoof.ClientSpoofPatch import app.revanced.patches.music.utils.fix.clientspoof.ClientSpoofPatch
import app.revanced.patches.music.utils.fix.fileprovider.FileProviderPatch
import app.revanced.patches.music.utils.mainactivity.MainActivityResolvePatch import app.revanced.patches.music.utils.mainactivity.MainActivityResolvePatch
import app.revanced.patches.music.utils.mainactivity.MainActivityResolvePatch.injectInit import app.revanced.patches.music.utils.mainactivity.MainActivityResolvePatch.injectInit
import app.revanced.patches.music.utils.microg.Constants.MUSIC_PACKAGE_NAME import app.revanced.patches.music.utils.microg.Constants.MUSIC_PACKAGE_NAME
@ -26,7 +27,8 @@ import app.revanced.patches.shared.patch.packagename.PackageNamePatch
ClientSpoofPatch::class, ClientSpoofPatch::class,
MainActivityResolvePatch::class, MainActivityResolvePatch::class,
MicroGResourcePatch::class, MicroGResourcePatch::class,
PackageNamePatch::class PackageNamePatch::class,
FileProviderPatch::class
], ],
compatiblePackages = [CompatiblePackage("com.google.android.apps.youtube.music")] compatiblePackages = [CompatiblePackage("com.google.android.apps.youtube.music")]
) )