Skip to content

Commit

Permalink
Fix bug is disabled notif after beta (#3875)
Browse files Browse the repository at this point in the history
<!--
Note: This checklist is a reminder of our shared engineering
expectations.
The items in Bold are required
If your PR involves UI changes:
1. Upload screenshots or screencasts that illustrate the changes before
/ after
2. Add them under the UI changes section (feel free to add more columns
if needed)
If your PR does not involve UI changes, you can remove the **UI
changes** section

At a minimum, make sure your changes are tested in API 23 and one of the
more recent API levels available.
-->

Task/Issue URL:
https://app.asana.com/0/488551667048375/1205967226515880/f

### Description
See attached task description

### Steps to test this PR
https://app.asana.com/0/0/1205967324060545/f
  • Loading branch information
karlenDimla authored Nov 16, 2023
1 parent 1c2cdbe commit c20b2cb
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.duckduckgo.mobile.android.vpn.service.VpnServiceCallbacks
import com.duckduckgo.mobile.android.vpn.state.VpnStateMonitor.VpnStopReason
import com.duckduckgo.networkprotection.api.NetworkProtectionState
import com.duckduckgo.networkprotection.impl.settings.NetPSettingsLocalConfig
import com.duckduckgo.networkprotection.impl.waitlist.NetPRemoteFeature
import com.squareup.anvil.annotations.ContributesMultibinding
import java.util.concurrent.atomic.AtomicReference
import javax.inject.Inject
Expand All @@ -43,6 +44,7 @@ class NetPDisabledNotificationScheduler @Inject constructor(
private val netPSettingsLocalConfig: NetPSettingsLocalConfig,
@AppCoroutineScope private val coroutineScope: CoroutineScope,
private val dispatcherProvider: DispatcherProvider,
private val netPRemoteFeature: NetPRemoteFeature,
) : VpnServiceCallbacks {

private var isNetPEnabled: AtomicReference<Boolean> = AtomicReference(false)
Expand Down Expand Up @@ -77,7 +79,7 @@ class NetPDisabledNotificationScheduler @Inject constructor(

private suspend fun shouldShowImmediateNotification(): Boolean {
// When VPN is stopped and if AppTP has been enabled AND user has been onboarded, then we show the disabled notif
return isNetPEnabled.get() && networkProtectionState.isOnboarded()
return isNetPEnabled.get() && networkProtectionState.isOnboarded() && netPRemoteFeature.waitlistBetaActive().isEnabled()
}

private suspend fun onVPNManuallyStopped() {
Expand All @@ -91,7 +93,7 @@ class NetPDisabledNotificationScheduler @Inject constructor(
override fun onVpnReconfigured(coroutineScope: CoroutineScope) {
coroutineScope.launch(dispatcherProvider.io()) {
val reconfiguredNetPState = networkProtectionState.isEnabled()
if (isNetPEnabled.getAndSet(reconfiguredNetPState) != reconfiguredNetPState) {
if (isNetPEnabled.getAndSet(reconfiguredNetPState) != reconfiguredNetPState && netPRemoteFeature.waitlistBetaActive().isEnabled()) {
if (!reconfiguredNetPState) {
logcat { "VPN has been reconfigured, showing disabled notification for NetP" }
showDisabledNotification()
Expand Down

0 comments on commit c20b2cb

Please sign in to comment.