This repository has been archived by the owner on Sep 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added restrictions for Google Maps API v1
Refs #1807
- Loading branch information
Showing
5 changed files
with
109 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package biz.bokhorst.xprivacy; | ||
|
||
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; | ||
|
||
private XGoogleMapV1(Methods method, String restrictionName) { | ||
super(restrictionName, method.name(), String.format("MapV1.%s", method.name())); | ||
mMethod = method; | ||
} | ||
|
||
private XGoogleMapV1(Methods method, String restrictionName, int sdk) { | ||
super(restrictionName, method.name(), String.format("MapV1.%s", method.name()), sdk); | ||
mMethod = method; | ||
} | ||
|
||
public String getClassName() { | ||
if (mMethod == Methods.getLatitudeE6 || mMethod == Methods.getLongitudeE6) | ||
return "com.google.android.maps.GeoPoint"; | ||
else | ||
return "com.google.android.maps.MyLocationOverlay"; | ||
} | ||
|
||
// @formatter:off | ||
|
||
// int getLatitudeE6() | ||
// int getLongitudeE6() | ||
// boolean enableMyLocation() | ||
// GeoPoint getMyLocation() | ||
// https://developers.google.com/maps/documentation/android/v1/reference/index | ||
|
||
// @formatter:on | ||
|
||
private enum Methods { | ||
getLatitudeE6, getLongitudeE6, enableMyLocation | ||
}; | ||
|
||
public static List<XHook> getInstances() { | ||
Util.log(null, Log.WARN, "Google Maps V1 uid=" + Binder.getCallingUid()); | ||
List<XHook> listHook = new ArrayList<XHook>(); | ||
for (Methods method : Methods.values()) | ||
listHook.add(new XGoogleMapV1(method, PrivacyManager.cLocation).optional()); | ||
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) { | ||
if (isRestricted(param)) | ||
param.setResult(false); | ||
|
||
} else | ||
Util.log(this, Log.WARN, "Unknown method=" + param.method.getName()); | ||
} | ||
|
||
@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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters