OSDN Git Service

Add a developer offload for tethering hardware acceleration.
authorLorenzo Colitti <lorenzo@google.com>
Tue, 4 Jul 2017 15:29:44 +0000 (00:29 +0900)
committerLorenzo Colitti <lorenzo@google.com>
Thu, 6 Jul 2017 03:13:11 +0000 (12:13 +0900)
Bug: 32163131
Test: builds
Change-Id: Icca7bbd2bdd572b1328e7d0fecb663405b115fe1

res/xml/development_prefs.xml
src/com/android/settings/development/DevelopmentSettings.java

index e443027..4d5eb70 100644 (file)
             android:title="@string/wifi_allow_scan_with_traffic"
             android:summary="@string/wifi_allow_scan_with_traffic_summary"/>
 
-       <SwitchPreference
+        <SwitchPreference
             android:key="mobile_data_always_on"
             android:title="@string/mobile_data_always_on"
             android:summary="@string/mobile_data_always_on_summary"/>
 
+        <SwitchPreference
+            android:key="tethering_hardware_offload"
+            android:title="@string/tethering_hardware_offload"
+            android:summary="@string/tethering_hardware_offload_summary"/>
+
         <ListPreference
             android:key="select_usb_configuration"
             android:title="@string/select_usb_configuration_title"
index a96e0e3..7d21a8e 100644 (file)
@@ -193,6 +193,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
     private static final String WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY = "wifi_allow_scan_with_traffic";
     private static final String USB_CONFIGURATION_KEY = "select_usb_configuration";
     private static final String MOBILE_DATA_ALWAYS_ON = "mobile_data_always_on";
+    private static final String TETHERING_HARDWARE_OFFLOAD = "tethering_hardware_offload";
     private static final String KEY_COLOR_MODE = "picture_color_mode";
     private static final String FORCE_RESIZABLE_KEY = "force_resizable_activities";
     private static final String COLOR_TEMPERATURE_KEY = "color_temperature";
@@ -279,6 +280,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
     private SwitchPreference mWifiVerboseLogging;
     private SwitchPreference mWifiAggressiveHandover;
     private SwitchPreference mMobileDataAlwaysOn;
+    private SwitchPreference mTetheringHardwareOffload;
     private SwitchPreference mBluetoothDisableAbsVolume;
     private SwitchPreference mBluetoothEnableInbandRinging;
 
@@ -475,6 +477,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
         mWifiAggressiveHandover = findAndInitSwitchPref(WIFI_AGGRESSIVE_HANDOVER_KEY);
         mWifiAllowScansWithTraffic = findAndInitSwitchPref(WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY);
         mMobileDataAlwaysOn = findAndInitSwitchPref(MOBILE_DATA_ALWAYS_ON);
+        mTetheringHardwareOffload = findAndInitSwitchPref(TETHERING_HARDWARE_OFFLOAD);
         mLogdSize = addListPreference(SELECT_LOGD_SIZE_KEY);
         if ("1".equals(SystemProperties.get("ro.debuggable", "0"))) {
             mLogpersist = addListPreference(SELECT_LOGPERSIST_KEY);
@@ -807,6 +810,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
         updateWifiAggressiveHandoverOptions();
         updateWifiAllowScansWithTrafficOptions();
         updateMobileDataAlwaysOnOptions();
+        updateTetheringHardwareOffloadOptions();
         updateSimulateColorSpace();
         updateUSBAudioOptions();
         updateForceResizableOptions();
@@ -1481,6 +1485,18 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
                 mMobileDataAlwaysOn.isChecked() ? 1 : 0);
     }
 
+    private void updateTetheringHardwareOffloadOptions() {
+        updateSwitchPreference(mTetheringHardwareOffload, Settings.Global.getInt(
+                getActivity().getContentResolver(),
+                Settings.Global.TETHER_OFFLOAD_DISABLED, 0) != 1);
+    }
+
+    private void writeTetheringHardwareOffloadOptions() {
+        Settings.Global.putInt(getActivity().getContentResolver(),
+                Settings.Global.TETHER_OFFLOAD_DISABLED,
+                mTetheringHardwareOffload.isChecked() ? 0 : 1);
+    }
+
     private String defaultLogdSizeValue() {
         String defaultValue = SystemProperties.get(SELECT_LOGD_DEFAULT_SIZE_PROPERTY);
         if ((defaultValue == null) || (defaultValue.length() == 0)) {
@@ -2498,6 +2514,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
             writeWifiAllowScansWithTrafficOptions();
         } else if (preference == mMobileDataAlwaysOn) {
             writeMobileDataAlwaysOnOptions();
+        } else if (preference == mTetheringHardwareOffload) {
+            writeTetheringHardwareOffloadOptions();
         } else if (preference == mColorTemperaturePreference) {
             writeColorTemperature();
         } else if (preference == mUSBAudio) {