-
-
Notifications
You must be signed in to change notification settings - Fork 290
Fix bypass universal apps being blocked by "Block apps not in use" when device locked #2149
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
Open
Copilot
wants to merge
5
commits into
main
Choose a base branch
from
copilot/fix-2148
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
75f012e
Initial plan
Copilot 0f67e4f
Fix bypass universal not respected in background blocking
Copilot 278b82f
Also exempt bypass universal apps from device lock blocking
Copilot 09f844e
Add unit test for bypass universal functionality
Copilot 1454828
Remove redundant bypass universal checks from device lock and backgro…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
65 changes: 65 additions & 0 deletions
65
app/src/test/java/com/celzero/bravedns/service/BypassUniversalTest.kt
This file contains hidden or 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,65 @@ | ||
| package com.celzero.bravedns.service | ||
|
|
||
| import org.junit.Test | ||
| import org.junit.Assert.assertEquals | ||
|
|
||
| /** | ||
| * Test for Bypass Universal functionality to ensure bypassed apps are not blocked | ||
| * by universal firewall rules. This test verifies the fix for issue #2148 where | ||
| * bypass universal setting was not respected in background blocking and device lock rules. | ||
| */ | ||
| class BypassUniversalTest { | ||
|
|
||
| @Test | ||
| fun testFirewallStatusBypassUniversal() { | ||
| // Test that BYPASS_UNIVERSAL status returns true for bypassUniversal() | ||
| val bypassStatus = FirewallManager.FirewallStatus.BYPASS_UNIVERSAL | ||
| assertEquals(true, bypassStatus.bypassUniversal()) | ||
|
|
||
| // Test that other statuses return false | ||
| assertEquals(false, FirewallManager.FirewallStatus.NONE.bypassUniversal()) | ||
| assertEquals(false, FirewallManager.FirewallStatus.EXCLUDE.bypassUniversal()) | ||
| assertEquals(false, FirewallManager.FirewallStatus.ISOLATE.bypassUniversal()) | ||
| } | ||
|
|
||
| @Test | ||
| fun testFirewallStatusIds() { | ||
| // Verify firewall status IDs are correctly defined | ||
| assertEquals(2, FirewallManager.FirewallStatus.BYPASS_UNIVERSAL.id) | ||
| assertEquals(3, FirewallManager.FirewallStatus.EXCLUDE.id) | ||
| assertEquals(4, FirewallManager.FirewallStatus.ISOLATE.id) | ||
| assertEquals(5, FirewallManager.FirewallStatus.NONE.id) | ||
| assertEquals(6, FirewallManager.FirewallStatus.UNTRACKED.id) | ||
| assertEquals(7, FirewallManager.FirewallStatus.BYPASS_DNS_FIREWALL.id) | ||
| } | ||
|
|
||
| @Test | ||
| fun testFirewallRulesetBypassRules() { | ||
| // Test that RULE8 is the correct bypass rule | ||
| assertEquals("Whitelist", FirewallRuleset.RULE8.id) | ||
| assertEquals(true, FirewallRuleset.isBypassRule(FirewallRuleset.RULE8)) | ||
|
|
||
| // Test that blocking rules are not bypass rules | ||
| assertEquals(false, FirewallRuleset.isBypassRule(FirewallRuleset.RULE3)) // Device lock | ||
| assertEquals(false, FirewallRuleset.isBypassRule(FirewallRuleset.RULE4)) // Background | ||
| } | ||
|
|
||
| /** | ||
| * This test documents the expected behavior for the fix to issue #2148. | ||
| * The bug was that apps with BYPASS_UNIVERSAL status were still being blocked | ||
| * by universal rules like background blocking and device lock. | ||
| */ | ||
| @Test | ||
| fun testBypassUniversalBehaviorDocumentation() { | ||
| // This test documents that when an app has BYPASS_UNIVERSAL status: | ||
| // 1. It should not be blocked by background data rules (RULE4) | ||
| // 2. It should not be blocked by device lock rules (RULE3) | ||
| // 3. It should return RULE8 (Whitelist) from the main bypass check | ||
|
|
||
| // The fix ensures that blockBackgroundData() and device lock check | ||
| // both respect the bypass universal setting before applying blocking rules. | ||
|
|
||
| val bypassStatus = FirewallManager.FirewallStatus.BYPASS_UNIVERSAL | ||
| assertEquals(true, bypassStatus.bypassUniversal()) | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.