File tree Expand file tree Collapse file tree
CSGuard/src/main/kotlin/com/csguard Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ object AllowlistStore {
1212 private const val PREFS_NAME = " csguard_allowlist"
1313 private const val KEY_ALWAYS = " always_allow_hosts"
1414 private const val KEY_BLOCKED_PROVIDERS = " blocked_providers"
15+ private const val KEY_GLOBAL_STRICT = " global_strict"
1516 private const val KEY_BLOCKED = " blocked_attempts_log"
1617 private const val MAX_BLOCKED_LOG = 200
1718
@@ -52,6 +53,14 @@ fun alwaysAllow(): Set<String> {
5253 return true
5354 }
5455
56+ fun isGlobalStrict (): Boolean {
57+ return prefs?.getBoolean(KEY_GLOBAL_STRICT , true ) ? : true
58+ }
59+
60+ fun setGlobalStrict (strict : Boolean ) {
61+ prefs?.edit()?.putBoolean(KEY_GLOBAL_STRICT , strict)?.apply ()
62+ }
63+
5564fun blockedProviders (): Set <String > {
5665 val raw = prefs?.getString(KEY_BLOCKED_PROVIDERS , " []" ) ? : " []"
5766 return try {
Original file line number Diff line number Diff line change @@ -74,10 +74,16 @@ try {
7474 Log .w(TAG , " VideoClickAction sanitization failed" , t)
7575 }
7676
77- try {
78- ProviderSanitizer .policy = GuardPolicy .STRICT
77+ try {
78+ val isStrict = AllowlistStore .isGlobalStrict()
79+ ProviderSanitizer .policy = GuardPolicy (
80+ blockKnownAdHosts = true ,
81+ blockAdPaths = true ,
82+ blockAllUnknown = isStrict,
83+ showToast = false
84+ )
7985 ProviderSanitizer .start(context)
80- Log .i(TAG , " ✓ Started ProviderSanitizer (interval=5s, policy=STRICT )" )
86+ Log .i(TAG , " ✓ Started ProviderSanitizer (policy.blockAllUnknown= $isStrict )" )
8187 } catch (t: Throwable ) {
8288 Log .e(TAG , " Failed to start ProviderSanitizer" , t)
8389 }
Original file line number Diff line number Diff line change @@ -95,6 +95,8 @@ class GuardSettingsDialog(
9595 val currentBlocks = AllowlistStore .blockedProviders()
9696 currentBlocks.forEach { AllowlistStore .removeBlockedProvider(it) }
9797 blockedSet.forEach { AllowlistStore .addBlockedProvider(it) }
98+
99+ AllowlistStore .setGlobalStrict(isGlobalStrict)
98100
99101 val newPolicy = GuardPolicy (
100102 blockKnownAdHosts = true ,
You can’t perform that action at this time.
0 commit comments