Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Disable analytics and telemetry patches #3448

Draft
wants to merge 21 commits into
base: dev
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package app.revanced.patches.all.analytics

import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.patch.options.PatchOption
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.booleanPatchOption
import app.revanced.patches.all.analytics.google.DisableGoogleAnalytics
import app.revanced.patches.all.analytics.statsig.DisableStatsig
import java.util.logging.Logger

@Patch(
name = "Disable privacy invasive components",
description = "Disables multiple analytics and telemetry SDKs embedded in the app",
)
@Suppress("unused")
object UniversalPrivacyPatch : BytecodePatch(
setOf()
) {

// We have to create a copy of the map as a MutableMapIterator does not exist
private val subPatchesOptionsEvaluated = mutableMapOf<Pair<String, BytecodePatch>, PatchOption<Boolean?>>()

private val subPatchesOptions = mapOf(
Pair("Google Analytics", DisableGoogleAnalytics) to false,
Pair("Statsig", DisableStatsig) to true,
).forEach {
subPatchesOptionsEvaluated[it.key] = booleanPatchOption(
key = it.key.first,
default = it.value,
values = mapOf(
),
title = "Enabled patches",
description = "Which SDK to target",
required = true
)
}


override fun execute(context: BytecodeContext) {
subPatchesOptionsEvaluated.forEach {
LisoUseInAIKyrios marked this conversation as resolved.
Show resolved Hide resolved
if (it.value.value == true){
Logger.getLogger(this::class.java.name).warning("Applying patch to disable ${it.key.first}")
LisoUseInAIKyrios marked this conversation as resolved.
Show resolved Hide resolved
it.key.second.execute(context)
}
}

}
}
Loading