From dd4b931f23c773196a2ac3c87ae1309e83bd0f52 Mon Sep 17 00:00:00 2001 From: Karl Dimla Date: Thu, 16 Nov 2023 15:49:38 +0100 Subject: [PATCH] Fix disabled notif being shown --- .../impl/notification/NetPDisabledNotificationScheduler.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/network-protection/network-protection-impl/src/main/java/com/duckduckgo/networkprotection/impl/notification/NetPDisabledNotificationScheduler.kt b/network-protection/network-protection-impl/src/main/java/com/duckduckgo/networkprotection/impl/notification/NetPDisabledNotificationScheduler.kt index d1089cae7304..0ab85a927205 100644 --- a/network-protection/network-protection-impl/src/main/java/com/duckduckgo/networkprotection/impl/notification/NetPDisabledNotificationScheduler.kt +++ b/network-protection/network-protection-impl/src/main/java/com/duckduckgo/networkprotection/impl/notification/NetPDisabledNotificationScheduler.kt @@ -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 @@ -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 = AtomicReference(false) @@ -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() { @@ -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()