├── app
├── .gitignore
├── src
│ └── main
│ │ ├── assets
│ │ └── xposed_init
│ │ ├── res
│ │ ├── drawable-hdpi
│ │ │ └── ic_nlp_app.png
│ │ ├── drawable-mdpi
│ │ │ └── ic_nlp_app.png
│ │ ├── drawable-xhdpi
│ │ │ └── ic_nlp_app.png
│ │ ├── drawable-xxhdpi
│ │ │ └── ic_nlp_app.png
│ │ ├── values
│ │ │ ├── dimens.xml
│ │ │ └── strings.xml
│ │ ├── menu
│ │ │ └── menu_settings.xml
│ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ └── layout
│ │ │ └── activity_settings.xml
│ │ ├── java
│ │ └── de
│ │ │ └── r3w6
│ │ │ └── xposedunifiednlp
│ │ │ ├── DummyBackend.java
│ │ │ ├── PackageCheckStep.java
│ │ │ ├── CheckStep.java
│ │ │ ├── NetworkLocationCheckStep.java
│ │ │ ├── LocationCheckStep.java
│ │ │ ├── PlayServiceLocationCheckStep.java
│ │ │ ├── Settings.java
│ │ │ └── UnifiedNlp.java
│ │ └── AndroidManifest.xml
├── libs
│ └── XposedBridgeApi-54.jar
├── proguard-rules.pro
├── build.gradle
└── manifest-merger-release-report.txt
├── settings.gradle
├── .gitignore
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── README.md
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/src/main/assets/xposed_init:
--------------------------------------------------------------------------------
1 | de.r3w6.xposedunifiednlp.UnifiedNlp
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea
4 | .DS_Store
5 | /build
6 | *.iml
7 | *.ipr
8 | *.iws
9 | *.apk
--------------------------------------------------------------------------------
/app/libs/XposedBridgeApi-54.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rawi01/XposedUnifiedNlp/HEAD/app/libs/XposedBridgeApi-54.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rawi01/XposedUnifiedNlp/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_nlp_app.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rawi01/XposedUnifiedNlp/HEAD/app/src/main/res/drawable-hdpi/ic_nlp_app.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_nlp_app.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rawi01/XposedUnifiedNlp/HEAD/app/src/main/res/drawable-mdpi/ic_nlp_app.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_nlp_app.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rawi01/XposedUnifiedNlp/HEAD/app/src/main/res/drawable-xhdpi/ic_nlp_app.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_nlp_app.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rawi01/XposedUnifiedNlp/HEAD/app/src/main/res/drawable-xxhdpi/ic_nlp_app.png
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_settings.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/java/de/r3w6/xposedunifiednlp/DummyBackend.java:
--------------------------------------------------------------------------------
1 | package de.r3w6.xposedunifiednlp;
2 |
3 | import android.location.Location;
4 |
5 | import org.microg.nlp.api.LocationBackendService;
6 | import org.microg.nlp.api.LocationHelper;
7 |
8 | /**
9 | * Created by raul on 26.05.16.
10 | */
11 | public class DummyBackend extends LocationBackendService {
12 | @Override
13 | protected Location update() {
14 | return LocationHelper.create("DummyBackend",42,42,10);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | XposedUnifiedNlp
5 | Settings
6 | Hello world!
7 | Settings
8 | Check Settings
9 | Checking...
10 | Dummy Backend
11 |
12 |
13 |
--------------------------------------------------------------------------------
/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:\adt-bundle-windows-x86_64-20140321\sdk/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 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle context.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle context configured through the IDE *will override*
5 | # any context 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 context.
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
--------------------------------------------------------------------------------
/app/src/main/java/de/r3w6/xposedunifiednlp/PackageCheckStep.java:
--------------------------------------------------------------------------------
1 | package de.r3w6.xposedunifiednlp;
2 |
3 | import android.content.Context;
4 | import android.content.pm.PackageManager;
5 |
6 | /**
7 | * Created on 13.02.2015.
8 | */
9 | class PackageCheckStep extends CheckStep {
10 | private Context context;
11 |
12 | public PackageCheckStep(Context context) {
13 | super("UnifiedNlp package");
14 | this.context = context;
15 | }
16 |
17 | @Override
18 | public void runStep() {
19 | try {
20 | context.getPackageManager().getPackageInfo("org.microg.gms", PackageManager.GET_ACTIVITIES);
21 | setState(StepState.SUCCESS);
22 | } catch (PackageManager.NameNotFoundException e) {
23 | setState(StepState.FAIL);
24 | }
25 | }
26 |
27 | @Override
28 | public String getSolution() {
29 | return "Please download and install the latest microG Core for GAPPS devices.";
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/de/r3w6/xposedunifiednlp/CheckStep.java:
--------------------------------------------------------------------------------
1 | package de.r3w6.xposedunifiednlp;
2 |
3 | import android.util.Log;
4 |
5 | /**
6 | * Created on 13.02.2015.
7 | */
8 | public abstract class CheckStep {
9 | public CheckStep(String name) {
10 | this.name = name;
11 | }
12 |
13 | protected abstract void runStep();
14 |
15 | private String name;
16 | private StepState state = StepState.WAIT;
17 | private String solution;
18 |
19 | public String getName() {
20 | return name;
21 | }
22 |
23 | public StepState getState() {
24 | return state;
25 | }
26 |
27 | protected void setState(StepState state) {
28 | Log.i("CheckStep", getName() + "s state changed to " + state);
29 | this.state = state;
30 | }
31 |
32 | public void setSolution(String solution) {
33 | this.solution = solution;
34 | }
35 | public String getSolution() {
36 | if(solution == null)
37 | return "No known solution";
38 | return solution;
39 | }
40 |
41 | public enum StepState {
42 | WAIT,
43 | SUCCESS,
44 | FAIL,
45 | RUNNING, SKIPPED
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/de/r3w6/xposedunifiednlp/NetworkLocationCheckStep.java:
--------------------------------------------------------------------------------
1 | package de.r3w6.xposedunifiednlp;
2 |
3 | import android.content.Context;
4 | import android.location.LocationManager;
5 |
6 | /**
7 | * Created on 13.02.2015.
8 | */
9 | class NetworkLocationCheckStep extends CheckStep {
10 | private Context context;
11 |
12 | public NetworkLocationCheckStep(Context context) {
13 | super("Network-based geolocation");
14 | this.context = context;
15 | }
16 |
17 | @Override
18 | public void runStep() {
19 | LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
20 | if(locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
21 | setState(StepState.SUCCESS);
22 | } else {
23 | setState(StepState.FAIL);
24 | }
25 | }
26 |
27 | @Override
28 | public String getSolution() {
29 | return "Please activate network-based geolocation in Settings->Location. Since KitKat, you need to select any mode but \"device only\", on older Android version this setting is called \"Wi-Fi & mobile network location\" (ignore any misleading texts saying this is for Google's location service)";
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | apply plugin: 'com.android.application'
16 |
17 | android {
18 | compileSdkVersion 23
19 | buildToolsVersion "23.0.3"
20 |
21 | defaultConfig {
22 | applicationId "de.r3w6.xposedunifiednlp"
23 | minSdkVersion 15
24 | targetSdkVersion 23
25 | versionCode 4
26 | versionName "1.0.5-EXPERIMENTAL"
27 | }
28 | }
29 |
30 | dependencies {
31 | compile 'com.android.support:appcompat-v7:23.3.0'
32 | compile 'com.android.support:design:23.3.0'
33 | compile 'org.microg:unifiednlp-api:1.5.3'
34 | compile 'com.google.android.gms:play-services-location:9.2.0'
35 |
36 | provided 'de.robv.android.xposed:api:82'
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_settings.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
19 |
20 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
14 |
17 |
20 |
23 |
24 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | XposedUnifiedNlp
2 | -
3 |
4 | Xposed module to integrate [UnifiedNlp](https://github.com/microg/android_packages_apps_UnifiedNlp) into the system even if GAPPS are installed.
5 |
6 | Installation
7 | ---
8 | 1. Download and install `UnifiedNlp.apk` from the UnifiedNlp [release page](https://github.com/microg/android_packages_apps_UnifiedNlp/releases/latest)
9 | 2. Download and install one or more [backends](https://github.com/microg/android_packages_apps_UnifiedNlp#usage)
10 | 3. Download and install this module
11 | 4. Restart
12 | 5. Done
13 |
14 |
15 | ### How do I know it's running
16 |
17 | If you use the experimental module you can open the module settings and press the "Check settings" button. It will check if everything works as intended.
18 | Otherwise have a look at [#1](https://github.com/Rawi01/XposedUnifiedNlp/issues/1).
19 |
20 | ### It doesn't work
21 |
22 | Check that you
23 | * installed `UnifiedNlp.apk` and not `NetworkLocation.apk` or `LegacyNetworkLocation.apk`. If you installed UnifiedNlp via F-Droid you have to use [µg UnifiedNlp (GAPPS)](https://f-droid.org/repository/browse/?fdid=org.microg.nlp).
24 | * activated the backends
25 | * activated network-based geolocation in Settings->Location
26 |
27 | If you followed the instructions above and it still does not work, feel free to open an issue.
28 |
29 | License
30 | ---
31 | Licensed under the Apache License, Version 2.0 (the "License");
32 | you may not use this file except in compliance with the License.
33 | You may obtain a copy of the License at
34 |
35 | http://www.apache.org/licenses/LICENSE-2.0
36 |
37 | Unless required by applicable law or agreed to in writing, software
38 | distributed under the License is distributed on an "AS IS" BASIS,
39 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40 | See the License for the specific language governing permissions and
41 | limitations under the License.
42 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/manifest-merger-release-report.txt:
--------------------------------------------------------------------------------
1 | -- Merging decision tree log ---
2 | manifest
3 | ADDED from AndroidManifest.xml:2:1
4 | xmlns:android
5 | ADDED from AndroidManifest.xml:2:11
6 | package
7 | ADDED from AndroidManifest.xml:3:5
8 | INJECTED from AndroidManifest.xml:0:0
9 | INJECTED from AndroidManifest.xml:0:0
10 | android:versionName
11 | INJECTED from AndroidManifest.xml:0:0
12 | INJECTED from AndroidManifest.xml:0:0
13 | android:versionCode
14 | INJECTED from AndroidManifest.xml:0:0
15 | INJECTED from AndroidManifest.xml:0:0
16 | uses-permission#android.permission.ACCESS_COARSE_LOCATION
17 | ADDED from AndroidManifest.xml:5:5
18 | android:name
19 | ADDED from AndroidManifest.xml:5:22
20 | uses-permission#android.permission.ACCESS_FINE_LOCATION
21 | ADDED from AndroidManifest.xml:6:5
22 | android:name
23 | ADDED from AndroidManifest.xml:6:22
24 | uses-permission#android.permission.ACCESS_WIFI_STATE
25 | ADDED from AndroidManifest.xml:7:5
26 | android:name
27 | ADDED from AndroidManifest.xml:7:22
28 | uses-permission#android.permission.CHANGE_WIFI_STATE
29 | ADDED from AndroidManifest.xml:8:5
30 | android:name
31 | ADDED from AndroidManifest.xml:8:22
32 | application
33 | ADDED from AndroidManifest.xml:10:5
34 | MERGED from com.android.support:support-v4:21.0.3:16:5
35 | android:label
36 | ADDED from AndroidManifest.xml:13:9
37 | android:allowBackup
38 | ADDED from AndroidManifest.xml:11:9
39 | android:icon
40 | ADDED from AndroidManifest.xml:12:9
41 | meta-data#xposedmodule
42 | ADDED from AndroidManifest.xml:14:9
43 | android:name
44 | ADDED from AndroidManifest.xml:15:13
45 | android:value
46 | ADDED from AndroidManifest.xml:16:13
47 | meta-data#xposeddescription
48 | ADDED from AndroidManifest.xml:17:9
49 | android:name
50 | ADDED from AndroidManifest.xml:18:13
51 | android:value
52 | ADDED from AndroidManifest.xml:19:13
53 | meta-data#xposedminversion
54 | ADDED from AndroidManifest.xml:20:9
55 | android:name
56 | ADDED from AndroidManifest.xml:21:13
57 | android:value
58 | ADDED from AndroidManifest.xml:22:13
59 | activity#de.r3w6.xposedunifiednlp.Settings
60 | ADDED from AndroidManifest.xml:24:9
61 | android:label
62 | ADDED from AndroidManifest.xml:26:13
63 | android:name
64 | ADDED from AndroidManifest.xml:25:13
65 | intent-filter#android.intent.action.MAIN+de.robv.android.xposed.category.MODULE_SETTINGS
66 | ADDED from AndroidManifest.xml:27:13
67 | action#android.intent.action.MAIN
68 | ADDED from AndroidManifest.xml:28:17
69 | android:name
70 | ADDED from AndroidManifest.xml:28:25
71 | category#de.robv.android.xposed.category.MODULE_SETTINGS
72 | ADDED from AndroidManifest.xml:29:17
73 | android:name
74 | ADDED from AndroidManifest.xml:29:27
75 | uses-sdk
76 | INJECTED from AndroidManifest.xml:0:0 reason: use-sdk injection requested
77 | MERGED from com.android.support:support-v4:21.0.3:15:5
78 | android:targetSdkVersion
79 | INJECTED from AndroidManifest.xml:0:0
80 | INJECTED from AndroidManifest.xml:0:0
81 | android:minSdkVersion
82 | INJECTED from AndroidManifest.xml:0:0
83 | INJECTED from AndroidManifest.xml:0:0
84 |
--------------------------------------------------------------------------------
/app/src/main/java/de/r3w6/xposedunifiednlp/LocationCheckStep.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed under the Apache License, Version 2.0 (the "License");
3 | * you may not use this file except in compliance with the License.
4 | * You may obtain a copy of the License at
5 | *
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Unless required by applicable law or agreed to in writing, software
9 | * distributed under the License is distributed on an "AS IS" BASIS,
10 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 | * See the License for the specific language governing permissions and
12 | * limitations under the License.
13 | */
14 |
15 | package de.r3w6.xposedunifiednlp;
16 |
17 | import android.content.Context;
18 | import android.location.Location;
19 | import android.location.LocationListener;
20 | import android.location.LocationManager;
21 | import android.os.Bundle;
22 | import android.os.Handler;
23 | import android.os.Looper;
24 | import android.util.Log;
25 |
26 | /**
27 | * Created on 13.02.2015.
28 | */
29 | class LocationCheckStep extends CheckStep {
30 | private Context context;
31 | private Location location;
32 |
33 | public LocationCheckStep(Context context) {
34 | super("UnifiedNlp location");
35 | this.context = context;
36 | }
37 |
38 | @Override
39 | public void runStep() {
40 | LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
41 | LocationListener listener = new LocationListener() {
42 | @Override
43 | public void onLocationChanged(Location location) {
44 | Log.d("Location found", location.toString());
45 | setLocation(location);
46 | Looper.myLooper().quit();
47 | }
48 | @Override public void onStatusChanged(String provider, int status, Bundle extras) {}
49 | @Override public void onProviderEnabled(String provider) {}
50 | @Override public void onProviderDisabled(String provider) {}
51 | };
52 | Looper.prepare();
53 | new Handler().postDelayed(new Runnable() {
54 | @Override
55 | public void run() {
56 | Looper.myLooper().quit();
57 | }
58 | }, 10000);
59 | locationManager.requestSingleUpdate(LocationManager.NETWORK_PROVIDER, listener, null);
60 | Looper.loop();
61 | if(location != null) {
62 | Bundle extras = location.getExtras();
63 | if (extras != null) {
64 | if (extras.containsKey("SERVICE_BACKEND_PROVIDER")) {
65 | setState(StepState.SUCCESS);
66 | return;
67 | }
68 | }
69 | setState(StepState.FAIL);
70 | setSolution("Your location were found but it looks not like an UnifiedNlp location. Check if you have activated this module.");
71 | } else {
72 | locationManager.removeUpdates(listener);
73 | setState(StepState.FAIL);
74 | setSolution("Your location were not found. Make sure you added at least one backend.");
75 | }
76 | }
77 |
78 | public void setLocation(Location location) {
79 | this.location = location;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/app/src/main/java/de/r3w6/xposedunifiednlp/PlayServiceLocationCheckStep.java:
--------------------------------------------------------------------------------
1 | package de.r3w6.xposedunifiednlp;
2 |
3 | import android.content.Context;
4 | import android.location.Location;
5 | import android.os.Bundle;
6 | import android.support.annotation.Nullable;
7 | import android.util.Log;
8 |
9 | import com.google.android.gms.common.api.GoogleApiClient;
10 | import com.google.android.gms.location.LocationListener;
11 | import com.google.android.gms.location.LocationRequest;
12 | import com.google.android.gms.location.LocationServices;
13 |
14 | /**
15 | * Created on 13.02.2015.
16 | */
17 | class PlayServiceLocationCheckStep extends CheckStep implements GoogleApiClient.ConnectionCallbacks {
18 | private Context context;
19 | private GoogleApiClient client;
20 | private Location location;
21 | private final Object lock = new Object();
22 | private LocationListener locationListener = new LocationListener() {
23 | @Override
24 | public void onLocationChanged(Location location) {
25 | Log.d("Location found", location.toString());
26 | setLocation(location);
27 | synchronized (lock) {
28 | lock.notifyAll();
29 | }
30 | }
31 | };
32 |
33 | public PlayServiceLocationCheckStep(Context context) {
34 | super("PlayServices location");
35 | this.context = context;
36 | }
37 |
38 | @Override
39 | public void runStep() {
40 | client = new GoogleApiClient.Builder(context)
41 | .addApi(LocationServices.API)
42 | .addConnectionCallbacks(this)
43 | .build();
44 | client.connect();
45 |
46 | synchronized (lock) {
47 | try {
48 | lock.wait(10000);
49 | } catch (InterruptedException e) {
50 | }
51 | }
52 |
53 | if(client.isConnected()) {
54 | LocationServices.FusedLocationApi.removeLocationUpdates(client, locationListener);
55 | }
56 |
57 | if(location != null) {
58 | Bundle extras = location.getExtras();
59 | if (extras != null) {
60 | if (extras.containsKey("SERVICE_BACKEND_PROVIDER")) {
61 | setState(StepState.SUCCESS);
62 | return;
63 | }
64 | }
65 | setState(StepState.FAIL);
66 | setSolution("Your location were found but it looks not like an UnifiedNlp location. Check if you have activated this module.");
67 | } else {
68 | setState(StepState.FAIL);
69 | setSolution("Your location were not found. Make sure you added at least one backend.");
70 | }
71 | }
72 |
73 | @Override
74 | public void onConnected(@Nullable Bundle bundle) {
75 | LocationRequest mLocationRequest = new LocationRequest();
76 | mLocationRequest.setInterval(1000);
77 | mLocationRequest.setFastestInterval(1000);
78 | mLocationRequest.setPriority(LocationRequest.PRIORITY_LOW_POWER);
79 | LocationServices.FusedLocationApi.requestLocationUpdates(client, mLocationRequest, locationListener);
80 | }
81 |
82 | @Override
83 | public void onConnectionSuspended(int i) {
84 |
85 | }
86 |
87 | public void setLocation(Location location) {
88 | this.location = location;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/java/de/r3w6/xposedunifiednlp/Settings.java:
--------------------------------------------------------------------------------
1 | package de.r3w6.xposedunifiednlp;
2 |
3 | import android.Manifest;
4 | import android.app.Activity;
5 | import android.content.pm.PackageManager;
6 | import android.graphics.Color;
7 | import android.os.AsyncTask;
8 | import android.os.Bundle;
9 | import android.support.v4.app.ActivityCompat;
10 | import android.text.Spannable;
11 | import android.text.SpannableString;
12 | import android.text.style.ForegroundColorSpan;
13 | import android.util.Log;
14 | import android.view.View;
15 | import android.widget.Button;
16 | import android.widget.TextView;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 | import java.util.concurrent.Executors;
21 |
22 |
23 | public class Settings extends Activity {
24 |
25 | private List steps = new ArrayList<>();
26 | private TextView logTextView;
27 |
28 | @Override
29 | protected void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.activity_settings);
32 |
33 | logTextView = (TextView) findViewById(R.id.textView);
34 |
35 | final Button button = (Button) findViewById(R.id.button);
36 | button.setOnClickListener(new View.OnClickListener() {
37 | public void onClick(View v) {
38 | logTextView.setText("");
39 | startCheck();
40 | }
41 | });
42 |
43 | initCheckSteps();
44 |
45 | if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
46 | ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
47 |
48 | ActivityCompat.requestPermissions(this,
49 | new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 1);
50 |
51 | }
52 |
53 | }
54 |
55 | private void initCheckSteps() {
56 | steps.add(new PackageCheckStep(this));
57 | steps.add(new NetworkLocationCheckStep(this));
58 | steps.add(new LocationCheckStep(this));
59 | steps.add(new PlayServiceLocationCheckStep(this));
60 | }
61 |
62 | private void startCheck() {
63 | final Button button = (Button) findViewById(R.id.button);
64 | button.setEnabled(false);
65 | button.setText(R.string.button_check_settings_checking);
66 | AsyncTask checkWorkingTask = new AsyncTask() {
67 | @Override
68 | protected Boolean doInBackground(CheckStep... steps) {
69 |
70 | for (CheckStep step : steps) {
71 | step.setState(CheckStep.StepState.RUNNING);
72 | //publishProgress(step);
73 | step.runStep();
74 | publishProgress(step);
75 | if(step.getState() == CheckStep.StepState.FAIL) {
76 | return false;
77 | }
78 |
79 | }
80 | return true;
81 | }
82 |
83 | @Override
84 | protected void onProgressUpdate(CheckStep... values) {
85 | CheckStep step = values[0];
86 | if(step.getState() == CheckStep.StepState.SUCCESS) {
87 | Spannable toAppend = new SpannableString("Check step \"" + step.getName() + "\" finished successful.\n");
88 | toAppend.setSpan(new ForegroundColorSpan(Color.GREEN), 0, toAppend.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
89 | logTextView.append(toAppend);
90 | } else {
91 | Spannable toAppend = new SpannableString("Check step \"" + step.getName() + "\" failed.\n" + step.getSolution());
92 | toAppend.setSpan(new ForegroundColorSpan(Color.RED), 0, toAppend.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
93 | logTextView.append(toAppend);
94 | }
95 |
96 | Log.d("CheckWorkingTask", values[0].getName() + ": " + values[0].getState());
97 | }
98 |
99 | @Override
100 | protected void onPostExecute(Boolean success) {
101 | if(success)
102 | logTextView.append("Everything seems to be fine");
103 |
104 | button.setText(R.string.button_check_settings);
105 | button.setEnabled(true);
106 | }
107 | };
108 | checkWorkingTask.executeOnExecutor(Executors.newSingleThreadExecutor(), steps.toArray(new CheckStep[steps.size()]));
109 | }
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/app/src/main/java/de/r3w6/xposedunifiednlp/UnifiedNlp.java:
--------------------------------------------------------------------------------
1 | package de.r3w6.xposedunifiednlp;
2 |
3 | import android.content.ComponentName;
4 | import android.content.Intent;
5 | import android.content.pm.ApplicationInfo;
6 | import android.content.pm.PackageManager;
7 | import android.content.pm.ResolveInfo;
8 | import android.content.res.XResources;
9 | import android.os.Build;
10 | import android.os.UserHandle;
11 | import android.util.Log;
12 |
13 | import java.util.HashMap;
14 |
15 | import de.robv.android.xposed.IXposedHookLoadPackage;
16 | import de.robv.android.xposed.IXposedHookZygoteInit;
17 | import de.robv.android.xposed.XC_MethodHook;
18 | import de.robv.android.xposed.XposedBridge;
19 | import de.robv.android.xposed.XposedHelpers;
20 | import de.robv.android.xposed.callbacks.XC_LoadPackage;
21 |
22 | public class UnifiedNlp implements IXposedHookZygoteInit, IXposedHookLoadPackage {
23 |
24 | private static final String TAG = "XposedUnifiedNlp";
25 |
26 | @Override
27 | public void initZygote(IXposedHookZygoteInit.StartupParam startupParam) throws Throwable {
28 | XResources.setSystemWideReplacement("android", "bool", "config_enableNetworkLocationOverlay", false);
29 | XResources.setSystemWideReplacement("android", "string", "config_networkLocationProviderPackageName", "org.microg.gms");
30 | XResources.setSystemWideReplacement("android", "bool", "config_enableGeocoderOverlay", false);
31 | XResources.setSystemWideReplacement("android", "string", "config_geocoderProviderPackageName", "org.microg.gms");
32 | XposedBridge.log("UnifiedNlp config set");
33 | }
34 |
35 | @Override
36 | public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
37 | hookIntent(lpparam);
38 |
39 | if(!lpparam.packageName.equals("com.android.settings"))
40 | return;
41 |
42 | XC_MethodHook methodHook = new XC_MethodHook() {
43 | @Override
44 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
45 | ResolveInfo ri = (ResolveInfo) param.args[0];
46 | ri.serviceInfo.applicationInfo.flags |= ApplicationInfo.FLAG_SYSTEM;
47 | }
48 | };
49 |
50 | if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
51 | XposedHelpers.findAndHookMethod("com.android.settings.location.SettingsInjector", lpparam.classLoader, "parseServiceInfo", ResolveInfo.class, PackageManager.class, methodHook);
52 | } else {
53 | XposedHelpers.findAndHookMethod("com.android.settings.location.SettingsInjector", lpparam.classLoader, "parseServiceInfo", ResolveInfo.class, UserHandle.class, PackageManager.class, methodHook);
54 | }
55 | }
56 |
57 | private static HashMap replaceMap = new HashMap<>();
58 |
59 | static {
60 | replaceMap.put("com.google.android.location.internal.GoogleLocationManagerService.START", "org.microg.gms.location.GoogleLocationManagerService");
61 | replaceMap.put("com.google.android.location.reporting.service.START", "org.microg.gms.location.ReportingAndroidService");
62 | replaceMap.put("com.google.android.gms.location.reporting.service.START", "org.microg.gms.location.ReportingAndroidService");
63 | replaceMap.put("com.google.android.gms.location.places.ui.PICK_PLACE", "org.microg.gms.ui.PlacePickerActivity");
64 | replaceMap.put("com.google.android.gms.location.places.GeoDataApi","org.microg.gms.places.GeoDataService");
65 | replaceMap.put("com.google.android.gms.location.places.PlacesApi","org.microg.gms.places.GeoDataService");
66 | replaceMap.put("com.google.android.gms.location.places.PlaceDetectionApi","org.microg.gms.places.PlaceDetectionService");
67 | //replaceMap.put("","");
68 | }
69 |
70 | private void hookIntent(final XC_LoadPackage.LoadPackageParam lpparam) {
71 | XposedHelpers.findAndHookMethod(Intent.class, "setPackage", String.class, new XC_MethodHook() {
72 | @Override
73 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
74 | Intent i = (Intent)param.thisObject;
75 | if(replaceMap.containsKey(i.getAction())) {
76 | Log.d(TAG, "Replacing package " + param.args[0] + " for action " + i.getAction() + " created by " + lpparam.packageName);
77 | param.args[0] = "org.microg.gms";
78 | }
79 | }
80 | });
81 |
82 | XposedHelpers.findAndHookMethod(Intent.class, "setComponent", ComponentName.class, new XC_MethodHook() {
83 | @Override
84 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
85 | Intent i = (Intent)param.thisObject;
86 | if(replaceMap.containsKey(i.getAction())) {
87 | param.args[0] = new ComponentName("org.microg.gms", replaceMap.get(i.getAction()));
88 | }
89 | }
90 | });
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------