From 9d55978063947d5865bb3fa4e0c2ebef78f78812 Mon Sep 17 00:00:00 2001 From: Guillaume Jacquart Date: Mon, 6 Nov 2023 08:14:27 +0000 Subject: epic18: Manage VPN services for Tor or Tracker control --- .../domain/entities/FeatureServiceState.kt | 25 --------- .../domain/entities/FeatureState.kt | 25 +++++++++ .../domain/entities/LocationMode.kt | 22 ++++++++ .../domain/entities/MainFeatures.kt | 31 ++++++++++++ .../domain/repositories/LocalStateRepository.kt | 59 ++++++++++++++++++++++ .../domain/usecases/VpnSupervisorUseCase.kt | 27 ++++++++++ .../servicesupervisors/FeatureSupervisor.kt | 27 ++++++++++ 7 files changed, 191 insertions(+), 25 deletions(-) delete mode 100644 core/src/main/java/foundation/e/advancedprivacy/domain/entities/FeatureServiceState.kt create mode 100644 core/src/main/java/foundation/e/advancedprivacy/domain/entities/FeatureState.kt create mode 100644 core/src/main/java/foundation/e/advancedprivacy/domain/entities/LocationMode.kt create mode 100644 core/src/main/java/foundation/e/advancedprivacy/domain/entities/MainFeatures.kt create mode 100644 core/src/main/java/foundation/e/advancedprivacy/domain/repositories/LocalStateRepository.kt create mode 100644 core/src/main/java/foundation/e/advancedprivacy/domain/usecases/VpnSupervisorUseCase.kt create mode 100644 core/src/main/java/foundation/e/advancedprivacy/externalinterfaces/servicesupervisors/FeatureSupervisor.kt (limited to 'core/src') diff --git a/core/src/main/java/foundation/e/advancedprivacy/domain/entities/FeatureServiceState.kt b/core/src/main/java/foundation/e/advancedprivacy/domain/entities/FeatureServiceState.kt deleted file mode 100644 index f079c56..0000000 --- a/core/src/main/java/foundation/e/advancedprivacy/domain/entities/FeatureServiceState.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 . - */ -package foundation.e.advancedprivacy.domain.entities - -enum class FeatureServiceState { - OFF, ON, STARTING, STOPPING; - - val isChecked get() = this == ON || this == STARTING - - val isLoading get() = this == STARTING || this == STOPPING -} diff --git a/core/src/main/java/foundation/e/advancedprivacy/domain/entities/FeatureState.kt b/core/src/main/java/foundation/e/advancedprivacy/domain/entities/FeatureState.kt new file mode 100644 index 0000000..c756f4a --- /dev/null +++ b/core/src/main/java/foundation/e/advancedprivacy/domain/entities/FeatureState.kt @@ -0,0 +1,25 @@ +/* + * 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 . + */ +package foundation.e.advancedprivacy.domain.entities + +enum class FeatureState { + OFF, ON, STARTING, STOPPING; + + val isChecked get() = this == ON || this == STARTING + + val isLoading get() = this == STARTING || this == STOPPING +} 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 . + */ + +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 . + */ +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 . + */ +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 + fun setBlockTrackers(enabled: Boolean) + + val areAllTrackersBlocked: MutableStateFlow + + val fakeLocationEnabled: StateFlow + fun setFakeLocationEnabled(enabled: Boolean) + + var fakeLocation: Pair + + val locationMode: MutableStateFlow + + fun setIpScramblingSetting(enabled: Boolean) + val ipScramblingSetting: StateFlow + + val internetPrivacyMode: MutableStateFlow + + suspend fun emitStartVpnDisclaimer(feature: MainFeatures) + + val startVpnDisclaimer: SharedFlow + + suspend fun emitOtherVpnRunning(appDesc: ApplicationDescription) + val otherVpnRunning: SharedFlow + + 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 . + */ +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 . + */ +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 +} -- cgit v1.2.1