Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Added restriction for activity recognition
Browse files Browse the repository at this point in the history
Closes #1608
  • Loading branch information
M66B committed Mar 29, 2014
1 parent 9e2d469 commit 23e5e9c
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Changelog

* Fixed error message for Android versions below JellyBean MR1 (SDK 17) ([issue](/../../issues/1602))
* Reverted "Fixed multi threaded database access", since it leads to freezes on some ROMs
* Added restriction for [activity recognition](http://developer.android.com/training/location/activity-recognition.html) ([issue](/../../issues/1608))
* Updated Arabic translation

[Open issues](https://github.com/M66B/XPrivacy/issues?state=open)
Expand Down
1 change: 1 addition & 0 deletions res/values/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<string name="location_GMS_addGeofences" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/com/google/android/gms/location/LocationClient.html#addGeofences(java.util.List&lt;com.google.android.gms.location.Geofence&gt;,%20android.app.PendingIntent,%20com.google.android.gms.location.LocationClient.OnAddGeofencesResultListener)">Google documentation</a>]]></string>
<string name="location_GMS_getLastLocation" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/com/google/android/gms/location/LocationClient.html#getLastLocation()">Google documentation</a>]]></string>
<string name="location_GMS_requestLocationUpdates" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/com/google/android/gms/location/LocationClient.html#requestLocationUpdates(com.google.android.gms.location.LocationRequest,%20android.app.PendingIntent)">Google documentation</a>]]></string>
<string name="location_GMS_requestActivityUpdates" translatable="false"><![CDATA[<a href="http://developer.android.com/training/location/activity-recognition.html">Google documentation</a>]]></string>
<!-- media -->
<string name="media_startRecording" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/media/AudioRecord.html#startRecording()">Google documentation</a>]]></string>
<string name="media_setPreviewCallback" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/hardware/Camera.html#setPreviewCallback(android.hardware.Camera.PreviewCallback)">Google documentation</a>]]></string>
Expand Down
1 change: 1 addition & 0 deletions src/biz/bokhorst/xprivacy/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public static List<Hook> get() {
mListHook.add(new Hook("location", "GMS.addGeofences", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, null, null));
mListHook.add(new Hook("location", "GMS.getLastLocation", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, null, null));
mListHook.add(new Hook("location", "GMS.requestLocationUpdates", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, null, null));
mListHook.add(new Hook("location", "GMS.requestActivityUpdates", "com.google.android.gms.permission.ACTIVITY_RECOGNITION", 1, null, null));

mListHook.add(new Hook("media", "startRecording", "RECORD_AUDIO", 3, null, null).doNotify());
mListHook.add(new Hook("media", "setPreviewCallback", "CAMERA", 1, null, null).doNotify());
Expand Down
63 changes: 63 additions & 0 deletions src/biz/bokhorst/xprivacy/XActivityRecognitionClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package biz.bokhorst.xprivacy;

import java.util.ArrayList;
import java.util.List;

import android.util.Log;

public class XActivityRecognitionClient extends XHook {
private Methods mMethod;

private XActivityRecognitionClient(Methods method, String restrictionName) {
super(restrictionName, "GMS." + method.name(), null);
mMethod = method;
}

private XActivityRecognitionClient(Methods method, String restrictionName, int sdk) {
super(restrictionName, "GMS." + method.name(), null, sdk);
mMethod = method;
}

public String getClassName() {
return "com.google.android.gms.location.ActivityRecognitionClient";
}

// @formatter:off

// public void removeActivityUpdates(PendingIntent callbackIntent)
// public void requestActivityUpdates(long detectionIntervalMillis, PendingIntent callbackIntent)
// http://developer.android.com/reference/com/google/android/gms/location/ActivityRecognitionClient.html

// @formatter:on

private enum Methods {
removeActivityUpdates, requestActivityUpdates
};

public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XActivityRecognitionClient(Methods.removeActivityUpdates, null, 1));
listHook.add(new XActivityRecognitionClient(Methods.requestActivityUpdates, PrivacyManager.cLocation));
return listHook;
}

@Override
protected void before(XParam param) throws Throwable {
if (mMethod == Methods.removeActivityUpdates) {
if (isRestricted(param, "GMS.requestActivityUpdates"))
param.setResult(null);

} else if (mMethod == Methods.requestActivityUpdates) {
if (isRestricted(param))
param.setResult(null);

} else

Util.log(this, Log.WARN, "Unknown method=" + param.method.getName());
}

@Override
protected void after(XParam param) throws Throwable {
// Do nothing
}
}
7 changes: 7 additions & 0 deletions src/biz/bokhorst/xprivacy/XPrivacy.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
} catch (Throwable ignored) {
}

// User activity
try {
Class.forName("com.google.android.gms.location.ActivityRecognitionClient", false, lpparam.classLoader);
hookAll(XActivityRecognitionClient.getInstances(), lpparam.classLoader, mSecret);
} catch (Throwable ignored) {
}

// Google auth
try {
Class.forName("com.google.android.gms.auth.GoogleAuthUtil", false, lpparam.classLoader);
Expand Down

0 comments on commit 23e5e9c

Please sign in to comment.