forked from M66B/XPrivacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs M66B#1774
- Loading branch information
Showing
2 changed files
with
66 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package biz.bokhorst.xprivacy; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import android.os.Binder; | ||
import android.util.Log; | ||
|
||
public class XActivityRecognitionApi extends XHook { | ||
private Methods mMethod; | ||
private String mClassName; | ||
|
||
private XActivityRecognitionApi(Methods method, String restrictionName, String className) { | ||
super(restrictionName, method.name(), "GMS5." + method.name()); | ||
mMethod = method; | ||
mClassName = className; | ||
} | ||
|
||
public String getClassName() { | ||
return mClassName; | ||
} | ||
|
||
// @formatter:off | ||
|
||
// Location getLastLocation(GoogleApiClient client) | ||
// abstract PendingResult<Status> removeActivityUpdates(GoogleApiClient client, PendingIntent callbackIntent) | ||
// abstract PendingResult<Status> requestActivityUpdates(GoogleApiClient client, long detectionIntervalMillis, PendingIntent callbackIntent) | ||
// https://developer.android.com/reference/com/google/android/gms/location/ActivityRecognitionApi.html | ||
|
||
// @formatter:on | ||
|
||
private enum Methods { | ||
removeActivityUpdates, requestActivityUpdates | ||
}; | ||
|
||
public static List<XHook> getInstances(Object instance) { | ||
String className = instance.getClass().getName(); | ||
Util.log(null, Log.INFO, "Hooking class=" + className + " uid=" + Binder.getCallingUid()); | ||
|
||
List<XHook> listHook = new ArrayList<XHook>(); | ||
listHook.add(new XActivityRecognitionApi(Methods.removeActivityUpdates, null, className)); | ||
listHook.add(new XActivityRecognitionApi(Methods.requestActivityUpdates, PrivacyManager.cLocation, className)); | ||
return listHook; | ||
} | ||
|
||
@Override | ||
protected void before(XParam param) throws Throwable { | ||
switch (mMethod) { | ||
case removeActivityUpdates: | ||
if (isRestricted(param, PrivacyManager.cLocation, "GMS.requestActivityUpdates")) | ||
param.setResult(null); | ||
break; | ||
|
||
case requestActivityUpdates: | ||
if (isRestricted(param)) | ||
param.setResult(null); | ||
break; | ||
} | ||
} | ||
|
||
@Override | ||
protected void after(XParam param) throws Throwable { | ||
// Do nothing | ||
} | ||
} |