From 5c92e28e19132b596b5c9b0c3bce39e29e8aa984 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 15 Aug 2014 14:00:27 +0200 Subject: [PATCH] Added restriction GMS.requestActivityUpdates Closes #1774 --- CHANGELOG.md | 1 + res/values/functions.xml | 3 +++ src/biz/bokhorst/xprivacy/Meta.java | 8 +++++--- .../xprivacy/XActivityRecognitionClient.java | 14 ++++++-------- .../bokhorst/xprivacy/XConnectionCallbacks.java | 6 +++++- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dadd9cd48..1409cf206 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ 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)) +* Added restriction *GMS.requestActivityUpdates* [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) diff --git a/res/values/functions.xml b/res/values/functions.xml index c642f0637..c3032f157 100644 --- a/res/values/functions.xml +++ b/res/values/functions.xml @@ -164,6 +164,9 @@ Google documentation]]> Google documentation]]> Google documentation]]> + Google documentation]]> + Google documentation]]> + Google documentation]]> Google documentation]]> Google documentation]]> Google documentation]]> diff --git a/src/biz/bokhorst/xprivacy/Meta.java b/src/biz/bokhorst/xprivacy/Meta.java index 26b8a972d..8e1993990 100644 --- a/src/biz/bokhorst/xprivacy/Meta.java +++ b/src/biz/bokhorst/xprivacy/Meta.java @@ -229,6 +229,7 @@ public static List get() { 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", "GMS5.requestActivityUpdates", "com.google.android.gms.permission.ACTIVITY_RECOGNITION", 1, "2.99.26", null).unsafe()); mListHook.add(new Hook("location", "MapV1.enableMyLocation", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, "2.1.25", null).unsafe().optional()); @@ -531,6 +532,10 @@ public static List get() { // ContextImpl / Activity mListHook.add(new Hook(null, "getSystemService", "", 1, null, null).notAOSP(19)); + // FusedLocationProviderApi // ActivityRecognitionApi + mListHook.add(new Hook(null, "GMS5.removeLocationUpdates", "", 1, "2.99.26", null).optional()); + mListHook.add(new Hook(null, "GMS5.removeActivityUpdates", "", 1, "2.99.26", null).optional()); + // GoogleApiClient.Builder mListHook.add(new Hook(null, "GMS5.addConnectionCallbacks", "", 1, null, null).optional()); mListHook.add(new Hook(null, "GMS5.onConnected", "", 1, null, null)); @@ -543,9 +548,6 @@ 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/XActivityRecognitionClient.java b/src/biz/bokhorst/xprivacy/XActivityRecognitionClient.java index 20357d6fb..99e2bd1a7 100644 --- a/src/biz/bokhorst/xprivacy/XActivityRecognitionClient.java +++ b/src/biz/bokhorst/xprivacy/XActivityRecognitionClient.java @@ -3,8 +3,6 @@ import java.util.ArrayList; import java.util.List; -import android.util.Log; - public class XActivityRecognitionClient extends XHook { private Methods mMethod; @@ -38,17 +36,17 @@ public static List getInstances() { @Override protected void before(XParam param) throws Throwable { - if (mMethod == Methods.removeActivityUpdates) { + switch (mMethod) { + case removeActivityUpdates: if (isRestricted(param, PrivacyManager.cLocation, "GMS.requestActivityUpdates")) param.setResult(null); + break; - } else if (mMethod == Methods.requestActivityUpdates) { + case requestActivityUpdates: if (isRestricted(param)) param.setResult(null); - - } else - - Util.log(this, Log.WARN, "Unknown method=" + param.method.getName()); + break; + } } @Override diff --git a/src/biz/bokhorst/xprivacy/XConnectionCallbacks.java b/src/biz/bokhorst/xprivacy/XConnectionCallbacks.java index 2aa879d34..1ca016ecc 100644 --- a/src/biz/bokhorst/xprivacy/XConnectionCallbacks.java +++ b/src/biz/bokhorst/xprivacy/XConnectionCallbacks.java @@ -33,7 +33,7 @@ private enum Methods { public static List getInstances(Object instance) { String className = instance.getClass().getName(); - Util.log(null, Log.WARN, "Hooking class=" + className + " uid=" + Binder.getCallingUid()); + Util.log(null, Log.INFO, "Hooking class=" + className + " uid=" + Binder.getCallingUid()); List listHook = new ArrayList(); listHook.add(new XConnectionCallbacks(Methods.onConnected, null, className)); @@ -61,6 +61,8 @@ protected void before(XParam param) throws Throwable { Object activityRecognitionApi = cRec.getDeclaredField("ActivityRecognitionApi").get(null); if (PrivacyManager.getTransient(activityRecognitionApi.getClass().getName(), null) == null) { PrivacyManager.setTransient(activityRecognitionApi.getClass().getName(), Boolean.toString(true)); + + XPrivacy.hookAll(XActivityRecognitionApi.getInstances(activityRecognitionApi), loader, getSecret()); } // AppIndexApi @@ -68,6 +70,8 @@ protected void before(XParam param) throws Throwable { Object appIndexApi = cApp.getDeclaredField("AppIndexApi").get(null); if (PrivacyManager.getTransient(appIndexApi.getClass().getName(), null) == null) { PrivacyManager.setTransient(appIndexApi.getClass().getName(), Boolean.toString(true)); + + // TODO: AppIndexApi } break;