summaryrefslogtreecommitdiff
path: root/fakelocation
diff options
context:
space:
mode:
authorGuillaume Jacquart <guillaume.jacquart@hoodbrains.com>2023-09-12 06:17:39 +0000
committerGuillaume Jacquart <guillaume.jacquart@hoodbrains.com>2023-09-12 06:17:39 +0000
commit53f4a9ce311d612d43fa770cf7e8f8e98fbb43a0 (patch)
tree59c58e58cfef0e370f39bd9c150e36c6dfcb50c0 /fakelocation
parent1a77e3924bc78eabca7b859ef62be30bbf2476ad (diff)
2: organise module with clean archi, use Koin for injection.
Diffstat (limited to 'fakelocation')
-rw-r--r--fakelocation/build.gradle8
-rw-r--r--fakelocation/fakelocationdemo/build.gradle2
-rw-r--r--fakelocation/fakelocationdemo/src/main/java/foundation/e/privacymodules/fakelocationdemo/MainActivity.kt10
-rw-r--r--fakelocation/src/main/AndroidManifest.xml3
-rw-r--r--fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/KoinModule.kt9
-rw-r--r--fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/domain/usecases/FakeLocationModule.kt (renamed from fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationModule.kt)11
-rw-r--r--fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/services/FakeLocationService.kt (renamed from fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationService.kt)3
-rw-r--r--fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/IFakeLocationModule.kt41
8 files changed, 31 insertions, 56 deletions
diff --git a/fakelocation/build.gradle b/fakelocation/build.gradle
index 91f8031..64fc633 100644
--- a/fakelocation/build.gradle
+++ b/fakelocation/build.gradle
@@ -46,7 +46,11 @@ android {
}
dependencies {
- implementation (libs.bundles.kotlin.android.coroutines)
- implementation project(':privacymodule-api')
+ implementation(
+ libs.bundles.koin,
+ libs.bundles.kotlin.android.coroutines
+ )
+ implementation project(':core')
+
}
diff --git a/fakelocation/fakelocationdemo/build.gradle b/fakelocation/fakelocationdemo/build.gradle
index 0145eca..6cb9af3 100644
--- a/fakelocation/fakelocationdemo/build.gradle
+++ b/fakelocation/fakelocationdemo/build.gradle
@@ -54,7 +54,7 @@ android {
}
dependencies {
- implementation project(':privacymodule-api')
+ implementation project(':core')
implementation project(':fakelocation')
implementation project(':permissionsstandalone')
diff --git a/fakelocation/fakelocationdemo/src/main/java/foundation/e/privacymodules/fakelocationdemo/MainActivity.kt b/fakelocation/fakelocationdemo/src/main/java/foundation/e/privacymodules/fakelocationdemo/MainActivity.kt
index b7c9ced..f2e10a4 100644
--- a/fakelocation/fakelocationdemo/src/main/java/foundation/e/privacymodules/fakelocationdemo/MainActivity.kt
+++ b/fakelocation/fakelocationdemo/src/main/java/foundation/e/privacymodules/fakelocationdemo/MainActivity.kt
@@ -33,12 +33,12 @@ import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.databinding.DataBindingUtil
-import foundation.e.privacymodules.fakelocation.FakeLocationModule
+import foundation.e.advancedprivacy.domain.entities.AppOpModes
+import foundation.e.advancedprivacy.domain.entities.ApplicationDescription
+import foundation.e.advancedprivacy.domain.entities.ProfileType
+import foundation.e.advancedprivacy.fakelocation.domain.usecases.FakeLocationModule
+import foundation.e.advancedprivacy.permissions.externalinterfaces.PermissionsPrivacyModule
import foundation.e.privacymodules.fakelocationdemo.databinding.ActivityMainBinding
-import foundation.e.privacymodules.permissions.PermissionsPrivacyModule
-import foundation.e.privacymodules.permissions.data.AppOpModes
-import foundation.e.privacymodules.permissions.data.ApplicationDescription
-import foundation.e.privacymodules.permissions.data.ProfileType
class MainActivity : AppCompatActivity() {
companion object {
diff --git a/fakelocation/src/main/AndroidManifest.xml b/fakelocation/src/main/AndroidManifest.xml
index 5077c24..fde371c 100644
--- a/fakelocation/src/main/AndroidManifest.xml
+++ b/fakelocation/src/main/AndroidManifest.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
+ ~ Copyright (C) 2023 MURENA SAS
~ Copyright (C) 2022 E FOUNDATION
~
~ This program is free software: you can redistribute it and/or modify
@@ -26,7 +27,7 @@
tools:ignore="MockLocation,ProtectedPermissions" />
<application>
- <service android:name="foundation.e.privacymodules.fakelocation.FakeLocationService"
+ <service android:name="foundation.e.advancedprivacy.fakelocation.services.FakeLocationService"
android:enabled="true" />
</application>
</manifest> \ No newline at end of file
diff --git a/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/KoinModule.kt b/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/KoinModule.kt
new file mode 100644
index 0000000..b833181
--- /dev/null
+++ b/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/KoinModule.kt
@@ -0,0 +1,9 @@
+package foundation.e.advancedprivacy.fakelocation
+
+import foundation.e.advancedprivacy.fakelocation.domain.usecases.FakeLocationModule
+import org.koin.core.module.dsl.singleOf
+import org.koin.dsl.module
+
+val fakelocationModule = module {
+ singleOf(::FakeLocationModule)
+}
diff --git a/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationModule.kt b/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/domain/usecases/FakeLocationModule.kt
index 4245836..c9aac0a 100644
--- a/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationModule.kt
+++ b/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/domain/usecases/FakeLocationModule.kt
@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-package foundation.e.privacymodules.fakelocation
+package foundation.e.advancedprivacy.fakelocation.domain.usecases
import android.content.Context
import android.content.Context.LOCATION_SERVICE
@@ -27,6 +27,7 @@ import android.location.provider.ProviderProperties
import android.os.Build
import android.os.SystemClock
import android.util.Log
+import foundation.e.advancedprivacy.fakelocation.services.FakeLocationService
/**
* Implementation of the functionality of fake location.
@@ -34,7 +35,7 @@ import android.util.Log
*
* @param context an Android context, to retrieve system services for example.
*/
-class FakeLocationModule(private val context: Context) : IFakeLocationModule {
+class FakeLocationModule(private val context: Context) {
companion object {
private const val TAG = "FakeLocationModule"
}
@@ -56,7 +57,7 @@ class FakeLocationModule(private val context: Context) : IFakeLocationModule {
* @see IFakeLocationModule.startFakeLocation
*/
@Synchronized
- override fun startFakeLocation() {
+ fun startFakeLocation() {
providers.forEach { provider ->
try {
locationManager.removeTestProvider(provider)
@@ -84,7 +85,7 @@ class FakeLocationModule(private val context: Context) : IFakeLocationModule {
}
}
- override fun setFakeLocation(latitude: Double, longitude: Double) {
+ fun setFakeLocation(latitude: Double, longitude: Double) {
context.startService(FakeLocationService.buildFakeLocationIntent(context, latitude, longitude))
}
@@ -118,7 +119,7 @@ class FakeLocationModule(private val context: Context) : IFakeLocationModule {
/**
* @see IFakeLocationModule.stopFakeLocation
*/
- override fun stopFakeLocation() {
+ fun stopFakeLocation() {
context.stopService(FakeLocationService.buildStopIntent(context))
providers.forEach { provider ->
try {
diff --git a/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationService.kt b/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/services/FakeLocationService.kt
index 34620fe..6eaae54 100644
--- a/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationService.kt
+++ b/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/services/FakeLocationService.kt
@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-package foundation.e.privacymodules.fakelocation
+package foundation.e.advancedprivacy.fakelocation.services
import android.app.Service
import android.content.Context
@@ -23,6 +23,7 @@ import android.content.Intent
import android.os.CountDownTimer
import android.os.IBinder
import android.util.Log
+import foundation.e.advancedprivacy.fakelocation.domain.usecases.FakeLocationModule
class FakeLocationService : Service() {
diff --git a/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/IFakeLocationModule.kt b/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/IFakeLocationModule.kt
deleted file mode 100644
index 32906f8..0000000
--- a/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/IFakeLocationModule.kt
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.privacymodules.fakelocation
-
-/**
- * Manage a fake location on the device.
- */
-interface IFakeLocationModule {
- /**
- * Start to fake the location module. Call [setFakeLocation] after to set the fake
- * position.
- */
- fun startFakeLocation()
-
- /**
- * Set or update the faked position.
- * @param latitude the latitude of the fake position in degrees.
- * @param longitude the longitude of the fake position in degrees.
- */
- fun setFakeLocation(latitude: Double, longitude: Double)
-
- /**
- * Stop the fake location module, giving back hand to the true location modules.
- */
- fun stopFakeLocation()
-}