From 5a02730c10833a8dd0ef3b4059052e804c605545 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 15 Aug 2014 14:14:04 +0200 Subject: [PATCH] Added missing file Refs #1774 --- CHANGELOG.md | 2 +- .../xprivacy/XActivityRecognitionApi.java | 65 +++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/biz/bokhorst/xprivacy/XActivityRecognitionApi.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 437ea1648..8b6ac10aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,7 +50,7 @@ Version 2.99.x and version 3.x will be available with a [pro license](http://www **Version 2.99.26 BETA** * Added restriction *GMS5.getLastLocation* and *GMS5.requestLocationUpdates* ([issue](/../../issues/1774)) -* Added restriction *GMS.requestActivityUpdates* +* Added restriction *GMS.requestActivityUpdates* ([issue](/../../issues/1774)) **Version 2.99.25 BETA** diff --git a/src/biz/bokhorst/xprivacy/XActivityRecognitionApi.java b/src/biz/bokhorst/xprivacy/XActivityRecognitionApi.java new file mode 100644 index 000000000..695d452ee --- /dev/null +++ b/src/biz/bokhorst/xprivacy/XActivityRecognitionApi.java @@ -0,0 +1,65 @@ +package biz.bokhorst.xprivacy; + +import java.util.ArrayList; +import java.util.List; + +import android.os.Binder; +import android.util.Log; + +public class XActivityRecognitionApi extends XHook { + private Methods mMethod; + private String mClassName; + + private XActivityRecognitionApi(Methods method, String restrictionName, String className) { + super(restrictionName, method.name(), "GMS5." + method.name()); + mMethod = method; + mClassName = className; + } + + public String getClassName() { + return mClassName; + } + + // @formatter:off + + // Location getLastLocation(GoogleApiClient client) + // abstract PendingResult removeActivityUpdates(GoogleApiClient client, PendingIntent callbackIntent) + // abstract PendingResult requestActivityUpdates(GoogleApiClient client, long detectionIntervalMillis, PendingIntent callbackIntent) + // https://developer.android.com/reference/com/google/android/gms/location/ActivityRecognitionApi.html + + // @formatter:on + + private enum Methods { + removeActivityUpdates, requestActivityUpdates + }; + + public static List getInstances(Object instance) { + String className = instance.getClass().getName(); + Util.log(null, Log.INFO, "Hooking class=" + className + " uid=" + Binder.getCallingUid()); + + List listHook = new ArrayList(); + listHook.add(new XActivityRecognitionApi(Methods.removeActivityUpdates, null, className)); + listHook.add(new XActivityRecognitionApi(Methods.requestActivityUpdates, PrivacyManager.cLocation, className)); + return listHook; + } + + @Override + protected void before(XParam param) throws Throwable { + switch (mMethod) { + case removeActivityUpdates: + if (isRestricted(param, PrivacyManager.cLocation, "GMS.requestActivityUpdates")) + param.setResult(null); + break; + + case requestActivityUpdates: + if (isRestricted(param)) + param.setResult(null); + break; + } + } + + @Override + protected void after(XParam param) throws Throwable { + // Do nothing + } +}