Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 029c13e1 authored by Selim Gurun's avatar Selim Gurun
Browse files

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
parent 0e0122a9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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] -->
+9 −5
Original line number Diff line number Diff line
@@ -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>
+24 −0
Original line number Diff line number Diff line
@@ -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) {