summaryrefslogtreecommitdiff
path: root/fakelocation
diff options
context:
space:
mode:
authorGuillaume Jacquart <guillaume.jacquart@hoodbrains.com>2022-11-06 18:19:17 +0000
committerGuillaume Jacquart <guillaume.jacquart@hoodbrains.com>2022-11-06 18:19:17 +0000
commit99b27efb59ba642bfca0c6fbabfaa2c6631e15b9 (patch)
treec55aed6119dff29a84d7120bedf88e2df1775597 /fakelocation
parent9701ef06a47560ca429f1e7fffd0958b376ec628 (diff)
parentfdeecefd34c00b225bd58f6cc7135a95e21728f1 (diff)
Merge branch '5561-name_the_vpn_already_running' into 'main'
5561: display name of other VPNrunning always on. See merge request e/os/advanced-privacy!96
Diffstat (limited to 'fakelocation')
-rw-r--r--fakelocation/fakelocationdemo/build.gradle2
-rw-r--r--fakelocation/fakelocationdemo/src/main/java/foundation/e/privacymodules/fakelocationdemo/MainActivity.kt29
-rw-r--r--fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationModule.kt12
-rw-r--r--fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationService.kt6
4 files changed, 25 insertions, 24 deletions
diff --git a/fakelocation/fakelocationdemo/build.gradle b/fakelocation/fakelocationdemo/build.gradle
index c182b2f..7e05b8a 100644
--- a/fakelocation/fakelocationdemo/build.gradle
+++ b/fakelocation/fakelocationdemo/build.gradle
@@ -68,4 +68,4 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
-} \ No newline at end of file
+}
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 1b0a35b..42cf658 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
@@ -58,7 +58,6 @@ class MainActivity : AppCompatActivity() {
)
}
-
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
@@ -79,7 +78,7 @@ class MainActivity : AppCompatActivity() {
binding.mockedLocation = mockedLocation
}
- private val listener = object: LocationListener {
+ private val listener = object : LocationListener {
override fun onLocationChanged(location: Location) {
binding.currentLocation = "lat: ${location.latitude} - lon: ${location.longitude}"
}
@@ -130,16 +129,19 @@ class MainActivity : AppCompatActivity() {
private val locationPermissionRequest = registerForActivityResult(
ActivityResultContracts.RequestMultiplePermissions()
) { permissions ->
- if (permissions.getOrDefault(Manifest.permission.ACCESS_FINE_LOCATION, false)
- || permissions.getOrDefault(Manifest.permission.ACCESS_COARSE_LOCATION, false)
+ if (permissions.getOrDefault(Manifest.permission.ACCESS_FINE_LOCATION, false) ||
+ permissions.getOrDefault(Manifest.permission.ACCESS_COARSE_LOCATION, false)
) {
startLocationUpdates()
}
}
private fun requireLocationPermissions() {
- if (ContextCompat.checkSelfPermission(this,
- Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
+ if (ContextCompat.checkSelfPermission(
+ this,
+ Manifest.permission.ACCESS_COARSE_LOCATION
+ ) == PackageManager.PERMISSION_GRANTED
+ ) {
startLocationUpdates()
} else {
// Before you perform the actual permission request, check whether your app
@@ -152,19 +154,20 @@ class MainActivity : AppCompatActivity() {
)
)
}
-
}
@Suppress("UNUSED_PARAMETER")
fun onClickPermission(view: View?) {
- val isGranted = permissionsModule.setAppOpMode(appDesc, AppOpsManager.OPSTR_MOCK_LOCATION,
- AppOpModes.ALLOWED)
+ val isGranted = permissionsModule.setAppOpMode(
+ appDesc, AppOpsManager.OPSTR_MOCK_LOCATION,
+ AppOpModes.ALLOWED
+ )
if (isGranted) {
updateData("")
return
}
- //dev mode disabled
+ // dev mode disabled
val alertDialog = AlertDialog.Builder(this)
alertDialog
.setTitle("Mock location disabled")
@@ -177,7 +180,7 @@ class MainActivity : AppCompatActivity() {
fun onClickReset(view: View?) {
try {
fakeLocationModule.stopFakeLocation()
- } catch(e: Exception) {
+ } catch (e: Exception) {
Log.e(TAG, "Can't stop FakeLocation", e)
}
}
@@ -185,11 +188,11 @@ class MainActivity : AppCompatActivity() {
private fun setFakeLocation(latitude: Double, longitude: Double) {
try {
fakeLocationModule.startFakeLocation()
- } catch(e: Exception) {
+ } catch (e: Exception) {
Log.e(TAG, "Can't startFakeLocation", e)
}
fakeLocationModule.setFakeLocation(latitude, longitude)
- updateData("lat: ${latitude} - lon: ${longitude}")
+ updateData("lat: $latitude - lon: $longitude")
}
@Suppress("UNUSED_PARAMETER")
diff --git a/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationModule.kt b/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationModule.kt
index 709963d..4245836 100644
--- a/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationModule.kt
+++ b/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationModule.kt
@@ -34,7 +34,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) : IFakeLocationModule {
companion object {
private const val TAG = "FakeLocationModule"
}
@@ -60,11 +60,10 @@ class FakeLocationModule(private val context: Context): IFakeLocationModule {
providers.forEach { provider ->
try {
locationManager.removeTestProvider(provider)
- } catch(e: Exception) {
+ } catch (e: Exception) {
Log.w(TAG, "Test provider $provider already removed.")
}
-
locationManager.addTestProvider(
provider,
false,
@@ -75,12 +74,13 @@ class FakeLocationModule(private val context: Context): IFakeLocationModule {
true,
true,
ProviderProperties.POWER_USAGE_LOW,
- ProviderProperties.ACCURACY_FINE)
+ ProviderProperties.ACCURACY_FINE
+ )
try {
locationManager.setTestProviderEnabled(provider, true)
} catch (e: Exception) {
- Log.e(TAG, "Can't enable test $provider", e)
- }
+ Log.e(TAG, "Can't enable test $provider", e)
+ }
}
}
diff --git a/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationService.kt b/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationService.kt
index 1337ddd..34620fe 100644
--- a/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationService.kt
+++ b/fakelocation/src/main/java/foundation/e/privacymodules/fakelocation/FakeLocationService.kt
@@ -17,7 +17,6 @@
package foundation.e.privacymodules.fakelocation
-
import android.app.Service
import android.content.Context
import android.content.Intent
@@ -25,7 +24,7 @@ import android.os.CountDownTimer
import android.os.IBinder
import android.util.Log
-class FakeLocationService: Service() {
+class FakeLocationService : Service() {
enum class Actions {
START_FAKE_LOCATION
@@ -83,10 +82,9 @@ class FakeLocationService: Service() {
super.onDestroy()
}
-
private fun initTimer() {
countDownTimer?.cancel()
- countDownTimer = object: CountDownTimer(PERIOD_UPDATES_SERIE, PERIOD_LOCATION_UPDATE) {
+ countDownTimer = object : CountDownTimer(PERIOD_UPDATES_SERIE, PERIOD_LOCATION_UPDATE) {
override fun onTick(millisUntilFinished: Long) {
fakeLocation?.let {
try {