diff options
author | Guillaume Jacquart <guillaume.jacquart@hoodbrains.com> | 2023-09-12 06:17:39 +0000 |
---|---|---|
committer | Guillaume Jacquart <guillaume.jacquart@hoodbrains.com> | 2023-09-12 06:17:39 +0000 |
commit | a38472602d259b6c265660bf3b0ba472f20c6a7f (patch) | |
tree | 59c58e58cfef0e370f39bd9c150e36c6dfcb50c0 /fakelocation/src/main | |
parent | 1a77e3924bc78eabca7b859ef62be30bbf2476ad (diff) | |
parent | 53f4a9ce311d612d43fa770cf7e8f8e98fbb43a0 (diff) |
Merge branch '2-privacymodules_to_clean_archi' into 'main'
2: organise module with clean archi, use Koin for injection.
See merge request e/os/advanced-privacy!144
Diffstat (limited to 'fakelocation/src/main')
-rw-r--r-- | fakelocation/src/main/AndroidManifest.xml | 3 | ||||
-rw-r--r-- | fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/KoinModule.kt | 9 | ||||
-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.kt | 41 |
5 files changed, 19 insertions, 48 deletions
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() -} |