Skip to content

Commit

Permalink
Added missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B authored and Phylon committed Aug 15, 2014
1 parent 31e055f commit 5a02730
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down
65 changes: 65 additions & 0 deletions src/biz/bokhorst/xprivacy/XActivityRecognitionApi.java
Original file line number Diff line number Diff line change
@@ -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<Status> removeActivityUpdates(GoogleApiClient client, PendingIntent callbackIntent)
// abstract PendingResult<Status> 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<XHook> getInstances(Object instance) {
String className = instance.getClass().getName();
Util.log(null, Log.INFO, "Hooking class=" + className + " uid=" + Binder.getCallingUid());

List<XHook> listHook = new ArrayList<XHook>();
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
}
}

0 comments on commit 5a02730

Please sign in to comment.