mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-12-07 01:51:27 +01:00
add fix content provider patch
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package app.revanced.extension.youtube.patches;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import app.revanced.extension.shared.Logger;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class FixContentProviderPatch {
|
||||
|
||||
/**
|
||||
* Injection point.
|
||||
*/
|
||||
public static void removeNullMapEntries(Map<?, ?> map) {
|
||||
map.entrySet().removeIf(entry -> {
|
||||
Object value = entry.getValue();
|
||||
if (value == null) {
|
||||
Logger.printDebug(() -> "Removing content provider key with null value: " + entry.getKey());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package app.revanced.patches.youtube.misc.debugging
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import app.revanced.patcher.string
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal val experimentalFeatureFlagParentFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC)
|
||||
returns("L")
|
||||
parameters("L", "J", "[B")
|
||||
instructions(
|
||||
string("Unable to parse proto typed experiment flag: ")
|
||||
)
|
||||
}
|
||||
|
||||
internal val experimentalBooleanFeatureFlagFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.STATIC)
|
||||
returns("Z")
|
||||
parameters("L", "J", "Z")
|
||||
}
|
||||
|
||||
internal val experimentalDoubleFeatureFlagFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("D")
|
||||
parameters("J", "D")
|
||||
}
|
||||
|
||||
internal val experimentalLongFeatureFlagFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("J")
|
||||
parameters("J", "J")
|
||||
}
|
||||
|
||||
internal val experimentalStringFeatureFlagFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("Ljava/lang/String;")
|
||||
parameters("J", "Ljava/lang/String;")
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package app.revanced.patches.youtube.misc.fix.contentprovider
|
||||
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.patch.bytecodePatch
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||
"Lapp/revanced/extension/youtube/patches/FixContentProviderPatch;"
|
||||
|
||||
/**
|
||||
* Fixes crashing for some users with a beta release where the YouTube content provider uses null map values.
|
||||
* It unknown if this crash can happen on stable releases.
|
||||
*/
|
||||
internal val fixContentProviderPatch = bytecodePatch{
|
||||
dependsOn(
|
||||
sharedExtensionPatch
|
||||
)
|
||||
|
||||
execute {
|
||||
unstableContentProviderFingerprint.let {
|
||||
val insertIndex = it.instructionMatches.first().index
|
||||
|
||||
it.method.apply {
|
||||
val register = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
|
||||
|
||||
it.method.addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->removeNullMapEntries(Ljava/util/Map;)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package app.revanced.patches.youtube.misc.fix.contentprovider
|
||||
|
||||
import app.revanced.patcher.fingerprint
|
||||
import app.revanced.patcher.methodCall
|
||||
import app.revanced.patcher.string
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal val unstableContentProviderFingerprint = fingerprint {
|
||||
accessFlags(AccessFlags.PUBLIC, AccessFlags.FINAL)
|
||||
returns("V")
|
||||
parameters("Landroid/content/ContentResolver;", "[Ljava/lang/String;")
|
||||
instructions(
|
||||
// Early targets use HashMap and later targets use ConcurrentMap.
|
||||
methodCall(
|
||||
name = "putAll",
|
||||
parameters = listOf("Ljava/util/Map;")
|
||||
),
|
||||
string("ContentProvider query returned null cursor")
|
||||
)
|
||||
}
|
||||
@@ -29,7 +29,6 @@ private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||
* 6. Resume the video
|
||||
* 7. Playback speed will incorrectly change to 1.0x.
|
||||
*/
|
||||
@Suppress("unused")
|
||||
val fixPlaybackSpeedWhilePlayingPatch = bytecodePatch{
|
||||
dependsOn(
|
||||
sharedExtensionPatch,
|
||||
|
||||
@@ -26,6 +26,7 @@ import app.revanced.patches.shared.misc.settings.preference.TextPreference
|
||||
import app.revanced.patches.shared.misc.settings.settingsPatch
|
||||
import app.revanced.patches.youtube.misc.check.checkEnvironmentPatch
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.fix.contentprovider.fixContentProviderPatch
|
||||
import app.revanced.patches.youtube.misc.fix.playbackspeed.fixPlaybackSpeedWhilePlayingPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_34_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.is_20_31_or_greater
|
||||
@@ -177,6 +178,7 @@ val settingsPatch = bytecodePatch(
|
||||
addResourcesPatch,
|
||||
versionCheckPatch,
|
||||
fixPlaybackSpeedWhilePlayingPatch,
|
||||
fixContentProviderPatch,
|
||||
// Currently there is no easy way to make a mandatory patch,
|
||||
// so for now this is a dependent of this patch.
|
||||
checkEnvironmentPatch,
|
||||
|
||||
Reference in New Issue
Block a user