From 6d9cfb6cb1b6244aa07ae669c59e57d8ec471b11 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 8 Mar 2014 15:36:20 +0100 Subject: [PATCH] Added restriction for time zone Closes #1524 --- CHANGELOG.md | 1 + res/values/functions.xml | 1 + src/biz/bokhorst/xprivacy/ActivityMain.java | 1 + src/biz/bokhorst/xprivacy/Meta.java | 2 + src/biz/bokhorst/xprivacy/XPrivacy.java | 3 ++ src/biz/bokhorst/xprivacy/XTimeZone.java | 48 +++++++++++++++++++++ 6 files changed, 56 insertions(+) create mode 100644 src/biz/bokhorst/xprivacy/XTimeZone.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b018fffe..3ced45061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ Changelog Other changes: +* Added restriction for time zone ([issue](/../../issues/1524)) * Updated Dutch translation * Updated Slovenian translation diff --git a/res/values/functions.xml b/res/values/functions.xml index 0d2d38ad7..c3bac3957 100644 --- a/res/values/functions.xml +++ b/res/values/functions.xml @@ -239,6 +239,7 @@ Google documentation]]> Google documentation]]> + Google documentation]]> Google documentation]]> Google documentation]]> diff --git a/src/biz/bokhorst/xprivacy/ActivityMain.java b/src/biz/bokhorst/xprivacy/ActivityMain.java index d3d0ba616..4a7fa0b13 100644 --- a/src/biz/bokhorst/xprivacy/ActivityMain.java +++ b/src/biz/bokhorst/xprivacy/ActivityMain.java @@ -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; diff --git a/src/biz/bokhorst/xprivacy/Meta.java b/src/biz/bokhorst/xprivacy/Meta.java index 07f5731de..e6d71aee2 100644 --- a/src/biz/bokhorst/xprivacy/Meta.java +++ b/src/biz/bokhorst/xprivacy/Meta.java @@ -272,6 +272,8 @@ public static List 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)); diff --git a/src/biz/bokhorst/xprivacy/XPrivacy.java b/src/biz/bokhorst/xprivacy/XPrivacy.java index f08030fe4..882ad6d10 100644 --- a/src/biz/bokhorst/xprivacy/XPrivacy.java +++ b/src/biz/bokhorst/xprivacy/XPrivacy.java @@ -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); diff --git a/src/biz/bokhorst/xprivacy/XTimeZone.java b/src/biz/bokhorst/xprivacy/XTimeZone.java new file mode 100644 index 000000000..9c7c43fa8 --- /dev/null +++ b/src/biz/bokhorst/xprivacy/XTimeZone.java @@ -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 getInstances() { + List listHook = new ArrayList(); + 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()); + } +}