CDMA DTMF application changes.
Wink Saville [Thu, 25 Jun 2009 05:18:12 +0000 (22:18 -0700)]
Also add network_message for change 5340.

res/values/strings.xml [changed mode: 0644->0755]
res/xml/cdma_call_feature_setting.xml [new file with mode: 0755]
src/com/android/phone/CallFeaturesSetting.java [changed mode: 0644->0755]
src/com/android/phone/DTMFTwelveKeyDialer.java [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 89c344a..8f49da9
     <!-- Label for ERI text widget, shown in list of all gadgets -->
     <string name="eri_text_label">ERI text</string>
 
+    <!-- Dtmf tones settings -->
+    <!-- Title for the DTMF Tones options displayed in Call Settings -->
+    <string name="dtmf_tones_title">DTMF Tones</string>
+    <!-- Summary for the DTMF Tones options displayed in Call Settings -->
+    <string name="dtmf_tones_summary">Set the length of DTMF tones</string>
+    <!-- Options displayed as part of DTMF Tones in Call Settings -->
+    <string-array name="dtmf_tone_entries">
+      <item>Normal</item>
+      <item>Long</item>
+    </string-array>
+    <!-- Do not translate. -->
+    <string-array name="dtmf_tone_values">
+       <item>0</item>
+       <item>1</item>
+    </string-array>
+
+    <!-- Title for the dialog used to display CDMA DisplayInfo -->
+    <string name="network_message">Network Message</string>
+
 </resources>
 
 
diff --git a/res/xml/cdma_call_feature_setting.xml b/res/xml/cdma_call_feature_setting.xml
new file mode 100755 (executable)
index 0000000..98554ac
--- /dev/null
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     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.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:phone="http://schemas.android.com/apk/res/com.android.phone">
+
+    <PreferenceCategory
+        android:title="@string/call_settings"/>
+
+    <!-- Note for all com.android.phone.EditPhoneNumberPreference objects
+
+         The last several attributes are for use with the EditText field
+         in the dialog.  These attributes are forwarded to that field
+         when the edittext is created.  The attributes include:
+           1. android:singleLine
+           2. android:autoText
+           3. android:background -->
+
+    <!-- Rearranged to allow for lazy queries. -->
+
+    <com.android.phone.EditPhoneNumberPreference
+        android:key="button_voicemail_key"
+        android:title="@string/voicemail"
+        android:summary="@string/sum_voicemail"
+        android:persistent="false"
+        android:dialogTitle="@string/voicemail"
+        phone:confirmMode="confirm"
+        android:singleLine="true"
+        android:autoText="false"/>
+
+    <CheckBoxPreference
+        android:key="button_voice_privacy_key"
+        android:title="@string/voice_privacy"
+        android:persistent="false"
+        android:summary="@string/voice_privacy_summary"/>
+
+ <!-- <CheckBoxPreference
+            android:key="button_tty_mode_key"
+            android:title="@string/tty_mode_title"
+            android:persistent="true"
+            android:summary="@string/tty_mode_summary"/>
+-->
+    <!-- CDMA TTY Options -->
+    <ListPreference
+        android:key="button_tty_mode_key"
+        android:title="@string/tty_mode_option_title"
+        android:summary="@string/tty_mode_option_summary"
+        android:persistent="false"
+        android:entries="@array/tty_mode_entries"
+        android:entryValues="@array/tty_mode_values" />
+    <!-- CDMA DTMF Options -->
+    <ListPreference
+        android:key="dtmf_settings"
+        android:title="@string/dtmf_tones_title"
+        android:summary="@string/dtmf_tones_summary"
+        android:entries="@array/dtmf_tone_entries"
+        android:entryValues="@array/dtmf_tone_values" />
+
+
+</PreferenceScreen>
old mode 100644 (file)
new mode 100755 (executable)
index 2a87767..9844d67
@@ -89,6 +89,7 @@ public class CallFeaturesSetting extends PreferenceActivity
 
     private static final String BUTTON_TTY_KEY = "button_tty_mode_key";
     private static final String BUTTON_VP_KEY = "button_voice_privacy_key";
+    private static final String BUTTON_DS_KEY = "dtmf_settings";
 
     private Intent mContactListIntent;
     private Intent mFDNSettingIntent;
@@ -106,7 +107,7 @@ public class CallFeaturesSetting extends PreferenceActivity
     private static final int EVENT_TTY_EXECUTED          = 700;
     private static final int EVENT_TTY_MODE_SET          = 800;
     private static final int EVENT_ENHANCED_VP_EXECUTED  = 1000;
-    
+
     // preferred TTY mode
     // 0 = disabled
     // 1 = full mode
@@ -119,6 +120,14 @@ public class CallFeaturesSetting extends PreferenceActivity
     // 1 = enabled
     static final int preferredVPMode = 1;
 
+    // Dtmf tone types
+    static final int DTMF_TONE_TYPE_NORMAL = 0;
+    static final int DTMF_TONE_TYPE_LONG   = 1;
+
+    // preferred DTMF Tones mode
+    static final int preferredDtmfMode = DTMF_TONE_TYPE_NORMAL;
+
+
     /** Handle to voicemail pref */
     private static final int VOICEMAIL_PREF_ID = CommandsInterface.CF_REASON_NOT_REACHABLE + 1;
 
@@ -187,6 +196,7 @@ public class CallFeaturesSetting extends PreferenceActivity
     private PreferenceScreen mButtonCDMAMoreExpand;
     private CheckBoxPreference mButtonVoicePrivacy;
     private ListPreference mButtonTTY;
+    private ListPreference mButtonDS;
 
     // cf number strings
     private String mDialingNumCFU;
@@ -250,6 +260,9 @@ public class CallFeaturesSetting extends PreferenceActivity
                     preferredTtyMode);
             mButtonTTY.setValue(Integer.toString(settingsTtyMode));
             return true;
+        } else if (preference == mButtonDS) {
+            // Let the normal listpreference UI take care of this
+            return false;
         }
 
         if (nextState != AppState.INPUT_READY) {
@@ -276,8 +289,11 @@ public class CallFeaturesSetting extends PreferenceActivity
         } else if (preference == mButtonTTY) {
             // send the command and update state.
             handleTTYClickRequest(preference, objValue);
+        } else if (preference == mButtonDS) {
+            int index = mButtonDS.findIndexOfValue((String) objValue);
+            Settings.System.putInt(mPhone.getContext().getContentResolver(),
+                    Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, index);
         }
-
         // always let the preference setting proceed.
         return true;
     }
@@ -1350,10 +1366,7 @@ public class CallFeaturesSetting extends PreferenceActivity
             // and the UI state would be inconsistent with actual state
             handleSetVPMessage();
             mPhone.queryTTYMode(Message.obtain(mQueryTTYComplete, EVENT_TTY_EXECUTED));
-            mButtonCFExpand.setEnabled(false);
-            mButtonCLIR.setEnabled(false);
-            mButtonCW.setChecked(false);
-            mButtonCW.setEnabled(false);
+            // TODO(Moto): Re-launch DTMF settings if necessary onResume
         } else {
             mButtonTTY.setEnabled(false);
             mButtonVoicePrivacy.setChecked(false);
@@ -1371,31 +1384,25 @@ public class CallFeaturesSetting extends PreferenceActivity
         super.onCreate(icicle);
         mPhone = PhoneFactory.getDefaultPhone();
 
-        addPreferencesFromResource(R.xml.call_feature_setting);
-
+        // If the phone loads in CDMA mode , Call Settings XML is CDMA specific
+        // TODO: For World Phone, that has options to switch n/w mode dynamically, this
+        // design will not work and this piece of code may be moved to onResume()
+        if (mPhone.getPhoneName().equals("CDMA")) {
+            addPreferencesFromResource(R.xml.cdma_call_feature_setting);
+        } else {
+            addPreferencesFromResource(R.xml.call_feature_setting);
+        }
         // get buttons
         PreferenceScreen prefSet = getPreferenceScreen();
-        mButtonCLIR  = (ListPreference) prefSet.findPreference(BUTTON_CLIR_KEY);
-        mButtonCW    = (CheckBoxPreference) prefSet.findPreference(BUTTON_CW_KEY);
-        mButtonCFU   = (EditPhoneNumberPreference) prefSet.findPreference(BUTTON_CFU_KEY);
-        mButtonCFB   = (EditPhoneNumberPreference) prefSet.findPreference(BUTTON_CFB_KEY);
-        mButtonCFNRy = (EditPhoneNumberPreference) prefSet.findPreference(BUTTON_CFNRY_KEY);
-        mButtonCFNRc = (EditPhoneNumberPreference) prefSet.findPreference(BUTTON_CFNRC_KEY);
         mSubMenuVoicemailSettings = (EditPhoneNumberPreference)
                 prefSet.findPreference(BUTTON_VOICEMAIL_KEY);
         mSubMenuFDNSettings = (PreferenceScreen) prefSet.findPreference(BUTTON_FDN_KEY);
-
-        // get a reference to the Preference Screens for Call Forwarding and "More" settings.
-        mButtonCFExpand = (PreferenceScreen) prefSet.findPreference(BUTTON_CF_EXPAND_KEY);
-        mButtonGSMMoreExpand = (PreferenceScreen) prefSet.findPreference(
-                BUTTON_GSM_MORE_EXPAND_KEY);
-        mButtonCDMAMoreExpand = (PreferenceScreen) prefSet.findPreference(
-                BUTTON_CDMA_MORE_EXPAND_KEY);
+        mButtonVoicePrivacy = (CheckBoxPreference) findPreference(BUTTON_VP_KEY);
 
         mButtonTTY = (ListPreference) prefSet.findPreference(BUTTON_TTY_KEY);
         mButtonTTY.setOnPreferenceChangeListener(this);
 
-        //Get the ttyMode from Settings.System and displays it
+        // Get the ttyMode from Settings.System and displays it
         int settingsTtyMode = android.provider.Settings.Secure.getInt(
                 mPhone.getContext().getContentResolver(),
                 android.provider.Settings.Secure.PREFERRED_TTY_MODE,
@@ -1403,47 +1410,75 @@ public class CallFeaturesSetting extends PreferenceActivity
         mButtonTTY.setValue(Integer.toString(settingsTtyMode));
         UpdatePreferredTtyModeSummary(settingsTtyMode);
 
-        // The intent code that resided here in the past has been moved into the
-        // more conventional location in network_setting.xml
-        mButtonVoicePrivacy = (CheckBoxPreference) findPreference(BUTTON_VP_KEY);
-
+        if (mPhone.getPhoneName().equals("CDMA")) {
+            mButtonDS = (ListPreference) findPreference(BUTTON_DS_KEY);
+            int index = Settings.System.getInt(getContentResolver(),
+                    Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, preferredDtmfMode);
+            mButtonDS.setValueIndex(index);
+            mButtonDS.setOnPreferenceChangeListener(this);
+        }
         if (mPhone.getPhoneName().equals("GSM")) {
+            mButtonCLIR  = (ListPreference) prefSet.findPreference(BUTTON_CLIR_KEY);
+            mButtonCW    = (CheckBoxPreference) prefSet.findPreference(BUTTON_CW_KEY);
+            mButtonCFU   = (EditPhoneNumberPreference) prefSet.findPreference(BUTTON_CFU_KEY);
+            mButtonCFB   = (EditPhoneNumberPreference) prefSet.findPreference(BUTTON_CFB_KEY);
+            mButtonCFNRy = (EditPhoneNumberPreference) prefSet.findPreference(BUTTON_CFNRY_KEY);
+            mButtonCFNRc = (EditPhoneNumberPreference) prefSet.findPreference(BUTTON_CFNRC_KEY);
+
+            // get a reference to the Preference Screens for Call Forwarding and "More" settings.
+            mButtonCFExpand = (PreferenceScreen) prefSet.findPreference(BUTTON_CF_EXPAND_KEY);
+            mButtonGSMMoreExpand = (PreferenceScreen) prefSet.findPreference(
+                    BUTTON_GSM_MORE_EXPAND_KEY);
+            mButtonCDMAMoreExpand = (PreferenceScreen) prefSet.findPreference(
+                    BUTTON_CDMA_MORE_EXPAND_KEY);
+
+            // The intent code that resided here in the past has been moved into the
+            // more conventional location in network_setting.xml
+
             mButtonVoicePrivacy.setEnabled(false);
-        }
 
-        // Set links to the current activity and any UI settings that
-        // effect the dialog for each preference.  Also set the
-        // dependencies between the child (CFB, CFNRy, CFNRc)
-        // preferences and the CFU preference.
-        if (mButtonCFU != null){
-            mButtonCFU.setParentActivity(this, CommandsInterface.CF_REASON_UNCONDITIONAL, this);
-            mButtonCFU.setDialogOnClosedListener(this);
-            mButtonCFU.setDialogTitle(R.string.labelCF);
-            mButtonCFU.setDialogMessage(R.string.messageCFU);
-        }
+            // Set links to the current activity and any UI settings that
+            // effect the dialog for each preference.  Also set the
+            // dependencies between the child (CFB, CFNRy, CFNRc)
+            // preferences and the CFU preference.
+            if (mButtonCFU != null){
+                mButtonCFU.setParentActivity(this, CommandsInterface.CF_REASON_UNCONDITIONAL, this);
+                mButtonCFU.setDialogOnClosedListener(this);
+                mButtonCFU.setDialogTitle(R.string.labelCF);
+                mButtonCFU.setDialogMessage(R.string.messageCFU);
+            }
 
-        if (mButtonCFB != null) {
-            mButtonCFB.setParentActivity(this, CommandsInterface.CF_REASON_BUSY, this);
-            mButtonCFB.setDialogOnClosedListener(this);
-            mButtonCFB.setDependency(BUTTON_CFU_KEY);
-            mButtonCFB.setDialogTitle(R.string.labelCF);
-            mButtonCFB.setDialogMessage(R.string.messageCFB);
-        }
+            if (mButtonCFB != null) {
+                mButtonCFB.setParentActivity(this, CommandsInterface.CF_REASON_BUSY, this);
+                mButtonCFB.setDialogOnClosedListener(this);
+                mButtonCFB.setDependency(BUTTON_CFU_KEY);
+                mButtonCFB.setDialogTitle(R.string.labelCF);
+                mButtonCFB.setDialogMessage(R.string.messageCFB);
+            }
 
-        if (mButtonCFNRy != null) {
-            mButtonCFNRy.setParentActivity(this, CommandsInterface.CF_REASON_NO_REPLY, this);
-            mButtonCFNRy.setDialogOnClosedListener(this);
-            mButtonCFNRy.setDependency(BUTTON_CFU_KEY);
-            mButtonCFNRy.setDialogTitle(R.string.labelCF);
-            mButtonCFNRy.setDialogMessage(R.string.messageCFNRy);
-        }
+            if (mButtonCFNRy != null) {
+                mButtonCFNRy.setParentActivity(this, CommandsInterface.CF_REASON_NO_REPLY, this);
+                mButtonCFNRy.setDialogOnClosedListener(this);
+                mButtonCFNRy.setDependency(BUTTON_CFU_KEY);
+                mButtonCFNRy.setDialogTitle(R.string.labelCF);
+                mButtonCFNRy.setDialogMessage(R.string.messageCFNRy);
+            }
 
-        if (mButtonCFNRc != null) {
-            mButtonCFNRc.setParentActivity(this, CommandsInterface.CF_REASON_NOT_REACHABLE, this);
-            mButtonCFNRc.setDialogOnClosedListener(this);
-            mButtonCFNRc.setDependency(BUTTON_CFU_KEY);
-            mButtonCFNRc.setDialogTitle(R.string.labelCF);
-            mButtonCFNRc.setDialogMessage(R.string.messageCFNRc);
+            if (mButtonCFNRc != null) {
+                mButtonCFNRc.setParentActivity(this, CommandsInterface.CF_REASON_NOT_REACHABLE, this);
+                mButtonCFNRc.setDialogOnClosedListener(this);
+                mButtonCFNRc.setDependency(BUTTON_CFU_KEY);
+                mButtonCFNRc.setDialogTitle(R.string.labelCF);
+                mButtonCFNRc.setDialogMessage(R.string.messageCFNRc);
+            }
+
+            // set the listener for the CLIR list preference so we can issue CLIR commands.
+            if (mButtonCLIR != null ) {
+                mButtonCLIR.setOnPreferenceChangeListener(this);
+            }
+            mFDNSettingIntent = new Intent(Intent.ACTION_MAIN);
+            mFDNSettingIntent.setClassName(this, FdnSetting.class.getName());
+            mSubMenuFDNSettings.setIntent (mFDNSettingIntent);
         }
 
         if (mSubMenuVoicemailSettings != null) {
@@ -1452,11 +1487,6 @@ public class CallFeaturesSetting extends PreferenceActivity
             mSubMenuVoicemailSettings.setDialogTitle(R.string.voicemail_settings_number_label);
         }
 
-        // set the listener for the CLIR list preference so we can issue CLIR commands.
-        if (mButtonCLIR != null ) {
-            mButtonCLIR.setOnPreferenceChangeListener(this);
-        }
-
         // create intent to bring up contact list
         mContactListIntent = new Intent(Intent.ACTION_GET_CONTENT);
         mContactListIntent.setType(android.provider.Contacts.Phones.CONTENT_ITEM_TYPE);
@@ -1470,38 +1500,40 @@ public class CallFeaturesSetting extends PreferenceActivity
         mAppState = AppState.INPUT_READY;
 
         if (icicle != null) {
-            // retrieve number state
-            mDialingNumCFU = icicle.getString(SUMMARY_CFU_KEY);
-            mDialingNumCFB = icicle.getString(SUMMARY_CFB_KEY);
-            mDialingNumCFNRy = icicle.getString(SUMMARY_CFNRY_KEY);
-            mDialingNumCFNRc = icicle.getString(SUMMARY_CFNRC_KEY);
-
-            // reset CF buttons
-            adjustCFbuttonState(mButtonCFU, icicle.getBoolean(BUTTON_CFU_KEY),
-                    R.string.sum_cfu_enabled, mDialingNumCFU);
-            adjustCFbuttonState(mButtonCFB, icicle.getBoolean(BUTTON_CFB_KEY),
-                    R.string.sum_cfb_enabled, mDialingNumCFB);
-            adjustCFbuttonState(mButtonCFNRy, icicle.getBoolean(BUTTON_CFNRY_KEY),
-                    R.string.sum_cfnry_enabled, mDialingNumCFNRy);
-            adjustCFbuttonState(mButtonCFNRc, icicle.getBoolean(BUTTON_CFNRC_KEY),
-                    R.string.sum_cfnrc_enabled, mDialingNumCFNRc);
-
-            // reset other button state
-            setButtonCLIRValue(icicle.getInt(BUTTON_CLIR_KEY));
-            if (mButtonCW != null) {
-                mButtonCW.setChecked(icicle.getBoolean(BUTTON_CW_KEY));
-            }
             if (mButtonVoicePrivacy != null) {
                 mButtonVoicePrivacy.setChecked(icicle.getBoolean(BUTTON_VP_KEY));
-                if (mPhone.getPhoneName().equals("GSM")) {
+            }
+            if (mPhone.getPhoneName().equals("GSM")) {
+                // retrieve number state
+                mDialingNumCFU = icicle.getString(SUMMARY_CFU_KEY);
+                mDialingNumCFB = icicle.getString(SUMMARY_CFB_KEY);
+                mDialingNumCFNRy = icicle.getString(SUMMARY_CFNRY_KEY);
+                mDialingNumCFNRc = icicle.getString(SUMMARY_CFNRC_KEY);
+
+                // reset CF buttons
+                adjustCFbuttonState(mButtonCFU, icicle.getBoolean(BUTTON_CFU_KEY),
+                        R.string.sum_cfu_enabled, mDialingNumCFU);
+                adjustCFbuttonState(mButtonCFB, icicle.getBoolean(BUTTON_CFB_KEY),
+                        R.string.sum_cfb_enabled, mDialingNumCFB);
+                adjustCFbuttonState(mButtonCFNRy, icicle.getBoolean(BUTTON_CFNRY_KEY),
+                        R.string.sum_cfnry_enabled, mDialingNumCFNRy);
+                adjustCFbuttonState(mButtonCFNRc, icicle.getBoolean(BUTTON_CFNRC_KEY),
+                        R.string.sum_cfnrc_enabled, mDialingNumCFNRc);
+
+                // reset other button state
+                setButtonCLIRValue(icicle.getInt(BUTTON_CLIR_KEY));
+                if (mButtonCW != null) {
+                    mButtonCW.setChecked(icicle.getBoolean(BUTTON_CW_KEY));
+                }
+                if (mButtonVoicePrivacy != null) {
                     mButtonVoicePrivacy.setEnabled(false);
                 }
+                mCFDataStale = icicle.getBoolean(BUTTON_CF_EXPAND_KEY);
+                mMoreDataStale = icicle.getBoolean(BUTTON_GSM_MORE_EXPAND_KEY);
             }
 
             // set app state
             mAppState = (AppState) icicle.getSerializable(APP_STATE_KEY);
-            mCFDataStale = icicle.getBoolean(BUTTON_CF_EXPAND_KEY);
-            mMoreDataStale = icicle.getBoolean(BUTTON_GSM_MORE_EXPAND_KEY);
             mDisplayMode = icicle.getInt(DISPLAY_MODE_KEY);
 
         } else {
@@ -1527,25 +1559,6 @@ public class CallFeaturesSetting extends PreferenceActivity
 
         if (DBG) log("onSaveInstanceState: saving relevant UI state.");
 
-        // save button state
-        if (mButtonCLIR != null) {
-            outState.putInt(BUTTON_CLIR_KEY, mButtonCLIR.findIndexOfValue(mButtonCLIR.getValue()));
-        }
-        if (mButtonCW != null) {
-            outState.putBoolean(BUTTON_CW_KEY, mButtonCW.isChecked());
-        }
-        if (mButtonCFU != null) {
-            outState.putBoolean(BUTTON_CFU_KEY, mButtonCFU.isToggled());
-        }
-        if (mButtonCFB != null) {
-            outState.putBoolean(BUTTON_CFB_KEY, mButtonCFB.isToggled());
-        }
-        if (mButtonCFNRy != null) {
-            outState.putBoolean(BUTTON_CFNRY_KEY, mButtonCFNRy.isToggled());
-        }
-        if (mButtonCFNRc != null) {
-            outState.putBoolean(BUTTON_CFNRC_KEY, mButtonCFNRc.isToggled());
-        }
         if (mButtonVoicePrivacy != null) {
             outState.putBoolean(BUTTON_VP_KEY, mButtonVoicePrivacy.isChecked());
         }
@@ -1553,16 +1566,39 @@ public class CallFeaturesSetting extends PreferenceActivity
             outState.putInt(BUTTON_TTY_KEY, mButtonTTY.findIndexOfValue(mButtonTTY.getValue()));
         }
 
-        // save number state
-        outState.putString(SUMMARY_CFU_KEY, mDialingNumCFU);
-        outState.putString(SUMMARY_CFB_KEY, mDialingNumCFB);
-        outState.putString(SUMMARY_CFNRY_KEY, mDialingNumCFNRy);
-        outState.putString(SUMMARY_CFNRC_KEY, mDialingNumCFNRc);
+        // save button state
+        if (mPhone.getPhoneName().equals("GSM")) {
+            if (mButtonCLIR != null) {
+                outState.putInt(BUTTON_CLIR_KEY, mButtonCLIR.findIndexOfValue(mButtonCLIR.getValue()));
+            }
+            if (mButtonCW != null) {
+                outState.putBoolean(BUTTON_CW_KEY, mButtonCW.isChecked());
+            }
+            if (mButtonCFU != null) {
+                outState.putBoolean(BUTTON_CFU_KEY, mButtonCFU.isToggled());
+           }
+            if (mButtonCFB != null) {
+                outState.putBoolean(BUTTON_CFB_KEY, mButtonCFB.isToggled());
+            }
+            if (mButtonCFNRy != null) {
+                outState.putBoolean(BUTTON_CFNRY_KEY, mButtonCFNRy.isToggled());
+            }
+            if (mButtonCFNRc != null) {
+                 outState.putBoolean(BUTTON_CFNRC_KEY, mButtonCFNRc.isToggled());
+            }
 
+            // save number state
+            outState.putString(SUMMARY_CFU_KEY, mDialingNumCFU);
+            outState.putString(SUMMARY_CFB_KEY, mDialingNumCFB);
+            outState.putString(SUMMARY_CFNRY_KEY, mDialingNumCFNRy);
+            outState.putString(SUMMARY_CFNRC_KEY, mDialingNumCFNRc);
+
+            outState.putBoolean(BUTTON_CF_EXPAND_KEY, mCFDataStale);
+            outState.putBoolean(BUTTON_GSM_MORE_EXPAND_KEY, mMoreDataStale);
+        }
         // save state of the app
         outState.putSerializable(APP_STATE_KEY, mAppState);
-        outState.putBoolean(BUTTON_CF_EXPAND_KEY, mCFDataStale);
-        outState.putBoolean(BUTTON_GSM_MORE_EXPAND_KEY, mMoreDataStale);
+
         outState.putInt(DISPLAY_MODE_KEY, mDisplayMode);
     }
 
@@ -1779,7 +1815,7 @@ public class CallFeaturesSetting extends PreferenceActivity
 
     //VP object click
     private void handleVoicePrivacyClickRequest(boolean value) {
-        mPhone.enableEnhancedVoicePrivacy(value, Message.obtain(mSetVoicePrivacyComplete, 
+        mPhone.enableEnhancedVoicePrivacy(value, Message.obtain(mSetVoicePrivacyComplete,
                 EVENT_ENHANCED_VP_EXECUTED));
     }
 
@@ -1800,7 +1836,7 @@ public class CallFeaturesSetting extends PreferenceActivity
 
     // VP Object Set
     private void handleSetVPMessage() {
-        mPhone.getEnhancedVoicePrivacy(Message.obtain(mQueryVoicePrivacyComplete, 
+        mPhone.getEnhancedVoicePrivacy(Message.obtain(mQueryVoicePrivacyComplete,
                 EVENT_ENHANCED_VP_EXECUTED));
         android.provider.Settings.Secure.putInt(mPhone.getContext().getContentResolver(),
                 android.provider.Settings.Secure.ENHANCED_VOICE_PRIVACY_ENABLED, preferredVPMode);
@@ -1837,7 +1873,7 @@ public class CallFeaturesSetting extends PreferenceActivity
             }
             syncVPState((int[]) ar.result);
             android.provider.Settings.Secure.putInt(mPhone.getContext().getContentResolver(),
-                    android.provider.Settings.Secure.ENHANCED_VOICE_PRIVACY_ENABLED, 
+                    android.provider.Settings.Secure.ENHANCED_VOICE_PRIVACY_ENABLED,
                     preferredVPMode );
         }
         return MSG_OK;
old mode 100644 (file)
new mode 100755 (executable)
index 5870500..fbb4523
@@ -44,6 +44,9 @@ import com.android.internal.telephony.CallerInfoAsyncQuery;
 import com.android.internal.telephony.Phone;
 
 import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Queue;
+
 
 /**
  * Dialer class that encapsulates the DTMF twelve key behaviour.
@@ -60,6 +63,10 @@ public class DTMFTwelveKeyDialer implements
 
     // events
     private static final int PHONE_DISCONNECT = 100;
+    private static final int DTMF_SEND_CNF = 101;
+    private static final int STOP_DTMF_TONE = 102;
+
+
 
     private Phone mPhone;
     private ToneGenerator mToneGenerator;
@@ -68,6 +75,19 @@ public class DTMFTwelveKeyDialer implements
     // indicate if we want to enable the DTMF tone playback.
     private boolean mDTMFToneEnabled;
 
+    // DTMF tone type
+    private int mDTMFToneType;
+
+    // indicate if the confirmation from TelephonyFW is pending.
+    private boolean mDTMFBurstCnfPending = false;
+
+    // Queue to queue the short dtmf characters.
+    private Queue<Character> mDTMFQueue = new LinkedList<Character>();
+
+    //  Short Dtmf tone duration
+    private static final int DTMF_DURATION_MS = 120;
+
+
     /** Hash Map to map a character to a tone*/
     private static final HashMap<Character, Integer> mToneMap =
         new HashMap<Character, Integer>();
@@ -528,6 +548,15 @@ public class DTMFTwelveKeyDialer implements
                     mPhone.unregisterForDisconnect(this);
                     closeDialer(false);
                     break;
+                case DTMF_SEND_CNF:
+                    if (DBG) log("dtmf confirmation received from FW.");
+                    // handle burst dtmf confirmation
+                    handleBurstDtmfConfirmation();
+                    break;
+                case STOP_DTMF_TONE:
+                    if (DBG) log("stop-dtmf-tone received.");
+                    stopToneCdma();
+                    break;
             }
         }
     };
@@ -604,6 +633,14 @@ public class DTMFTwelveKeyDialer implements
             mDialerContainer.setOnDrawerOpenListener(null);
             mDialerContainer.setOnDrawerCloseListener(null);
         }
+        if (mPhone.getPhoneName().equals("CDMA")) {
+            mHandler.removeMessages(STOP_DTMF_TONE);
+            mHandler.removeMessages(DTMF_SEND_CNF);
+            synchronized (mDTMFQueue) {
+                mDTMFBurstCnfPending = false;
+                mDTMFQueue.clear();
+            }
+        }
         closeDialer(false);
     }
 
@@ -955,18 +992,21 @@ public class DTMFTwelveKeyDialer implements
     /**
      * Starts playing a DTMF tone.  Also begins the local tone playback,
      * if enabled.
-     *
+     * The access of this function is package rather than private
+     * since this is being referred from InCallScreen.
+     * InCallScreen calls this function to utilize the DTMF ToneGenerator properties
+     * defined here.
      * @param tone a tone code from {@link ToneGenerator}
      */
-    private void startTone(char tone) {
-        if (DBG) log("startTone()...");
-        PhoneApp.getInstance().phone.startDtmf(tone);
+    /* package */ void startDtmfTone(char tone) {
+        if (DBG) log("startDtmfTone()...");
+        mPhone.startDtmf(tone);
 
         // if local tone playback is enabled, start it.
         if (mDTMFToneEnabled) {
             synchronized (mToneGeneratorLock) {
                 if (mToneGenerator == null) {
-                    if (DBG) log("startTone: mToneGenerator == null, tone: " + tone);
+                    if (DBG) log("startDtmfTone: mToneGenerator == null, tone: " + tone);
                 } else {
                     if (DBG) log("starting local tone " + tone);
                     mToneGenerator.startTone(mToneMap.get(tone));
@@ -981,17 +1021,21 @@ public class DTMFTwelveKeyDialer implements
      * The ToneStopper class (similar to that in {@link TwelveKeyDialer#mToneStopper})
      * has been removed in favor of synchronous start / stop calls since tone duration
      * is now a function of the input.
+     * The acess of this function is package rather than private
+     * since this is being referred from InCallScreen.
+     * InCallScreen calls this function to utilize the DTMF ToneGenerator properties
+     * defined here.
      */
-    private void stopTone() {
-        if (DBG) log("stopTone()...");
-        PhoneApp.getInstance().phone.stopDtmf();
+    /* package */ void stopDtmfTone() {
+        if (DBG) log("stopDtmfTone()...");
+        mPhone.stopDtmf();
 
         // if local tone playback is enabled, stop it.
         if (DBG) log("trying to stop local tone...");
         if (mDTMFToneEnabled) {
             synchronized (mToneGeneratorLock) {
                 if (mToneGenerator == null) {
-                    if (DBG) log("stopTone: mToneGenerator == null");
+                    if (DBG) log("stopDtmfTone: mToneGenerator == null");
                 } else {
                     if (DBG) log("stopping local tone.");
                     mToneGenerator.stopTone();
@@ -1013,4 +1057,126 @@ public class DTMFTwelveKeyDialer implements
     private static void log(String msg) {
         Log.d(LOG_TAG, msg);
     }
+
+    /**
+     * Plays the local tone based the phone type.
+     */
+    private void startTone(char c) {
+        if (mPhone.getPhoneName().equals("GSM")) {
+            startDtmfTone(c);
+        } else {
+            startToneCdma(c);
+        }
+    }
+
+    /**
+     * Stops the local tone based on the phone type.
+     */
+    private void stopTone() {
+        if (mPhone.getPhoneName().equals("GSM")) {
+            stopDtmfTone();
+        } else {
+            // Cdma case we do stopTone only for Long DTMF Setting
+            if (mDTMFToneType == CallFeaturesSetting.DTMF_TONE_TYPE_LONG) {
+                stopToneCdma();
+            }
+        }
+    }
+
+    /**
+     * Plays tone when the DTMF setting is normal(Short).
+     */
+    void startToneCdma(char tone) {
+        // Read the settings as it may be changed by the user during the call
+        mDTMFToneType = Settings.System.getInt(mInCallScreen.getContentResolver(),
+                Settings.System.DTMF_TONE_TYPE_WHEN_DIALING,
+                CallFeaturesSetting.preferredDtmfMode);
+        // For Short DTMF we need to play the local tone for fixed duration
+        if (mDTMFToneType == CallFeaturesSetting.DTMF_TONE_TYPE_NORMAL) {
+            sendShortDtmfToNetwork (tone);
+            mHandler.sendEmptyMessageDelayed(STOP_DTMF_TONE,DTMF_DURATION_MS);
+        } else {
+            // Pass as a char to be sent to network
+            Log.i(LOG_TAG, "send long dtmf for " + tone);
+            mPhone.startDtmf(tone);
+        }
+
+        // if local tone playback is enabled, start it.
+        if (mDTMFToneEnabled) {
+            synchronized (mToneGeneratorLock) {
+                if (mToneGenerator == null) {
+                    if (DBG) log("startToneCdma: mToneGenerator == null, tone: " + tone);
+                } else {
+                    if (DBG) log("starting local tone " + tone);
+                    // Remove pending STOP_DTMF_TONE messages
+                    if (mDTMFToneType == CallFeaturesSetting.DTMF_TONE_TYPE_NORMAL)
+                            mHandler.removeMessages(STOP_DTMF_TONE);
+
+                    // Start the new tone (will stop any playing tone)
+                    mToneGenerator.startTone(mToneMap.get(tone));
+               }
+            }
+        }
+    }
+
+    /**
+     * Sends the dtmf character over the network for short DTMF settings
+     * When the characters are entered in quick succession, the characters are queued before sending over the network.
+     */
+    private void sendShortDtmfToNetwork(char dtmfDigit) {
+        synchronized (mDTMFQueue) {
+            if (mDTMFBurstCnfPending == true) {
+                // Insert the dtmf char to the queue
+                mDTMFQueue.add(new Character(dtmfDigit));
+            } else {
+                String dtmfStr = Character.toString(dtmfDigit);
+                Log.i(LOG_TAG,"dtmfsent = " + dtmfStr);
+                mPhone.sendBurstDtmf(dtmfStr, mHandler.obtainMessage(DTMF_SEND_CNF));
+                // Set flag to indicate wait for Telephony confirmation.
+                mDTMFBurstCnfPending = true;
+            }
+        }
+    }
+
+    /**
+     * Stops the dtmf from being sent over the network for Long DTMF case and stops local DTMF key feedback tone.
+     */
+    private void stopToneCdma() {
+        if (DBG) log("stopping remote tone.");
+
+        if (mDTMFToneType == CallFeaturesSetting.DTMF_TONE_TYPE_LONG) {
+            mPhone.stopDtmf();
+        }
+
+        // if local tone playback is enabled, stop it.
+        if (DBG) log("trying to stop local tone...");
+        if (mDTMFToneEnabled) {
+            synchronized (mToneGeneratorLock) {
+                if (mToneGenerator == null) {
+                    if (DBG) log("stopToneCdma: mToneGenerator == null");
+                } else {
+                    if (DBG) log("stopping local tone.");
+                    mToneGenerator.stopTone();
+                }
+            }
+        }
+    }
+
+    /**
+     * Handles Burst Dtmf Confirmation from the Framework.
+     */
+    void handleBurstDtmfConfirmation() {
+        Character dtmfChar = null;
+        synchronized(mDTMFQueue) {
+            mDTMFBurstCnfPending = false;
+            if(!mDTMFQueue.isEmpty()) {
+                dtmfChar = mDTMFQueue.remove();
+                Log.i(LOG_TAG, "The dtmf character removed from queue" + dtmfChar);
+            }
+        }
+        if (dtmfChar != null) {
+            sendShortDtmfToNetwork(dtmfChar);
+        }
+    }
+
 }