generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
92 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/kotlin/app/revanced/patches/duolingo/ad/DisableAdsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package app.revanced.patches.duolingo.ad | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patches.duolingo.ad.fingerprints.InitializeMonetizationDebugSettingsFingerprint | ||
import app.revanced.util.exception | ||
import app.revanced.util.resultOrThrow | ||
import com.android.tools.smali.dexlib2.Opcode | ||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction22c | ||
|
||
@Patch( | ||
name = "Disable ads", | ||
compatiblePackages = [CompatiblePackage("com.duolingo")] | ||
) | ||
@Suppress("unused") | ||
object DisableAdsPatch : BytecodePatch( | ||
setOf(InitializeMonetizationDebugSettingsFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
// Couple approaches to remove ads exist: | ||
// | ||
// MonetizationDebugSettings has a boolean value for "disableAds". | ||
// OnboardingState has a getter to check if the user has any "adFreeSessions". | ||
// SharedPreferences has a debug boolean value with key "disable_ads", which maps to "DebugCategory.DISABLE_ADS". | ||
// | ||
// MonetizationDebugSettings seems to be the most general setting to work fine. | ||
InitializeMonetizationDebugSettingsFingerprint.resultOrThrow().mutableMethod.apply { | ||
val setDisableAdsIndex = getInstructions().firstOrNull { | ||
it.opcode == Opcode.IPUT_BOOLEAN | ||
} as? BuilderInstruction22c ?: throw InitializeMonetizationDebugSettingsFingerprint.exception | ||
|
||
addInstructions( | ||
setDisableAdsIndex.location.index, | ||
"const/4 v${setDisableAdsIndex.registerA}, 0x1" | ||
) | ||
} | ||
} | ||
} |
42 changes: 0 additions & 42 deletions
42
src/main/kotlin/app/revanced/patches/duolingo/ad/RemoveDuolingoAdsPatch.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/kotlin/app/revanced/patches/duolingo/debug/EnableDebugMenuPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package app.revanced.patches.duolingo.debug | ||
|
||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstructions | ||
import app.revanced.patcher.patch.BytecodePatch | ||
import app.revanced.patcher.patch.annotation.CompatiblePackage | ||
import app.revanced.patcher.patch.annotation.Patch | ||
import app.revanced.patches.duolingo.debug.fingerprints.InitializeBuildConfigProviderFingerprint | ||
import app.revanced.util.exception | ||
import app.revanced.util.resultOrThrow | ||
import com.android.tools.smali.dexlib2.Opcode | ||
import com.android.tools.smali.dexlib2.builder.instruction.BuilderInstruction22c | ||
|
||
@Patch( | ||
name = "Enable debug menu", | ||
compatiblePackages = [CompatiblePackage("com.duolingo")], | ||
use = false | ||
) | ||
@Suppress("unused") | ||
object EnableDebugMenuPatch : BytecodePatch( | ||
setOf(InitializeBuildConfigProviderFingerprint) | ||
) { | ||
override fun execute(context: BytecodeContext) { | ||
InitializeBuildConfigProviderFingerprint.resultOrThrow().mutableMethod.apply { | ||
val setIsDebugBuildIndex = getInstructions().firstOrNull { | ||
it.opcode == Opcode.IPUT_BOOLEAN | ||
} as? BuilderInstruction22c ?: throw InitializeBuildConfigProviderFingerprint.exception | ||
|
||
addInstructions( | ||
setIsDebugBuildIndex.location.index, | ||
"const/4 v${setIsDebugBuildIndex.registerA}, 0x1" | ||
) | ||
} | ||
} | ||
} |
36 changes: 0 additions & 36 deletions
36
src/main/kotlin/app/revanced/patches/duolingo/debug/MakeDebugMenuAvailable.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters