summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/build.gradle9
-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.kt22
-rw-r--r--core/src/main/java/foundation/e/advancedprivacy/domain/entities/MainFeatures.kt31
-rw-r--r--core/src/main/java/foundation/e/advancedprivacy/domain/repositories/LocalStateRepository.kt59
-rw-r--r--core/src/main/java/foundation/e/advancedprivacy/domain/usecases/VpnSupervisorUseCase.kt27
-rw-r--r--core/src/main/java/foundation/e/advancedprivacy/externalinterfaces/servicesupervisors/FeatureSupervisor.kt27
7 files changed, 174 insertions, 3 deletions
diff --git a/core/build.gradle b/core/build.gradle
index 0e53f22..3b5234d 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2023 MURENA SAS
* Copyright (C) 2022 E FOUNDATION
*
* This program is free software: you can redistribute it and/or modify
@@ -15,8 +16,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-apply plugin: 'com.android.library'
-apply plugin: 'kotlin-android'
+plugins {
+ id 'com.android.library'
+ id 'kotlin-android'
+ id 'kotlin-kapt'
+ id 'kotlin-parcelize'
+}
group 'foundation.e'
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>
+}