summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonard Kugis <leonard@kug.is>2024-01-04 02:39:04 +0100
committerLeonard Kugis <leonard@kug.is>2024-01-04 02:39:04 +0100
commitaa93b37883deb00c6ca74ad72a5464284fe9171f (patch)
treebcbc0792e914059a763a04182bbe0f2538b3a5b4
parentcb28d70fb5d220953dec337885601597c654e4fd (diff)
Added additional fake location parameters
Bearing, Bearing jitter, Speed jitter, Altitude jitter
-rw-r--r--app/src/main/java/foundation/e/advancedprivacy/data/repositories/LocalStateRepository.kt36
-rw-r--r--app/src/main/java/foundation/e/advancedprivacy/domain/usecases/FakeLocationStateUseCase.kt40
-rw-r--r--app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt52
-rw-r--r--app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationState.kt4
-rw-r--r--app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationViewModel.kt12
-rw-r--r--app/src/main/res/layout/fragment_fake_location.xml76
-rw-r--r--app/src/main/res/values/strings.xml4
-rw-r--r--core/src/main/java/foundation/e/advancedprivacy/domain/entities/FakeLocationCoordinate.kt5
-rw-r--r--core/src/main/java/foundation/e/advancedprivacy/domain/repositories/LocalStateRepository.kt4
-rw-r--r--fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/domain/usecases/FakeLocationModule.kt16
-rw-r--r--fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/services/FakeLocationService.kt38
11 files changed, 269 insertions, 18 deletions
diff --git a/app/src/main/java/foundation/e/advancedprivacy/data/repositories/LocalStateRepository.kt b/app/src/main/java/foundation/e/advancedprivacy/data/repositories/LocalStateRepository.kt
index 9643899..b1f5ec3 100644
--- a/app/src/main/java/foundation/e/advancedprivacy/data/repositories/LocalStateRepository.kt
+++ b/app/src/main/java/foundation/e/advancedprivacy/data/repositories/LocalStateRepository.kt
@@ -41,7 +41,11 @@ class LocalStateRepositoryImpl(context: Context) : LocalStateRepository {
private const val KEY_IP_SCRAMBLING = "ipScrambling"
private const val KEY_FAKE_ALTITUDE = "fakeAltitude"
private const val KEY_FAKE_SPEED = "fakeSpeed"
+ private const val KEY_FAKE_BEARING = "fakeBearing"
private const val KEY_FAKE_JITTER = "fakeJitter"
+ private const val KEY_FAKE_JITTER_ALTITUDE = "fakeJitterAltitude"
+ private const val KEY_FAKE_JITTER_SPEED = "fakeJitterSpeed"
+ private const val KEY_FAKE_JITTER_BEARING = "fakeJitterBearing"
private const val KEY_LOCATION_MODE = "locationMode"
private const val KEY_LOCATION_ROUTE = "locationRoute"
private const val KEY_LOCATION_ROUTE_LOOP = "locationRouteLoop"
@@ -82,6 +86,14 @@ class LocalStateRepositoryImpl(context: Context) : LocalStateRepository {
.apply()
}
+ override var fakeBearing: Float
+ get() = sharedPref.getFloat(KEY_FAKE_BEARING, 0.0f)
+ set(value) {
+ sharedPref.edit()
+ .putFloat(KEY_FAKE_BEARING, value)
+ .apply()
+ }
+
override var fakeJitter: Float
get() = sharedPref.getFloat(KEY_FAKE_JITTER, 3.0f)
set(value) {
@@ -90,6 +102,30 @@ class LocalStateRepositoryImpl(context: Context) : LocalStateRepository {
.apply()
}
+ override var fakeJitterAltitude: Float
+ get() = sharedPref.getFloat(KEY_FAKE_JITTER_ALTITUDE, 3.0f)
+ set(value) {
+ sharedPref.edit()
+ .putFloat(KEY_FAKE_JITTER_ALTITUDE, value)
+ .apply()
+ }
+
+ override var fakeJitterSpeed: Float
+ get() = sharedPref.getFloat(KEY_FAKE_JITTER_SPEED, 0.1f)
+ set(value) {
+ sharedPref.edit()
+ .putFloat(KEY_FAKE_JITTER_SPEED, value)
+ .apply()
+ }
+
+ override var fakeJitterBearing: Float
+ get() = sharedPref.getFloat(KEY_FAKE_JITTER_BEARING, 10.0f)
+ set(value) {
+ sharedPref.edit()
+ .putFloat(KEY_FAKE_JITTER_BEARING, value)
+ .apply()
+ }
+
override var fakeLocation: Pair<Float, Float>
get() = Pair(
// Initial default value is Quezon City
diff --git a/app/src/main/java/foundation/e/advancedprivacy/domain/usecases/FakeLocationStateUseCase.kt b/app/src/main/java/foundation/e/advancedprivacy/domain/usecases/FakeLocationStateUseCase.kt
index b7743df..1f92554 100644
--- a/app/src/main/java/foundation/e/advancedprivacy/domain/usecases/FakeLocationStateUseCase.kt
+++ b/app/src/main/java/foundation/e/advancedprivacy/domain/usecases/FakeLocationStateUseCase.kt
@@ -54,7 +54,7 @@ class FakeLocationStateUseCase(
coroutineScope: CoroutineScope
) {
private val _configuredLocationMode = MutableStateFlow<FakeLocationState>(
- FakeLocationState(LocationMode.REAL_LOCATION, null, null, null, null, null, null, false, null, false, false)
+ FakeLocationState(LocationMode.REAL_LOCATION, null, null, null, null, null, null, null, null, null, null, false, null, false, false)
)
val configuredLocationMode: StateFlow<FakeLocationState> = _configuredLocationMode
@@ -120,6 +120,10 @@ class FakeLocationStateUseCase(
null,
null,
null,
+ null,
+ null,
+ null,
+ null,
false,
localStateRepository.route,
isEnabled,
@@ -129,13 +133,17 @@ class FakeLocationStateUseCase(
localStateRepository.routeLoopEnabled = isEnabled
}
- fun setFakeLocationParameters(altitude: Float, speed: Float, jitter: Float) {
+ fun setFakeLocationParameters(altitude: Float, speed: Float, bearing: Float, jitter: Float, jitterAltitude: Float, jitterSpeed: Float, jitterBearing: Float) {
_configuredLocationMode.value = FakeLocationState(
LocationMode.SPECIFIC_LOCATION,
null,
altitude,
speed,
+ bearing,
jitter,
+ jitterAltitude,
+ jitterSpeed,
+ jitterBearing,
localStateRepository.fakeLocation.first,
localStateRepository.fakeLocation.second,
false,
@@ -146,7 +154,11 @@ class FakeLocationStateUseCase(
localStateRepository.fakeAltitude = altitude
localStateRepository.fakeSpeed = speed
+ localStateRepository.fakeBearing = bearing
localStateRepository.fakeJitter = jitter
+ localStateRepository.fakeJitterAltitude = jitterAltitude
+ localStateRepository.fakeJitterSpeed = jitterSpeed
+ localStateRepository.fakeJitterBearing = jitterBearing
}
fun useRealLocation() {
@@ -158,6 +170,10 @@ class FakeLocationStateUseCase(
null,
null,
null,
+ null,
+ null,
+ null,
+ null,
false,
null,
false,
@@ -183,7 +199,11 @@ class FakeLocationStateUseCase(
null,
localStateRepository.fakeAltitude,
localStateRepository.fakeSpeed,
+ localStateRepository.fakeBearing,
localStateRepository.fakeJitter,
+ localStateRepository.fakeJitterAltitude,
+ localStateRepository.fakeJitterSpeed,
+ localStateRepository.fakeJitterBearing,
location.first,
location.second,
false,
@@ -197,7 +217,11 @@ class FakeLocationStateUseCase(
localStateRepository.setLocationMode(LocationMode.SPECIFIC_LOCATION)
fakeLocationModule.setFakeLocation(localStateRepository.fakeAltitude.toDouble(),
localStateRepository.fakeSpeed,
+ localStateRepository.fakeBearing,
localStateRepository.fakeJitter,
+ localStateRepository.fakeJitterAltitude.toDouble(),
+ localStateRepository.fakeJitterSpeed,
+ localStateRepository.fakeJitterBearing,
localStateRepository.fakeLocation.first.toDouble(),
localStateRepository.fakeLocation.second.toDouble())
} else {
@@ -215,6 +239,10 @@ class FakeLocationStateUseCase(
null,
null,
null,
+ null,
+ null,
+ null,
+ null,
false,
route ?: localStateRepository.route,
localStateRepository.routeLoopEnabled,
@@ -235,6 +263,10 @@ class FakeLocationStateUseCase(
null,
null,
null,
+ null,
+ null,
+ null,
+ null,
false,
route,
localStateRepository.routeLoopEnabled,
@@ -253,6 +285,10 @@ class FakeLocationStateUseCase(
null,
null,
null,
+ null,
+ null,
+ null,
+ null,
false,
localStateRepository.route,
localStateRepository.routeLoopEnabled,
diff --git a/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt b/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt
index 33884f7..f1288cb 100644
--- a/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt
+++ b/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationFragment.kt
@@ -284,7 +284,11 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location)
Action.UpdateMockLocationParameters(
binding.edittextAltitude.text.toString().toFloat(),
binding.edittextSpeed.text.toString().toFloat(),
+ binding.edittextBearing.text.toString().toFloat(),
binding.edittextJitter.text.toString().toFloat(),
+ binding.edittextJitterAltitude.text.toString().toFloat(),
+ binding.edittextJitterSpeed.text.toString().toFloat(),
+ binding.edittextJitterBearing.text.toString().toFloat(),
)
)
} catch (e: NumberFormatException) {
@@ -305,12 +309,36 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location)
}
@Suppress("UNUSED_PARAMETER")
+ private fun onBearingTextChanged(editable: Editable?) {
+ if(!validateBounds(binding.textlayoutBearing, 0.0f, 360.0f)) return
+ updateMockLocationParameters()
+ }
+
+ @Suppress("UNUSED_PARAMETER")
private fun onJitterTextChanged(editable: Editable?) {
if(!validateBounds(binding.textlayoutJitter, 0.0f, 10000000.0f)) return
updateMockLocationParameters()
}
@Suppress("UNUSED_PARAMETER")
+ private fun onJitterAltitudeTextChanged(editable: Editable?) {
+ if(!validateBounds(binding.textlayoutJitterAltitude, -100000.0f, 100000.0f)) return
+ updateMockLocationParameters()
+ }
+
+ @Suppress("UNUSED_PARAMETER")
+ private fun onJitterSpeedTextChanged(editable: Editable?) {
+ if(!validateBounds(binding.textlayoutJitterSpeed, 0.0f, 299792458.0f)) return
+ updateMockLocationParameters()
+ }
+
+ @Suppress("UNUSED_PARAMETER")
+ private fun onJitterBearingTextChanged(editable: Editable?) {
+ if(!validateBounds(binding.textlayoutJitterBearing, 0.0f, 360.0f)) return
+ updateMockLocationParameters()
+ }
+
+ @Suppress("UNUSED_PARAMETER")
private fun onLatTextChanged(editable: Editable?) {
if (!binding.edittextLatitude.isFocused ||
!validateCoordinate(binding.textlayoutLatitude, 90f)
@@ -406,12 +434,20 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location)
binding.edittextAltitude.addTextChangedListener(afterTextChanged = ::onAltitudeTextChanged)
binding.edittextSpeed.addTextChangedListener(afterTextChanged = ::onSpeedTextChanged)
+ binding.edittextBearing.addTextChangedListener(afterTextChanged = ::onBearingTextChanged)
binding.edittextJitter.addTextChangedListener(afterTextChanged = ::onJitterTextChanged)
+ binding.edittextJitterAltitude.addTextChangedListener(afterTextChanged = ::onJitterAltitudeTextChanged)
+ binding.edittextJitterSpeed.addTextChangedListener(afterTextChanged = ::onJitterSpeedTextChanged)
+ binding.edittextJitterBearing.addTextChangedListener(afterTextChanged = ::onJitterBearingTextChanged)
binding.edittextLatitude.addTextChangedListener(afterTextChanged = ::onLatTextChanged)
binding.edittextLongitude.addTextChangedListener(afterTextChanged = ::onLonTextChanged)
binding.edittextAltitude.onFocusChangeListener = latLonOnFocusChangeListener
binding.edittextSpeed.onFocusChangeListener = latLonOnFocusChangeListener
+ binding.edittextBearing.onFocusChangeListener = latLonOnFocusChangeListener
binding.edittextJitter.onFocusChangeListener = latLonOnFocusChangeListener
+ binding.edittextJitterAltitude.onFocusChangeListener = latLonOnFocusChangeListener
+ binding.edittextJitterSpeed.onFocusChangeListener = latLonOnFocusChangeListener
+ binding.edittextJitterBearing.onFocusChangeListener = latLonOnFocusChangeListener
binding.edittextLatitude.onFocusChangeListener = latLonOnFocusChangeListener
binding.edittextLongitude.onFocusChangeListener = latLonOnFocusChangeListener
@@ -435,7 +471,11 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location)
binding.textlayoutAltitude.isVisible = state.mode == LocationMode.SPECIFIC_LOCATION
binding.textlayoutSpeed.isVisible = state.mode == LocationMode.SPECIFIC_LOCATION
+ binding.textlayoutBearing.isVisible = state.mode == LocationMode.SPECIFIC_LOCATION
binding.textlayoutJitter.isVisible = state.mode == LocationMode.SPECIFIC_LOCATION
+ binding.textlayoutJitterAltitude.isVisible = state.mode == LocationMode.SPECIFIC_LOCATION
+ binding.textlayoutJitterSpeed.isVisible = state.mode == LocationMode.SPECIFIC_LOCATION
+ binding.textlayoutJitterBearing.isVisible = state.mode == LocationMode.SPECIFIC_LOCATION
binding.buttonLocationRoutePathSelect.isVisible = state.mode == LocationMode.ROUTE
binding.locationRoutePath.isVisible = state.mode == LocationMode.ROUTE
@@ -455,9 +495,21 @@ class FakeLocationFragment : NavToolbarFragment(R.layout.fragment_fake_location)
if(!binding.edittextSpeed.isFocused)
binding.edittextSpeed.setText(state.speed?.toString())
+ if(!binding.edittextBearing.isFocused)
+ binding.edittextBearing.setText(state.bearing?.toString())
+
if(!binding.edittextJitter.isFocused)
binding.edittextJitter.setText(state.jitter?.toString())
+ if(!binding.edittextJitterAltitude.isFocused)
+ binding.edittextJitterAltitude.setText(state.jitterAltitude?.toString())
+
+ if(!binding.edittextJitterSpeed.isFocused)
+ binding.edittextJitterSpeed.setText(state.jitterSpeed?.toString())
+
+ if(!binding.edittextJitterBearing.isFocused)
+ binding.edittextJitterBearing.setText(state.jitterBearing?.toString())
+
if (state.mode == LocationMode.SPECIFIC_LOCATION) {
binding.mapLoader.isVisible = false
binding.mapOverlay.isVisible = false
diff --git a/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationState.kt b/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationState.kt
index 56acdfd..41e1402 100644
--- a/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationState.kt
+++ b/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationState.kt
@@ -27,7 +27,11 @@ data class FakeLocationState(
val currentLocation: Location? = null,
val altitude: Float? = null,
val speed: Float? = null,
+ val bearing: Float? = null,
val jitter: Float? = null,
+ val jitterAltitude: Float? = null,
+ val jitterSpeed: Float? = null,
+ val jitterBearing: Float? = null,
val specificLatitude: Float? = null,
val specificLongitude: Float? = null,
val forceRefresh: Boolean = false,
diff --git a/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationViewModel.kt b/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationViewModel.kt
index 049c707..17d8c98 100644
--- a/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationViewModel.kt
+++ b/app/src/main/java/foundation/e/advancedprivacy/features/location/FakeLocationViewModel.kt
@@ -72,7 +72,11 @@ class FakeLocationViewModel(
mode = ss.mode,
altitude = ss.altitude,
speed = ss.speed,
+ bearing = ss.bearing,
jitter = ss.jitter,
+ jitterAltitude = ss.jitterAltitude,
+ jitterSpeed = ss.jitterSpeed,
+ jitterBearing = ss.jitterBearing,
specificLatitude = ss.specificLatitude,
specificLongitude = ss.specificLongitude,
route = ss.route,
@@ -86,7 +90,7 @@ class FakeLocationViewModel(
},
mockLocationParametersInputFlow
.debounce(SET_MOCK_LOCATION_PARAMETERS_DELAY).map { action ->
- fakeLocationStateUseCase.setFakeLocationParameters(action.altitude, action.speed, action.jitter)
+ fakeLocationStateUseCase.setFakeLocationParameters(action.altitude, action.speed, action.bearing, action.jitter, action.jitterAltitude, action.jitterSpeed, action.jitterBearing)
},
routeInputFlow
.debounce(SET_ROUTE_DELAY).map { action ->
@@ -154,7 +158,11 @@ class FakeLocationViewModel(
data class UpdateMockLocationParameters(
val altitude: Float,
val speed: Float,
- val jitter: Float
+ val bearing: Float,
+ val jitter: Float,
+ val jitterAltitude: Float,
+ val jitterSpeed: Float,
+ val jitterBearing: Float
) : Action()
data class SetSpecificLocationAction(
val latitude: Float,
diff --git a/app/src/main/res/layout/fragment_fake_location.xml b/app/src/main/res/layout/fragment_fake_location.xml
index d9f8a08..c946d5c 100644
--- a/app/src/main/res/layout/fragment_fake_location.xml
+++ b/app/src/main/res/layout/fragment_fake_location.xml
@@ -132,6 +132,25 @@
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
+ android:id="@+id/textlayout_bearing"
+ android:hint="@string/location_bearing"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_marginTop="16dp"
+ app:endIconDrawable="@drawable/ic_valid"
+ app:endIconMode="custom"
+ app:endIconTint="@color/green_valid"
+ >
+ <com.google.android.material.textfield.TextInputEditText
+ android:id="@+id/edittext_bearing"
+ android:inputType="numberDecimal"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ />
+ </com.google.android.material.textfield.TextInputLayout>
+
+ <com.google.android.material.textfield.TextInputLayout
+ style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:id="@+id/textlayout_jitter"
android:hint="@string/location_jitter"
android:layout_height="wrap_content"
@@ -149,6 +168,63 @@
/>
</com.google.android.material.textfield.TextInputLayout>
+ <com.google.android.material.textfield.TextInputLayout
+ style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
+ android:id="@+id/textlayout_jitter_altitude"
+ android:hint="@string/location_jitter_altitude"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_marginTop="16dp"
+ app:endIconDrawable="@drawable/ic_valid"
+ app:endIconMode="custom"
+ app:endIconTint="@color/green_valid"
+ >
+ <com.google.android.material.textfield.TextInputEditText
+ android:id="@+id/edittext_jitter_altitude"
+ android:inputType="numberDecimal"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ />
+ </com.google.android.material.textfield.TextInputLayout>
+
+ <com.google.android.material.textfield.TextInputLayout
+ style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
+ android:id="@+id/textlayout_jitter_speed"
+ android:hint="@string/location_jitter_speed"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_marginTop="16dp"
+ app:endIconDrawable="@drawable/ic_valid"
+ app:endIconMode="custom"
+ app:endIconTint="@color/green_valid"
+ >
+ <com.google.android.material.textfield.TextInputEditText
+ android:id="@+id/edittext_jitter_speed"
+ android:inputType="numberDecimal"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ />
+ </com.google.android.material.textfield.TextInputLayout>
+
+ <com.google.android.material.textfield.TextInputLayout
+ style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
+ android:id="@+id/textlayout_jitter_bearing"
+ android:hint="@string/location_jitter_bearing"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ android:layout_marginTop="16dp"
+ app:endIconDrawable="@drawable/ic_valid"
+ app:endIconMode="custom"
+ app:endIconTint="@color/green_valid"
+ >
+ <com.google.android.material.textfield.TextInputEditText
+ android:id="@+id/edittext_jitter_bearing"
+ android:inputType="numberDecimal"
+ android:layout_height="wrap_content"
+ android:layout_width="match_parent"
+ />
+ </com.google.android.material.textfield.TextInputLayout>
+
<Button
android:id="@+id/button_location_route_path_select"
android:layout_width="match_parent"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 638f157..3b63984 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -86,7 +86,11 @@
<string name="location_info" weblate_ctx="location-1">Your location can reveal a lot about yourself or your activities.\n\nManage my location enables you to use a fake location instead of your real position. This way, your real location isn\'t shared with applications that might be snooping too much.</string>
<string name="location_altitude">Altitude [m]</string>
<string name="location_speed">Speed [m/s]</string>
+ <string name="location_bearing">Bearing [deg]</string>
<string name="location_jitter">Jitter [m]</string>
+ <string name="location_jitter_altitude">Altitude jitter [m]</string>
+ <string name="location_jitter_speed">Speed jitter [m/s]</string>
+ <string name="location_jitter_bearing">Bearing jitter [deg]</string>
<string name="location_use_real_location" weblate_ctx="location-1">Use my real location</string>
<string name="location_use_random_location" weblate_ctx="location-1">Use a random plausible location</string>
<string name="location_use_specific_location" weblate_ctx="location-1">Use a specific location</string>
diff --git a/core/src/main/java/foundation/e/advancedprivacy/domain/entities/FakeLocationCoordinate.kt b/core/src/main/java/foundation/e/advancedprivacy/domain/entities/FakeLocationCoordinate.kt
index b497b13..f692f2a 100644
--- a/core/src/main/java/foundation/e/advancedprivacy/domain/entities/FakeLocationCoordinate.kt
+++ b/core/src/main/java/foundation/e/advancedprivacy/domain/entities/FakeLocationCoordinate.kt
@@ -22,8 +22,11 @@
val longitude: Float,
val altitude: Float,
val speed: Float,
- val jitter: Float,
val bearing: Float,
+ val jitter: Float,
+ val jitterAltitude: Float,
+ val jitterSpeed: Float,
+ val jitterBearing: Float,
val timestamp: Float
)
\ No newline at end of file
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
index 34bc096..386af67 100644
--- a/core/src/main/java/foundation/e/advancedprivacy/domain/repositories/LocalStateRepository.kt
+++ b/core/src/main/java/foundation/e/advancedprivacy/domain/repositories/LocalStateRepository.kt
@@ -34,7 +34,11 @@ interface LocalStateRepository {
var fakeAltitude: Float
var fakeSpeed: Float
+ var fakeBearing: Float
var fakeJitter: Float
+ var fakeJitterAltitude: Float
+ var fakeJitterSpeed: Float
+ var fakeJitterBearing: Float
var fakeLocation: Pair<Float, Float>
diff --git a/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/domain/usecases/FakeLocationModule.kt b/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/domain/usecases/FakeLocationModule.kt
index 7424f38..9036a92 100644
--- a/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/domain/usecases/FakeLocationModule.kt
+++ b/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/domain/usecases/FakeLocationModule.kt
@@ -95,11 +95,11 @@ class FakeLocationModule(private val context: Context) {
context.stopService(FakeLocationService.buildStopIntent(context))
}
- fun setFakeLocation(altitude: Double, speed: Float, jitter: Float, latitude: Double, longitude: Double) {
- context.startService(FakeLocationService.buildFakeLocationIntent(context, altitude, speed, jitter, latitude, longitude))
+ fun setFakeLocation(altitude: Double, speed: Float, bearing: Float, jitter: Float, jitterAltitude: Double, jitterSpeed: Float, jitterBearing: Float, latitude: Double, longitude: Double) {
+ context.startService(FakeLocationService.buildFakeLocationIntent(context, altitude, speed, bearing, jitter, jitterAltitude, jitterSpeed, jitterBearing, latitude, longitude))
}
- internal fun setTestProviderLocation(altitude: Double, speed: Float, jitter: Float, latitude: Double, longitude: Double) {
+ internal fun setTestProviderLocation(altitude: Double, speed: Float, bearing: Float, accuracy: Float, accuracyAltitude: Float, accuracySpeed: Float, accuracyBearing: Float, latitude: Double, longitude: Double) {
providers.forEach { provider ->
val location = Location(provider)
location.latitude = latitude
@@ -109,14 +109,14 @@ class FakeLocationModule(private val context: Context) {
location.altitude = altitude
location.time = System.currentTimeMillis()
location.speed = speed
- location.bearing = 1f
- location.accuracy = jitter
+ location.bearing = bearing
+ location.accuracy = accuracy
location.elapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- location.bearingAccuracyDegrees = jitter / 10.0f
- location.verticalAccuracyMeters = jitter / 10.0f
- location.speedAccuracyMetersPerSecond = jitter / 100.0f
+ location.bearingAccuracyDegrees = accuracyBearing
+ location.verticalAccuracyMeters = accuracyAltitude
+ location.speedAccuracyMetersPerSecond = accuracySpeed
}
try {
locationManager.setTestProviderLocation(provider, location)
diff --git a/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/services/FakeLocationService.kt b/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/services/FakeLocationService.kt
index f9a3c52..41784a1 100644
--- a/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/services/FakeLocationService.kt
+++ b/fakelocation/src/main/java/foundation/e/advancedprivacy/fakelocation/services/FakeLocationService.kt
@@ -45,18 +45,26 @@ class FakeLocationService : Service() {
private const val PARAM_ALTITUDE = "PARAM_ALTITUDE"
private const val PARAM_SPEED = "PARAM_SPEED"
+ private const val PARAM_BEARING = "PARAM_BEARING"
private const val PARAM_JITTER = "PARAM_JITTER"
+ private const val PARAM_JITTER_ALTITUDE = "PARAM_JITTER_ALTITUDE"
+ private const val PARAM_JITTER_SPEED = "PARAM_JITTER_SPEED"
+ private const val PARAM_JITTER_BEARING = "PARAM_JITTER_BEARING"
private const val PARAM_LATITUDE = "PARAM_LATITUDE"
private const val PARAM_LONGITUDE = "PARAM_LONGITUDE"
private const val PARAM_ROUTE = "PARAM_ROUTE"
private const val PARAM_ROUTE_LOOP = "PARAM_ROUTE_LOOP"
- fun buildFakeLocationIntent(context: Context, altitude: Double, speed: Float, jitter: Float, latitude: Double, longitude: Double): Intent {
+ fun buildFakeLocationIntent(context: Context, altitude: Double, speed: Float, bearing: Float, jitter: Float, jitterAltitude: Double, jitterSpeed: Float, jitterBearing: Float, latitude: Double, longitude: Double): Intent {
return Intent(context, FakeLocationService::class.java).apply {
action = Actions.START_FAKE_LOCATION.name
putExtra(PARAM_ALTITUDE, altitude)
putExtra(PARAM_SPEED, speed)
+ putExtra(PARAM_BEARING, bearing)
putExtra(PARAM_JITTER, jitter)
+ putExtra(PARAM_JITTER_ALTITUDE, jitterAltitude)
+ putExtra(PARAM_JITTER_SPEED, jitterSpeed)
+ putExtra(PARAM_JITTER_BEARING, jitterBearing)
putExtra(PARAM_LATITUDE, latitude)
putExtra(PARAM_LONGITUDE, longitude)
}
@@ -81,7 +89,11 @@ class FakeLocationService : Service() {
private var altitude: Double? = null
private var speed: Float? = null
+ private var bearing: Float? = null
private var jitter: Float? = null
+ private var jitterAltitude: Double? = null
+ private var jitterSpeed: Float? = null
+ private var jitterBearing: Float? = null
private var fakeLocation: Pair<Double, Double>? = null
@@ -100,7 +112,11 @@ class FakeLocationService : Service() {
Actions.START_FAKE_LOCATION -> {
altitude = it.getDoubleExtra(PARAM_ALTITUDE, 3.0)
speed = it.getFloatExtra(PARAM_SPEED, 1.0f)
+ bearing = it.getFloatExtra(PARAM_BEARING, 0.0f)
jitter = it.getFloatExtra(PARAM_JITTER, 3.0f)
+ jitterAltitude = it.getDoubleExtra(PARAM_JITTER_ALTITUDE, 3.0)
+ jitterSpeed = it.getFloatExtra(PARAM_JITTER_SPEED, 0.1f)
+ jitterBearing = it.getFloatExtra(PARAM_JITTER_BEARING, 10.0f)
fakeLocation = Pair(
it.getDoubleExtra(PARAM_LATITUDE, 0.0),
it.getDoubleExtra(PARAM_LONGITUDE, 0.0)
@@ -131,14 +147,22 @@ class FakeLocationService : Service() {
override fun onTick(millisUntilFinished: Long) {
var altitude_buf: Double = altitude ?: return
var speed_buf: Float = speed ?: return
+ var bearing_buf: Float = bearing ?: return
var jitter_buf: Float = jitter ?: return
+ var jitterAltitude_buf: Double = jitterAltitude ?: return
+ var jitterSpeed_buf: Float = jitterSpeed ?: return
+ var jitterBearing_buf: Float = jitterBearing ?: return
var fakeLocation_buf: Pair<Double, Double> = fakeLocation ?: return
if(fakeLocation != null && altitude != null && speed != null && jitter != null) {
try {
fakeLocationModule.setTestProviderLocation(
- (altitude_buf + ((Random.nextFloat() * jitter_buf) - (jitter_buf * 0.5f))).toDouble(),
- speed_buf + ((Random.nextFloat() * jitter_buf) - (jitter_buf * 0.5f)),
+ (altitude_buf + ((Random.nextFloat() * jitterAltitude_buf) - (jitterAltitude_buf * 0.5f))).toDouble(),
+ speed_buf + ((Random.nextFloat() * jitterSpeed_buf) - (jitterSpeed_buf * 0.5f)),
+ bearing_buf + ((Random.nextFloat() * jitterBearing_buf) - (jitterBearing_buf * 0.5f)),
jitter_buf,
+ jitterAltitude_buf.toFloat(),
+ jitterSpeed_buf,
+ jitterBearing_buf,
(fakeLocation_buf.first + (((Random.nextFloat() * jitter_buf) - (jitter_buf * 0.5f)) / 111139.0f)).toDouble(),
(fakeLocation_buf.second + (((Random.nextFloat() * jitter_buf) - (jitter_buf * 0.5f)) / 111139.0f)).toDouble()
)
@@ -212,9 +236,13 @@ class FakeLocationService : Service() {
}
try {
fakeLocationModule.setTestProviderLocation(
- (coord.first.altitude + ((Random.nextFloat() * coord.first.jitter) - (coord.first.jitter * 0.5f))).toDouble(),
- coord.first.speed + ((Random.nextFloat() * coord.first.jitter) - (coord.first.jitter * 0.5f)),
+ (coord.first.altitude + ((Random.nextFloat() * coord.first.jitterAltitude) - (coord.first.jitterAltitude * 0.5f))).toDouble(),
+ coord.first.speed + ((Random.nextFloat() * coord.first.jitterSpeed) - (coord.first.jitterSpeed * 0.5f)),
+ coord.first.bearing + ((Random.nextFloat() * coord.first.jitterBearing) - (coord.first.jitterBearing * 0.5f)),
coord.first.jitter,
+ coord.first.jitterAltitude,
+ coord.first.jitterSpeed,
+ coord.first.jitterBearing,
(coord.second.first + (((Random.nextFloat() * coord.first.jitter) - (coord.first.jitter * 0.5f)) / 111139.0f)).toDouble(),
(coord.second.second + (((Random.nextFloat() * coord.first.jitter) - (coord.first.jitter * 0.5f)) / 111139.0f)).toDouble()
)