Skip to content

Commit 2edb60d

Browse files
Merge pull request #2695 from dsremo/dsremo/stopforeground-remove
BraveVPNService.onDestroy: STOP_FOREGROUND_REMOVE so notification clears on stop
2 parents 29a905e + d3ecf32 commit 2edb60d

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

app/src/main/java/com/celzero/bravedns/service/BraveVPNService.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3479,9 +3479,13 @@ class BraveVPNService : VpnService(), ConnectionMonitor.NetworkListener, Bridge,
34793479

34803480
Logger.w(LOG_TAG_VPN, "Destroying VPN service")
34813481

3482-
// stop foreground service will take care of stopping the service for both
3483-
// version >= 24 and < 24
3484-
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_DETACH)
3482+
// Use STOP_FOREGROUND_REMOVE so the persistent VPN-active notification clears
3483+
// when the service ends. STOP_FOREGROUND_DETACH only strips the service's
3484+
// foreground status while leaving the notification visible — which causes
3485+
// a stale "RethinkDNS protected" notification to linger after the user has
3486+
// stopped the VPN, until the user manually swipes it away or the service is
3487+
// re-created. REMOVE is the right semantics for "we're done, clean up."
3488+
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
34853489
}
34863490

34873491
private fun startPauseTimer() {

0 commit comments

Comments
 (0)