This commit is contained in:
Tad 2017-11-05 16:49:52 -05:00
parent d2b8412b97
commit 112384f039
3 changed files with 110 additions and 9 deletions

View File

@ -0,0 +1,97 @@
From e5a4d460e3683bb382b17e709a0b541d552c8247 Mon Sep 17 00:00:00 2001
From: Alexandre Oliveira <rockytvbr@gmail.com>
Date: Fri, 28 Jul 2017 18:05:18 -0300
Subject: [PATCH] Jelly: add option to remove identifying headers
Based off anthonycr's commit for LightningBrowser:
https://github.com/anthonycr/Lightning-Browser/commit/7a0c79d11ee1f0a19ebf61b37b8ebd53eee6eb57
Change-Id: If7c5978bd7ab5cdfd766585f2d2c479c4412e63f
---
app/src/main/java/org/lineageos/jelly/utils/PrefsUtils.java | 6 ++++++
app/src/main/java/org/lineageos/jelly/webview/WebViewExt.java | 7 +++++++
app/src/main/res/values/strings.xml | 4 ++++
app/src/main/res/xml/settings.xml | 6 ++++++
4 files changed, 23 insertions(+)
diff --git a/app/src/main/java/org/lineageos/jelly/utils/PrefsUtils.java b/app/src/main/java/org/lineageos/jelly/utils/PrefsUtils.java
index 6b913d5..b554f30 100644
--- a/app/src/main/java/org/lineageos/jelly/utils/PrefsUtils.java
+++ b/app/src/main/java/org/lineageos/jelly/utils/PrefsUtils.java
@@ -32,6 +32,7 @@
private static final String KEY_DO_NOT_TRACK = "key_do_not_track";
private static final String KEY_SAVE_FORM_DATA = "key_save_form_data";
private static final String KEY_SUGGESTION_PROVIDER = "key_suggestion_provider";
+ private static final String KEY_REMOVE_IDENTIFYING_HEADERS = "key_remove_identifying_headers";
public enum SuggestionProviderType {
BAIDU,
@@ -91,6 +92,11 @@ public static boolean getSaveFormData(Context context) {
return prefs.getBoolean(KEY_SAVE_FORM_DATA, true);
}
+ public static boolean getRemoveIdentifyingHeaders(Context context) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ return prefs.getBoolean(KEY_REMOVE_IDENTIFYING_HEADERS, false);
+ }
+
public static SuggestionProviderType getSuggestionProvider(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
try {
diff --git a/app/src/main/java/org/lineageos/jelly/webview/WebViewExt.java b/app/src/main/java/org/lineageos/jelly/webview/WebViewExt.java
index bc88c22..ae96204 100644
--- a/app/src/main/java/org/lineageos/jelly/webview/WebViewExt.java
+++ b/app/src/main/java/org/lineageos/jelly/webview/WebViewExt.java
@@ -54,6 +54,8 @@
private final Map<String, String> mRequestHeaders = new ArrayMap<>();
private static final String HEADER_DNT = "DNT";
+ private static final String HEADER_REQUESTED_WITH = "X-Requested-With";
+ private static final String HEADER_WAP_PROFILE = "X-Wap-Profile";
public WebViewExt(Context context) {
super(context);
@@ -145,6 +147,11 @@ public boolean onLongClick(View v) {
if (PrefsUtils.getDoNotTrack(mActivity)) {
mRequestHeaders.put(HEADER_DNT, "1");
}
+
+ if (PrefsUtils.getRemoveIdentifyingHeaders(mActivity)) {
+ mRequestHeaders.put(HEADER_REQUESTED_WITH, "");
+ mRequestHeaders.put(HEADER_WAP_PROFILE, "");
+ }
}
public void init(WebViewExtActivity activity, EditText editText,
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 9784dc7..a325947 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -116,6 +116,10 @@
<string name="pref_save_form_data_title">Save form data</string>
<!-- Settings: suggestions provider title -->
<string name="pref_suggestions_provider">Suggestions provider</string>
+ <!-- Settings: remove identifying headers preference title -->
+ <string name="pref_remove_identifying_headers_title">Remove identifying headers</string>
+ <!-- Settings: remove identifying headers preference summary -->
+ <string name="pref_remove_identifying_headers_summary">Prevent some personally identifiable information from being sent to websites you visit</string>
<!-- History: title -->
<string name="history_title">History</string>
diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml
index 8bf0718..9bbf074 100644
--- a/app/src/main/res/xml/settings.xml
+++ b/app/src/main/res/xml/settings.xml
@@ -73,6 +73,12 @@
android:title="@string/pref_do_not_track_title" />
<SwitchPreference
+ android:defaultValue="0"
+ android:key="key_remove_identifying_headers"
+ android:summary="@string/pref_remove_identifying_headers_summary"
+ android:title="@string/pref_remove_identifying_headers_title" />
+
+ <SwitchPreference
android:defaultValue="1"
android:key="key_cookie"
android:summary="@string/pref_cookie_summary"

View File

@ -15,7 +15,7 @@
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <https://www.gnu.org/licenses/>.
#Changes default settings
#Changes various default settings
echo "Changing default settings..."
@ -36,13 +36,14 @@ sed -i 's|DEFAULT_HIDE_ANTI_FEATURE_APPS = false;|DEFAULT_HIDE_ANTI_FEATURE_APPS
cd $base"packages/apps/Jelly"
#Because someone is going to eventually ask... the reason we're disabling ads on DuckDuckgGo is because their ads are shit and are almost always just links to what you search for on some shit tier ad infested metasearch engine. Like if DuckDuckGo partnered with Amazon or something and showed sponsored Amazon links that would be a million times better, because they are actually ads.
#sed -i 's|duckduckgo.com/?q=|duckduckgo.com/?k1=-1&kaq=-1&kap=-1&kao=-1&kak=-1&kax=-1&q=|' app/src/main/res/values/search_engines.xml; #Disable ads and popups
#sed -i 's|default_search_engine">https://google.com/search?ie=UTF-8&amp;source=android-browser&amp;q={searchTerms}|default_search_engine">https://duckduckgo.com/?k1=-1&kaq=-1&kap=-1&kao=-1&kak=-1&kax=-1&q={searchTerms}|' app/src/main/res/values/strings.xml; #Change default search engine TODO: Fix me
sed -i 's|default_home_page">https://google.com|default_home_page">https://duckduckgo.com/?k1=-1&kaq=-1&kap=-1&kao=-1&kak=-1&kax=-1|' app/src/main/res/values/strings.xml; #Change homepage from Google to DuckDuckGo
#sed -i 's|default_home_page">https://google.com|default_home_page">https://duckduckgo.com/?k1=-1&kaq=-1&kap=-1&kao=-1&kak=-1&kax=-1|' app/src/main/res/values/strings.xml; #Change homepage from Google to DuckDuckGo
sed -i 's|default_suggestion_provider">GOOGLE|default_suggestion_provider">NONE|' app/src/main/res/values/strings.xml; #Disable search suggestions
sed -i 's|duckduckgo.com/?q=|duckduckgo.com/?k1=-1&kaq=-1&kap=-1&kao=-1&kak=-1&kax=-1&q=|' app/src/main/res/values/search_engines.xml; #Disable ads and popups
sed -i 's|KEY_LOCATION, true|KEY_LOCATION, false|' java/org/lineageos/jelly/utils/PrefsUtils.java; #Disable location
sed -i 's|KEY_DO_NOT_TRACK, false|KEY_DO_NOT_TRACK, true|' java/org/lineageos/jelly/utils/PrefsUtils.java; #Enable do not track
sed -i 's|KEY_SAVE_FORM_DATA, true|KEY_SAVE_FORM_DATA, false|' java/org/lineageos/jelly/utils/PrefsUtils.java; #Disable form data saving
sed -i 's|KEY_LOCATION, true|KEY_LOCATION, false|' app/src/main/java/org/lineageos/jelly/utils/PrefsUtils.java; #Disable location
sed -i 's|KEY_DO_NOT_TRACK, false|KEY_DO_NOT_TRACK, true|' app/src/main/java/org/lineageos/jelly/utils/PrefsUtils.java; #Enable do not track
sed -i 's|KEY_SAVE_FORM_DATA, true|KEY_SAVE_FORM_DATA, false|' app/src/main/java/org/lineageos/jelly/utils/PrefsUtils.java; #Disable form data saving
sed -i 's|KEY_REMOVE_IDENTIFYING_HEADERS, false|KEY_REMOVE_IDENTIFYING_HEADERS, true|' app/src/main/java/org/lineageos/jelly/utils/PrefsUtils.java; #Remove certain headers
cd $base"packages/apps/Nfc"
sed -i 's/static final boolean NFC_ON_DEFAULT = true;/static final boolean NFC_ON_DEFAULT = false;/' src/com/android/nfc/NfcService.java; #Disable NFC

View File

@ -140,9 +140,6 @@ sed -i 's|config_showWeatherMenu">true|config_showWeatherMenu">false|' res/value
patch -p1 < $patches"android_packages_apps_CMParts/0001-Remove_Analytics.patch" #Remove the rest of CMStats
patch -p1 < $patches"android_packages_apps_CMParts/0002-Reduced_Resolution.patch" #Allow reducing resolution to save power
enter "packages/apps/Updater"
patch -p1 < $patches"android_packages_apps_Updater/0001-Server.patch" #Switch to our server
enter "packages/apps/FakeStore"
sed -i 's|$(OUT_DIR)/target/|$(PWD)/$(OUT_DIR)/target/|' Android.mk;
sed -i 's/ln -s /ln -sf /' Android.mk;
@ -170,6 +167,9 @@ sed -i 's|$(OUT_DIR)/target/|$(PWD)/$(OUT_DIR)/target/|' Android.mk;
sed -i 's/compileSdkVersion 23/compileSdkVersion 25/' build.gradle;
sed -i 's/buildToolsVersion "23.0.2"/buildToolsVersion "25.0.3"/' build.gradle;
enter "packages/apps/Jelly"
git apply --3way $patches"android_packages_apps_Jelly/182322-3.patch" #Add option to remove identifying headers
enter "packages/apps/Settings"
sed -i 's/private int mPasswordMaxLength = 16;/private int mPasswordMaxLength = 48;/' src/com/android/settings/ChooseLockPassword.java; #Increase max password length
sed -i 's/GSETTINGS_PROVIDER = "com.google.settings";/GSETTINGS_PROVIDER = "com.google.oQuae4av";/' src/com/android/settings/PrivacySettings.java; #MicroG doesn't support Backup, hide the options
@ -180,6 +180,9 @@ patch -p1 < $patches"android_packages_apps_SetupWizard/0001-Remove_Analytics.pat
enter "packages/apps/Silence"
cp $patches"Silence/Android.mk" Android.mk #Add a build file
enter "packages/apps/Updater"
patch -p1 < $patches"android_packages_apps_Updater/0001-Server.patch" #Switch to our server
enter "packages/apps/WallpaperPicker"
rm res/drawable-nodpi/{*.png,*.jpg} res/values-nodpi/wallpapers.xml; #Remove old ones
cp -r $dosWallpapers'Compressed/.' res/drawable-nodpi/;