diff options
author | Guillaume Jacquart <guillaume.jacquart@hoodbrains.com> | 2023-11-06 08:14:27 +0000 |
---|---|---|
committer | Guillaume Jacquart <guillaume.jacquart@hoodbrains.com> | 2023-11-06 08:14:27 +0000 |
commit | 95d9421d4d982562f83db019e5c3f59c5acfcdf4 (patch) | |
tree | 56c69c0911e512aaaecd22cb02f2c1305f42d8e2 /core/src | |
parent | 50e213ce1db332b95af5018e553c0ee2cd810e39 (diff) | |
parent | 9d55978063947d5865bb3fa4e0c2ebef78f78812 (diff) |
Merge branch 'epic18-standalone_trackers_tor' into 'main'
epic18: Manage VPN services for Tor or Tracker control
See merge request e/os/advanced-privacy!149
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/java/foundation/e/advancedprivacy/domain/entities/FeatureState.kt (renamed from core/src/main/java/foundation/e/advancedprivacy/domain/entities/FeatureServiceState.kt) | 2 | ||||
-rw-r--r-- | core/src/main/java/foundation/e/advancedprivacy/domain/entities/LocationMode.kt | 22 | ||||
-rw-r--r-- | core/src/main/java/foundation/e/advancedprivacy/domain/entities/MainFeatures.kt | 31 | ||||
-rw-r--r-- | core/src/main/java/foundation/e/advancedprivacy/domain/repositories/LocalStateRepository.kt | 59 | ||||
-rw-r--r-- | core/src/main/java/foundation/e/advancedprivacy/domain/usecases/VpnSupervisorUseCase.kt | 27 | ||||
-rw-r--r-- | core/src/main/java/foundation/e/advancedprivacy/externalinterfaces/servicesupervisors/FeatureSupervisor.kt | 27 |
6 files changed, 167 insertions, 1 deletions
diff --git a/core/src/main/java/foundation/e/advancedprivacy/domain/entities/FeatureServiceState.kt b/core/src/main/java/foundation/e/advancedprivacy/domain/entities/FeatureState.kt index f079c56..c756f4a 100644 --- a/core/src/main/java/foundation/e/advancedprivacy/domain/entities/FeatureServiceState.kt +++ b/core/src/main/java/foundation/e/advancedprivacy/domain/entities/FeatureState.kt @@ -16,7 +16,7 @@ */ package foundation.e.advancedprivacy.domain.entities -enum class FeatureServiceState { +enum class FeatureState { OFF, ON, STARTING, STOPPING; val isChecked get() = this == ON || this == STARTING diff --git a/core/src/main/java/foundation/e/advancedprivacy/domain/entities/LocationMode.kt b/core/src/main/java/foundation/e/advancedprivacy/domain/entities/LocationMode.kt new file mode 100644 index 0000000..62581eb --- /dev/null +++ b/core/src/main/java/foundation/e/advancedprivacy/domain/entities/LocationMode.kt @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2021 E FOUNDATION + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package foundation.e.advancedprivacy.domain.entities + +enum class LocationMode { + REAL_LOCATION, RANDOM_LOCATION, SPECIFIC_LOCATION +} diff --git a/core/src/main/java/foundation/e/advancedprivacy/domain/entities/MainFeatures.kt b/core/src/main/java/foundation/e/advancedprivacy/domain/entities/MainFeatures.kt new file mode 100644 index 0000000..1af2ae0 --- /dev/null +++ b/core/src/main/java/foundation/e/advancedprivacy/domain/entities/MainFeatures.kt @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2023 MURENA SAS + * Copyright (C) 2022 E FOUNDATION + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package foundation.e.advancedprivacy.domain.entities + +import android.content.Intent +import android.os.Parcelable +import kotlinx.parcelize.Parcelize + +sealed class MainFeatures : Parcelable { + @Parcelize + data class TrackersControl(val startVpnDisclaimer: Intent? = null) : MainFeatures() + @Parcelize + object FakeLocation : MainFeatures() + @Parcelize + data class IpScrambling(val startVpnDisclaimer: Intent? = null) : MainFeatures() +} diff --git a/core/src/main/java/foundation/e/advancedprivacy/domain/repositories/LocalStateRepository.kt b/core/src/main/java/foundation/e/advancedprivacy/domain/repositories/LocalStateRepository.kt new file mode 100644 index 0000000..0266f85 --- /dev/null +++ b/core/src/main/java/foundation/e/advancedprivacy/domain/repositories/LocalStateRepository.kt @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2023 MURENA SAS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package foundation.e.advancedprivacy.domain.repositories + +import foundation.e.advancedprivacy.domain.entities.ApplicationDescription +import foundation.e.advancedprivacy.domain.entities.FeatureState +import foundation.e.advancedprivacy.domain.entities.LocationMode +import foundation.e.advancedprivacy.domain.entities.MainFeatures +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.StateFlow + +interface LocalStateRepository { + val blockTrackers: StateFlow<Boolean> + fun setBlockTrackers(enabled: Boolean) + + val areAllTrackersBlocked: MutableStateFlow<Boolean> + + val fakeLocationEnabled: StateFlow<Boolean> + fun setFakeLocationEnabled(enabled: Boolean) + + var fakeLocation: Pair<Float, Float> + + val locationMode: MutableStateFlow<LocationMode> + + fun setIpScramblingSetting(enabled: Boolean) + val ipScramblingSetting: StateFlow<Boolean> + + val internetPrivacyMode: MutableStateFlow<FeatureState> + + suspend fun emitStartVpnDisclaimer(feature: MainFeatures) + + val startVpnDisclaimer: SharedFlow<MainFeatures> + + suspend fun emitOtherVpnRunning(appDesc: ApplicationDescription) + val otherVpnRunning: SharedFlow<ApplicationDescription> + + var firstBoot: Boolean + + var hideWarningTrackers: Boolean + + var hideWarningLocation: Boolean + + var hideWarningIpScrambling: Boolean +} diff --git a/core/src/main/java/foundation/e/advancedprivacy/domain/usecases/VpnSupervisorUseCase.kt b/core/src/main/java/foundation/e/advancedprivacy/domain/usecases/VpnSupervisorUseCase.kt new file mode 100644 index 0000000..fce9fd0 --- /dev/null +++ b/core/src/main/java/foundation/e/advancedprivacy/domain/usecases/VpnSupervisorUseCase.kt @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2023 MURENA SAS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package foundation.e.advancedprivacy.domain.usecases + +import foundation.e.advancedprivacy.domain.entities.MainFeatures + +interface VpnSupervisorUseCase { + fun listenSettings() + + fun startVpnService(feature: MainFeatures) + + fun cancelStartVpnService(feature: MainFeatures) +} diff --git a/core/src/main/java/foundation/e/advancedprivacy/externalinterfaces/servicesupervisors/FeatureSupervisor.kt b/core/src/main/java/foundation/e/advancedprivacy/externalinterfaces/servicesupervisors/FeatureSupervisor.kt new file mode 100644 index 0000000..632172d --- /dev/null +++ b/core/src/main/java/foundation/e/advancedprivacy/externalinterfaces/servicesupervisors/FeatureSupervisor.kt @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2023 MURENA SAS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package foundation.e.advancedprivacy.externalinterfaces.servicesupervisors + +import foundation.e.advancedprivacy.domain.entities.FeatureState +import kotlinx.coroutines.flow.StateFlow + +interface FeatureSupervisor { + fun start(): Boolean + fun stop(): Boolean + + val state: StateFlow<FeatureState> +} |