From 50c9ed0999771bb392b1ff66af30f9bb62821307 Mon Sep 17 00:00:00 2001 From: Marcel Bokhorst Date: Sat, 31 Aug 2013 13:21:30 +0200 Subject: [PATCH] Setting for browser user agent Fixes #608 --- README.md | 1 + res/layout/settings.xml | 12 ++++++++++++ res/values-ar/strings.xml | 1 + res/values-bg/strings.xml | 1 + res/values-ca/strings.xml | 1 + res/values-cs/strings.xml | 1 + res/values-da/strings.xml | 1 + res/values-de/strings.xml | 1 + res/values-el/strings.xml | 1 + res/values-es/strings.xml | 1 + res/values-fa/strings.xml | 1 + res/values-fr/strings.xml | 1 + res/values-he/strings.xml | 1 + res/values-hi/strings.xml | 1 + res/values-hu/strings.xml | 1 + res/values-it/strings.xml | 1 + res/values-iw/strings.xml | 1 + res/values-ja/strings.xml | 1 + res/values-lt/strings.xml | 1 + res/values-nb-rNO/strings.xml | 1 + res/values-nl/strings.xml | 1 + res/values-nn-rNO/strings.xml | 1 + res/values-no-rNO/strings.xml | 1 + res/values-pl/strings.xml | 1 + res/values-pt/strings.xml | 1 + res/values-ro/strings.xml | 1 + res/values-ru/strings.xml | 1 + res/values-sk/strings.xml | 1 + res/values-sl/strings.xml | 1 + res/values-sr/strings.xml | 1 + res/values-sv/strings.xml | 1 + res/values-tr/strings.xml | 1 + res/values-vi/strings.xml | 1 + res/values-zh-rCN/strings.xml | 1 + res/values/strings.xml | 1 + src/biz/bokhorst/xprivacy/ActivityMain.java | 4 ++++ src/biz/bokhorst/xprivacy/PrivacyManager.java | 5 +++++ src/biz/bokhorst/xprivacy/XWebSettings.java | 4 +--- src/biz/bokhorst/xprivacy/XWebSettingsClassic.java | 4 ++-- 39 files changed, 58 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index eb8bb2f5f..48a842cef 100644 --- a/README.md +++ b/README.md @@ -587,6 +587,7 @@ How to get beta releases: * Split restriction cache timeout (15 seconds) and settings cache timeout (30 seconds) * Fixed not handled exception ([issue](https://github.com/M66B/XPrivacy/issues/610)) * Send intent *biz.bokhorst.xprivacy.action.ACTIVE* after boot ([issue](https://github.com/M66B/XPrivacy/issues/606)) +* Setting for browser user agent ([issue](https://github.com/M66B/XPrivacy/issues/608)) * Updated Lithuanian translation * Updated Russian translation * Updated Turkish translation diff --git a/res/layout/settings.xml b/res/layout/settings.xml index 420195cb0..67fdc2c8a 100644 --- a/res/layout/settings.xml +++ b/res/layout/settings.xml @@ -221,6 +221,18 @@ android:maxLength="15" /> + + + + + + + الدولة المُشغل IMSI + User agent تصفية بواسطة الأُذونات تصفية بواسطة نوع التطبيق سِجِل تصحيح الأخطاء (يتطلب إعادة التشغيل) diff --git a/res/values-bg/strings.xml b/res/values-bg/strings.xml index 589ea1646..50ceb2b19 100644 --- a/res/values-bg/strings.xml +++ b/res/values-bg/strings.xml @@ -78,6 +78,7 @@ Държава Operator Абонатно ID + User agent Филтриране по разрешения Filter by application type Debug log (requires restart) diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index bc4ea8241..82e6d9c0b 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -76,6 +76,7 @@ País Operador ID de subscriptor + User agent Filta per permís Filter by application type Debug log (requires restart) diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index efcf2ca1c..08d402eec 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -79,6 +79,7 @@ nicméně je nemožné zaručit bezchybnou funkčnost na všech zařízeních a Země Operátor IMSI + User agent Filtrovat dle oprávnění Filter by application type Debug log (requires restart) diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index fdc9c0a61..3f2ca645d 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -78,6 +78,7 @@ however it is impossible to guarantee it will work flawless on each and every de Land Operator Abonnent ID + User agent Filtrer efter Restriktioner Filter by application type Debug log (requires restart) diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 760febe58..1b876609f 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -78,6 +78,7 @@ Land Mobilfunkanbieter Subscriber-ID + User agent Nach Android-Berechtigungen filtern Nach App-Typ filtern Debug Log (erfordert Neustart) diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index 80815c3f9..80acf5b54 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -78,6 +78,7 @@ Χώρα Operator Αναγνωριστικό συνδρομητή + User agent Φιλτράρισμα ανά άδεια Filter by application type Debug log (requires restart) diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 1b9091f97..9e6b218a0 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -78,6 +78,7 @@ however it is impossible to guarantee it will work flawless on each and every de País Operator Subscriber ID + User agent Ocultar permisos no utilizados Filter by application type Debug log (requires restart) diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index 72655c006..8593ba645 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -80,6 +80,7 @@ کشور اپراتور شناسه مشترک + User agent فیلتر بر اساس مجوزها Filter by application type لاگ ایرادیابی (نیازمند دوباره راه اندازی می باشد) diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 687f2e4a3..4d135a1e5 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -78,6 +78,7 @@ il est impossible de garantir un fonctionnement parfait sur chaque appareil et p Pays Opérateur ID Abonné + User agent Filtrer par permissions Filtrer par type d\'application Debug log (redémarrage nécessaire) diff --git a/res/values-he/strings.xml b/res/values-he/strings.xml index 20e8f861f..5d16d8703 100644 --- a/res/values-he/strings.xml +++ b/res/values-he/strings.xml @@ -78,6 +78,7 @@ however it is impossible to guarantee it will work flawless on each and every de מדינה Operator מנוי ID + User agent סינון לפי הרשאות Filter by application type Debug log (requires restart) diff --git a/res/values-hi/strings.xml b/res/values-hi/strings.xml index 442228b5b..2cb0e3c5a 100644 --- a/res/values-hi/strings.xml +++ b/res/values-hi/strings.xml @@ -78,6 +78,7 @@ देश ऑपरेटर ग्राहक क्रमांक + User agent अनुमति के द्वारा फिल्टर करे Application के प्रकार के द्वारा फिल्टर करे Debug log (पुनरारंभ जरूरी) diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index 9a4eb5a2e..473282d3e 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -78,6 +78,7 @@ de lehetetlen garantálni hogy tökéletesen működjön az összes eszközön Ország Operator Előfizető azonosító + User agent Szűrés engedély szerint Filter by application type Debug log (requires restart) diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index ef5002da6..859c021d7 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -78,6 +78,7 @@ Nazione Operatore Subscriber ID + User agent Filtra per permessi Filter by application type Debug log (requires restart) diff --git a/res/values-iw/strings.xml b/res/values-iw/strings.xml index 20e8f861f..5d16d8703 100644 --- a/res/values-iw/strings.xml +++ b/res/values-iw/strings.xml @@ -78,6 +78,7 @@ however it is impossible to guarantee it will work flawless on each and every de מדינה Operator מנוי ID + User agent סינון לפי הרשאות Filter by application type Debug log (requires restart) diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index b7b85da5e..a42ca4610 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -78,6 +78,7 @@ キャリア 契約者固有ID + User agent 権限でフィルタ アプリタイプでフィルタ デバッグログ(要再起動) diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index 5ad3fb70e..97f4f5479 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -78,6 +78,7 @@ Tačiau neįmanoma garantuoti, kad dirbs nepriekaištingai su kiekvienu prietais Šalis Operatorius Abonento ID + User agent Tik naudojami leidimai Filter by application type DEBUG žurnalas (reikia paleisti iš naujo) diff --git a/res/values-nb-rNO/strings.xml b/res/values-nb-rNO/strings.xml index 0b92246d8..f03d838c8 100644 --- a/res/values-nb-rNO/strings.xml +++ b/res/values-nb-rNO/strings.xml @@ -76,6 +76,7 @@ Land Operator Abonnent ID + User agent Velg etter tillatelse Filter by application type Debug log (requires restart) diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index ad3469896..370e4d061 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -78,6 +78,7 @@ maar het is onmogelijk om te garanderen dat het op elk apparaat en voor elke app Land Operator Abonnee ID + User agent Filter op rechten Filter by application type Debug log (herstart vereist) diff --git a/res/values-nn-rNO/strings.xml b/res/values-nn-rNO/strings.xml index 0b92246d8..f03d838c8 100644 --- a/res/values-nn-rNO/strings.xml +++ b/res/values-nn-rNO/strings.xml @@ -76,6 +76,7 @@ Land Operator Abonnent ID + User agent Velg etter tillatelse Filter by application type Debug log (requires restart) diff --git a/res/values-no-rNO/strings.xml b/res/values-no-rNO/strings.xml index 0b92246d8..f03d838c8 100644 --- a/res/values-no-rNO/strings.xml +++ b/res/values-no-rNO/strings.xml @@ -76,6 +76,7 @@ Land Operator Abonnent ID + User agent Velg etter tillatelse Filter by application type Debug log (requires restart) diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index c0153a500..e4e58246e 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -79,6 +79,7 @@ Kraj Operator Subscriber ID + User agent Filtruj według uprawnień Filtruj według typu aplikacji Debug log (wymaga restartu) diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index 8183542c3..dc4f725be 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -78,6 +78,7 @@ porém é impossível garantir que irá funcionar sem problemas em todos os disp País Operador Identidade do subscritor + User agent Filtrar por permissão Filter by application type Relatório de depuração (requer reinicialização) diff --git a/res/values-ro/strings.xml b/res/values-ro/strings.xml index 0a9bf054b..7d4fcc3af 100644 --- a/res/values-ro/strings.xml +++ b/res/values-ro/strings.xml @@ -78,6 +78,7 @@ however it is impossible to guarantee it will work flawless on each and every de Country Operator Subscriber ID + User agent Filter by permission Filter by application type Debug log (requires restart) diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index b65572ae1..4dc8bc548 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -79,6 +79,7 @@ Страна Оператор Subscriber ID + User agent Фильтровать по разрешениям Фильтровать по типу приложения Отладочный лог (требует перезагрузки) diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index 65d9d133b..3237bfe32 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -79,6 +79,7 @@ avšak nie je nemožné zaručiť, že bude fungovať bezchybne na každom zaria Krajina Operátor IMSI + User agent Filtrovať podľa povolenia Filtrovať podľa typu aplikácie Záznam na ladenie (vyžaduje reštart) diff --git a/res/values-sl/strings.xml b/res/values-sl/strings.xml index 3a76c331b..62bf0cbc8 100644 --- a/res/values-sl/strings.xml +++ b/res/values-sl/strings.xml @@ -80,6 +80,7 @@ Država Operater ID naročnika + User agent Filtriraj po pravicah Filter by application type Debug log (requires restart) diff --git a/res/values-sr/strings.xml b/res/values-sr/strings.xml index 72d773737..3fea37e39 100644 --- a/res/values-sr/strings.xml +++ b/res/values-sr/strings.xml @@ -78,6 +78,7 @@ however it is impossible to guarantee it will work flawless on each and every de Земља Operator Претплатнички ИД + User agent Филтрирај по дозволи Filter by application type Debug log (requires restart) diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index 16a02b520..7d088f54f 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -78,6 +78,7 @@ Det är emellertid omöjligt att garantera att appen fungerar på alla enheter o Land Operatör Abonnent-ID + User agent Filtrera efter behörighet Filter by application type Debug log (requires restart) diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 658d676c1..5a72ceda2 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -77,6 +77,7 @@ Ülke Operator Sim Numarası (IMSI) + User agent İzne göre gizle Uygulama tipine göre gizle Hata ayıklama modu (Yeniden başlatma gerekir) diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index 792e7fc25..f76b29d10 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -77,6 +77,7 @@ Nước Nhà mạng ID người đăng kí + User agent Lọc theo quyền Lọc theo kiểu ứng dụng Lưu thông tin gỡ rối (yêu cầu khởi động lại) diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 3b8345770..e8a75e531 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -78,6 +78,7 @@ 国家 运营商 IMSI + User agent 无关权限过滤 按应用级别过滤 调试日志 (需要重启) diff --git a/res/values/strings.xml b/res/values/strings.xml index 8a621cf80..7cbb2b902 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -89,6 +89,7 @@ however it is impossible to guarantee it will work flawless on each and every de Operator ICC ID Subscriber ID + User agent Filter by permission Filter by application type Debug log (requires restart) diff --git a/src/biz/bokhorst/xprivacy/ActivityMain.java b/src/biz/bokhorst/xprivacy/ActivityMain.java index 9d814970b..64b6be4be 100644 --- a/src/biz/bokhorst/xprivacy/ActivityMain.java +++ b/src/biz/bokhorst/xprivacy/ActivityMain.java @@ -614,6 +614,7 @@ private void optionSettings() { final EditText etOperator = (EditText) dlgSettings.findViewById(R.id.etOperator); final EditText etIccId = (EditText) dlgSettings.findViewById(R.id.etIccId); final EditText etSubscriber = (EditText) dlgSettings.findViewById(R.id.etSubscriber); + final EditText etUa = (EditText) dlgSettings.findViewById(R.id.etUa); final CheckBox cbLog = (CheckBox) dlgSettings.findViewById(R.id.cbLog); final Button btnRandom = (Button) dlgSettings.findViewById(R.id.btnRandom); final CheckBox cbRandom = (CheckBox) dlgSettings.findViewById(R.id.cbRandom); @@ -645,6 +646,7 @@ private void optionSettings() { etIccId.setText(PrivacyManager.getSetting(null, ActivityMain.this, 0, PrivacyManager.cSettingIccId, "", false)); etSubscriber.setText(PrivacyManager.getSetting(null, ActivityMain.this, 0, PrivacyManager.cSettingSubscriber, "", false)); + etUa.setText(PrivacyManager.getSetting(null, ActivityMain.this, 0, PrivacyManager.cSettingUa, "", false)); cbLog.setChecked(log); cbRandom.setChecked(random); @@ -749,6 +751,8 @@ public void onClick(View view) { .toString()); PrivacyManager.setSetting(null, ActivityMain.this, 0, PrivacyManager.cSettingSubscriber, etSubscriber .getText().toString()); + PrivacyManager.setSetting(null, ActivityMain.this, 0, PrivacyManager.cSettingUa, etUa.getText() + .toString()); PrivacyManager.setSetting(null, ActivityMain.this, 0, PrivacyManager.cSettingLog, Boolean.toString(cbLog.isChecked())); diff --git a/src/biz/bokhorst/xprivacy/PrivacyManager.java b/src/biz/bokhorst/xprivacy/PrivacyManager.java index 9c53dc135..61f259685 100644 --- a/src/biz/bokhorst/xprivacy/PrivacyManager.java +++ b/src/biz/bokhorst/xprivacy/PrivacyManager.java @@ -86,6 +86,7 @@ public class PrivacyManager { public final static String cSettingOperator = "Operator"; public final static String cSettingIccId = "ICC_ID"; public final static String cSettingSubscriber = "Subscriber"; + public final static String cSettingUa = "UA"; public final static String cSettingFPermission = "FPermission"; public final static String cSettingFSystem = "FSystem"; public final static String cSettingTheme = "Theme"; @@ -815,6 +816,10 @@ public static Object getDefacedProp(int uid, String name) { if (name.equals("Bytes3")) return new byte[] { (byte) 0xDE, (byte) 0xFA, (byte) 0xCE }; + if (name.equals("UA")) + return getSetting(null, null, uid, cSettingUa, + "Mozilla/5.0 (Linux; U; Android; en-us) AppleWebKit/999+ (KHTML, like Gecko) Safari/999.9", true); + // Fallback Util.log(null, Log.WARN, "Fallback value name=" + name); return cDeface; diff --git a/src/biz/bokhorst/xprivacy/XWebSettings.java b/src/biz/bokhorst/xprivacy/XWebSettings.java index cf141e066..dc4e09e43 100644 --- a/src/biz/bokhorst/xprivacy/XWebSettings.java +++ b/src/biz/bokhorst/xprivacy/XWebSettings.java @@ -10,8 +10,6 @@ import de.robv.android.xposed.XC_MethodHook.MethodHookParam; public class XWebSettings extends XHook { - public final static String cUserAgent = "Mozilla/5.0 (Linux; U; Android; en-us) AppleWebKit/999+ (KHTML, like Gecko) Safari/999.9"; - private XWebSettings(String methodName, String restrictionName, int sdk) { super(restrictionName, methodName, null, sdk); } @@ -33,7 +31,7 @@ public static List getInstances() { @Override protected void before(MethodHookParam param) throws Throwable { if (isRestricted(param)) - param.setResult(cUserAgent); + param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "UA")); } @Override diff --git a/src/biz/bokhorst/xprivacy/XWebSettingsClassic.java b/src/biz/bokhorst/xprivacy/XWebSettingsClassic.java index a4d66b41c..c752f41f8 100644 --- a/src/biz/bokhorst/xprivacy/XWebSettingsClassic.java +++ b/src/biz/bokhorst/xprivacy/XWebSettingsClassic.java @@ -52,14 +52,14 @@ public static List getInstances() { protected void before(MethodHookParam param) throws Throwable { if (mMethod.equals(Methods.setUserAgentString)) if (isRestricted(param) && param.args.length > 0) - param.args[0] = XWebSettings.cUserAgent; + param.args[0] = PrivacyManager.getDefacedProp(Binder.getCallingUid(), "UA"); } @Override protected void after(MethodHookParam param) throws Throwable { if (mMethod.equals(Methods.getDefaultUserAgentForLocale) || mMethod.equals(Methods.getUserAgentString)) if (isRestricted(param)) - param.setResult(XWebSettings.cUserAgent); + param.setResult(PrivacyManager.getDefacedProp(Binder.getCallingUid(), "UA")); } @Override