├── app ├── .gitignore ├── src │ └── main │ │ ├── assets │ │ └── xposed_init │ │ ├── res │ │ ├── drawable │ │ │ ├── avatar_pie.png │ │ │ ├── baseline_error_24.xml │ │ │ ├── baseline_info_24.xml │ │ │ ├── baseline_check_circle_24.xml │ │ │ ├── baseline_radio_button_unchecked_24.xml │ │ │ ├── baseline_credit_score_24.xml │ │ │ ├── baseline_search_24.xml │ │ │ ├── baseline_my_location_24.xml │ │ │ └── baseline_settings_20.xml │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ ├── values │ │ │ ├── arrays.xml │ │ │ ├── dimens.xml │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── layout │ │ │ ├── activity_about.xml │ │ │ └── activity_main.xml │ │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── thepiemonster │ │ │ └── hidemocklocation │ │ │ ├── AboutActivity.java │ │ │ ├── Common.java │ │ │ ├── XposedModule.java │ │ │ ├── GPSJoystickFixer.java │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml ├── libs_compile_only │ ├── api-82.jar │ └── api-82-sources.jar ├── keystore │ └── hide_mock_location.keystore ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── README.md ├── .gitignore ├── gradlew.bat ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /app/src/main/assets/xposed_init: -------------------------------------------------------------------------------- 1 | com.github.thepiemonster.hidemocklocation.XposedModule -------------------------------------------------------------------------------- /app/libs_compile_only/api-82.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotionbug/HideMockLocation/HEAD/app/libs_compile_only/api-82.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotionbug/HideMockLocation/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/keystore/hide_mock_location.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotionbug/HideMockLocation/HEAD/app/keystore/hide_mock_location.keystore -------------------------------------------------------------------------------- /app/libs_compile_only/api-82-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotionbug/HideMockLocation/HEAD/app/libs_compile_only/api-82-sources.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/avatar_pie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotionbug/HideMockLocation/HEAD/app/src/main/res/drawable/avatar_pie.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotionbug/HideMockLocation/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotionbug/HideMockLocation/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotionbug/HideMockLocation/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotionbug/HideMockLocation/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotionbug/HideMockLocation/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | android 5 | 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Feb 18 00:14:02 CST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/thepiemonster/hidemocklocation/AboutActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.thepiemonster.hidemocklocation; 2 | 3 | import androidx.appcompat.app.AppCompatActivity; 4 | 5 | import android.os.Bundle; 6 | 7 | public class AboutActivity extends AppCompatActivity { 8 | 9 | @Override 10 | protected void onCreate(Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.activity_about); 13 | } 14 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_error_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_info_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_check_circle_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_radio_button_unchecked_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_credit_score_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_search_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/thepiemonster/hidemocklocation/Common.java: -------------------------------------------------------------------------------- 1 | package com.github.thepiemonster.hidemocklocation; 2 | 3 | import android.annotation.SuppressLint; 4 | 5 | import de.robv.android.xposed.callbacks.XC_LoadPackage; 6 | 7 | public class Common { 8 | public static final String GMS_MOCK_KEY = "mockLocation"; // FusedLocationProviderApi.KEY_MOCK_LOCATION 9 | 10 | 11 | @SuppressLint("PrivateApi") 12 | public static Class loadClassIfExist(XC_LoadPackage.LoadPackageParam lpparam, String name) { 13 | try { 14 | return lpparam.classLoader.loadClass(name); 15 | } catch (ClassNotFoundException e) { 16 | return null; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Android/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_my_location_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #ff80ab 6 | #757575 7 | @color/colorAccent 8 | #FFBB86FC 9 | #FF6200EE 10 | #FF3700B3 11 | #F44336 12 | #FF03DAC5 13 | #FF018786 14 | #FF000000 15 | #FFFFFFFF 16 | #EEEEEE 17 | 18 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | android.enableJetifier=true 20 | android.useAndroidX=true 21 | org.gradle.unsafe.configuration-cache=true -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hide Mock Location 2 | Main Repo 3 | 4 | [![Release](https://img.shields.io/github/v/release/emotionbug/HideMockLocation?label=Release)](https://github.com/emotionbug/HideMockLocation/releases/latest) 5 | [![Download](https://img.shields.io/github/downloads/emotionbug/HideMockLocation/total)](https://github.com/emotionbug/HideMockLocation/releases/latest) 6 | 7 | ## Summary 8 | ![Logo](app/src/main/res/mipmap-xhdpi/ic_launcher.png) 9 | 10 | Hide Mock Location is an Xposed Module (now LSPosed on Android 11), which hides information 11 | about the 'Allow mock locations' setting on A12+ Devices. 12 | 13 | ## Usage 14 | * Install module to your device. 15 | * Enable module in LSPosed and reboot device. 16 | * System Framework 17 | * Target App 18 | * That's it! You can open Hide Mock Location and view the "Test Location Data" page to view the status of the mock location setting. 19 | 20 | ## Tips 21 | * You can view the "Test Location Data" page without enabling the module in LSPosed. 22 | * Try enabling a mock location application before and after enabling the LSPosed module to view different output settings. 23 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/baseline_settings_20.xml: -------------------------------------------------------------------------------- 1 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 20 | 21 | 25 | 26 | 32 | 33 | 37 | 38 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdk 33 7 | 8 | defaultConfig { 9 | applicationId "com.github.thepiemonster.hidemocklocation" 10 | minSdk 29 11 | targetSdk 33 12 | versionCode 214 13 | versionName "2.1.4" 14 | } 15 | 16 | signingConfigs { 17 | release { 18 | storeFile = file("keystore/hide_mock_location.keystore") 19 | storePassword System.getenv("SIGNING_STORE_PASSWORD") 20 | keyAlias System.getenv("SIGNING_KEY_ALIAS") 21 | keyPassword System.getenv("SIGNING_KEY_PASSWORD") 22 | } 23 | } 24 | 25 | buildTypes { 26 | debug { 27 | debuggable true 28 | } 29 | release { 30 | minifyEnabled false 31 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 32 | signingConfig signingConfigs.release 33 | } 34 | } 35 | 36 | dataBinding { 37 | enabled true 38 | } 39 | 40 | buildFeatures { 41 | viewBinding true 42 | } 43 | namespace 'com.github.thepiemonster.hidemocklocation' 44 | } 45 | 46 | dependencies { 47 | implementation fileTree(include: ['*.jar'], dir: 'libs') 48 | compileOnly fileTree(include: ['*.jar'], dir: 'libs_compile_only') 49 | 50 | implementation 'androidx.appcompat:appcompat:1.6.1' 51 | implementation 'androidx.recyclerview:recyclerview:1.3.0' 52 | implementation 'com.google.gms:google-services:4.3.15' 53 | implementation 'com.google.android.material:material:1.9.0-alpha02' 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 15 | 16 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 32 | 35 | 38 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/android,intellij 2 | 3 | ### Android ### 4 | # Built application files 5 | *.apk 6 | *.ap_ 7 | 8 | # Files for the ART/Dalvik VM 9 | *.dex 10 | 11 | # Java class files 12 | *.class 13 | 14 | # Generated files 15 | bin/ 16 | gen/ 17 | out/ 18 | 19 | # Gradle files 20 | .gradle/ 21 | build/ 22 | 23 | # Local configuration file (sdk path, etc) 24 | local.properties 25 | 26 | # Proguard folder generated by Eclipse 27 | proguard/ 28 | 29 | # Log Files 30 | *.log 31 | 32 | # Android Studio Navigation editor temp files 33 | .navigation/ 34 | 35 | # Android Studio captures folder 36 | captures/ 37 | 38 | # Intellij 39 | *.iml 40 | .idea/* 41 | .idea/workspace.xml 42 | .idea/libraries 43 | 44 | # Keystore files 45 | #*.jks 46 | 47 | ### Android Patch ### 48 | gen-external-apklibs 49 | 50 | 51 | ### Intellij ### 52 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 53 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 54 | 55 | # User-specific stuff: 56 | .idea/workspace.xml 57 | .idea/tasks.xml 58 | .idea/dictionaries 59 | .idea/vcs.xml 60 | .idea/jsLibraryMappings.xml 61 | 62 | # Sensitive or high-churn files: 63 | .idea/dataSources.ids 64 | .idea/dataSources.xml 65 | .idea/dataSources.local.xml 66 | .idea/sqlDataSources.xml 67 | .idea/dynamic.xml 68 | .idea/uiDesigner.xml 69 | 70 | # Gradle: 71 | .idea/gradle.xml 72 | .idea/libraries 73 | 74 | # Mongo Explorer plugin: 75 | .idea/mongoSettings.xml 76 | 77 | ## File-based project format: 78 | *.iws 79 | 80 | ## Plugin-specific files: 81 | 82 | # IntelliJ 83 | /out/ 84 | 85 | # mpeltonen/sbt-idea plugin 86 | .idea_modules/ 87 | 88 | # JIRA plugin 89 | atlassian-ide-plugin.xml 90 | 91 | # Crashlytics plugin (for Android Studio and IntelliJ) 92 | com_crashlytics_export_strings.xml 93 | crashlytics.properties 94 | crashlytics-build.properties 95 | fabric.properties 96 | 97 | ### Intellij Patch ### 98 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 99 | 100 | # *.iml 101 | # modules.xml 102 | # .idea/misc.xml 103 | # *.ipr 104 | 105 | # Misc 106 | *.zip 107 | /app/release/* 108 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Hide Mock Location 3 | Donate 4 | Hide Mock Location is disabled. 5 | To use it, please enable module in LSPosed and reboot device. Make sure that the module is installed on internal storage. 6 | https://www.paypal.com/ 7 | Search 8 | Icon 9 | Settings 10 | General 11 | Show app icon in launcher 12 | Whitelist Google Play Services 13 | When unchecked, some whitelisted apps may not see that location is mocked. 14 | 15 | Select Apps 16 | 17 | View Location Data 18 | Location whitelist 19 | Settings 20 | About this module 21 | 22 | Not activated 23 | Make sure you have correctly set up this module 24 | 25 | Activated 26 | View Location Data to test module 27 | Served for 0 times 28 | 29 | Not available 30 | Coming soon :) 31 | 32 | About This Module 33 | About 34 | This module is designed to hide the use of the Android Mock Locations feature from system and application usage. When this module is enabled, the mock locations feature will show as disabled to all applications. \n\nhttps://github.com/ThePieMonster/HideMockLocation 35 | 36 | Legal 37 | You agree to use this module (i.e. Hide Mock Locations) only for legally compliant purposes. You agree that the author will not be held liable for any consequences resulting from a violation of this statement. \n\nBy continuing to use this module, you agree to the above terms. 38 | 39 | Recommendations 40 | 41 | Developers & Contributors 42 | 43 | ThePieMonster 44 | Lead developer 45 | https://github.com/ThePieMonster 46 | 47 | Open Source Licenses 48 | No result 49 | 50 | Location Data 51 | Ok 52 | Close 53 | 54 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 21 | 22 | 25 | 26 | 27 | 31 | 32 | 38 | 39 | 45 | 46 | 47 | 51 | 52 | 61 | 62 | 72 | 73 | 80 | 81 | 85 | 86 | 92 | 93 | 96 | 97 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 36 | 37 | 44 | 45 | 52 | 53 | 61 | 62 | 69 | 70 | 71 | 72 | 73 | 74 | 78 | 79 | 82 | 83 | 86 | 87 | 90 | 91 | 92 | 93 | 97 | 98 | 101 | 102 | 105 | 106 | 109 | 110 | 111 | 112 | 113 | 114 | 119 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/thepiemonster/hidemocklocation/XposedModule.java: -------------------------------------------------------------------------------- 1 | package com.github.thepiemonster.hidemocklocation; 2 | 3 | import static com.github.thepiemonster.hidemocklocation.Common.loadClassIfExist; 4 | 5 | import android.annotation.SuppressLint; 6 | import android.app.Activity; 7 | import android.location.Location; 8 | import android.os.Build; 9 | import android.os.Bundle; 10 | 11 | import java.lang.reflect.Method; 12 | 13 | import de.robv.android.xposed.IXposedHookLoadPackage; 14 | import de.robv.android.xposed.IXposedHookZygoteInit; 15 | import de.robv.android.xposed.XC_MethodHook; 16 | import de.robv.android.xposed.XposedBridge; 17 | import de.robv.android.xposed.XposedHelpers; 18 | import de.robv.android.xposed.callbacks.XC_LoadPackage; 19 | 20 | 21 | public class XposedModule implements IXposedHookZygoteInit, IXposedHookLoadPackage { 22 | 23 | public XC_MethodHook hideMockProviderHook; 24 | public XC_MethodHook hideMockGooglePlayServicesHook; 25 | 26 | @Override 27 | public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) { 28 | if (lpparam == null) { 29 | return; 30 | } 31 | 32 | if (lpparam.packageName.equals("android")) { 33 | //// // First way 34 | // Class GnssNativeCls = loadClassIfExist(lpparam, "com.android.server.location.gnss.hal.GnssNative"); 35 | // if (GnssNativeCls == null) { 36 | // // Android < 12 37 | // GnssNativeCls = loadClassIfExist(lpparam, "com.android.server.location.gnss.GnssNative"); 38 | // } 39 | // if (GnssNativeCls != null) { 40 | // Method GnssNativeCls_isSupported = XposedHelpers.findMethodExactIfExists(GnssNativeCls, "isSupported"); 41 | // if (GnssNativeCls_isSupported != null) { 42 | // XposedBridge.hookMethod(GnssNativeCls_isSupported, new XC_MethodHook() { 43 | // @Override 44 | // protected void beforeHookedMethod(MethodHookParam param) { 45 | // param.setResult(false); 46 | // } 47 | // }); 48 | // } 49 | // } 50 | 51 | // Second way 52 | Class GnssLocationProviderCls = loadClassIfExist(lpparam, "com.android.server.location.gnss.GnssLocationProvider"); 53 | if (GnssLocationProviderCls == null) { 54 | // Android < 12 55 | GnssLocationProviderCls = loadClassIfExist(lpparam, "com.android.server.location.GnssLocationProvider"); 56 | } 57 | 58 | if (GnssLocationProviderCls != null) { 59 | Method handleRequestLocation = XposedHelpers.findMethodExactIfExists(GnssLocationProviderCls, "handleRequestLocation", boolean.class, boolean.class); 60 | Method handleReportLocation = XposedHelpers.findMethodExactIfExists(GnssLocationProviderCls, "handleReportLocation", boolean.class, Location.class); 61 | 62 | if (handleRequestLocation != null) { 63 | XposedBridge.hookMethod(handleRequestLocation, new XC_MethodHook() { 64 | @Override 65 | protected void beforeHookedMethod(MethodHookParam param) { 66 | param.setResult(null); 67 | } 68 | }); 69 | } 70 | if (handleReportLocation != null) { 71 | XposedBridge.hookMethod(handleReportLocation, new XC_MethodHook() { 72 | @Override 73 | protected void beforeHookedMethod(MethodHookParam param) { 74 | param.setResult(null); 75 | } 76 | }); 77 | } 78 | } 79 | } else if (!GPSJoystickFixer.tryFixJoystickApp(lpparam)) { 80 | handleLoadPackageForApps(lpparam); 81 | tryHideSamsungIAPDialog(lpparam); 82 | } 83 | } 84 | 85 | private void tryHideSamsungIAPDialog(XC_LoadPackage.LoadPackageParam lpparam) { 86 | Class SamsungIAPHelperUtil = loadClassIfExist(lpparam, "com.samsung.android.sdk.iap.lib.helper.HelperUtil"); 87 | if (SamsungIAPHelperUtil == null) 88 | return; 89 | Method showUpdateGalaxyStoreDialog = XposedHelpers.findMethodExactIfExists(SamsungIAPHelperUtil, 90 | "showUpdateGalaxyStoreDialog", 91 | Activity.class); 92 | if (showUpdateGalaxyStoreDialog == null) 93 | return; 94 | 95 | XposedBridge.hookMethod(showUpdateGalaxyStoreDialog, new XC_MethodHook() { 96 | @Override 97 | protected void beforeHookedMethod(MethodHookParam param) { 98 | try { 99 | Activity activity = (Activity) param.args[0]; 100 | activity.finish(); 101 | param.setResult(null); 102 | } catch (Exception e) { 103 | // do nothing. 104 | } 105 | } 106 | }); 107 | } 108 | 109 | @SuppressLint("ObsoleteSdkInt") 110 | private void handleLoadPackageForApps(XC_LoadPackage.LoadPackageParam lpparam) { 111 | // Additional info - not implemented - probably will not be implemented in future: 112 | // 113 | // There is one more method - getUriFor. Its returned value can be used 114 | // to listen for setting changes, without getting any settings values. 115 | // (Low risk of checking something only with this way) 116 | 117 | // Google Play Services 118 | XposedHelpers.findAndHookMethod("android.location.Location", lpparam.classLoader, "getExtras", hideMockGooglePlayServicesHook); 119 | 120 | // New way of checking if location is mocked, SDK 18+ 121 | // deprecated in API level 31 122 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) 123 | XposedHelpers.findAndHookMethod("android.location.Location", lpparam.classLoader, "isFromMockProvider", hideMockProviderHook); 124 | 125 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) 126 | XposedHelpers.findAndHookMethod("android.location.Location", lpparam.classLoader, "isMock", hideMockProviderHook); 127 | } 128 | 129 | @Override 130 | public void initZygote(StartupParam startupParam) { 131 | hideMockProviderHook = new XC_MethodHook() { 132 | @Override 133 | protected void beforeHookedMethod(MethodHookParam param) { 134 | param.setResult(false); 135 | } 136 | }; 137 | 138 | hideMockGooglePlayServicesHook = new XC_MethodHook() { 139 | @Override 140 | protected void afterHookedMethod(MethodHookParam param) { 141 | Bundle extras = (Bundle) param.getResult(); 142 | if (extras != null && extras.getBoolean(Common.GMS_MOCK_KEY)) 143 | extras.putBoolean(Common.GMS_MOCK_KEY, false); 144 | param.setResult(extras); 145 | 146 | } 147 | }; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/thepiemonster/hidemocklocation/GPSJoystickFixer.java: -------------------------------------------------------------------------------- 1 | package com.github.thepiemonster.hidemocklocation; 2 | 3 | import static com.github.thepiemonster.hidemocklocation.Common.loadClassIfExist; 4 | 5 | import android.app.Service; 6 | import android.location.LocationManager; 7 | 8 | import java.lang.reflect.InvocationTargetException; 9 | import java.lang.reflect.Method; 10 | import java.util.List; 11 | 12 | import de.robv.android.xposed.XC_MethodHook; 13 | import de.robv.android.xposed.XposedBridge; 14 | import de.robv.android.xposed.XposedHelpers; 15 | import de.robv.android.xposed.callbacks.XC_LoadPackage; 16 | 17 | public class GPSJoystickFixer { 18 | 19 | // makes not kill process. but, joystick app uses for terminate threading. 20 | static boolean fixService(XC_LoadPackage.LoadPackageParam lpparam) { 21 | String packageName = lpparam.packageName; 22 | Class joystick_MapOverlayService = loadClassIfExist(lpparam, packageName + ".service.MapOverlayService"); 23 | Class joystick_OverlayService = loadClassIfExist(lpparam, packageName + ".service.OverlayService"); 24 | if (joystick_MapOverlayService != null && joystick_OverlayService != null) { 25 | Method joystick_MapOverlayService_onDestroy = XposedHelpers.findMethodExactIfExists( 26 | joystick_MapOverlayService, 27 | "onDestroy" 28 | ); 29 | Method joystick_OverlayService_onDestroy = XposedHelpers.findMethodExactIfExists( 30 | joystick_OverlayService, 31 | "onDestroy" 32 | ); 33 | if (joystick_MapOverlayService_onDestroy != null) { 34 | XposedBridge.hookMethod(joystick_MapOverlayService_onDestroy, new XC_MethodHook() { 35 | @Override 36 | protected void beforeHookedMethod(MethodHookParam param) { 37 | Service thisObject = (Service) param.thisObject; 38 | Method _internalDestroyMethod = XposedHelpers.findMethodExactIfExists( 39 | thisObject.getClass(), 40 | // 4.3.2 41 | "p" 42 | ); 43 | if (_internalDestroyMethod != null) { 44 | try { 45 | _internalDestroyMethod.invoke(thisObject); 46 | param.setResult(null); 47 | } catch (IllegalAccessException | InvocationTargetException e) { 48 | // do nothing. 49 | } 50 | } else { 51 | XposedBridge.log("Failed to call internal destroy method(Joystick@MapOverlayService)"); 52 | } 53 | } 54 | }); 55 | } 56 | 57 | if (joystick_OverlayService_onDestroy != null) { 58 | XposedBridge.hookMethod(joystick_OverlayService_onDestroy, new XC_MethodHook() { 59 | @Override 60 | protected void beforeHookedMethod(MethodHookParam param) { 61 | Service thisObject = (Service) param.thisObject; 62 | Method _internalDestroyMethod = XposedHelpers.findMethodExactIfExists( 63 | thisObject.getClass(), 64 | // 4.3.2 65 | "D" 66 | ); 67 | if (_internalDestroyMethod != null) { 68 | try { 69 | _internalDestroyMethod.invoke(thisObject); 70 | param.setResult(null); 71 | } catch (IllegalAccessException | InvocationTargetException e) { 72 | // do nothing. 73 | } 74 | } else { 75 | XposedBridge.log("Failed to call internal destroy method(Joystick2OverlayService)"); 76 | } 77 | } 78 | }); 79 | } 80 | XposedBridge.log("fixService()"); 81 | return true; 82 | } 83 | return false; 84 | } 85 | 86 | static boolean isJoystickApp(XC_LoadPackage.LoadPackageParam lpparam) { 87 | String packageName = lpparam.packageName; 88 | Class joystick_MapOverlayService = loadClassIfExist(lpparam, packageName + ".service.MapOverlayService"); 89 | Class joystick_OverlayService = loadClassIfExist(lpparam, packageName + ".service.OverlayService"); 90 | return joystick_MapOverlayService != null && joystick_OverlayService != null; 91 | } 92 | 93 | static boolean fixTestProviderUpdates(XC_LoadPackage.LoadPackageParam lpparam) { 94 | String packageName = lpparam.packageName; 95 | if (!isJoystickApp(lpparam)) 96 | return false; 97 | Class joystick_MockLocationManager = loadClassIfExist(lpparam, packageName + ".b.u"); 98 | if (joystick_MockLocationManager != null) { 99 | Method updateLocationMethod = XposedHelpers.findMethodExactIfExists(joystick_MockLocationManager, 100 | "a", 101 | double.class, // d 102 | double.class, // d2 103 | double.class, // d3 104 | float.class, // f 105 | boolean.class, // z 106 | float.class, // f2 107 | float.class, // f3 108 | boolean.class // z2 109 | 110 | ); 111 | Method addTestProviderMethod = XposedHelpers.findMethodExactIfExists(joystick_MockLocationManager, 112 | "b" 113 | ); 114 | 115 | if (addTestProviderMethod != null) { 116 | XposedBridge.hookMethod(addTestProviderMethod, new XC_MethodHook() { 117 | @Override 118 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable { 119 | super.beforeHookedMethod(param); 120 | 121 | @SuppressWarnings("unchecked") 122 | List providers = (List) XposedHelpers.getObjectField(param.thisObject, "j"); 123 | providers.clear(); 124 | providers.add(LocationManager.GPS_PROVIDER); 125 | providers.add(LocationManager.NETWORK_PROVIDER); 126 | } 127 | }); 128 | } 129 | if (updateLocationMethod != null) { 130 | XposedBridge.hookMethod(updateLocationMethod, new XC_MethodHook() { 131 | @Override 132 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable { 133 | super.beforeHookedMethod(param); 134 | Object o = param.thisObject; 135 | 136 | LocationManager locationManager = (LocationManager) XposedHelpers.getObjectField(o, "d"); 137 | @SuppressWarnings("unchecked") 138 | List providers = (List) XposedHelpers.getObjectField(o, "j"); 139 | 140 | try { 141 | for (String next : providers) { 142 | if (!locationManager.isProviderEnabled(next)) { 143 | locationManager.setTestProviderEnabled(next, true); 144 | } 145 | 146 | } 147 | } catch (Exception e) { 148 | // removeProviders 149 | XposedHelpers.callMethod(o, "c"); 150 | // addProviders 151 | XposedHelpers.callMethod(o, "b"); 152 | } 153 | } 154 | }); 155 | return true; 156 | } 157 | } 158 | return false; 159 | } 160 | 161 | static boolean tryFixJoystickApp(XC_LoadPackage.LoadPackageParam lpparam) { 162 | return fixTestProviderUpdates(lpparam); 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /app/src/main/java/com/github/thepiemonster/hidemocklocation/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.thepiemonster.hidemocklocation; 2 | 3 | import android.Manifest; 4 | import android.content.Intent; 5 | import android.content.pm.PackageManager; 6 | import android.graphics.Color; 7 | import android.location.Criteria; 8 | import android.location.Location; 9 | import android.location.LocationListener; 10 | import android.location.LocationManager; 11 | import android.os.Bundle; 12 | import android.text.SpannableString; 13 | import android.text.style.ForegroundColorSpan; 14 | import android.util.Log; 15 | import android.view.View; 16 | import android.widget.Toast; 17 | 18 | import androidx.appcompat.app.AlertDialog; 19 | import androidx.appcompat.app.AppCompatActivity; 20 | import androidx.appcompat.content.res.AppCompatResources; 21 | import androidx.core.app.ActivityCompat; 22 | 23 | import com.github.thepiemonster.hidemocklocation.databinding.ActivityMainBinding; 24 | import com.google.android.material.dialog.MaterialAlertDialogBuilder; 25 | 26 | 27 | public class MainActivity extends AppCompatActivity { 28 | 29 | private static final String TAG = MainActivity.class.getName(); 30 | ActivityMainBinding binding; 31 | private LocationManager locationManager; 32 | public static final int MY_PERMISSIONS_REQUEST_LOCATION = 99; 33 | 34 | @Override 35 | protected void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | binding = ActivityMainBinding.inflate(getLayoutInflater()); // inflating our xml layout in our activity main binding 38 | setModuleState(binding); 39 | 40 | binding.txtVersion.setText(BuildConfig.VERSION_NAME); 41 | 42 | binding.menuDetectionTest.setOnClickListener(view -> { 43 | Log.v(TAG, "View MenuDetectionTest"); 44 | getMockLocationSetting(); 45 | }); 46 | binding.menuAbout.setOnClickListener(view -> { 47 | Log.v(TAG, "Starting About Activity"); 48 | startActivity(new Intent(MainActivity.this, AboutActivity.class)); 49 | }); 50 | setContentView(binding.getRoot()); // set content view for our layout 51 | 52 | // Initialize the location fields 53 | this.locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); 54 | } 55 | 56 | public String getLocationProvider(LocationManager locationManager) { 57 | Criteria criteria = new Criteria(); 58 | return locationManager.getBestProvider(criteria, false); 59 | } 60 | 61 | public void getMockLocationSetting() { 62 | // Check location permissions 63 | if (!checkLocationPermission()) { 64 | return; 65 | } 66 | 67 | // Get location from location manager 68 | Location location = null; 69 | int maxAttempts = 2; 70 | for (int count = 0; count < maxAttempts; count++) { 71 | try { 72 | String provider = getLocationProvider(locationManager); 73 | location = locationManager.getLastKnownLocation(provider); 74 | // location could return null if no location updates have been provided since device boot. IE: opened Google maps. 75 | if (location == null) { 76 | locationManager.requestLocationUpdates(provider, 0, 0, locationListener); 77 | location = locationManager.getLastKnownLocation(provider); 78 | if (location == null) { 79 | throwErrorDialog("Location is null"); 80 | return; 81 | } 82 | } 83 | count = maxAttempts; 84 | } catch (Exception e) { 85 | throwErrorDialog(e.toString()); 86 | return; 87 | } 88 | } 89 | 90 | // Create Material Dialog 91 | MaterialAlertDialogBuilder dialogBuilder = new MaterialAlertDialogBuilder(MainActivity.this, 92 | R.style.AlertDialogTheme); 93 | dialogBuilder.setTitle(getString(R.string.alert_dialog_title)); 94 | 95 | // Gather system location metadata 96 | boolean isMockProvider = location.isFromMockProvider(); 97 | 98 | String infoText = "Enable/Disable a mock location provider application and then view the below info."; 99 | String isMockProviderText = "\n\nlocation.isFromMockProvider(): "; 100 | 101 | int infoTextCount = infoText.length(); 102 | 103 | int isMockSettingsNewerThanAndroid6Color; 104 | if (isMockProvider) { 105 | isMockSettingsNewerThanAndroid6Color = Color.RED; 106 | } else { 107 | isMockSettingsNewerThanAndroid6Color = Color.GREEN; 108 | } 109 | 110 | int textPosition = infoTextCount; 111 | SpannableString string = new SpannableString(infoText + isMockProviderText + isMockProvider); 112 | textPosition += isMockProviderText.length(); 113 | string.setSpan(new ForegroundColorSpan(isMockSettingsNewerThanAndroid6Color), 114 | textPosition, 115 | textPosition + String.valueOf(isMockProvider).length(), 116 | SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE); 117 | 118 | dialogBuilder.setMessage(string); 119 | dialogBuilder.setNegativeButton(getString(R.string.alert_dialog_close), (dialogInterface, i) -> { 120 | }); 121 | dialogBuilder.show(); 122 | } 123 | 124 | /** 125 | * Location Listener 126 | */ 127 | LocationListener locationListener = new LocationListener() { 128 | @Override 129 | public void onLocationChanged(android.location.Location location) { 130 | Log.d(TAG, "GPS LocationChanged"); 131 | double lat = location.getLatitude(); 132 | double lng = location.getLongitude(); 133 | Log.d(TAG, "Received GPS request for " + lat + "," + lng); 134 | } 135 | 136 | @Override 137 | public void onProviderEnabled(String provider) { 138 | } 139 | 140 | @Override 141 | public void onProviderDisabled(String provider) { 142 | } 143 | }; 144 | 145 | 146 | /** 147 | * Creates an alert dialog window with the supplied exception message 148 | * 149 | * @param e Pass Exception object as parameter 150 | */ 151 | public void throwErrorDialog(String e) { 152 | new AlertDialog.Builder(this).setTitle("Exception Thrown").setMessage(e).setPositiveButton(R.string.alert_dialog_ok, (dialogInterface, i) -> startActivity(new Intent(MainActivity.this, MainActivity.class))).create().show(); 153 | } 154 | 155 | /** 156 | * Check if location permission is granted 157 | */ 158 | private boolean checkLocationPermission() { 159 | if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { 160 | Toast.makeText(MainActivity.this, "Location Permission Required", Toast.LENGTH_LONG).show(); 161 | if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) { 162 | new AlertDialog.Builder(this) 163 | .setTitle("Location Permission Required") 164 | .setMessage("This application requires location permissions") 165 | .setPositiveButton(R.string.alert_dialog_ok, (dialogInterface, i) -> { 166 | // Prompt the user once explanation has been shown 167 | ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, MY_PERMISSIONS_REQUEST_LOCATION); 168 | }).create().show(); 169 | } else { 170 | ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, MY_PERMISSIONS_REQUEST_LOCATION); 171 | } 172 | return false; 173 | } else { 174 | return true; 175 | } 176 | } 177 | 178 | /** 179 | * Check if this module is enabled in LSPosed 180 | * 181 | * @param binding Pass ActivityMainBinding object as parameter 182 | */ 183 | private void setModuleState(ActivityMainBinding binding) { 184 | if (isModuleEnabled()) { 185 | binding.moduleStatusCard.setCardBackgroundColor(getColor(R.color.purple_500)); 186 | binding.moduleStatusIcon.setImageDrawable(AppCompatResources.getDrawable(this, R.drawable.baseline_check_circle_24)); 187 | binding.moduleStatusText.setText(getString(R.string.card_title_activated)); 188 | binding.serviceStatusText.setText(getString(R.string.card_detail_activated)); 189 | binding.serveTimes.setText(getString(R.string.card_serve_time)); 190 | } else { 191 | binding.moduleStatusCard.setCardBackgroundColor(getColor(R.color.red_500)); 192 | binding.moduleStatusIcon.setImageDrawable(AppCompatResources.getDrawable(this, R.drawable.baseline_error_24)); 193 | binding.moduleStatusText.setText(getText(R.string.card_title_not_activated)); 194 | binding.serviceStatusText.setText(getText(R.string.card_detail_not_activated)); 195 | binding.serveTimes.setVisibility(View.GONE); 196 | } 197 | } 198 | 199 | /** 200 | * Self-hook method. 201 | * Logging and Boolean object are present to avoid ART optimization. 202 | */ 203 | @SuppressWarnings("all") 204 | private static boolean isModuleEnabled() { 205 | Log.i(TAG, "Xposed module not active."); 206 | return Boolean.valueOf(false); 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------