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

Commit

Permalink
Added restriction GMS.requestActivityUpdates
Browse files Browse the repository at this point in the history
Closes #1774
  • Loading branch information
M66B committed Aug 15, 2014
1 parent a8f5eb7 commit e442697
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions res/values/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@
<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="https://developer.android.com/training/location/activity-recognition.html">Google documentation</a>]]></string>
<string name="location_GMS5_getLastLocation" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/com/google/android/gms/location/FusedLocationProviderApi.html#getLastLocation(com.google.android.gms.common.api.GoogleApiClient)">Google documentation</a>]]></string>
<string name="location_GMS5_requestLocationUpdates" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/com/google/android/gms/location/FusedLocationProviderApi.html#requestLocationUpdates(com.google.android.gms.common.api.GoogleApiClient, com.google.android.gms.location.LocationRequest,%20com.google.android.gms.location.LocationListener,%20android.os.Looper)">Google documentation</a>]]></string>
<string name="location_GMS5_requestActivityUpdates" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/com/google/android/gms/location/ActivityRecognitionApi.html#requestActivityUpdates(com.google.android.gms.common.api.GoogleApiClient,%20long,%20android.app.PendingIntent)">Google documentation</a>]]></string>
<string name="location_MapV1_enableMyLocation" translatable="false"><![CDATA[<a href="https://developers.google.com/maps/documentation/android/v1/reference/index">Google documentation</a>]]></string>
<string name="location_MapV2_getMyLocation" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/com/google/android/gms/maps/GoogleMap.html">Google documentation</a>]]></string>
<string name="location_MapV2_getPosition" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/com/google/android/gms/maps/model/Marker.html">Google documentation</a>]]></string>
Expand Down
8 changes: 5 additions & 3 deletions src/biz/bokhorst/xprivacy/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ public static List<Hook> 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());

Expand Down Expand Up @@ -531,6 +532,10 @@ public static List<Hook> 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));
Expand All @@ -543,9 +548,6 @@ public static List<Hook> 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));
Expand Down
14 changes: 6 additions & 8 deletions src/biz/bokhorst/xprivacy/XActivityRecognitionClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import java.util.ArrayList;
import java.util.List;

import android.util.Log;

public class XActivityRecognitionClient extends XHook {
private Methods mMethod;

Expand Down Expand Up @@ -38,17 +36,17 @@ public static List<XHook> 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
Expand Down
6 changes: 5 additions & 1 deletion src/biz/bokhorst/xprivacy/XConnectionCallbacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private enum Methods {

public static List<XHook> 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<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XConnectionCallbacks(Methods.onConnected, null, className));
Expand Down Expand Up @@ -61,13 +61,17 @@ 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
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));

// TODO: AppIndexApi
}

break;
Expand Down

0 comments on commit e442697

Please sign in to comment.