DO NOT MERGE. Remove CDMA options for GSM Mobile Networks screen.
Amith Yamasani [Wed, 15 Jul 2009 18:24:08 +0000 (11:24 -0700)]
Revert to old style "Use 2G only" and pull Apn / Network selection to higher level.

res/values/strings.xml
res/xml/network_setting.xml
src/com/android/phone/CdmaOptions.java
src/com/android/phone/GsmUmtsOptions.java
src/com/android/phone/Settings.java

index c57c9f9..5fdbc39 100755 (executable)
     <string name="gsm_umts_network_preferneces_summary">Not implemented yet! </string>
     <string name="gsm_umts_network_preferences_dialogtitle">GSM/UMTS network preferences</string>
     <string-array name="gsm_umts_network_preferences_choices">
-        <item>GSM/WCDMA (auto mode)</item>
-        <item>WCDMA only</item>
-        <item>GSM only</item>
-        <item>GSM/WCDA (WCDMA preferred)</item>
+        <item>3G preferred</item>
+        <item>2G only</item>
+        <item>3G only</item>
     </string-array>
     <string-array name="gsm_umts_network_preferences_values">
         <item>"0"</item>
         <item>"1"</item>
         <item>"2"</item>
-        <item>"3"</item>
     </string-array>
 
+    <!-- Mobile network settings screen, setting option name -->
+    <string name="prefer_2g">Use only 2G networks</string>
+    <!-- Mobile network settings screen, setting summary text -->
+    <string name="prefer_2g_summary">Saves battery</string>
+
     <!-- CDMA System select strings -->
     <!-- Mobile network settings screen, setting option name -->
     <string name="cdma_system_select_title">System select</string>
     <string name="cdma_network_preferneces_summary">Not implemented yet! </string>
     <string name="cdma_network_preferences_dialogtitle">CDMA network preferences</string>
     <string-array name="cdma_network_preferences_choices">
-        <item>CDMA/EvDo</item>
-        <item>CDMA only</item>
+        <item>CDMA/EvDo auto</item>
+        <item>CDMA w/o EvDo</item>
         <item>EvDo only</item>
     </string-array>
     <string-array name="cdma_network_preferences_values">
-        <item>"0"</item>
-        <item>"1"</item>
-        <item>"2"</item>
+        <item>"4"</item>
+        <item>"5"</item>
+        <item>"6"</item>
     </string-array>
     <string name="subscription_title">CDMA Subscription TEST</string>
     <string name="subscription_summary">Change between RUIM/SIM and NV</string>
index 9a2d706..f902be6 100644 (file)
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:phone="http://schemas.android.com/apk/res/com.android.phone"
         android:title="@string/mobile_networks">
-    
-    <CheckBoxPreference 
-        android:key="button_roaming_key" 
+
+    <CheckBoxPreference
+        android:key="button_roaming_key"
         android:title="@string/roaming"
         android:persistent="false"
         android:summaryOn="@string/roaming_enable"
         android:summaryOff="@string/roaming_disable"/>
-        
-    <ListPreference 
-        android:key="preferred_network_mode_key"
-        android:title="@string/preferred_network_mode_title"
-        android:summary="@string/preferred_network_mode_summary"
-        android:entries="@array/preferred_network_mode_choices"
-        android:entryValues="@array/preferred_network_mode_values"
-        android:dialogTitle="@string/preferred_network_mode_dialogtitle" />
-        
+
+    <CheckBoxPreference
+        android:key="button_prefer_2g_key"
+        android:title="@string/prefer_2g"
+        android:persistent="false"
+        android:summary="@string/prefer_2g_summary"/>
+
     <PreferenceScreen 
-        android:key="gsm_umts_options_key" 
-        android:title="@string/gsm_umts_options"
+        android:key="button_carrier_sel_key"
+        android:title="@string/networks"
+        android:summary="@string/sum_carrier_select"
         android:persistent="false">
         
         <intent android:action="android.intent.action.MAIN"
             android:targetPackage="com.android.phone"
-            android:targetClass="com.android.phone.GsmUmtsOptions" />
+            android:targetClass="com.android.phone.NetworkSetting" />
         
     </PreferenceScreen>
         
     <PreferenceScreen 
-        android:key="cdma_options_key" 
-        android:title="@string/cdma_options"
+        android:key="button_apn_key"
+        android:title="@string/apn_settings"
         android:persistent="false">
         
         <intent android:action="android.intent.action.MAIN"
-            android:targetPackage="com.android.phone"
-            android:targetClass="com.android.phone.CdmaOptions" />
+            android:targetPackage="com.android.settings"
+            android:targetClass="com.android.settings.ApnSettings" />
             
     </PreferenceScreen>
-        
+
 </PreferenceScreen>
index f340933..706cb36 100644 (file)
@@ -148,10 +148,6 @@ public class CdmaOptions extends PreferenceActivity implements Preference.OnPref
                     android.provider.Settings.Secure.CDMA_SUBSCRIPTION_MODE, 
                     preferredSubscriptionMode);
             mButtonCdmaSubscription.setValue(Integer.toString(settingsCdmaSubscriptionMode));
-        } else {
-            mButtonCdmaRoam.setEnabled(false);
-            mButtonCdmaSubscription.setEnabled(false);
-            mButtonCbSmsExpand.setEnabled(false);
         }
     }
 
@@ -167,10 +163,6 @@ public class CdmaOptions extends PreferenceActivity implements Preference.OnPref
         if (mPhone.getPhoneName().equals("CDMA")) {
             mPhone.queryCdmaRoamingPreference(
                     mHandler.obtainMessage(MyHandler.MESSAGE_QUERY_ROAMING_PREFERENCE));
-        } else {
-            mButtonCdmaRoam.setEnabled(false);
-            mButtonCdmaSubscription.setEnabled(false);
-            mButtonCbSmsExpand.setEnabled(false);
         }
     }
 
index 254cf52..f199f63 100644 (file)
@@ -28,25 +28,10 @@ import com.android.internal.telephony.PhoneFactory;
  */
 public class GsmUmtsOptions extends PreferenceActivity {
 
-    private PreferenceScreen mButtonAPNExpand;
-    private PreferenceScreen mButtonOperatorSelectionExpand;
-
-    private static final String BUTTON_APN_EXPAND_KEY = "button_apn_key";
-    private static final String BUTTON_OPERATOR_SELECTION_EXPAND_KEY = "button_carrier_sel_key";
-
-
     @Override
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
         addPreferencesFromResource(R.xml.gsm_umts_options);
-        PreferenceScreen prefSet = getPreferenceScreen();
-        mButtonAPNExpand = (PreferenceScreen) prefSet.findPreference(BUTTON_APN_EXPAND_KEY);
-        mButtonOperatorSelectionExpand = 
-                (PreferenceScreen) prefSet.findPreference(BUTTON_OPERATOR_SELECTION_EXPAND_KEY);
-        if (PhoneFactory.getDefaultPhone().getPhoneName().equals("CDMA")) {
-            mButtonAPNExpand.setEnabled(false);
-            mButtonOperatorSelectionExpand.setEnabled(false);
-        }
     }
 }
index 09ef0aa..9852540 100644 (file)
@@ -45,7 +45,10 @@ public class Settings extends PreferenceActivity implements DialogInterface.OnCl
     //String keys for preference lookup
     private static final String BUTTON_PREFERED_NETWORK_MODE = "preferred_network_mode_key";
     private static final String BUTTON_ROAMING_KEY = "button_roaming_key";
+    private static final String BUTTON_PREFER_2G_KEY = "button_prefer_2g_key";
     private static final String BUTTON_CDMA_SYSTEM_SELECT_KEY = "cdma_system_select_key";
+    private static final String GSM_OPTIONS_KEY = "gsm_umts_options_key";
+    private static final String CDMA_OPTIONS_KEY = "cdma_options_key";
 
     // Used for CDMA roaming mode
     private static final int CDMA_ROAMING_MODE_HOME = 0;
@@ -62,6 +65,7 @@ public class Settings extends PreferenceActivity implements DialogInterface.OnCl
     //UI objects
     private ListPreference mButtonPreferredNetworkMode;
     private CheckBoxPreference mButtonDataRoam;
+    private CheckBoxPreference mButtonPrefer2g;
     private ListPreference mButtonCdmaRoam;
 
     private Phone mPhone;
@@ -133,6 +137,16 @@ public class Settings extends PreferenceActivity implements DialogInterface.OnCl
             mButtonCdmaRoam.setValue(Integer.toString(cdmaRoamingMode));
             return true;
         }
+        else if (preference == mButtonPrefer2g) {
+            int networkType = mButtonPrefer2g.isChecked() ? Phone.NT_MODE_GSM_ONLY
+                    : Phone.NT_MODE_WCDMA_PREF;
+            android.provider.Settings.Secure.putInt(mPhone.getContext().getContentResolver(),
+                    android.provider.Settings.Secure.PREFERRED_NETWORK_MODE,
+                    networkType);
+            mPhone.setPreferredNetworkType(networkType,
+                    mHandler.obtainMessage(MyHandler.MESSAGE_SET_PREFERRED_NETWORK_TYPE));
+            return true;
+        }
         else {
             // if the button is anything but the simple toggle preference,
             // we'll need to disable all preferences to reject all click
@@ -162,8 +176,13 @@ public class Settings extends PreferenceActivity implements DialogInterface.OnCl
         mHandler = new MyHandler();
         mButtonDataRoam = (CheckBoxPreference) prefSet.findPreference(BUTTON_ROAMING_KEY);
 
+        // Remove the other network type options
+        boolean isCdma = mPhone.getPhoneName().equals("CDMA");
+
         // TODO: The radio technology could be changed dynamically after the phone has been created
-        if (mPhone.getPhoneName().equals("CDMA")) {
+        if (isCdma) {
+            Preference otherNetworkType = getPreferenceScreen().findPreference(GSM_OPTIONS_KEY);
+            getPreferenceScreen().removePreference(otherNetworkType);
             mButtonCdmaRoam =
                 (ListPreference) prefSet.findPreference(BUTTON_CDMA_SYSTEM_SELECT_KEY);
             // set the listener for the mButtonCdmaRoam list preference so we can issue
@@ -177,20 +196,7 @@ public class Settings extends PreferenceActivity implements DialogInterface.OnCl
                     PREFERRED_CDMA_ROAMING_MODE);
             mButtonCdmaRoam.setValue(Integer.toString(settingsCdmaRoamingMode));
         } else {
-            mButtonPreferredNetworkMode = (ListPreference) prefSet.findPreference(
-                BUTTON_PREFERED_NETWORK_MODE);
-
-            // set the listener for the mButtonPreferredNetworkMode list preference so we can issue
-            // change Preferred Network Mode.
-            mButtonPreferredNetworkMode.setOnPreferenceChangeListener(this);
-
-            //Get the networkMode from Settings.System and displays it
-            int settingsNetworkMode = android.provider.Settings.Secure.getInt(mPhone.getContext().
-                 getContentResolver(),android.provider.Settings.Secure.PREFERRED_NETWORK_MODE,
-                 preferredNetworkMode);
-            mButtonPreferredNetworkMode.setValue(Integer.toString(settingsNetworkMode));
-            // The intent code that resided here in the past has been moved into the
-            // more conventional location in network_setting.xml
+            mButtonPrefer2g = (CheckBoxPreference) prefSet.findPreference(BUTTON_PREFER_2G_KEY);
         }
     }
 
@@ -210,6 +216,7 @@ public class Settings extends PreferenceActivity implements DialogInterface.OnCl
             mPhone.queryCdmaRoamingPreference(
                     mHandler.obtainMessage(MyHandler.MESSAGE_QUERY_ROAMING_PREFERENCE));
         } else {
+            // Get the state for 'prefer 2g' setting
             mPhone.getPreferredNetworkType(mHandler.obtainMessage(
                     MyHandler.MESSAGE_GET_PREFERRED_NETWORK_TYPE));
         }
@@ -263,7 +270,7 @@ public class Settings extends PreferenceActivity implements DialogInterface.OnCl
                     default:
                         modemNetworkMode = Phone.PREFERRED_NT_MODE;
                 }
-                UpdatePreferredNetworkModeSummary(buttonNetworkMode);
+                updatePreferredNetworkModeSummary(buttonNetworkMode);
 
                 android.provider.Settings.Secure.putInt(mPhone.getContext().getContentResolver(),
                         android.provider.Settings.Secure.PREFERRED_NETWORK_MODE,
@@ -391,10 +398,13 @@ public class Settings extends PreferenceActivity implements DialogInterface.OnCl
                                 android.provider.Settings.Secure.PREFERRED_NETWORK_MODE,
                                 settingsNetworkMode );
                     }
-
-                    UpdatePreferredNetworkModeSummary(modemNetworkMode);
-                    // changes the mButtonPreferredNetworkMode accordingly to modemNetworkMode
-                    mButtonPreferredNetworkMode.setValue(Integer.toString(modemNetworkMode));
+                    if (mPhone.getPhoneName().equals("CDMA")) {
+                        updatePreferredNetworkModeSummary(modemNetworkMode);
+                        // changes the mButtonPreferredNetworkMode accordingly to modemNetworkMode
+                        mButtonPreferredNetworkMode.setValue(Integer.toString(modemNetworkMode));
+                    } else {
+                        mButtonPrefer2g.setChecked(modemNetworkMode == Phone.NT_MODE_GSM_ONLY);
+                    }
                 } else {
                     if (DBG) log("handleGetPreferredNetworkTypeResponse: else: reset to default");
                     resetNetworkModeToDefault();
@@ -406,19 +416,29 @@ public class Settings extends PreferenceActivity implements DialogInterface.OnCl
             AsyncResult ar = (AsyncResult) msg.obj;
 
             if (ar.exception == null) {
-                int networkMode = Integer.valueOf(
-                        mButtonPreferredNetworkMode.getValue()).intValue();
+                int networkMode;
+                if (mPhone.getPhoneName().equals("CDMA")) {
+                    networkMode =
+                        Integer.valueOf(mButtonPreferredNetworkMode.getValue()).intValue();
+                } else {
+                    networkMode = mButtonPrefer2g.isChecked()
+                            ? Phone.NT_MODE_GSM_ONLY : Phone.NT_MODE_WCDMA_PREF;
+                }
                 android.provider.Settings.Secure.putInt(mPhone.getContext().getContentResolver(),
                         android.provider.Settings.Secure.PREFERRED_NETWORK_MODE,
-                        networkMode );
+                        networkMode);
             } else {
                 mPhone.getPreferredNetworkType(obtainMessage(MESSAGE_GET_PREFERRED_NETWORK_TYPE));
             }
         }
 
         private void resetNetworkModeToDefault() {
-            //set the mButtonPreferredNetworkMode
-            mButtonPreferredNetworkMode.setValue(Integer.toString(preferredNetworkMode));
+            if (mPhone.getPhoneName().equals("CDMA")) {
+                //set the mButtonPreferredNetworkMode
+                mButtonPreferredNetworkMode.setValue(Integer.toString(preferredNetworkMode));
+            } else {
+                mButtonPrefer2g.setChecked(preferredNetworkMode == Phone.NT_MODE_GSM_ONLY);
+            }
             //set the Settings.System
             android.provider.Settings.Secure.putInt(mPhone.getContext().getContentResolver(),
                         android.provider.Settings.Secure.PREFERRED_NETWORK_MODE,
@@ -491,34 +511,9 @@ public class Settings extends PreferenceActivity implements DialogInterface.OnCl
         }
     }
 
-    private void UpdatePreferredNetworkModeSummary(int NetworkMode) {
-        switch(NetworkMode) {
-            case Phone.NT_MODE_WCDMA_PREF:
-                // TODO T: Make all of these strings come from res/values/strings.xml.
-                mButtonPreferredNetworkMode.setSummary("Preferred network mode: WCDMA pref");
-                break;
-            case Phone.NT_MODE_GSM_ONLY:
-                mButtonPreferredNetworkMode.setSummary("Preferred network mode: GSM only");
-                break;
-            case Phone.NT_MODE_WCDMA_ONLY:
-                mButtonPreferredNetworkMode.setSummary("Preferred network mode: WCDMA only");
-                break;
-            case Phone.NT_MODE_GSM_UMTS:
-                mButtonPreferredNetworkMode.setSummary("Preferred network mode: GSM/WCDMA");
-                break;
-            case Phone.NT_MODE_CDMA:
-                mButtonPreferredNetworkMode.setSummary("Preferred network mode: CDMA / EvDo");
-                break;
-            case Phone.NT_MODE_CDMA_NO_EVDO:
-                mButtonPreferredNetworkMode.setSummary("Preferred network mode: CDMA only");
-                break;
-            case Phone.NT_MODE_EVDO_NO_CDMA:
-                mButtonPreferredNetworkMode.setSummary("Preferred network mode: EvDo only");
-                break;
-            case Phone.NT_MODE_GLOBAL:
-            default:
-                mButtonPreferredNetworkMode.setSummary("Preferred network mode: Global");
-        }
+    private void updatePreferredNetworkModeSummary(int NetworkMode) {
+        if (!mPhone.getPhoneName().equals("CDMA")) return;
+        mButtonPreferredNetworkMode.setSummary(mButtonPreferredNetworkMode.getEntry());
     }
 
     private static void log(String msg) {