mirror of
https://github.com/revanced/revanced-patches
synced 2024-09-03 04:56:05 +02:00
feat(youtube/microg-support): handle availability of Vanced MicroG
This commit is contained in:
parent
45ce4a2162
commit
81db6145eb
@ -14,7 +14,7 @@ import app.revanced.patcher.patch.annotations.Patch
|
|||||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
|
||||||
import app.revanced.patches.youtube.interaction.swipecontrols.annotation.SwipeControlsCompatibility
|
import app.revanced.patches.youtube.interaction.swipecontrols.annotation.SwipeControlsCompatibility
|
||||||
import app.revanced.patches.youtube.interaction.swipecontrols.fingerprints.SwipeControlsHostActivityFingerprint
|
import app.revanced.patches.youtube.interaction.swipecontrols.fingerprints.SwipeControlsHostActivityFingerprint
|
||||||
import app.revanced.patches.youtube.interaction.swipecontrols.fingerprints.WatchWhileActivityFingerprint
|
import app.revanced.shared.fingerprints.WatchWhileActivityFingerprint
|
||||||
import app.revanced.patches.youtube.interaction.swipecontrols.patch.resource.SwipeControlsResourcePatch
|
import app.revanced.patches.youtube.interaction.swipecontrols.patch.resource.SwipeControlsResourcePatch
|
||||||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
|
||||||
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
||||||
|
@ -4,10 +4,13 @@ import app.revanced.patcher.annotation.Description
|
|||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.addInstruction
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.patch.annotations.Patch
|
import app.revanced.patcher.patch.annotations.Patch
|
||||||
|
import app.revanced.shared.fingerprints.WatchWhileActivityFingerprint
|
||||||
import app.revanced.patches.youtube.layout.castbutton.patch.HideCastButtonPatch
|
import app.revanced.patches.youtube.layout.castbutton.patch.HideCastButtonPatch
|
||||||
import app.revanced.patches.youtube.misc.clientspoof.patch.ClientSpoofPatch
|
import app.revanced.patches.youtube.misc.clientspoof.patch.ClientSpoofPatch
|
||||||
import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility
|
import app.revanced.patches.youtube.misc.microg.annotations.MicroGPatchCompatibility
|
||||||
@ -38,9 +41,10 @@ class MicroGBytecodePatch : BytecodePatch(
|
|||||||
CastDynamiteModuleV2Fingerprint,
|
CastDynamiteModuleV2Fingerprint,
|
||||||
CastContextFetchFingerprint,
|
CastContextFetchFingerprint,
|
||||||
PrimeFingerprint,
|
PrimeFingerprint,
|
||||||
|
WatchWhileActivityFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext) =
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
// apply common microG patch
|
// apply common microG patch
|
||||||
MicroGBytecodeHelper.patchBytecode(
|
MicroGBytecodeHelper.patchBytecode(
|
||||||
context, arrayOf(
|
context, arrayOf(
|
||||||
@ -62,5 +66,11 @@ class MicroGBytecodePatch : BytecodePatch(
|
|||||||
CastDynamiteModuleV2Fingerprint,
|
CastDynamiteModuleV2Fingerprint,
|
||||||
CastContextFetchFingerprint
|
CastContextFetchFingerprint
|
||||||
)
|
)
|
||||||
).let { PatchResultSuccess() }
|
)
|
||||||
|
|
||||||
|
// inject the notice for MicroG
|
||||||
|
MicroGBytecodeHelper.injectNotice(WatchWhileActivityFingerprint)
|
||||||
|
|
||||||
|
return PatchResultSuccess()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,10 @@ class MicroGResourcePatch : ResourcePatch {
|
|||||||
SPOOFED_PACKAGE_NAME,
|
SPOOFED_PACKAGE_NAME,
|
||||||
SPOOFED_PACKAGE_SIGNATURE
|
SPOOFED_PACKAGE_SIGNATURE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// add strings
|
||||||
|
MicroGResourceHelper.addStrings(context)
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package app.revanced.patches.youtube.interaction.swipecontrols.fingerprints
|
package app.revanced.shared.fingerprints
|
||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.annotation.Version
|
import app.revanced.patcher.annotation.Version
|
@ -1,6 +1,7 @@
|
|||||||
package app.revanced.util.microg
|
package app.revanced.util.microg
|
||||||
|
|
||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
|
import app.revanced.patcher.extensions.addInstruction
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.replaceInstruction
|
import app.revanced.patcher.extensions.replaceInstruction
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
@ -20,6 +21,17 @@ import org.jf.dexlib2.immutable.reference.ImmutableStringReference
|
|||||||
* Helper class for applying bytecode patches needed for the microg-support patches.
|
* Helper class for applying bytecode patches needed for the microg-support patches.
|
||||||
*/
|
*/
|
||||||
internal object MicroGBytecodeHelper {
|
internal object MicroGBytecodeHelper {
|
||||||
|
/**
|
||||||
|
* Hook a method to check the availability of MicroG.
|
||||||
|
*
|
||||||
|
* @param fingerprint The fingerprint of the method to add the call for the notice in.
|
||||||
|
*/
|
||||||
|
fun injectNotice(fingerprint: MethodFingerprint) {
|
||||||
|
fingerprint.result!!.mutableMethod.addInstruction(
|
||||||
|
0,
|
||||||
|
"invoke-static {}, Lapp/revanced/integrations/patches/MicroGSupport;->checkAvailability()V"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform strings with package name out of [fromPackageName] and [toPackageName].
|
* Transform strings with package name out of [fromPackageName] and [toPackageName].
|
||||||
|
@ -1,16 +1,26 @@
|
|||||||
package app.revanced.util.microg
|
package app.revanced.util.microg
|
||||||
|
|
||||||
import app.revanced.patcher.data.ResourceContext
|
import app.revanced.patcher.data.ResourceContext
|
||||||
|
import app.revanced.util.resources.ResourceUtils.Settings.mergeStrings
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class for applying resource patches needed for the microg-support patches.
|
* Helper class for applying resource patches needed for the microg-support patches.
|
||||||
*/
|
*/
|
||||||
internal object MicroGResourceHelper {
|
internal object MicroGResourceHelper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add necessary strings to the strings.xml file.
|
||||||
|
*
|
||||||
|
* @param context The resource context.
|
||||||
|
* @param stringsHost The file which hosts the strings.
|
||||||
|
*/
|
||||||
|
fun addStrings(context: ResourceContext, stringsHost: String = "microg/host/values/strings.xml") = context.mergeStrings(stringsHost)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Patch the manifest to work with MicroG.
|
* Patch the manifest to work with MicroG.
|
||||||
*
|
*
|
||||||
* @param context Bytecode context.
|
* @param context The resource context.
|
||||||
* @param fromPackageName Original package name.
|
* @param fromPackageName The original package name.
|
||||||
* @param toPackageName The package name to accept.
|
* @param toPackageName The package name to accept.
|
||||||
* @param toName The new name of the app.
|
* @param toName The new name of the app.
|
||||||
*/
|
*/
|
||||||
|
4
src/main/resources/microg/host/values/strings.xml
Normal file
4
src/main/resources/microg/host/values/strings.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="microg_not_installed_warning">Vanced MicroG is not installed. Please install it.</string>
|
||||||
|
</resources>
|
Loading…
Reference in New Issue
Block a user