From ed4c82956a49b0cf0202c4ba80f1e1619e9aab04 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 9 Aug 2014 07:47:20 +0200 Subject: [PATCH] Removed restrictions MapV1.getLatitude/LongitudeE6 Fixes #1862 --- CHANGELOG.md | 3 + res/values/functions.xml | 2 - src/biz/bokhorst/xprivacy/Meta.java | 3 +- src/biz/bokhorst/xprivacy/XGoogleMapV1.java | 61 ++++++--------------- 4 files changed, 20 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34d8e46da..c6cb3effa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/res/values/functions.xml b/res/values/functions.xml index 69e8b16d9..4b468ce67 100644 --- a/res/values/functions.xml +++ b/res/values/functions.xml @@ -161,8 +161,6 @@ Google documentation]]> Google documentation]]> Google documentation]]> - Google documentation]]> - Google documentation]]> Google documentation]]> Google documentation]]> Google documentation]]> diff --git a/src/biz/bokhorst/xprivacy/Meta.java b/src/biz/bokhorst/xprivacy/Meta.java index da47f1bbf..379ec7e4d 100644 --- a/src/biz/bokhorst/xprivacy/Meta.java +++ b/src/biz/bokhorst/xprivacy/Meta.java @@ -222,8 +222,6 @@ public static List 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()); @@ -522,6 +520,7 @@ public static List 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)); diff --git a/src/biz/bokhorst/xprivacy/XGoogleMapV1.java b/src/biz/bokhorst/xprivacy/XGoogleMapV1.java index a287efdb3..0f96f040e 100644 --- a/src/biz/bokhorst/xprivacy/XGoogleMapV1.java +++ b/src/biz/bokhorst/xprivacy/XGoogleMapV1.java @@ -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; @@ -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 getInstances() { List listHook = new ArrayList(); - 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 } }