forked from duckduckgo/Android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FF for inactive beta (duckduckgo#3445)
Task/Issue URL: https://app.asana.com/0/488551667048375/1205246005374437/f ### Description See [asana](https://app.asana.com/0/488551667048375/1205246005374437/f) task ### Steps to test this PR Run [test cases](https://app.asana.com/0/0/1205234536443774/f)
- Loading branch information
Showing
29 changed files
with
538 additions
and
76 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
61 changes: 61 additions & 0 deletions
61
...tion-impl/src/main/java/com/duckduckgo/networkprotection/impl/state/NetPFeatureRemover.kt
This file contains 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,61 @@ | ||
/* | ||
* Copyright (c) 2023 DuckDuckGo | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.duckduckgo.networkprotection.impl.state | ||
|
||
import com.duckduckgo.anvil.annotations.ContributesPluginPoint | ||
import com.duckduckgo.app.global.DispatcherProvider | ||
import com.duckduckgo.app.global.plugins.PluginPoint | ||
import com.duckduckgo.di.scopes.AppScope | ||
import com.duckduckgo.mobile.android.vpn.VpnFeaturesRegistry | ||
import com.duckduckgo.networkprotection.impl.NetPVpnFeature | ||
import com.squareup.anvil.annotations.ContributesBinding | ||
import javax.inject.Inject | ||
import kotlinx.coroutines.withContext | ||
import logcat.logcat | ||
|
||
interface NetPFeatureRemover { | ||
|
||
/** | ||
* Call this method to clear all NetP state. | ||
* DO NOT set any dispatcher for this method, it's done directly from it | ||
*/ | ||
suspend fun removeFeature() | ||
|
||
@ContributesPluginPoint(AppScope::class) | ||
interface NetPStoreRemovalPlugin { | ||
/** | ||
* Any NetP store that keeps some state data about NetP should contribute an implementation of this type | ||
* so that the entire state can be cleared when necessary | ||
*/ | ||
fun clearStore() | ||
} | ||
} | ||
|
||
@ContributesBinding(AppScope::class) | ||
class NetPFeatureRemoverImpl @Inject constructor( | ||
private val netpStores: PluginPoint<NetPFeatureRemover.NetPStoreRemovalPlugin>, | ||
private val dispatcherProvider: DispatcherProvider, | ||
private val vpnFeaturesRegistry: VpnFeaturesRegistry, | ||
) : NetPFeatureRemover { | ||
override suspend fun removeFeature() = withContext(dispatcherProvider.io()) { | ||
netpStores.getPlugins().forEach { | ||
logcat { "NetP clearing state for ${it.javaClass}" } | ||
it.clearStore() | ||
} | ||
vpnFeaturesRegistry.unregisterFeature(NetPVpnFeature.NETP_VPN) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.