From eeabe02ffd0315b52bec12a2330213c7bc28e2c6 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 1 Feb 2015 15:06:21 +0100 Subject: [PATCH] Fixed location restriction in AOSP mode Refs #2129 --- CHANGELOG.md | 2 +- .../bokhorst/xprivacy/XLocationManager.java | 33 ++++++++++++++----- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80cfc6062..643d09dc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ Changelog **Next release** -* ... +* Fixed location restriction in AOSP mode ([issue](/../../issues/2129)) [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) diff --git a/src/biz/bokhorst/xprivacy/XLocationManager.java b/src/biz/bokhorst/xprivacy/XLocationManager.java index 653048c47..88a77be00 100644 --- a/src/biz/bokhorst/xprivacy/XLocationManager.java +++ b/src/biz/bokhorst/xprivacy/XLocationManager.java @@ -341,7 +341,7 @@ else if (param.args[arg] != null && param.thisObject != null) { // Create proxy Util.log(this, Log.INFO, "Creating proxy uid=" + Binder.getCallingUid()); - Object proxy = new ProxyLocationListener(Binder.getCallingUid(), (LocationListener) param.args[arg]); + Object proxy = new ProxyLocationListener(Binder.getCallingUid(), param.args[arg]); // Use proxy synchronized (mMapProxy) { @@ -369,9 +369,9 @@ else if (param.args[arg] != null) { private static class ProxyLocationListener implements LocationListener { private int mUid; - private LocationListener mListener; + private Object mListener; - public ProxyLocationListener(int uid, LocationListener listener) { + public ProxyLocationListener(int uid, Object listener) { mUid = uid; mListener = listener; } @@ -379,23 +379,40 @@ public ProxyLocationListener(int uid, LocationListener listener) { @Override public void onLocationChanged(Location location) { Util.log(null, Log.INFO, "Location changed uid=" + Binder.getCallingUid()); - Location fakeLocation = PrivacyManager.getDefacedLocation(mUid, location); - mListener.onLocationChanged(fakeLocation); + try { + Location fakeLocation = PrivacyManager.getDefacedLocation(mUid, location); + mListener.getClass().getMethod("onLocationChanged", Location.class).invoke(mListener, fakeLocation); + } catch (Exception ex) { + Util.bug(null, ex); + } } @Override public void onProviderDisabled(String provider) { - mListener.onProviderDisabled(provider); + try { + mListener.getClass().getMethod("onProviderDisabled", String.class).invoke(mListener, provider); + } catch (Exception ex) { + Util.bug(null, ex); + } } @Override public void onProviderEnabled(String provider) { - mListener.onProviderEnabled(provider); + try { + mListener.getClass().getMethod("onProviderEnabled", String.class).invoke(mListener, provider); + } catch (Exception ex) { + Util.bug(null, ex); + } } @Override public void onStatusChanged(String provider, int status, Bundle extras) { - mListener.onStatusChanged(provider, status, extras); + try { + mListener.getClass().getMethod("onStatusChanged", String.class, int.class, Bundle.class) + .invoke(mListener, provider); + } catch (Exception ex) { + Util.bug(null, ex); + } } } }