diff --git a/fakelocation/fakelocationdemo/.gitignore b/fakelocation/fakelocationdemo/.gitignore deleted file mode 100644 index 42afabfd2abebf31384ca7797186a27a4b7dbee8..0000000000000000000000000000000000000000 --- a/fakelocation/fakelocationdemo/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/fakelocation/fakelocationdemo/build.gradle b/fakelocation/fakelocationdemo/build.gradle deleted file mode 100644 index 49b4c3a3bc238b212a78cad7ffd122e53ae9971e..0000000000000000000000000000000000000000 --- a/fakelocation/fakelocationdemo/build.gradle +++ /dev/null @@ -1,70 +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 . - */ - -plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' -} - -android { - compileSdkVersion buildConfig.compileSdk - - defaultConfig { - applicationId "foundation.e.privacymodules.fakelocationdemo" - minSdkVersion buildConfig.minSdk - targetSdkVersion buildConfig.targetSdk - - versionCode buildConfig.version.code - versionName buildConfig.version.name - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = '17' - allWarningsAsErrors = false - } - buildFeatures { - dataBinding true - } - namespace 'foundation.e.privacymodules.fakelocationdemo' -} - -dependencies { - implementation project(':core') - implementation project(':fakelocation') - implementation project(':permissionsstandalone') - - - implementation ( - libs.androidx.core.ktx, - libs.androidx.appcompat, - libs.google.material, - ) - testImplementation libs.junit - -} diff --git a/fakelocation/fakelocationdemo/proguard-rules.pro b/fakelocation/fakelocationdemo/proguard-rules.pro deleted file mode 100644 index 481bb434814107eb79d7a30b676d344b0df2f8ce..0000000000000000000000000000000000000000 --- a/fakelocation/fakelocationdemo/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/fakelocation/fakelocationdemo/src/main/AndroidManifest.xml b/fakelocation/fakelocationdemo/src/main/AndroidManifest.xml deleted file mode 100644 index a832d59b8402a380f29f18659985fb9114f4136f..0000000000000000000000000000000000000000 --- a/fakelocation/fakelocationdemo/src/main/AndroidManifest.xml +++ /dev/null @@ -1,41 +0,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 deleted file mode 100644 index 78543e61263356509fd83c13793d433bc358f753..0000000000000000000000000000000000000000 --- a/fakelocation/fakelocationdemo/src/main/java/foundation/e/privacymodules/fakelocationdemo/MainActivity.kt +++ /dev/null @@ -1,217 +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 . - */ - -package foundation.e.privacymodules.fakelocationdemo - -import android.Manifest -import android.app.AppOpsManager -import android.content.Context -import android.content.pm.PackageManager -import android.location.Location -import android.location.LocationListener -import android.location.LocationManager -import android.os.Bundle -import android.os.Process.myUid -import android.util.Log -import android.view.View -import androidx.activity.result.contract.ActivityResultContracts -import androidx.appcompat.app.AlertDialog -import androidx.appcompat.app.AppCompatActivity -import androidx.core.content.ContextCompat -import androidx.databinding.DataBindingUtil -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.PermissionsPrivacyModuleImpl -import foundation.e.privacymodules.fakelocationdemo.databinding.ActivityMainBinding - -class MainActivity : AppCompatActivity() { - companion object { - const val TAG = "fakeLoc" - } - - private val fakeLocationModule: FakeLocationModule by lazy { FakeLocationModule(this) } - private val permissionsModule by lazy { PermissionsPrivacyModuleImpl(this) } - - private lateinit var binding: ActivityMainBinding - - private val appDesc by lazy { - ApplicationDescription( - packageName = packageName, - uid = myUid(), - label = getString(R.string.app_name), - icon = null, - profileId = 0, - profileType = ProfileType.MAIN - ) - } - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - binding = DataBindingUtil.setContentView(this, R.layout.activity_main) - - actionBar?.setDisplayHomeAsUpEnabled(true) - - binding.view = this - } - - override fun onResume() { - super.onResume() - updateData("") - } - - private fun updateData(mockedLocation: String) { - binding.granted = permissionsModule.getAppOpMode(appDesc, AppOpsManager.OPSTR_MOCK_LOCATION) == AppOpModes.ALLOWED - - binding.mockedLocation = mockedLocation - } - - private val listener = object : LocationListener { - override fun onLocationChanged(location: Location) { - binding.currentLocation = "lat: ${location.latitude} - lon: ${location.longitude}" - } - - @Deprecated("Deprecated since API 29, never called.") - override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) { - TODO("Not yet implemented") - } - - override fun onProviderEnabled(provider: String) { - binding.providerInfo = "onProdivderEnabled: $provider" - } - - override fun onProviderDisabled(provider: String) { - binding.providerInfo = "onProdivderDisabled: $provider" - } - } - - @Suppress("UNUSED_PARAMETER") - fun onClickToggleListenLocation(view: View?) { - val locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager - - if (binding.toggleListenLocation.isChecked) { - requireLocationPermissions() - return - } - - locationManager.removeUpdates(listener) - binding.currentLocation = "no listening" - } - - private fun startLocationUpdates() { - val locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager - - try { - Log.d(TAG, "requestLocationUpdates") - locationManager.requestLocationUpdates( - LocationManager.GPS_PROVIDER, // TODO: tight this with fakelocation module. - 1000L, - 1f, - listener - ) - binding.currentLocation = "listening started" - } catch (se: SecurityException) { - Log.e(TAG, "Missing permission", se) - } - } - - private val locationPermissionRequest = registerForActivityResult( - ActivityResultContracts.RequestMultiplePermissions() - ) { permissions -> - 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 - ) { - startLocationUpdates() - } else { - // Before you perform the actual permission request, check whether your app - // already has the permissions, and whether your app needs to show a permission - // rationale dialog. For more details, see Request permissions. - locationPermissionRequest.launch( - arrayOf( - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.ACCESS_COARSE_LOCATION - ) - ) - } - } - - @Suppress("UNUSED_PARAMETER") - fun onClickPermission(view: View?) { - val isGranted = permissionsModule.setAppOpMode( - appDesc, - AppOpsManager.OPSTR_MOCK_LOCATION, - AppOpModes.ALLOWED - ) - - if (isGranted) { - updateData("") - return - } - // dev mode disabled - val alertDialog = AlertDialog.Builder(this) - alertDialog - .setTitle("Mock location disabled") - .setNegativeButton("Cancel") { _, _ -> - } - alertDialog.create().show() - } - - @Suppress("UNUSED_PARAMETER") - fun onClickReset(view: View?) { - try { - fakeLocationModule.stopFakeLocation() - } catch (e: Exception) { - Log.e(TAG, "Can't stop FakeLocation", e) - } - } - - private fun setFakeLocation(latitude: Double, longitude: Double) { - try { - fakeLocationModule.startFakeLocation() - } catch (e: Exception) { - Log.e(TAG, "Can't startFakeLocation", e) - } - fakeLocationModule.setFakeLocation(latitude, longitude) - updateData("lat: $latitude - lon: $longitude") - } - - @Suppress("UNUSED_PARAMETER") - fun onClickParis(view: View?) { - setFakeLocation(48.8502282, 2.3542286) - } - - @Suppress("UNUSED_PARAMETER") - fun onClickLondon(view: View?) { - setFakeLocation(51.5287718, -0.2416803) - } - - @Suppress("UNUSED_PARAMETER") - fun onClickAmsterdam(view: View?) { - setFakeLocation(52.3547498, 4.8339211) - } -} diff --git a/fakelocation/fakelocationdemo/src/main/res/layout/activity_main.xml b/fakelocation/fakelocationdemo/src/main/res/layout/activity_main.xml deleted file mode 100644 index 33fce699a4bc61e33b29f66650f19e19d290445c..0000000000000000000000000000000000000000 --- a/fakelocation/fakelocationdemo/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - - - - - - - - - -