Skip to content

Commit

Permalink
Added restriction GMS5.view
Browse files Browse the repository at this point in the history
Closes M66B#1778
  • Loading branch information
M66B authored and Phylon committed Aug 15, 2014
1 parent 2519452 commit c880a23
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 6 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 *registerListener* to the *Sensors* category, which will limit the rate of the gyroscope to 100 Hz to prevent eavesdropping ([issue](/../../issues/1878))
* Added restriction [GMS5.view](https://developer.android.com/reference/com/google/android/gms/appindexing/AppIndexApi.html) ([issue](/../../issues/1778))
* Updated Slovenian translation

[Open issues](https://github.com/M66B/XPrivacy/issues?state=open)
Expand Down
5 changes: 3 additions & 2 deletions res/values/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@
<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_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,%20com.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">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 Expand Up @@ -396,5 +396,6 @@
<string name="view_setUserAgentString" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/webkit/WebSettings.html#setUserAgentString(java.lang.String)">Google documentation</a>]]></string>
<string name="view_android_intent_action_VIEW" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/content/Intent.html#ACTION_VIEW">Google documentation</a>]]></string>
<string name="view_Srv_android_intent_action_VIEW" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/android/content/Intent.html#ACTION_VIEW">Google documentation</a>]]></string>
<string name="view_GMS5_view" translatable="false"><![CDATA[<a href="https://developer.android.com/reference/com/google/android/gms/appindexing/AppIndexApi.html">Google documentation</a>]]></string>

</resources>
5 changes: 5 additions & 0 deletions src/biz/bokhorst/xprivacy/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ public static List<Hook> get() {
mListHook.add(new Hook("view", Intent.ACTION_VIEW, "", 1, null, null).notAOSP(19).doNotify().whitelist(cTypeUrl));
mListHook.add(new Hook("view", "Srv_" + Intent.ACTION_VIEW, "", 19, "2.99", Intent.ACTION_VIEW).AOSP(19).doNotify().whitelist(cTypeUrl));

mListHook.add(new Hook("view", "GMS5.view", "", 1, null, null).unsafe());

// AccountManager
mListHook.add(new Hook(null, "removeOnAccountsUpdatedListener", "", 5, null, null));

Expand Down Expand Up @@ -505,6 +507,9 @@ public static List<Hook> get() {
mListHook.add(new Hook(null, "wakingUp", "", 16, null, null));
mListHook.add(new Hook(null, "shutdown", "", 15, null, null));

// AppIndexApi
mListHook.add(new Hook(null, "GMS5.viewEnd", "", 1, null, null));

// Application
mListHook.add(new Hook(null, "onCreate", "", 1, null, null));

Expand Down
2 changes: 1 addition & 1 deletion src/biz/bokhorst/xprivacy/XActivityRecognitionApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static List<XHook> getInstances(Object instance) {
protected void before(XParam param) throws Throwable {
switch (mMethod) {
case removeActivityUpdates:
if (isRestricted(param, PrivacyManager.cLocation, "GMS.requestActivityUpdates"))
if (isRestricted(param, PrivacyManager.cLocation, "GMS5.requestActivityUpdates"))
param.setResult(null);
break;

Expand Down
66 changes: 66 additions & 0 deletions src/biz/bokhorst/xprivacy/XAppIndexApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package biz.bokhorst.xprivacy;

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

import android.os.Binder;
import android.util.Log;

public class XAppIndexApi extends XHook {
private Methods mMethod;
private String mClassName;

private XAppIndexApi(Methods method, String restrictionName, String className) {
super(restrictionName, method.name(), "GMS5." + method.name());
mMethod = method;
mClassName = className;
}

public String getClassName() {
return mClassName;
}

// @formatter:off

// abstract PendingResult<Status> view(GoogleApiClient apiClient, Activity activity, Intent viewIntent, String title, Uri webUrl, List<AppIndexApi.AppIndexingLink> outLinks)
// abstract PendingResult<Status> view(GoogleApiClient apiClient, Activity activity, Uri appIndexingUrl, String title, Uri webUrl, List<AppIndexApi.AppIndexingLink> outLinks)
// abstract PendingResult<Status> viewEnd(GoogleApiClient apiClient, Activity activity, Uri appIndexingUrl)
// abstract PendingResult<Status> viewEnd(GoogleApiClient apiClient, Activity activity, Intent viewIntent)
// https://developer.android.com/reference/com/google/android/gms/appindexing/AppIndexApi.html

// @formatter:on

private enum Methods {
view, viewEnd
};

public static List<XHook> getInstances(Object instance) {
String className = instance.getClass().getName();
Util.log(null, Log.WARN, "Hooking class=" + className + " uid=" + Binder.getCallingUid());

List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XAppIndexApi(Methods.viewEnd, null, className));
listHook.add(new XAppIndexApi(Methods.view, PrivacyManager.cView, className));
return listHook;
}

@Override
protected void before(XParam param) throws Throwable {
switch (mMethod) {
case viewEnd:
if (isRestricted(param, PrivacyManager.cView, "GMS5.view"))
param.setResult(null);
break;

case view:
if (isRestricted(param))
param.setResult(null);
break;
}
}

@Override
protected void after(XParam param) throws Throwable {
// Do nothing
}
}
9 changes: 6 additions & 3 deletions src/biz/bokhorst/xprivacy/XConnectionCallbacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ protected void before(XParam param) throws Throwable {
if (PrivacyManager.getTransient(fusedLocationApi.getClass().getName(), null) == null) {
PrivacyManager.setTransient(fusedLocationApi.getClass().getName(), Boolean.toString(true));

XPrivacy.hookAll(XFusedLocationApi.getInstances(fusedLocationApi), loader, getSecret());
if (fusedLocationApi != null)
XPrivacy.hookAll(XFusedLocationApi.getInstances(fusedLocationApi), loader, getSecret());
}

// ActivityRecognitionApi
Expand All @@ -62,7 +63,8 @@ protected void before(XParam param) throws Throwable {
if (PrivacyManager.getTransient(activityRecognitionApi.getClass().getName(), null) == null) {
PrivacyManager.setTransient(activityRecognitionApi.getClass().getName(), Boolean.toString(true));

XPrivacy.hookAll(XActivityRecognitionApi.getInstances(activityRecognitionApi), loader, getSecret());
if (activityRecognitionApi != null)
XPrivacy.hookAll(XActivityRecognitionApi.getInstances(activityRecognitionApi), loader, getSecret());
}

// AppIndexApi
Expand All @@ -71,7 +73,8 @@ protected void before(XParam param) throws Throwable {
if (PrivacyManager.getTransient(appIndexApi.getClass().getName(), null) == null) {
PrivacyManager.setTransient(appIndexApi.getClass().getName(), Boolean.toString(true));

// TODO: AppIndexApi
if (appIndexApi != null)
XPrivacy.hookAll(XAppIndexApi.getInstances(appIndexApi), loader, getSecret());
}

break;
Expand Down

0 comments on commit c880a23

Please sign in to comment.