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

Commit

Permalink
Fixed location restriction in AOSP mode
Browse files Browse the repository at this point in the history
Refs #2129
  • Loading branch information
M66B committed Feb 1, 2015
1 parent 63e120f commit eeabe02
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
33 changes: 25 additions & 8 deletions src/biz/bokhorst/xprivacy/XLocationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -369,33 +369,50 @@ 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;
}

@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);
}
}
}
}

0 comments on commit eeabe02

Please sign in to comment.