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

Commit

Permalink
Removed restrictions MapV1.getLatitude/LongitudeE6
Browse files Browse the repository at this point in the history
Fixes #1862
  • Loading branch information
M66B committed Aug 9, 2014
1 parent d3d3804 commit ed4c829
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 49 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ If there is no message about running in compatibility mode in *About*, XPrivacy

**Next release**

* Removed restrictions *MapV1.getLatitudeE6* and *MapV1.getLongitudeE6*, since these are not needed and bad for performance ([issue](/../../issues/1862))
* Handling *MapV1.disableMyLocation* when *MapV1.enableMyLocation* is restricted

[Open issues](https://github.com/M66B/XPrivacy/issues?state=open)

<a name="xprivacy3"></a>
Expand Down
2 changes: 0 additions & 2 deletions res/values/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@
<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_MapV1_getLatitudeE6" translatable="false"><![CDATA[<a href="https://developers.google.com/maps/documentation/android/v1/reference/index">Google documentation</a>]]></string>
<string name="location_MapV1_getLongitudeE6" translatable="false"><![CDATA[<a href="https://developers.google.com/maps/documentation/android/v1/reference/index">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
3 changes: 1 addition & 2 deletions src/biz/bokhorst/xprivacy/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ public static List<Hook> get() {
mListHook.add(new Hook("location", "GMS.requestLocationUpdates", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, null, null).unsafe().optional());
mListHook.add(new Hook("location", "GMS.requestActivityUpdates", "com.google.android.gms.permission.ACTIVITY_RECOGNITION", 1, null, null).unsafe());

mListHook.add(new Hook("location", "MapV1.getLatitudeE6", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, "2.1.25", null).unsafe().optional());
mListHook.add(new Hook("location", "MapV1.getLongitudeE6", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, "2.1.25", null).unsafe().optional());
mListHook.add(new Hook("location", "MapV1.enableMyLocation", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, "2.1.25", null).unsafe().optional());

mListHook.add(new Hook("location", "MapV2.getMyLocation", "ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION", 1, "2.1.25", null).unsafe().optional());
Expand Down Expand Up @@ -522,6 +520,7 @@ public static List<Hook> get() {
mListHook.add(new Hook(null, "Srv_removeUpdates", "", 19, null, null));
mListHook.add(new Hook(null, "Srv_removeGeofence", "", 19, null, null));
mListHook.add(new Hook(null, "Srv_removeGpsStatusListener", "", 19, null, null));
mListHook.add(new Hook(null, "MapV1.disableMyLocation", "", 1, null, null).optional());

// Resources
mListHook.add(new Hook(null, "updateConfiguration", "", 1, null, null));
Expand Down
61 changes: 16 additions & 45 deletions src/biz/bokhorst/xprivacy/XGoogleMapV1.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
import java.util.ArrayList;
import java.util.List;

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

public class XGoogleMapV1 extends XHook {
private Methods mMethod;

Expand All @@ -16,67 +12,42 @@ private XGoogleMapV1(Methods method, String restrictionName) {
}

public String getClassName() {
if (mMethod == Methods.getLatitudeE6 || mMethod == Methods.getLongitudeE6)
return "com.google.android.maps.GeoPoint";
else
return "com.google.android.maps.MyLocationOverlay";
return "com.google.android.maps.MyLocationOverlay";
}

// @formatter:off

// int getLatitudeE6()
// int getLongitudeE6()
// boolean enableMyLocation()
// GeoPoint getMyLocation()
// void disableMyLocation()
// https://developers.google.com/maps/documentation/android/v1/reference/index

// @formatter:on

private enum Methods {
getLatitudeE6, getLongitudeE6, enableMyLocation
enableMyLocation, disableMyLocation
};

public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
for (Methods method : Methods.values())
listHook.add(new XGoogleMapV1(method, PrivacyManager.cLocation));
listHook.add(new XGoogleMapV1(Methods.enableMyLocation, PrivacyManager.cLocation));
listHook.add(new XGoogleMapV1(Methods.disableMyLocation, null));
return listHook;
}

@Override
protected void before(XParam param) throws Throwable {
if (mMethod == Methods.getLatitudeE6) {
// Do nothing

} else if (mMethod == Methods.getLongitudeE6) {
// Do nothing

} else if (mMethod == Methods.enableMyLocation) {
switch (mMethod) {
case enableMyLocation:
if (isRestricted(param))
param.setResult(false);

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

case disableMyLocation:
if (isRestricted(param, PrivacyManager.cLocation, "MapV1.enableMyLocation"))
if (isRestricted(param))
param.setResult(null);
break;
}
}

@Override
protected void after(XParam param) throws Throwable {
if (mMethod == Methods.getLatitudeE6) {
if (isRestricted(param)) {
Location fakeLocation = PrivacyManager.getDefacedLocation(Binder.getCallingUid(), null);
param.setResult((int) Math.round(fakeLocation.getLatitude() * 1e6));
}

} else if (mMethod == Methods.getLongitudeE6) {
if (isRestricted(param)) {
Location fakeLocation = PrivacyManager.getDefacedLocation(Binder.getCallingUid(), null);
param.setResult((int) Math.round(fakeLocation.getLongitude() * 1e6));
}

} else if (mMethod == Methods.enableMyLocation) {
// Do nothing

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

0 comments on commit ed4c829

Please sign in to comment.