diff --git a/CHANGELOG.md b/CHANGELOG.md index eeaba9888..dadd9cd48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,8 @@ Version 2.99.x and version 3.x will be available with a [pro license](http://www **Next release** +* Added restriction *GMS5.getLastLocation* and *GMS5.requestLocationUpdates* ([issue](/../../issues/1774)) + [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) **Version 2.99.25 BETA** diff --git a/src/biz/bokhorst/xprivacy/Meta.java b/src/biz/bokhorst/xprivacy/Meta.java index 3c9406e44..26b8a972d 100644 --- a/src/biz/bokhorst/xprivacy/Meta.java +++ b/src/biz/bokhorst/xprivacy/Meta.java @@ -227,6 +227,9 @@ public static List get() { mListHook.add(new Hook("location", "GMS.requestLocationUpdates", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, null, null).unsafe().optional()); mListHook.add(new Hook("location", "GMS.requestActivityUpdates", "com.google.android.gms.permission.ACTIVITY_RECOGNITION", 1, null, null).unsafe()); + mListHook.add(new Hook("location", "GMS5.getLastLocation", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, "2.99.26", null).unsafe().optional()); + mListHook.add(new Hook("location", "GMS5.requestLocationUpdates", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, "2.99.26", null).unsafe().optional()); + mListHook.add(new Hook("location", "MapV1.enableMyLocation", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, "2.1.25", null).unsafe().optional()); mListHook.add(new Hook("location", "MapV2.getMyLocation", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, "2.1.25", null).unsafe().optional()); @@ -529,8 +532,8 @@ public static List get() { mListHook.add(new Hook(null, "getSystemService", "", 1, null, null).notAOSP(19)); // GoogleApiClient.Builder - mListHook.add(new Hook(null, "GAC.addConnectionCallbacks", "", 1, null, null).optional()); - mListHook.add(new Hook(null, "GAC.onConnected", "", 1, null, null)); + mListHook.add(new Hook(null, "GMS5.addConnectionCallbacks", "", 1, null, null).optional()); + mListHook.add(new Hook(null, "GMS5.onConnected", "", 1, null, null)); // IntentFirewall mListHook.add(new Hook(null, "checkIntent", "", 19, null, null)); @@ -540,6 +543,9 @@ public static List get() { mListHook.add(new Hook(null, "GMS.removeGeofences", "", 1, null, null).optional()); mListHook.add(new Hook(null, "GMS.removeLocationUpdates", "", 1, null, null).optional()); + // FusedLocationProviderApi + mListHook.add(new Hook(null, "GMS5.removeLocationUpdates", "", 1, "2.99.26", null).optional()); + // LocationManager/Service mListHook.add(new Hook(null, "removeUpdates", "", 3, null, null).notAOSP(19)); mListHook.add(new Hook(null, "Srv_removeUpdates", "", 19, null, null)); diff --git a/src/biz/bokhorst/xprivacy/XConnectionCallbacks.java b/src/biz/bokhorst/xprivacy/XConnectionCallbacks.java index 1d1f2402f..2aa879d34 100644 --- a/src/biz/bokhorst/xprivacy/XConnectionCallbacks.java +++ b/src/biz/bokhorst/xprivacy/XConnectionCallbacks.java @@ -11,7 +11,7 @@ public class XConnectionCallbacks extends XHook { private String mClassName; private XConnectionCallbacks(Methods method, String restrictionName, String className) { - super(restrictionName, method.name(), "GAC." + method.name()); + super(restrictionName, method.name(), "GMS5." + method.name()); mMethod = method; mClassName = className; } @@ -33,7 +33,7 @@ private enum Methods { public static List getInstances(Object instance) { String className = instance.getClass().getName(); - Util.log(null, Log.INFO, "Hooking class=" + className + " uid=" + Binder.getCallingUid()); + Util.log(null, Log.WARN, "Hooking class=" + className + " uid=" + Binder.getCallingUid()); List listHook = new ArrayList(); listHook.add(new XConnectionCallbacks(Methods.onConnected, null, className)); @@ -44,14 +44,31 @@ public static List getInstances(Object instance) { protected void before(XParam param) throws Throwable { switch (mMethod) { case onConnected: + Util.log(this, Log.INFO, "onConnected uid=" + Binder.getCallingUid()); ClassLoader loader = param.thisObject.getClass().getClassLoader(); + + // FusedLocationApi Class cLoc = Class.forName("com.google.android.gms.location.LocationServices", false, loader); Object fusedLocationApi = cLoc.getDeclaredField("FusedLocationApi").get(null); - Util.log(this, Log.WARN, "FusedLocationApi class=" + fusedLocationApi.getClass()); + if (PrivacyManager.getTransient(fusedLocationApi.getClass().getName(), null) == null) { + PrivacyManager.setTransient(fusedLocationApi.getClass().getName(), Boolean.toString(true)); + + XPrivacy.hookAll(XFusedLocationApi.getInstances(fusedLocationApi), loader, getSecret()); + } + // ActivityRecognitionApi Class cRec = Class.forName("com.google.android.gms.location.ActivityRecognition", false, loader); Object activityRecognitionApi = cRec.getDeclaredField("ActivityRecognitionApi").get(null); - Util.log(this, Log.WARN, "ActivityRecognitionApi class=" + activityRecognitionApi.getClass()); + if (PrivacyManager.getTransient(activityRecognitionApi.getClass().getName(), null) == null) { + PrivacyManager.setTransient(activityRecognitionApi.getClass().getName(), Boolean.toString(true)); + } + + // AppIndexApi + Class cApp = Class.forName("com.google.android.gms.appindexing.AppIndex", false, loader); + Object appIndexApi = cApp.getDeclaredField("AppIndexApi").get(null); + if (PrivacyManager.getTransient(appIndexApi.getClass().getName(), null) == null) { + PrivacyManager.setTransient(appIndexApi.getClass().getName(), Boolean.toString(true)); + } break; } diff --git a/src/biz/bokhorst/xprivacy/XFusedLocationApi.java b/src/biz/bokhorst/xprivacy/XFusedLocationApi.java index 470aec3f3..cb42e5b67 100644 --- a/src/biz/bokhorst/xprivacy/XFusedLocationApi.java +++ b/src/biz/bokhorst/xprivacy/XFusedLocationApi.java @@ -49,13 +49,9 @@ public static List getInstances(Object instance) { Util.log(null, Log.INFO, "Hooking class=" + className + " uid=" + Binder.getCallingUid()); List listHook = new ArrayList(); - if (PrivacyManager.getTransient(className, null) == null) { - PrivacyManager.setTransient(className, Boolean.toString(true)); - - listHook.add(new XFusedLocationApi(Methods.getLastLocation, PrivacyManager.cLocation, className)); - listHook.add(new XFusedLocationApi(Methods.removeLocationUpdates, PrivacyManager.cLocation, className)); - listHook.add(new XFusedLocationApi(Methods.requestLocationUpdates, PrivacyManager.cLocation, className)); - } + listHook.add(new XFusedLocationApi(Methods.getLastLocation, PrivacyManager.cLocation, className)); + listHook.add(new XFusedLocationApi(Methods.removeLocationUpdates, null, className)); + listHook.add(new XFusedLocationApi(Methods.requestLocationUpdates, PrivacyManager.cLocation, className)); return listHook; } diff --git a/src/biz/bokhorst/xprivacy/XGoogleApiClient.java b/src/biz/bokhorst/xprivacy/XGoogleApiClient.java index db23c25ee..bee24b9a8 100644 --- a/src/biz/bokhorst/xprivacy/XGoogleApiClient.java +++ b/src/biz/bokhorst/xprivacy/XGoogleApiClient.java @@ -3,11 +3,14 @@ import java.util.ArrayList; import java.util.List; +import android.os.Binder; +import android.util.Log; + public class XGoogleApiClient extends XHook { private Methods mMethod; private XGoogleApiClient(Methods method, String restrictionName) { - super(restrictionName, method.name(), "GAC." + method.name()); + super(restrictionName, method.name(), "GMS5." + method.name()); mMethod = method; } @@ -27,7 +30,7 @@ private enum Methods { }; public static List getInstances() { - Util.log(null, android.util.Log.WARN, "Loaded GAC"); + Util.log(null, Log.INFO, "Loaded GoogleApiClient$Builder uid=" + Binder.getCallingUid()); List listHook = new ArrayList(); listHook.add(new XGoogleApiClient(Methods.addConnectionCallbacks, null)); return listHook; @@ -41,6 +44,7 @@ protected void before(XParam param) throws Throwable { Class clazz = param.args[0].getClass(); if (PrivacyManager.getTransient(clazz.getName(), null) == null) { PrivacyManager.setTransient(clazz.getName(), Boolean.toString(true)); + XPrivacy.hookAll(XConnectionCallbacks.getInstances(param.args[0]), clazz.getClassLoader(), getSecret()); } diff --git a/src/biz/bokhorst/xprivacy/XLocationClient.java b/src/biz/bokhorst/xprivacy/XLocationClient.java index c07ea02a4..e6d742bde 100644 --- a/src/biz/bokhorst/xprivacy/XLocationClient.java +++ b/src/biz/bokhorst/xprivacy/XLocationClient.java @@ -84,7 +84,7 @@ protected void before(XParam param) throws Throwable { if (isRestricted(param)) if (param.args[1] instanceof PendingIntent) param.setResult(null); - else if (param.thisObject != null) { + else if (param.thisObject != null && param.args[1] != null) { // Create proxy ClassLoader cl = param.thisObject.getClass().getClassLoader(); Class ll = Class.forName("com.google.android.gms.location.LocationListener", false, cl); diff --git a/src/biz/bokhorst/xprivacy/XPrivacy.java b/src/biz/bokhorst/xprivacy/XPrivacy.java index b71973daa..03018d92b 100644 --- a/src/biz/bokhorst/xprivacy/XPrivacy.java +++ b/src/biz/bokhorst/xprivacy/XPrivacy.java @@ -382,7 +382,7 @@ private static void handleLoadPackage(String packageName, ClassLoader classLoade // GoogleApiClient.Builder try { - Class.forName("com.google.android.gms.common.api.GoogleApiClient", false, classLoader); + Class.forName("com.google.android.gms.common.api.GoogleApiClient$Builder", false, classLoader); hookAll(XGoogleApiClient.getInstances(), classLoader, secret); } catch (Throwable ignored) { }