Add an experimental webview setting to dev options.

Bug:12492817

Add an experimental webview setting to developer options to enable
data reduction proxy.

Change-Id: I6e0931b39c8dd129622129589ae67352c8396cd2
This commit is contained in:
Selim Gurun
2014-05-05 16:02:41 -07:00
parent 0e0122a999
commit 029c13e1d9
3 changed files with 39 additions and 5 deletions

View File

@@ -4538,6 +4538,12 @@
<string name="show_all_anrs_summary">Show App Not Responding dialog
for background apps</string>
<!-- UI debug setting: webview data reduction proxy [CHAR LIMIT=25] -->
<string name="webview_data_reduction_proxy">Reduce WebView Network Usage</string>
<!-- UI debug setting: webview data reduction proxy summary [CHAR LIMIT=150] -->
<string name="webview_data_reduction_proxy_summary">Reduce network usage by
proxying WebView connections through Google compression servers (Experimental)</string>
<!-- Activity title for network data usage summary. [CHAR LIMIT=25] -->
<string name="data_usage_summary_title">Data usage</string>
<!-- Title for option to pick visible time range from a list available usage periods. [CHAR LIMIT=25] -->

View File

@@ -4,9 +4,9 @@
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,9 +32,9 @@
android:targetClass="com.android.settings.SetFullBackupPassword" />
</PreferenceScreen>
<CheckBoxPreference
android:key="keep_screen_on"
android:title="@string/keep_screen_on"
<CheckBoxPreference
android:key="keep_screen_on"
android:title="@string/keep_screen_on"
android:summary="@string/keep_screen_on_summary"/>
<ListPreference
@@ -286,6 +286,10 @@
android:title="@string/show_all_anrs"
android:summary="@string/show_all_anrs_summary"/>
<CheckBoxPreference
android:key="webview_data_reduction_proxy"
android:title="@string/webview_data_reduction_proxy"
android:summary="@string/webview_data_reduction_proxy_summary"/>
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -60,6 +60,7 @@ import android.view.HardwareRenderer;
import android.view.IWindowManager;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
import android.webkit.WebView;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;
@@ -144,6 +145,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private static final String SHOW_ALL_ANRS_KEY = "show_all_anrs";
private static final String WEBVIEW_DATA_REDUCTION_PROXY_KEY = "webview_data_reduction_proxy";
private static final String PROCESS_STATS = "proc_stats";
private static final String TAG_CONFIRM_ENFORCE = "confirm_enforce";
@@ -209,6 +212,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private CheckBoxPreference mShowAllANRs;
private CheckBoxPreference mWebViewDataReductionProxy;
private PreferenceScreen mProcessStats;
private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>();
@@ -340,6 +345,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mProcessStats = (PreferenceScreen) findPreference(PROCESS_STATS);
mAllPrefs.add(mProcessStats);
mWebViewDataReductionProxy = findAndInitCheckboxPref(WEBVIEW_DATA_REDUCTION_PROXY_KEY);
}
private ListPreference addListPreference(String prefKey) {
@@ -515,6 +522,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
updateImmediatelyDestroyActivitiesOptions();
updateAppProcessLimitOptions();
updateShowAllANRsOptions();
updateWebViewDataReductionProxyOptions();
updateVerifyAppsOverUsbOptions();
updateBugreportOptions();
updateForceRtlOptions();
@@ -1193,6 +1201,20 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
getActivity().getContentResolver(), Settings.Secure.ANR_SHOW_BACKGROUND, 0) != 0);
}
private void writeWebViewDataReductionProxyOptions() {
Settings.Secure.putInt(getActivity().getContentResolver(),
Settings.Secure.WEBVIEW_DATA_REDUCTION_PROXY,
mWebViewDataReductionProxy.isChecked() ? 1 : 0);
Intent intent = new Intent(WebView.DATA_REDUCTION_PROXY_SETTING_CHANGED);
getActivity().sendBroadcast(intent);
}
private void updateWebViewDataReductionProxyOptions() {
updateCheckBox(mWebViewDataReductionProxy, Settings.Secure.getInt(
getActivity().getContentResolver(),
Settings.Secure.WEBVIEW_DATA_REDUCTION_PROXY, 0) != 0);
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView == mEnabledSwitch) {
@@ -1309,6 +1331,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
writeImmediatelyDestroyActivitiesOptions();
} else if (preference == mShowAllANRs) {
writeShowAllANRsOptions();
} else if (preference == mWebViewDataReductionProxy) {
writeWebViewDataReductionProxyOptions();
} else if (preference == mForceHardwareUi) {
writeHardwareUiOptions();
} else if (preference == mForceMsaa) {