Add settings for persisting the mobile data connection.

Change-Id: I9b92104893e860e2beb63ac86d417419699c085b
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6e597ca..3f84463 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3557,6 +3557,8 @@
     <string name="wifi_allow_scan_with_traffic">Always allow Wi\u2011Fi Roam Scans</string>
     <!-- Setting Checkbox title whether to enable WiFi Scanning in the presence of traffic. [CHAR LIMIT=80] -->
     <string name="legacy_dhcp_client">Use legacy DHCP client</string>
+    <!-- Setting Checkbox title whether to always keep cellular data active. [CHAR LIMIT=80] -->
+    <string name="mobile_data_always_on">Cellular data always active</string>
 
     <!-- setting Checkbox summary whether to show options for wireless display certification  -->
     <string name="wifi_display_certification_summary">Show options for wireless display certification</string>
@@ -3583,6 +3585,7 @@
     <!-- Title of warning dialog about the implications of enabling USB debugging -->
     <!-- Setting Checkbox summary whether to use DHCP client from Lollipop (Android 5.0) [CHAR LIMIT=130] -->
     <string name="legacy_dhcp_client_summary">Use the DHCP client from Lollipop instead of the new Android DHCP client.</string>
+    <string name="mobile_data_always_on_summary">Always keep mobile data active, even when Wi\u2011Fi is active (for fast network switching).</string>
     <string name="adb_warning_title">Allow USB debugging?</string>
     <!-- Warning text to user about the implications of enabling USB debugging -->
     <string name="adb_warning_message">USB debugging is intended for development purposes only. Use it to copy data between your computer and your device, install apps on your device without notification, and read log data.</string>
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index 6911892..ecab700 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -137,9 +137,14 @@
 
        <SwitchPreference
             android:key="legacy_dhcp_client"
-            android:title="@string/legacy_dhcp_client" />
+            android:title="@string/legacy_dhcp_client"
             android:summary="@string/legacy_dhcp_client_summary"/>
 
+       <SwitchPreference
+            android:key="mobile_data_always_on"
+            android:title="@string/mobile_data_always_on"
+            android:summary="@string/mobile_data_always_on_summary"/>
+
         <ListPreference
             android:key="select_usb_configuration"
             android:title="@string/select_usb_configuration_title"
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 6c2f135..3c964c9 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -155,6 +155,7 @@
     private static final String USB_CONFIGURATION_KEY = "select_usb_configuration";
     private static final String SELECT_USB_CONFIGURATION_PROPERTY = "sys.usb.config";
     private static final String WIFI_LEGACY_DHCP_CLIENT_KEY = "legacy_dhcp_client";
+    private static final String MOBILE_DATA_ALWAYS_ON = "mobile_data_always_on";
 
     private static final String OPENGL_TRACES_KEY = "enable_opengl_traces";
 
@@ -208,6 +209,7 @@
     private SwitchPreference mWifiVerboseLogging;
     private SwitchPreference mWifiAggressiveHandover;
     private SwitchPreference mLegacyDhcpClient;
+    private SwitchPreference mMobileDataAlwaysOn;
 
     private SwitchPreference mWifiAllowScansWithTraffic;
     private SwitchPreference mStrictMode;
@@ -353,6 +355,7 @@
         mWifiAggressiveHandover = findAndInitSwitchPref(WIFI_AGGRESSIVE_HANDOVER_KEY);
         mWifiAllowScansWithTraffic = findAndInitSwitchPref(WIFI_ALLOW_SCAN_WITH_TRAFFIC_KEY);
         mLegacyDhcpClient = findAndInitSwitchPref(WIFI_LEGACY_DHCP_CLIENT_KEY);
+        mMobileDataAlwaysOn = findAndInitSwitchPref(MOBILE_DATA_ALWAYS_ON);
         mLogdSize = addListPreference(SELECT_LOGD_SIZE_KEY);
         mUsbConfiguration = addListPreference(USB_CONFIGURATION_KEY);
 
@@ -586,6 +589,7 @@
         updateWifiAggressiveHandoverOptions();
         updateWifiAllowScansWithTrafficOptions();
         updateLegacyDhcpClientOptions();
+        updateMobileDataAlwaysOnOptions();
         updateSimulateColorSpace();
         updateUseNuplayerOptions();
         updateUSBAudioOptions();
@@ -1152,6 +1156,18 @@
                 mLegacyDhcpClient.isChecked() ? 1 : 0);
     }
 
+    private void updateMobileDataAlwaysOnOptions() {
+        updateSwitchPreference(mMobileDataAlwaysOn, Settings.Global.getInt(
+                getActivity().getContentResolver(),
+                Settings.Global.MOBILE_DATA_ALWAYS_ON, 0) != 0);
+    }
+
+    private void writeMobileDataAlwaysOnOptions() {
+        Settings.Global.putInt(getActivity().getContentResolver(),
+                Settings.Global.MOBILE_DATA_ALWAYS_ON,
+                mMobileDataAlwaysOn.isChecked() ? 1 : 0);
+    }
+
     private void updateLogdSizeValues() {
         if (mLogdSize != null) {
             String currentValue = SystemProperties.get(SELECT_LOGD_SIZE_PROPERTY);
@@ -1592,6 +1608,8 @@
             writeWifiAllowScansWithTrafficOptions();
         } else if (preference == mLegacyDhcpClient) {
             writeLegacyDhcpClientOptions();
+        } else if (preference == mMobileDataAlwaysOn) {
+            writeMobileDataAlwaysOnOptions();
         } else if (preference == mUseAwesomePlayer) {
             writeUseAwesomePlayerOptions();
         } else if (preference == mUSBAudio) {