From d3d38042cf18b9baa4e6b0d1b4fe7e1ccb4a0c47 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 9 Aug 2014 07:47:11 +0200 Subject: [PATCH] Refactoring --- src/biz/bokhorst/xprivacy/XGoogleMapV2.java | 37 ++++++++++++--------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/biz/bokhorst/xprivacy/XGoogleMapV2.java b/src/biz/bokhorst/xprivacy/XGoogleMapV2.java index fe30d02b1..5051300bd 100644 --- a/src/biz/bokhorst/xprivacy/XGoogleMapV2.java +++ b/src/biz/bokhorst/xprivacy/XGoogleMapV2.java @@ -6,7 +6,6 @@ import android.location.Location; import android.os.Binder; -import android.util.Log; public class XGoogleMapV2 extends XHook { private Methods mMethod; @@ -51,32 +50,38 @@ public static List 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); @@ -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; + } } }