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 051200f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 39 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
53 changes: 14 additions & 39 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,24 +12,19 @@ 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() {
Expand All @@ -45,38 +36,22 @@ public static List<XHook> getInstances() {

@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 051200f

Please sign in to comment.