From 4e0a3a7967be34a4b2c3ff03ec5b42072d45002d Mon Sep 17 00:00:00 2001 From: Seweryn Fornalik Date: Tue, 11 May 2021 20:16:42 +0200 Subject: Try to force real location (failed) --- app/src/main/AndroidManifest.xml | 7 +++++++ .../features/location/FakeLocationFeature.kt | 2 +- .../features/location/FakeLocationFragment.kt | 1 + .../features/location/LocationApiDelegate.kt | 19 +++++++++++++++++++ privacymodulesapi/privacymodulesapi-debug.aar | Bin 34047 -> 34149 bytes 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 74c226c..5fe282d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,9 +1,16 @@ + + { - action.locationApiDelegate.stopFakeLocation() + action.locationApiDelegate.startRealLocation() val success = DummyDataSource.setLocationMode(LocationMode.REAL_LOCATION) if (success) { flowOf( diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt index ff15e31..c11a7ea 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/location/FakeLocationFragment.kt @@ -185,6 +185,7 @@ class FakeLocationFragment : } } } + locationApiDelegate.startRealLocation() } override fun onAttach(context: Context) { diff --git a/app/src/main/java/foundation/e/privacycentralapp/features/location/LocationApiDelegate.kt b/app/src/main/java/foundation/e/privacycentralapp/features/location/LocationApiDelegate.kt index efacae2..dd2e5c1 100644 --- a/app/src/main/java/foundation/e/privacycentralapp/features/location/LocationApiDelegate.kt +++ b/app/src/main/java/foundation/e/privacycentralapp/features/location/LocationApiDelegate.kt @@ -50,6 +50,10 @@ class LocationApiDelegate( fun stopFakeLocation() { try { + permissionsModule.setAppOpMode( + appDesc, AppOpsManager.OPSTR_MOCK_LOCATION, + AppOpModes.IGNORED + ) permissionsModule.setAppOpMode( appDesc, AppOpsManager.OPSTR_MOCK_LOCATION, AppOpModes.IGNORED @@ -59,4 +63,19 @@ class LocationApiDelegate( Log.e(TAG, "Can't stop FakeLocation", e) } } + fun startRealLocation() { + stopFakeLocation() + try { + permissionsModule.setAppOpMode( + appDesc, AppOpsManager.OPSTR_COARSE_LOCATION, + AppOpModes.ALLOWED + ) + permissionsModule.setAppOpMode( + appDesc, AppOpsManager.OPSTR_FINE_LOCATION, + AppOpModes.ALLOWED + ) + } catch (e: Exception) { + Log.e(TAG, "Can't start RealLocation", e) + } + } } diff --git a/privacymodulesapi/privacymodulesapi-debug.aar b/privacymodulesapi/privacymodulesapi-debug.aar index 7a6609a..233eb30 100644 Binary files a/privacymodulesapi/privacymodulesapi-debug.aar and b/privacymodulesapi/privacymodulesapi-debug.aar differ -- cgit v1.2.1