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

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Aug 9, 2014
1 parent 6df8624 commit d3d3804
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/biz/bokhorst/xprivacy/XGoogleMapV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

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

public class XGoogleMapV2 extends XHook {
private Methods mMethod;
Expand Down Expand Up @@ -51,32 +50,38 @@ public static List<XHook> getInstances() {

@Override
protected void before(XParam param) throws Throwable {
if (mMethod == Methods.getMyLocation) {
switch (mMethod) {
case getMyLocation:
// Do nothing
break;

} else if (mMethod == Methods.getPosition) {
case getPosition:
// Do nothing
break;

} else if (mMethod == Methods.setLocationSource || mMethod == Methods.setOnMapClickListener
|| mMethod == Methods.setOnMapLongClickListener || mMethod == Methods.setOnMyLocationChangeListener) {
case setLocationSource:
case setOnMapClickListener:
case setOnMapLongClickListener:
case setOnMyLocationChangeListener:
if (isRestricted(param))
param.setResult(null);

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

@Override
protected void after(XParam param) throws Throwable {
if (mMethod == Methods.getMyLocation) {
switch (mMethod) {
case getMyLocation:
if (param.getResult() != null)
if (isRestricted(param)) {
Location originalLocation = (Location) param.getResult();
Location fakeLocation = PrivacyManager.getDefacedLocation(Binder.getCallingUid(), originalLocation);
param.setResult(fakeLocation);
}
break;

} else if (mMethod == Methods.getPosition) {
case getPosition:
if (param.getResult() != null)
if (isRestricted(param)) {
Location fakeLocation = PrivacyManager.getDefacedLocation(Binder.getCallingUid(), null);
Expand All @@ -87,12 +92,14 @@ protected void after(XParam param) throws Throwable {
fLat.set(param.getResult(), fakeLocation.getLatitude());
fLon.set(param.getResult(), fakeLocation.getLongitude());
}
break;

} else if (mMethod == Methods.setLocationSource || mMethod == Methods.setOnMapClickListener
|| mMethod == Methods.setOnMapLongClickListener || mMethod == Methods.setOnMyLocationChangeListener) {
case setLocationSource:
case setOnMapClickListener:
case setOnMapLongClickListener:
case setOnMyLocationChangeListener:
// Do nothing

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

0 comments on commit d3d3804

Please sign in to comment.