Skip to content

Commit

Permalink
Added restriction for time zone
Browse files Browse the repository at this point in the history
Closes M66B#1524
  • Loading branch information
M66B authored and Phylon committed Mar 10, 2014
1 parent 7a2fa37 commit 4c9a36c
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Changelog

Other changes:

* Added restriction for time zone ([issue](/../../issues/1524))
* Updated Dutch translation
* Updated Slovenian translation

Expand Down
1 change: 1 addition & 0 deletions res/values/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
<string name="system_android_intent_action_EXTERNAL_APPLICATIONS_AVAILABLE" translatable="false"><![CDATA[<a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE">Google documentation</a>]]></string>
<string name="system_android_intent_action_EXTERNAL_APPLICATIONS_UNAVAILABLE" translatable="false"><![CDATA[<a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE">Google documentation</a>]]></string>
<string name="system_ApplicationsProvider" translatable="false"><![CDATA[Will restrict access to a list of applications installed on the phone to provide search suggestions]]></string>
<string name="system_TZ_getDefault" translatable="false"><![CDATA[<a href="http://developer.android.com/reference/java/util/TimeZone.html#getDefault()">Google documentation</a>]]></string>
<!-- view -->
<string name="view_loadUrl" translatable="false"><![CDATA[<a href="http://developer.android.com/reference/android/webkit/WebView.html#loadUrl(java.lang.String)">Google documentation</a>]]></string>
<string name="view_WebView" translatable="false"><![CDATA[<a href="http://developer.android.com/reference/android/webkit/WebView.html">Google documentation</a>]]></string>
Expand Down
1 change: 1 addition & 0 deletions src/biz/bokhorst/xprivacy/ActivityMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.TimeZone;
import java.util.TreeMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand Down
2 changes: 2 additions & 0 deletions src/biz/bokhorst/xprivacy/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ public static List<Hook> get() {
mListHook.add(new Hook("system", "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE", "", 8, null, null).dangerous());
mListHook.add(new Hook("system", "ApplicationsProvider", "", 1, null, null));

mListHook.add(new Hook("system", "TZ.getDefault", "", 1, null, null).dangerous());

mListHook.add(new Hook("view", "loadUrl", "", 1, null, null).whitelist(cTypeUrl));
mListHook.add(new Hook("view", "WebView", "", 1, null, null));
mListHook.add(new Hook("view", "getDefaultUserAgent", "", 17, null, null));
Expand Down
3 changes: 3 additions & 0 deletions src/biz/bokhorst/xprivacy/XPrivacy.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
// System properties
hookAll(XSystemProperties.getInstances(), mSecret);

// Time zone
hookAll(XTimeZone.getInstances(), mSecret);

// Web view
hookAll(XWebView.getInstances(), mSecret);

Expand Down
48 changes: 48 additions & 0 deletions src/biz/bokhorst/xprivacy/XTimeZone.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package biz.bokhorst.xprivacy;

import java.util.ArrayList;
import java.util.List;
import java.util.SimpleTimeZone;

import android.util.Log;

public class XTimeZone extends XHook {
private Methods mMethod;

private XTimeZone(Methods method, String restrictionName) {
super(restrictionName, method.name(), "TZ." + method.name());
mMethod = method;
}

public String getClassName() {
return "java.util.TimeZone";
}

// public static synchronized TimeZone getDefault()
// http://developer.android.com/reference/android/app/ActivityManager.html

private enum Methods {
getDefault
};

public static List<XHook> getInstances() {
List<XHook> listHook = new ArrayList<XHook>();
listHook.add(new XTimeZone(Methods.getDefault, PrivacyManager.cSystem));
return listHook;
}

@Override
protected void before(XParam param) throws Throwable {
// Do nothing
}

@Override
protected void after(XParam param) throws Throwable {
if (mMethod == Methods.getDefault) {
if (param.getResult() != null && isRestricted(param))
param.setResult(new SimpleTimeZone(0, "UTC"));

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

0 comments on commit 4c9a36c

Please sign in to comment.