Teleca 2b changes.
Wink Saville [Mon, 18 May 2009 06:46:33 +0000 (23:46 -0700)]
22 files changed:
AndroidManifest.xml
res/drawable/picture_emergency.png [new file with mode: 0644]
res/layout/ecbm_layout.xml [new file with mode: 0644]
res/layout/eri_text_layout.xml [new file with mode: 0644]
res/values/strings.xml
res/values/styles.xml
res/xml/call_feature_setting.xml
res/xml/eri_text_appwidget.xml [new file with mode: 0644]
src/com/android/phone/BluetoothHandsfree.java
src/com/android/phone/CallFeaturesSetting.java
src/com/android/phone/CallNotifier.java
src/com/android/phone/CdmaOptions.java
src/com/android/phone/CellBroadcastSms.java
src/com/android/phone/DTMFTwelveKeyDialer.java
src/com/android/phone/EmergencyCallbackMode.java [new file with mode: 0644]
src/com/android/phone/EriTextWidgetProvider.java [new file with mode: 0644]
src/com/android/phone/InCallScreen.java
src/com/android/phone/NotificationMgr.java
src/com/android/phone/PhoneApp.java
src/com/android/phone/PhoneInterfaceManager.java
src/com/android/phone/PhoneUtils.java
src/com/android/phone/Settings.java

index eb5537b..9786fc4 100644 (file)
         <activity android:name="NetworkSetting" android:label="@string/networks">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
-                <action android:name="android.settings.NETWORK_OPERATOR_SETTINGS" />
+                <action android:name="android.settings.NETWORK_OPERATOR_" />
             </intent-filter>
         </activity>
 
                 <action android:name="android.intent.action.MAIN" />
             </intent-filter>
         </activity>
+        
+        <!-- Emergency Callback Mode screen -->
+        <activity android:name="EmergencyCallbackMode" 
+                android:label="Emergency Call Back"
+                android:theme="@style/EmergencyCallBack"
+                android:launchMode="singleTask"
+                android:taskAffinity=":EmergencyCallbackMode">
+        </activity>
 
         <!-- call feature setting -->
         <activity android:name="CallFeaturesSetting" android:label="@string/call_settings">
                 <action android:name="android.bluetooth.IBluetoothHeadset" />
             </intent-filter>
         </service>
+
+        <!-- Broadcast Receiver that will process cdma ERI text updates -->    
+        <receiver android:name="EriTextWidgetProvider" android:label="@string/eri_text_label">
+            <intent-filter>
+                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
+            </intent-filter>
+            <meta-data android:name="android.appwidget.provider" android:resource="@xml/eri_text_appwidget" />
+        </receiver>
     </application>
 </manifest>
 
diff --git a/res/drawable/picture_emergency.png b/res/drawable/picture_emergency.png
new file mode 100644 (file)
index 0000000..3690b07
Binary files /dev/null and b/res/drawable/picture_emergency.png differ
diff --git a/res/layout/ecbm_layout.xml b/res/layout/ecbm_layout.xml
new file mode 100644 (file)
index 0000000..436a0ff
--- /dev/null
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 
+     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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+            android:layout_width="fill_parent" 
+            android:layout_height="fill_parent" 
+            android:orientation="vertical" >
+    <TextView android:id="@+id/text_title"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="20dip"
+            android:minHeight="50sp"
+            android:layout_gravity="center_vertical|center_horizontal"
+            android:text="@string/ecbm_mode_text" />
+    <ImageButton android:id="@+id/button_dial"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="80dip"
+            android:layout_gravity="center"
+            android:src="@drawable/picture_emergency" />  
+    <TextView android:id="@+id/text_instruction"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textSize="10sp"
+            android:layout_gravity="center_horizontal"
+            android:text="@string/ecbm_instruction_text" />
+            
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+            android:layout_width="fill_parent" 
+            android:layout_height="fill_parent" 
+            android:orientation="horizontal" >
+
+            <Button android:id="@+id/button_ok"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginBottom="10dip"
+                    android:layout_marginLeft="70dip"
+                    android:layout_gravity="left|bottom"
+                    android:text="@string/ecbm_ok_text" />
+            <Button android:id="@+id/button_exit"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginBottom="10dip"
+                    android:layout_marginLeft="70dip"
+                    android:layout_gravity="left|bottom"
+                    android:text="@string/ecbm_exit_text" />
+    </LinearLayout>        
+</LinearLayout>
+
+    
\ No newline at end of file
diff --git a/res/layout/eri_text_layout.xml b/res/layout/eri_text_layout.xml
new file mode 100644 (file)
index 0000000..5ad2e0d
--- /dev/null
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2009 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.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/widget"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <TextView
+        android:id="@+id/message"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="12dip"
+        android:padding="10dip"
+        android:gravity="center"
+        style="@style/TextAppearance.EriWidget" />
+
+</LinearLayout>
index 3076a43..2353778 100644 (file)
     <string name="callFailed_dsac_restricted_emergency">Emergency calls are restricted by access control.</string>
     <!-- In-call screen: call failure reason (Normal call denied because domain specific access control is on)-->
     <string name="callFailed_dsac_restricted_normal">Normal calls are restricted by access control.</string>
+    <!-- In-call screen: call failure reason (Phone is locked until next power cycle)-->
+    <string name="callFailed_cdma_lockedUntilPowerCycle">CDMA: Phone locked until power cycle.</string>
+    <!-- In-call screen: call failure reason (CDMA: call dropped)-->
+    <string name="callFailed_cdma_drop">CDMA: Call dropped.</string>
+    <!-- In-call screen: call failure reason (CDMA: call intercepted)-->
+    <string name="callFailed_cdma_intercept">CDMA: Call intercepted.</string>
+    <!-- In-call screen: call failure reason (CDMA reorder)-->
+    <string name="callFailed_cdma_reorder">CDMA: reorder.</string>
+    <!-- In-call screen: call failure reason (CDMA: Service Option Reject)-->
+    <string name="callFailed_cdma_SO_reject">CDMA: Service Option Reject.</string>
+    <!-- In-call screen: call failure reason (CDMA: retry order)-->
+    <string name="callFailed_cdma_retryOrder">CDMA: retry order.</string>
+    <!-- In-call screen: call failure reason (CDMA: Access failure)-->
+    <string name="callFailed_cdma_accessFailure">CDMA: Access failure.</string>
+    <!-- In-call screen: call failure reason (CDMA: Preempted)-->
+    <string name="callFailed_cdma_preempted">CDMA: Preempted.</string>
+    <!-- In-call screen: call failure reason (Only Emergency calls are possible)-->
+    <string name="callFailed_cdma_notEmergency">Only Emergency calls are possible.</string>
     <!-- In-call screen: status label for a conference call -->
     <string name="confCall">Conference call</string>
 
     <!-- Label for "cancel" button on the MMI dialog -->
     <string name="cancel">Cancel</string>
 
+    <!-- ECBM strings -->
+    <string name="ecbm_mode_text">Emergency Call Back</string>
+    <string name="ecbm_exit_text">EXIT</string>
+    <string name="ecbm_ok_text">  OK  </string>
+    <string name="ecbm_emergency_number">Dial 911</string>
+    <string name="ecbm_instruction_text">Press button for emergency call</string>
+
     <!-- In-call menu item labels -->
     <!-- Regular in-call menu items: -->
     <!-- In-call menu: Label for "speakerphone" menu item -->
     <string name="voice_privacy_summary">Enable enhanced privacy mode</string>
     <string name="tty_mode_title">TTY mode</string>
     <string name="tty_mode_summary">Enable TTY mode</string>
+    <string name="tty_mode_option_title">TTY mode</string>
+    <string name="tty_mode_option_summary">Set TTY mode</string>
 
     <!-- FDN list screen: menu item label -->
     <string name="menu_add">Add contact</string>
     <string name="card_title_conf_call">Conference call</string>
     <!-- In-call screen: status label for an incoming call -->
     <string name="card_title_incoming_call">Incoming call</string>
+    <!-- In-call screen: status label for an cdma call waiting -->
+    <string name="card_title_cdma_call_waiting">Cdma callwaiting </string>
     <!-- In-call screen: status label displayed briefly after a call ends -->
     <string name="card_title_call_ended">Call ended</string>
     <!-- In-call screen: status label for call that's on hold -->
     <!-- Import a single contact entry from contacts to the SIM card -->
     <string name="importToFDNfromContacts">Import from contacts</string>
 
+    <!-- Service option entries.  -->
+    <string-array name="tty_mode_entries">
+        <item>TTY Off</item>
+        <item>TTY HCO</item>
+        <item>TTY VCO</item>
+        <item>TTY Full</item>
+    </string-array>
+
+    <!-- Do not translate. -->
+    <string-array name="tty_mode_values">
+        <!-- Do not translate. -->
+        <item>0</item>"
+        <!-- Do not translate. -->
+        <item>2</item>
+        <!-- Do not translate. -->
+        <item>3</item>
+        <!-- Do not translate. -->
+        <item>1</item>
+    </string-array>
+
+    <!-- Label for ERI text widget, shown in list of all gadgets -->
+    <string name="eri_text_label">ERI text</string>
+
 </resources>
 
 
index 7729c67..9ffa05f 100644 (file)
         <item name="changeNumButtonText">@string/change_num</item>
         <item name="confirmMode">activation</item>
     </style>
+
+    <!-- Preference Style for the emergency callback mode -->
+    <!-- This styles is currently not used and just prepared for further usage -->
+    <style name="EmergencyCallBack">
+        <item name="android:textSize">20sp</item>
+        <item name="android:textColor">#ffffff</item>
+        <item name="android:windowNoTitle">true</item>
+        <item name="android:colorForeground">#fff</item>
+    </style>
+
+    <!-- Preference Style for the ERI text -->
+    <style name="EriWidgetBackground">
+    </style>
+
+    <style name="TextAppearance.EriWidget">
+        <item name="android:textSize">16sp</item>
+        <item name="android:textStyle">bold</item>
+        <item name="android:textColor">@android:color/black</item>
+    </style>
+
+
+
 </resources>
index 2bdb741..0b26b2e 100644 (file)
             android:persistent="false"
             android:summary="@string/voice_privacy_summary"/>
             
-        <CheckBoxPreference 
+<!--         <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" />
+
     </PreferenceScreen>
                     
 
diff --git a/res/xml/eri_text_appwidget.xml b/res/xml/eri_text_appwidget.xml
new file mode 100644 (file)
index 0000000..82bc2c7
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 
+     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.
+-->
+
+<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
+    android:minWidth="146dip"
+    android:minHeight="72dip"
+    android:updatePeriodMillis="0"
+    android:initialLayout="@layout/eri_text_layout"
+    >
+</appwidget-provider>
index 8267669..5780d4a 100644 (file)
@@ -40,6 +40,7 @@ import android.os.PowerManager.WakeLock;
 import android.os.SystemProperties;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.ServiceState;
+import android.telephony.SignalStrength;
 import android.util.Log;
 
 import com.android.internal.telephony.Call;
@@ -355,7 +356,7 @@ public class BluetoothHandsfree {
             updatePhoneState(false, null);
             mBattchg = 5;  // There is currently no API to get battery level
                            // on demand, so set to 5 and wait for an update
-            mSignal = asuToSignal(mPhone.getSignalStrengthASU());
+            mSignal = asuToSignal(mPhone.getSignalStrength());
 
             // register for updates
             mPhone.registerForServiceStateChanged(mStateChangeHandler,
@@ -390,7 +391,7 @@ public class BluetoothHandsfree {
         /* convert [0,31] ASU signal strength to the [0,5] expected by
          * bluetooth devices. Scale is similar to status bar policy
          */
-        private int asuToSignal(int asu) {
+        private int gsmAsuToSignal(int asu) {
             if      (asu >= 16) return 5;
             else if (asu >= 8)  return 4;
             else if (asu >= 4)  return 3;
@@ -399,6 +400,28 @@ public class BluetoothHandsfree {
             else                return 0;
         }
 
+        /* convert cdma dBm signal strength to the [0,5] expected by
+         * bluetooth devices. Scale is similar to status bar policy
+         */
+        private int cdmaDbmToSignal(int cdmaDbm) {
+            if (cdmaDbm >= -75)       return 5;
+            else if (cdmaDbm >= -85)  return 4;
+            else if (cdmaDbm >= -95)  return 3;
+            else if (cdmaDbm >= -100) return 2;
+            else if (cdmaDbm >= -105) return 2;
+            else return 0;
+        }
+
+
+        private int asuToSignal(SignalStrength signalStrength) {
+            if (!signalStrength.isGsm()) {
+                return gsmAsuToSignal(signalStrength.getCdmaDbm());
+            } else {
+                return cdmaDbmToSignal(signalStrength.getGsmSignalStrength());
+            }
+        }
+
+
         /* convert [0,5] signal strength to a rssi signal strength for CSQ
          * which is [0,31]. Despite the same scale, this is not the same value
          * as ASU.
@@ -444,14 +467,22 @@ public class BluetoothHandsfree {
         }
 
         private synchronized void updateSignalState(Intent intent) {
+            // NOTE this function is called by the BroadcastReceiver mStateReceiver after intent
+            // ACTION_SIGNAL_STRENGTH_CHANGED and by the DebugThread mDebugThread
+            SignalStrength signalStrength = SignalStrength.newFromBundle(intent.getExtras());
             int signal;
-            signal = asuToSignal(intent.getIntExtra("asu", -1));
-            mRssi = signalToRssi(signal);  // no unsolicited CSQ
-            if (signal != mSignal) {
-                mSignal = signal;
-                if (sendUpdate()) {
-                    sendURC("+CIEV: 5," + mSignal);
+
+            if (signalStrength != null) {
+                signal = asuToSignal(signalStrength);
+                mRssi = signalToRssi(signal);  // no unsolicited CSQ
+                if (signal != mSignal) {
+                    mSignal = signal;
+                    if (sendUpdate()) {
+                        sendURC("+CIEV: 5," + mSignal);
+                    }
                 }
+            } else {
+                Log.e(TAG, "Signal Strength null");
             }
         }
 
@@ -1774,8 +1805,12 @@ public class BluetoothHandsfree {
 
                 int signalLevel = SystemProperties.getInt(DEBUG_HANDSFREE_SIGNAL, -1);
                 if (signalLevel >= 0 && signalLevel <= 31) {
+                    SignalStrength signalStrength = new SignalStrength(signalLevel, -1, -1, -1,
+                            -1, -1, -1, true);
                     Intent intent = new Intent();
-                    intent.putExtra("asu", signalLevel);
+                    Bundle data = new Bundle();
+                    signalStrength.fillInNotifierBundle(data);
+                    intent.putExtras(data);
                     mPhoneState.updateSignalState(intent);
                 }
 
index b5754ed..32ca69e 100644 (file)
@@ -104,12 +104,15 @@ public class CallFeaturesSetting extends PreferenceActivity
     private static final int EVENT_INITAL_QUERY_CANCELED = 600;
     /** Event for TTY mode change */
     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 = enabled
-    static final int preferredTTYMode = 0;
+    // 1 = full mode
+    // 2 = HCO mode
+    // 3 = VCO mode
+    static final int preferredTtyMode = 0;
 
     // preferred VoicePrivacy mode
     // 0 = disabled
@@ -183,7 +186,7 @@ public class CallFeaturesSetting extends PreferenceActivity
     private PreferenceScreen mButtonGSMMoreExpand;
     private PreferenceScreen mButtonCDMAMoreExpand;
     private CheckBoxPreference mButtonVoicePrivacy;
-    private CheckBoxPreference mButtonTTY;
+    private ListPreference mButtonTTY;
 
     // cf number strings
     private String mDialingNumCFU;
@@ -240,7 +243,13 @@ public class CallFeaturesSetting extends PreferenceActivity
         } else if (preference == mButtonVoicePrivacy) {
             handleVoicePrivacyClickRequest(mButtonVoicePrivacy.isChecked());
         } else if (preference == mButtonTTY) {
-            handleTTYClickRequest(mButtonTTY.isChecked());
+            //displays the value taken from the Settings.System
+            int settingsTtyMode = android.provider.Settings.Secure.getInt(
+                    mPhone.getContext().getContentResolver(),
+                    android.provider.Settings.Secure.PREFERRED_TTY_MODE ,
+                    preferredTtyMode);
+            mButtonTTY.setValue(Integer.toString(settingsTtyMode));
+            return true;
         }
 
         if (nextState != AppState.INPUT_READY) {
@@ -264,6 +273,9 @@ public class CallFeaturesSetting extends PreferenceActivity
             // send the command and update state.
             handleCLIRClickRequest(mButtonCLIR.findIndexOfValue((String) objValue));
             setAppState(AppState.BUSY_NETWORK_CONNECT);
+        } else if (preference == mButtonTTY) {
+            // send the command and update state.
+            handleTTYClickRequest(preference, objValue);
         }
 
         // always let the preference setting proceed.
@@ -783,11 +795,11 @@ public class CallFeaturesSetting extends PreferenceActivity
      * Helper function to set both the value and the summary of the CLIR preference.
      */
     private void setButtonCLIRValue (int value) {
-        
+
         if (mButtonCLIR == null) {
             return;
         }
-        
+
         // first, set the value.
         mButtonCLIR.setValueIndex(value);
 
@@ -810,11 +822,11 @@ public class CallFeaturesSetting extends PreferenceActivity
     // called by syncCFUIState to do repetitive changes to UI button state.
     private void adjustCFbuttonState(EditPhoneNumberPreference epn,
             boolean isActive, int template, String number) {
-        
+
         if (epn == null) {
             return;
         }
-        
+
         CharSequence summaryOn = "";
 
         if (isActive) {
@@ -861,7 +873,7 @@ public class CallFeaturesSetting extends PreferenceActivity
         if (mSubMenuVoicemailSettings == null) {
             return;
         }
-        
+
         mOldVmNumber = mPhone.getVoiceMailNumber();
         if (mOldVmNumber == null) {
             mOldVmNumber = "";
@@ -1000,7 +1012,7 @@ public class CallFeaturesSetting extends PreferenceActivity
                     if (status != MSG_OK) {
                         setAppState(AppState.NETWORK_ERROR, status);
                     } else {
-                        mPhone.getCallWaiting(Message.obtain(mGetMoreOptionsComplete, 
+                        mPhone.getCallWaiting(Message.obtain(mGetMoreOptionsComplete,
                                 EVENT_CW_EXECUTED));
                     }
                     break;
@@ -1327,7 +1339,7 @@ public class CallFeaturesSetting extends PreferenceActivity
     protected void onResume() {
         super.onResume();
         mPhone = PhoneFactory.getDefaultPhone();
-        
+
         // upon resumption from the sub-activity, make sure we re-enable the
         // preferences.
         getPreferenceScreen().setEnabled(true);
@@ -1337,20 +1349,19 @@ public class CallFeaturesSetting extends PreferenceActivity
             // app to change this setting's backend, and re-launch this settings app
             // and the UI state would be inconsistent with actual state
             handleSetVPMessage();
-            mPhone.queryTTYModeEnabled(Message.obtain(mQueryTTYComplete, EVENT_TTY_EXECUTED));
+            mPhone.queryTTYMode(Message.obtain(mQueryTTYComplete, EVENT_TTY_EXECUTED));
             mButtonCFExpand.setEnabled(false);
             mButtonCLIR.setEnabled(false);
             mButtonCW.setChecked(false);
             mButtonCW.setEnabled(false);
         } else {
-            mButtonTTY.setChecked(false);
             mButtonTTY.setEnabled(false);
             mButtonVoicePrivacy.setChecked(false);
             mButtonVoicePrivacy.setEnabled(false);
         }
 
     }
-    
+
     /*
      * Activity class methods
      */
@@ -1381,8 +1392,21 @@ public class CallFeaturesSetting extends PreferenceActivity
         mButtonCDMAMoreExpand = (PreferenceScreen) prefSet.findPreference(
                 BUTTON_CDMA_MORE_EXPAND_KEY);
 
-        mButtonTTY = (CheckBoxPreference) findPreference(BUTTON_TTY_KEY);
+        mButtonTTY = (ListPreference) prefSet.findPreference(BUTTON_TTY_KEY);
+        mButtonTTY.setOnPreferenceChangeListener(this);
+
+        //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,
+                preferredTtyMode);
+        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("GSM")) {
             mButtonVoicePrivacy.setEnabled(false);
         }
@@ -1397,7 +1421,7 @@ public class CallFeaturesSetting extends PreferenceActivity
             mButtonCFU.setDialogTitle(R.string.labelCF);
             mButtonCFU.setDialogMessage(R.string.messageCFU);
         }
-        
+
         if (mButtonCFB != null) {
             mButtonCFB.setParentActivity(this, CommandsInterface.CF_REASON_BUSY, this);
             mButtonCFB.setDialogOnClosedListener(this);
@@ -1405,7 +1429,7 @@ public class CallFeaturesSetting extends PreferenceActivity
             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);
@@ -1413,7 +1437,7 @@ public class CallFeaturesSetting extends PreferenceActivity
             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);
@@ -1421,13 +1445,13 @@ public class CallFeaturesSetting extends PreferenceActivity
             mButtonCFNRc.setDialogTitle(R.string.labelCF);
             mButtonCFNRc.setDialogMessage(R.string.messageCFNRc);
         }
-        
+
         if (mSubMenuVoicemailSettings != null) {
             mSubMenuVoicemailSettings.setParentActivity(this, VOICEMAIL_PREF_ID, this);
             mSubMenuVoicemailSettings.setDialogOnClosedListener(this);
             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);
@@ -1464,16 +1488,13 @@ public class CallFeaturesSetting extends PreferenceActivity
             setButtonCLIRValue(icicle.getInt(BUTTON_CLIR_KEY));
             if (mButtonCW != null) {
                 mButtonCW.setChecked(icicle.getBoolean(BUTTON_CW_KEY));
-        }
-        if (mButtonVoicePrivacy != null) {
+            }
+            if (mButtonVoicePrivacy != null) {
                 mButtonVoicePrivacy.setChecked(icicle.getBoolean(BUTTON_VP_KEY));
                 if (mPhone.getPhoneName().equals("GSM")) {
                     mButtonVoicePrivacy.setEnabled(false);
                 }
             }
-            if (mButtonTTY != null) {
-                mButtonTTY.setChecked(icicle.getBoolean(BUTTON_TTY_KEY));
-            }
 
             // set app state
             mAppState = (AppState) icicle.getSerializable(APP_STATE_KEY);
@@ -1527,7 +1548,7 @@ public class CallFeaturesSetting extends PreferenceActivity
             outState.putBoolean(BUTTON_VP_KEY, mButtonVoicePrivacy.isChecked());
         }
         if (mButtonTTY != null) {
-            outState.putBoolean(BUTTON_TTY_KEY, mButtonTTY.isChecked());
+            outState.putInt(BUTTON_TTY_KEY, mButtonTTY.findIndexOfValue(mButtonTTY.getValue()));
         }
 
         // save number state
@@ -1544,10 +1565,43 @@ public class CallFeaturesSetting extends PreferenceActivity
     }
 
     // TTY object
-    private void handleTTYClickRequest(boolean b) {
+    private void handleTTYClickRequest(Preference preference, Object objValue) {
+        int buttonTtyMode;
+        buttonTtyMode = Integer.valueOf((String) objValue).intValue();
+        int settingsTtyMode = android.provider.Settings.Secure.getInt(
+                mPhone.getContext().getContentResolver(),
+                android.provider.Settings.Secure.PREFERRED_TTY_MODE, preferredTtyMode);
         if (DBG) log("handleTTYClickRequest: requesting set TTY mode enable (TTY) to" +
-                Boolean.toString(b));
-        mPhone.setTTYModeEnabled(b, Message.obtain(mSetTTYComplete, EVENT_TTY_EXECUTED));
+                Integer.toString(buttonTtyMode));
+
+        if (buttonTtyMode != settingsTtyMode) {
+            switch(buttonTtyMode) {
+            case Phone.TTY_MODE_OFF:
+                mPhone.setTTYMode(Phone.TTY_MODE_OFF,
+                        Message.obtain(mSetTTYComplete, EVENT_TTY_MODE_SET));
+                break;
+            case Phone.TTY_MODE_FULL:
+                mPhone.setTTYMode(Phone.TTY_MODE_FULL,
+                        Message.obtain(mSetTTYComplete, EVENT_TTY_MODE_SET));
+                break;
+            case Phone.TTY_MODE_HCO:
+                mPhone.setTTYMode(Phone.TTY_MODE_HCO,
+                        Message.obtain(mSetTTYComplete, EVENT_TTY_MODE_SET));
+                break;
+            case Phone.TTY_MODE_VCO:
+                mPhone.setTTYMode(Phone.TTY_MODE_VCO,
+                        Message.obtain(mSetTTYComplete, EVENT_TTY_MODE_SET));
+                break;
+            default:
+                mPhone.setTTYMode(Phone.TTY_MODE_OFF,
+                        Message.obtain(mSetTTYComplete, EVENT_TTY_MODE_SET));
+            }
+            UpdatePreferredTtyModeSummary(buttonTtyMode);
+
+            android.provider.Settings.Secure.putInt(mPhone.getContext().getContentResolver(),
+                    android.provider.Settings.Secure.PREFERRED_TTY_MODE,
+                    buttonTtyMode );
+        }
     }
 
     /*
@@ -1561,7 +1615,11 @@ public class CallFeaturesSetting extends PreferenceActivity
             // query to make sure we're looking at the same data as that in the network.
             switch (msg.what) {
                 case EVENT_TTY_EXECUTED:
-                    handleSetTTYMessage();
+                    handleQueryTtyResponse(msg);
+                    onResume();
+                    break;
+                case EVENT_TTY_MODE_SET:
+                    onResume();
                     break;
                 default:
                     // TODO: should never reach this, may want to throw exception
@@ -1574,9 +1632,89 @@ public class CallFeaturesSetting extends PreferenceActivity
         if (DBG) {
             log("handleSetTTYMessage: set TTY request complete, reading value from network.");
         }
-        mPhone.queryTTYModeEnabled(Message.obtain(mQueryTTYComplete, EVENT_TTY_EXECUTED));
+        mPhone.queryTTYMode(Message.obtain(mQueryTTYComplete, EVENT_TTY_EXECUTED));
+        android.provider.Settings.Secure.putInt(mPhone.getContext().getContentResolver(),
+                android.provider.Settings.Secure.TTY_MODE_ENABLED, preferredTtyMode );
+    }
+
+    private void handleQueryTtyResponse(Message msg) {
+        AsyncResult ar = (AsyncResult) msg.obj;
+
+        if (ar.exception == null) {
+            int ttyMode = ((int[])ar.result)[0];
+
+
+
+            int settingsTtyMode = android.provider.Settings.Secure.getInt(
+                    mPhone.getContext().getContentResolver(),
+                    android.provider.Settings.Secure.PREFERRED_TTY_MODE,
+                    preferredTtyMode);
+
+            //check that modemNetworkMode is from an accepted value
+            if (ttyMode == Phone.TTY_MODE_OFF ||
+                    ttyMode == Phone.TTY_MODE_HCO ||
+                    ttyMode == Phone.TTY_MODE_VCO ||
+                    ttyMode == Phone.TTY_MODE_FULL) {
+
+                //check changes in modemNetworkMode and updates settingsNetworkMode
+                if (ttyMode != settingsTtyMode) {
+                    if (DBG) {
+                        log("handleGetPreferredNetworkTypeResponse: if 2: " +
+                                "modemNetworkMode != settingsNetworkMode");
+                    }
+
+                    settingsTtyMode = ttyMode;
+
+                    if (DBG) { log("handleGetPreferredNetworkTypeResponse: if 2: " +
+                            "settingsNetworkMode = " + settingsTtyMode);
+                    }
+
+                    //changes the Settings.System accordingly to modemNetworkMode
+                    android.provider.Settings.Secure.putInt(
+                            mPhone.getContext().getContentResolver(),
+                            android.provider.Settings.Secure.PREFERRED_NETWORK_MODE,
+                            settingsTtyMode);
+                }
+
+                UpdatePreferredTtyModeSummary(ttyMode);
+                // changes the mButtonPreferredNetworkMode accordingly to modemNetworkMode
+                mButtonTTY.setValue(Integer.toString(ttyMode));
+            } else {
+                if (DBG) log("handleGetPreferredNetworkTypeResponse: else: reset to default");
+                resetTtyModeToDefault();
+            }
+        }
+    }
+
+    private void resetTtyModeToDefault() {
+        //set the mButtonPreferredTtyMode
+        mButtonTTY.setValue(Integer.toString(preferredTtyMode));
+        //set the Settings.System
         android.provider.Settings.Secure.putInt(mPhone.getContext().getContentResolver(),
-                android.provider.Settings.Secure.TTY_MODE_ENABLED, preferredTTYMode );
+                    android.provider.Settings.Secure.PREFERRED_TTY_MODE,
+                    preferredTtyMode );
+        //Set the Modem
+        mPhone.setTTYMode(preferredTtyMode,
+                Message.obtain(mSetTTYComplete, EVENT_TTY_EXECUTED));
+    }
+
+    private void UpdatePreferredTtyModeSummary(int TtyMode) {
+        switch(TtyMode) {
+            case Phone.TTY_MODE_OFF:
+                mButtonTTY.setSummary("TTY Mode OFF");
+                break;
+            case Phone.TTY_MODE_HCO:
+                mButtonTTY.setSummary("TTY Mode HCO");
+                break;
+            case Phone.TTY_MODE_VCO:
+                mButtonTTY.setSummary("TTY Mode VCO");
+                break;
+            case Phone.TTY_MODE_FULL:
+                mButtonTTY.setSummary("TTY Mode Full");
+                break;
+            default:
+                mButtonTTY.setSummary("TTY Mode OFF");
+        }
     }
 
     /*
@@ -1606,38 +1744,36 @@ public class CallFeaturesSetting extends PreferenceActivity
             if (DBG) log("handleQueryTTYModeMessage: TTY enable state successfully queried.");
             syncTTYState((int[]) ar.result);
             android.provider.Settings.Secure.putInt(mPhone.getContext().getContentResolver(),
-                    android.provider.Settings.Secure.TTY_MODE_ENABLED, preferredTTYMode );
+                    android.provider.Settings.Secure.TTY_MODE_ENABLED, preferredTtyMode );
         }
         return MSG_OK;
     }
+    /**
+     * Tells the StatusBar whether the TTY mode is enabled or disabled
+     */
+    private static void setStatusBarIcon(Context context, boolean enabled) {
+        Intent ttyModeChanged = new Intent(TtyIntent.TTY_ENABLED_CHANGE_ACTION);
+        ttyModeChanged.putExtra("ttyEnabled", enabled);
+        context.sendBroadcast(ttyModeChanged);
+    }
 
     // set the state of the UI based on TTY State
     private void syncTTYState(int ttyArray[]) {
-        if (DBG) log("syncTTYState: Setting UI state consistent with TTY enable state of " +
-                ((ttyArray[0] != 0) ? "ENABLED" : "DISABLED"));
-
-        mButtonTTY.setChecked(ttyArray[0] != 0);
+    if (DBG) log("syncTTYState: Setting UI state consistent with TTY enable state of " +
+           ((ttyArray[0] != 0) ? "ENABLED" : "DISABLED"));
 
         Context context = this;
 
-        if (ttyArray[0] == 1) {
-            //display TTY icon at StatusBar
-            setStatusBarIcon(context, true);
-        }
-        else {
+        if (ttyArray[0] == 0) {
             // turn off TTY icon at StatusBar
             setStatusBarIcon(context, false);
         }
+        else {
+            //display TTY icon at StatusBar
+            setStatusBarIcon(context, true);
+        }
     }
 
-    /**
-     * Tells the StatusBar whether the TTY mode is enabled or disabled
-     */
-    private static void setStatusBarIcon(Context context, boolean enabled) {
-        Intent ttyModeChanged = new Intent(TtyIntent.TTY_ENABLED_CHANGE_ACTION);
-        ttyModeChanged.putExtra("ttyEnabled", enabled);
-        context.sendBroadcast(ttyModeChanged);
-    }
 
     //VP object click
     private void handleVoicePrivacyClickRequest(boolean value) {
index e107872..9def49d 100644 (file)
@@ -80,9 +80,10 @@ public class CallNotifier extends Handler
     private static final int PHONE_DISCONNECT = 3;
     private static final int PHONE_UNKNOWN_CONNECTION_APPEARED = 4;
     private static final int PHONE_INCOMING_RING = 5;
+    private static final int PHONE_CDMA_CALL_WAITING = 6;
     // Events generated internally:
-    private static final int PHONE_MWI_CHANGED = 6;
-    private static final int PHONE_BATTERY_LOW = 7;
+    private static final int PHONE_MWI_CHANGED = 7;
+    private static final int PHONE_BATTERY_LOW = 8;
 
     private PhoneApp mApplication;
     private Phone mPhone;
@@ -100,6 +101,7 @@ public class CallNotifier extends Handler
         mPhone.registerForDisconnect(this, PHONE_DISCONNECT, null);
         mPhone.registerForUnknownConnection(this, PHONE_UNKNOWN_CONNECTION_APPEARED, null);
         mPhone.registerForIncomingRing(this, PHONE_INCOMING_RING, null);
+        mPhone.registerForCdmaCallWaiting(this,PHONE_CDMA_CALL_WAITING, null);
         mRinger = ringer;
         mBluetoothHandsfree = btMgr;
 
@@ -131,7 +133,10 @@ public class CallNotifier extends Handler
                     if (DBG) log("RING before NEW_RING, skipping");
                 }
                 break;
-
+            case PHONE_CDMA_CALL_WAITING:
+                if (DBG) log("CDMA CALL WAITING... ");
+                onCdmaCallwaiting((AsyncResult) msg.obj);
+                break;
             case PHONE_STATE_CHANGED:
                 onPhoneStateChanged((AsyncResult) msg.obj);
                 break;
@@ -257,6 +262,17 @@ public class CallNotifier extends Handler
         if (VDBG) log("- onNewRingingConnection() done.");
     }
 
+    private void onCdmaCallwaiting(AsyncResult r) {
+      /**
+       * TODO(Teleca): From one of our UI engineers: "FWIW, this can probably just
+       * be another path thru onNewRingingConnection(), since that method already
+       * can tell the difference between a regular incoming call and a call-waiting
+       * call (for GSM, so far at least.)
+       */
+       // TODO: write the code
+       return;
+    }
+
     /**
      * Helper method to manage the start of incoming call queries
      */
index c63ab31..f340933 100644 (file)
@@ -61,7 +61,7 @@ public class CdmaOptions extends PreferenceActivity implements Preference.OnPref
     
     //preferredSubscriptionMode  0 - RUIM/SIM, preferred
     //                           1 - NV
-    static final int preferredSubscriptionMode = 0;
+    static final int preferredSubscriptionMode = CDMA_SUBSCRIPTION_NV;
     
     //UI objects
     private ListPreference mButtonCdmaRoam;
@@ -229,8 +229,10 @@ public class CdmaOptions extends PreferenceActivity implements Preference.OnPref
                         statusCdmaSubscriptionMode = Phone.CDMA_SUBSCRIPTION_NV;
                         break;
                     case CDMA_SUBSCRIPTION_RUIM_SIM:
-                    default:
                         statusCdmaSubscriptionMode = Phone.CDMA_SUBSCRIPTION_RUIM_SIM;
+                        break;
+                    default:
+                        statusCdmaSubscriptionMode = Phone.PREFERRED_CDMA_SUBSCRIPTION;
                 } 
                 //Set the Settings.System network mode        
                 android.provider.Settings.Secure.putInt(mPhone.getContext().getContentResolver(),
index 19e89eb..e110121 100644 (file)
@@ -442,15 +442,11 @@ public class CellBroadcastSms extends PreferenceActivity
     protected void onPause() {
         super.onPause();
 
-        int currentSelection[] = CellBroadcastSmsConfig.getCbSmsAllValues();
-
-        if (currentSelection[0] > 0) {
             CellBroadcastSmsConfig.setCbSmsNoOfStructs(NO_OF_SERVICE_CATEGORIES);
 
             mPhone.setCellBroadcastSmsConfig(CellBroadcastSmsConfig.getCbSmsAllValues(),
                     Message.obtain(mHandler, MESSAGE_SET_CB_SMS_CONFIG));
         }
-    }
 
     private void enableDisableAllCbConfigButtons(boolean enable) {
         mButtonEmergencyBroadcast.setEnabled(enable);
index 31b6cd0..5870500 100644 (file)
@@ -457,8 +457,10 @@ public class DTMFTwelveKeyDialer implements
          */
         public boolean onKeyUp(KeyEvent event) {
             if (event == null) {
-                if (DBG) log("Stopping the last played tone.");
-                stopTone();
+                //the below piece of code sends stopDTMF event unnecessarily even when a null event
+                //is received, hence commenting it.
+                /*if (DBG) log("Stopping the last played tone.");
+                stopTone();*/
                 return true;
             }
 
diff --git a/src/com/android/phone/EmergencyCallbackMode.java b/src/com/android/phone/EmergencyCallbackMode.java
new file mode 100644 (file)
index 0000000..7c134b6
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * 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.
+ */
+
+package com.android.phone;
+
+
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.AsyncResult;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.ImageButton;
+
+import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneFactory;
+
+/**
+ * Phone app Emergency Callback screen.
+ */
+public class EmergencyCallbackMode extends Activity {
+
+    /** Event for TTY mode change */
+    private static final int EVENT_EXIT_ECBM    = 100;
+
+    private Phone mPhone;
+
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.ecbm_layout);
+
+        //get mPhone instance
+        mPhone = PhoneFactory.getDefaultPhone();
+
+        // Watch for button clicks.
+        ImageButton dialButton = (ImageButton)findViewById(R.id.button_dial);
+        dialButton.setOnClickListener(mDialListener);
+
+        Button exitButton = (Button)findViewById(R.id.button_exit);
+        exitButton.setOnClickListener(mExitListener);
+
+        Button okButton = (Button)findViewById(R.id.button_ok);
+        okButton.setOnClickListener(mOkListener);
+
+        //cancel ECBM notification
+        NotificationMgr.getDefault().cancelEcbmNotification();
+    }
+
+    private OnClickListener mDialListener = new OnClickListener()
+    {
+        public void onClick(View v)
+        {
+            Intent intent = new Intent(Intent.ACTION_CALL_EMERGENCY,  Uri.parse("tel:911"));
+            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+            startActivity(intent);
+            //create Notification
+            NotificationMgr.getDefault().notifyECBM();
+            // finish Application
+            finish();
+
+        }
+    };
+
+    private OnClickListener mExitListener = new OnClickListener()
+    {
+        public void onClick(View v) {
+            // Send ECBM exit
+            mPhone.exitEmergencyCallbackMode(Message.obtain(mExitEmergencyCallbackMode,
+                    EVENT_EXIT_ECBM));
+        }
+    };
+
+
+    // **Callback on Exit Emergency callback mode
+    private Handler mExitEmergencyCallbackMode = new Handler() {
+        @Override
+        public void handleMessage(Message msg) {
+            // query to make sure we're looking at the same data as that in the network.
+            switch (msg.what) {
+                case EVENT_EXIT_ECBM:
+                    handleExitEmergencyCallbackModeResponse(msg);
+                    break;
+                default:
+                    // TODO: should never reach this, may want to throw exception
+            }
+        }
+    };
+
+    /*
+     * Handle the respone of the ExitEmergencyCallbackMode request
+     */
+    private void handleExitEmergencyCallbackModeResponse(Message msg) {
+        AsyncResult ar = (AsyncResult) msg.obj;
+
+        if (ar.exception == null) {
+            // Finish Emergency Callback Mode Application
+            finish();
+        }
+    }
+
+
+    private OnClickListener mOkListener = new OnClickListener()
+    {
+        public void onClick(View v)
+        {
+            // create a notification
+            NotificationMgr.getDefault().notifyECBM();
+            // finish Application
+            finish();
+        }
+    };
+
+
+    @Override
+    public boolean onKeyDown(int keyCode, KeyEvent event) {
+        // suppress all key presses except of call key
+        switch (keyCode) {
+            case KeyEvent.KEYCODE_CALL: {
+                Intent intent = new Intent(Intent.ACTION_CALL_EMERGENCY,  Uri.parse("tel:911"));
+                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                startActivity(intent);
+                finish();
+            }
+        }
+        return true;
+    }
+
+}
\ No newline at end of file
diff --git a/src/com/android/phone/EriTextWidgetProvider.java b/src/com/android/phone/EriTextWidgetProvider.java
new file mode 100644 (file)
index 0000000..c44679c
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2009 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.
+ */
+
+package com.android.phone;
+
+import android.app.PendingIntent;
+import android.app.Service;
+import android.appwidget.AppWidgetManager;
+import android.appwidget.AppWidgetProvider;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Resources;
+import android.os.IBinder;
+import android.telephony.TelephonyManager;
+import android.text.format.Time;
+import android.util.Log;
+import android.widget.RemoteViews;
+
+public class EriTextWidgetProvider extends AppWidgetProvider {
+    static final String LOG_TAG = "EriTextWidgetProvider";
+
+    static final ComponentName THIS_APPWIDGET =
+        new ComponentName("com.android.phone",
+                "com.android.phone.EriTextWidgetProvider");
+
+    private static EriTextWidgetProvider sInstance;
+
+    static synchronized EriTextWidgetProvider getInstance() {
+        if (sInstance == null) {
+            sInstance = new EriTextWidgetProvider();
+        }
+        return sInstance;
+    }
+
+    @Override
+    public void onEnabled(Context context) {
+        TelephonyManager mPhone;
+        String eriText = "ERI not init";
+
+        try {
+            mPhone = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
+            eriText = mPhone.getCdmaEriText();
+        } catch (Exception ex){
+            Log.e(LOG_TAG, "onEnabled, error setting Cdma Eri Text: " + ex);
+        }
+
+        if (eriText == null) eriText = "ERI not available";
+
+        performUpdate(context,eriText);
+    }
+
+    @Override
+    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
+        TelephonyManager mPhone;
+        String eriText = "ERI not init";
+
+        try {
+            mPhone = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
+            eriText = mPhone.getCdmaEriText();
+        } catch (Exception ex){
+            Log.e(LOG_TAG, "onEnabled, error setting Cdma Eri Text: " + ex);
+        }
+
+        if (eriText == null) eriText = "ERI not available";
+
+        performUpdate(context,eriText);
+    }
+
+    void performUpdate(Context context, String eriText) {
+        final Resources res = context.getResources();
+        final RemoteViews views = new RemoteViews(context.getPackageName(),
+            R.layout.eri_text_layout);
+
+        views.setTextViewText(R.id.message, eriText);
+
+        AppWidgetManager manager = AppWidgetManager.getInstance(context);
+        manager.updateAppWidget(THIS_APPWIDGET, views);
+
+    }
+}
+
index 735b2f9..ce3d74d 100644 (file)
@@ -675,7 +675,7 @@ public class InCallScreen extends Activity
         // the same time that the phone state is changing.  This can
         // end up causing the sleep request to be ignored.
         if (mHandler.hasMessages(DELAYED_CLEANUP_AFTER_DISCONNECT)) {
-            if (DBG) log("onPause(): DELAYED_CLEANUP_AFTER_DISCONNECT detected, finishing...");
+            if (DBG) log("DELAYED_CLEANUP_AFTER_DISCONNECT detected, moving UI to background.");
             finish();
         }
 
@@ -1435,6 +1435,33 @@ public class InCallScreen extends Activity
         } else if (cause == Connection.DisconnectCause.CS_RESTRICTED_NORMAL) {
             showGenericErrorDialog(R.string.callFailed_dsac_restricted_normal, false);
             return;
+        } else if (cause == Connection.DisconnectCause.CDMA_LOCKED_UNTIL_POWER_CYCLE) {
+            showGenericErrorDialog(R.string.callFailed_cdma_lockedUntilPowerCycle, false);
+            return;
+        } else if (cause == Connection.DisconnectCause.CDMA_DROP) {
+            showGenericErrorDialog(R.string.callFailed_cdma_drop, false);
+            return;
+        } else if (cause == Connection.DisconnectCause.CDMA_INTERCEPT) {
+            showGenericErrorDialog(R.string.callFailed_cdma_intercept, false);
+            return;
+        } else if (cause == Connection.DisconnectCause.CDMA_REORDER) {
+            showGenericErrorDialog(R.string.callFailed_cdma_reorder, false);
+            return;
+        } else if (cause == Connection.DisconnectCause.CDMA_SO_REJECT) {
+            showGenericErrorDialog(R.string.callFailed_cdma_SO_reject, false);
+            return;
+        }else if (cause == Connection.DisconnectCause.CDMA_RETRY_ORDER) {
+            showGenericErrorDialog(R.string.callFailed_cdma_retryOrder, false);
+            return;
+        } else if (cause == Connection.DisconnectCause.CDMA_ACCESS_FAILURE) {
+            showGenericErrorDialog(R.string.callFailed_cdma_accessFailure, false);
+            return;
+        } else if (cause == Connection.DisconnectCause.CDMA_PREEMPTED) {
+            showGenericErrorDialog(R.string.callFailed_cdma_preempted, false);
+            return;
+        } else if (cause == Connection.DisconnectCause.CDMA_NOT_EMERGENCY) {
+            showGenericErrorDialog(R.string.callFailed_cdma_notEmergency, false);
+            return;
         }
 
         final PhoneApp app = PhoneApp.getInstance();
@@ -1859,6 +1886,7 @@ public class InCallScreen extends Activity
         // this screen in the first place.)
 
         // Need to treat running MMI codes as a connection as well.
+        // Do not check for getPendingMmiCodes when phone is a CDMA phone
         if (!mForegroundCall.isIdle() || !mBackgroundCall.isIdle() || !mRingingCall.isIdle()
             || mPhone.getPhoneName().equals("CDMA") || !mPhone.getPendingMmiCodes().isEmpty()) {
             if (VDBG) log("syncWithPhoneState: it's ok to be here; update the screen...");
@@ -2109,9 +2137,10 @@ public class InCallScreen extends Activity
             mMissingVoicemailDialog.dismiss();
             mMissingVoicemailDialog = null;
         }
-        if (DBG) log("show vm setting, finishing...");
         finish();
 
+        if (DBG) log("show vm setting");
+
         // navigate to the Voicemail setting in the Call Settings activity.
         Intent intent = new Intent(CallFeaturesSetting.ACTION_ADD_VOICEMAIL);
         intent.setClass(this, CallFeaturesSetting.class);
index e68ab8c..9c7237f 100644 (file)
@@ -39,6 +39,7 @@ import android.util.Log;
 import android.widget.RemoteViews;
 import android.widget.Toast;
 
+import com.android.internal.R.drawable;
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.CallerInfo;
 import com.android.internal.telephony.CallerInfoAsyncQuery;
@@ -90,6 +91,7 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
     static final int VOICEMAIL_NOTIFICATION = 5;
     static final int CALL_FORWARD_NOTIFICATION = 6;
     static final int DATA_DISCONNECTED_ROAMING_NOTIFICATION = 7;
+    static final int ECBM_NOTIFICATION = 8;
 
     private static NotificationMgr sMe = null;
     private Phone mPhone;
@@ -134,7 +136,7 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
 
     static void init(Context context) {
         sMe = new NotificationMgr(context);
-        
+
         // update the notifications that need to be touched at startup.
         sMe.updateNotifications();
     }
@@ -149,9 +151,9 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
      * the Status bar.  All interaction with the status bar should be
      * though the methods contained herein.
      */
-    
-    /** 
-     * Factory method 
+
+    /**
+     * Factory method
      */
     StatusBarMgr getStatusBarMgr() {
         if (mStatusBarMgr == null) {
@@ -159,23 +161,23 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
         }
         return mStatusBarMgr;
     }
-    
+
     /**
      * StatusBarMgr implementation
-     */ 
+     */
     class StatusBarMgr {
         // current settings
         private boolean mIsNotificationEnabled = true;
         private boolean mIsExpandedViewEnabled = true;
-        
+
         private StatusBarMgr () {
         }
-        
+
         /**
-         * Sets the notification state (enable / disable 
+         * Sets the notification state (enable / disable
          * vibrating notifications) for the status bar,
          * updates the status bar service if there is a change.
-         * Independent of the remaining Status Bar 
+         * Independent of the remaining Status Bar
          * functionality, including icons and expanded view.
          */
         void enableNotificationAlerts(boolean enable) {
@@ -184,12 +186,12 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
                 updateStatusBar();
             }
         }
-        
+
         /**
-         * Sets the ability to expand the notifications for the 
-         * status bar, updates the status bar service if there 
-         * is a change. Independent of the remaining Status Bar 
-         * functionality, including icons and notification 
+         * Sets the ability to expand the notifications for the
+         * status bar, updates the status bar service if there
+         * is a change. Independent of the remaining Status Bar
+         * functionality, including icons and notification
          * alerts.
          */
         void enableExpandedView(boolean enable) {
@@ -198,28 +200,28 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
                 updateStatusBar();
             }
         }
-        
+
         /**
-         * Method to synchronize status bar state with our current 
+         * Method to synchronize status bar state with our current
          * state.
          */
         void updateStatusBar() {
             int state = StatusBarManager.DISABLE_NONE;
-            
+
             if (!mIsExpandedViewEnabled) {
                 state |= StatusBarManager.DISABLE_EXPAND;
             }
-            
+
             if (!mIsNotificationEnabled) {
                 state |= StatusBarManager.DISABLE_NOTIFICATION_ALERTS;
             }
-            
+
             // send the message to the status bar manager.
             if (DBG) log("updating status bar state: " + state);
             mStatusBar.disable(state);
         }
     }
-    
+
     /**
      * Makes sure notifications are up to date.
      */
@@ -233,11 +235,11 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
         StringBuilder where = new StringBuilder("type=");
         where.append(Calls.MISSED_TYPE);
         where.append(" AND new=1");
-        
+
         // start the query
         mQueryHandler.startQuery(CALL_LOG_TOKEN, null, Calls.CONTENT_URI,  CALL_LOG_PROJECTION,
                 where.toString(), null, Calls.DEFAULT_SORT_ORDER);
-        
+
         // synchronize the in call notification
         if (mPhone.getState() != Phone.State.OFFHOOK) {
             if (DBG) log("Phone is idle, canceling notification.");
@@ -246,27 +248,27 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
             if (DBG) log("Phone is offhook, updating notification.");
             updateInCallNotification();
         }
-        
+
         // Depend on android.app.StatusBarManager to be set to
         // disable(DISABLE_NONE) upon startup.  This will be the
         // case even if the phone app crashes.
     }
-    
+
     /** The projection to use when querying the phones table */
     static final String[] PHONES_PROJECTION = new String[] {
             Phones.NUMBER,
             Phones.NAME
     };
-    
+
     /**
      * Class used to run asynchronous queries to re-populate
      * the notifications we care about.
      */
     private class QueryHandler extends AsyncQueryHandler {
-        
+
         /**
-         * Used to store relevant fields for the Missed Call 
-         * notifications. 
+         * Used to store relevant fields for the Missed Call
+         * notifications.
          */
         private class NotificationInfo {
             public String name;
@@ -274,7 +276,7 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
             public String label;
             public long date;
         }
-        
+
         public QueryHandler(ContentResolver cr) {
             super(cr);
         }
@@ -283,63 +285,63 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
          * Handles the query results.  There are really 2 steps to this,
          * similar to what happens in RecentCallsListActivity.
          *  1. Find the list of missed calls
-         *  2. For each call, run a query to retrieve the caller's name. 
+         *  2. For each call, run a query to retrieve the caller's name.
          */
         @Override
         protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
             // TODO: it would be faster to use a join here, but for the purposes
             // of this small record set, it should be ok.
-            
-            // Note that CursorJoiner is not useable here because the number 
-            // comparisons are not strictly equals; the comparisons happen in 
-            // the SQL function PHONE_NUMBERS_EQUAL, which is not available for 
+
+            // Note that CursorJoiner is not useable here because the number
+            // comparisons are not strictly equals; the comparisons happen in
+            // the SQL function PHONE_NUMBERS_EQUAL, which is not available for
             // the CursorJoiner.
-            
+
             // Executing our own query is also feasible (with a join), but that
             // will require some work (possibly destabilizing) in Contacts
             // Provider.
-            
+
             // At this point, we will execute subqueries on each row just as
             // RecentCallsListActivity.java does.
             switch (token) {
                 case CALL_LOG_TOKEN:
                     if (DBG) log("call log query complete.");
-                    
+
                     // initial call to retrieve the call list.
                     if (cursor != null) {
                         while (cursor.moveToNext()) {
-                            // for each call in the call log list, create 
+                            // for each call in the call log list, create
                             // the notification object and query contacts
                             NotificationInfo n = getNotificationInfo (cursor);
-                            
+
                             if (DBG) log("query contacts for number: " + n.number);
-                            
-                            mQueryHandler.startQuery(CONTACT_TOKEN, n, 
-                                    Uri.withAppendedPath(Phones.CONTENT_FILTER_URL, n.number), 
+
+                            mQueryHandler.startQuery(CONTACT_TOKEN, n,
+                                    Uri.withAppendedPath(Phones.CONTENT_FILTER_URL, n.number),
                                     PHONES_PROJECTION, null, null, Phones.DEFAULT_SORT_ORDER);
                         }
-                        
+
                         if (DBG) log("closing call log cursor.");
                         cursor.close();
                     }
                     break;
                 case CONTACT_TOKEN:
                     if (DBG) log("contact query complete.");
-                    
+
                     // subqueries to get the caller name.
                     if ((cursor != null) && (cookie != null)){
                         NotificationInfo n = (NotificationInfo) cookie;
-                        
+
                         if (cursor.moveToFirst()) {
                             // we have contacts data, get the name.
                             if (DBG) log("contact :" + n.name + " found for phone: " + n.number);
                             n.name = cursor.getString(cursor.getColumnIndexOrThrow(Phones.NAME));
                         }
-                        
+
                         // send the notification
                         if (DBG) log("sending notification.");
                         notifyMissedCall(n.name, n.number, n.label, n.date);
-                        
+
                         if (DBG) log("closing contact cursor.");
                         cursor.close();
                     }
@@ -347,10 +349,10 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
                 default:
             }
         }
-        
+
         /**
          * Factory method to generate a NotificationInfo object given a
-         * cursor from the call log table. 
+         * cursor from the call log table.
          */
         private final NotificationInfo getNotificationInfo(Cursor cursor) {
             NotificationInfo n = new NotificationInfo();
@@ -358,23 +360,23 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
             n.number = cursor.getString(cursor.getColumnIndexOrThrow(Calls.NUMBER));
             n.label = cursor.getString(cursor.getColumnIndexOrThrow(Calls.TYPE));
             n.date = cursor.getLong(cursor.getColumnIndexOrThrow(Calls.DATE));
-            
+
             // make sure we update the number depending upon saved values in
             // CallLog.addCall().  If either special values for unknown or
             // private number are detected, we need to hand off the message
             // to the missed call notification.
-            if ( (n.number.equals(CallerInfo.UNKNOWN_NUMBER)) || 
+            if ( (n.number.equals(CallerInfo.UNKNOWN_NUMBER)) ||
                  (n.number.equals(CallerInfo.PRIVATE_NUMBER)) ||
                  (n.number.equals(CallerInfo.PAYPHONE_NUMBER)) ) {
                 n.number = null;
             }
-            
+
             if (DBG) log("NotificationInfo constructed for number: " + n.number);
 
             return n;
         }
     }
-    
+
     /**
      * Displays a notification about a missed call.
      *
@@ -386,7 +388,7 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
         int titleResId;
         // the text in the notification's line 1 and 2.
         String expandedText, callName;
-        
+
         // increment number of missed calls.
         mNumberMissedCalls++;
 
@@ -400,7 +402,7 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
             // use "unknown" if the caller is unidentifiable.
             callName = mContext.getString(R.string.unknown);
         }
-        
+
         // display the first line of the notification:
         // 1 missed call: call name
         // more than 1 missed call: <number of calls> + "missed calls"
@@ -409,13 +411,13 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
             expandedText = callName;
         } else {
             titleResId = R.string.notification_missedCallsTitle;
-            expandedText = mContext.getString(R.string.notification_missedCallsMsg, 
+            expandedText = mContext.getString(R.string.notification_missedCallsMsg,
                     mNumberMissedCalls);
         }
-        
+
         // create the target call log intent
         final Intent intent = PhoneApp.createCallLogIntent();
-        
+
         // make the notification
         mNotificationMgr.notify(
                 MISSED_CALL_NOTIFICATION,
@@ -437,6 +439,49 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
         mNotificationMgr.cancel(MISSED_CALL_NOTIFICATION);
     }
 
+    /**
+     * Displays a notification for Emergency Callback Mode.
+     *
+     * @param nameOrNumber either the contact name, or the phone number if no contact
+     * @param label the label of the number if nameOrNumber is a name, null if it is a number
+     */
+    void notifyECBM() {
+        // The details of our message
+        CharSequence message = "Emergency Callback Mode is active";
+
+        // look up the notification manager service
+        mContext.getSystemService(Context.NOTIFICATION_SERVICE);
+
+        // The PendingIntent to launch our activity if the user selects this notification
+        Intent EmcbAlarm = new Intent(Intent.ACTION_MAIN, null);
+        EmcbAlarm.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        EmcbAlarm.setClassName("com.android.phone", EmergencyCallbackMode.class.getName());
+
+        PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0,
+                EmcbAlarm, 0);
+
+        // The ticker text, this uses a formatted string so our message could be localized
+        String tickerText = mContext.getString(R.string.ecbm_mode_text, message);
+
+        // construct the Notification object.
+         Notification ecbmNotif = new Notification(com.android.internal.R.drawable.stat_ecb_mode,
+                 tickerText, System.currentTimeMillis());
+
+        // Set the info for the views that show in the notification panel.
+        ecbmNotif.setLatestEventInfo(mContext, null, message, contentIntent);
+
+        // Note that we use R.layout.incoming_message_panel as the ID for
+        // the notification.  It could be any integer you want, but we use
+        // the convention of using a resource id for a string related to
+        // the notification.  It will always be a unique number within your
+        // application.
+        mNotificationMgr.notify(ECBM_NOTIFICATION, ecbmNotif);
+    }
+
+    void cancelEcbmNotification() {
+        mNotificationMgr.cancel(ECBM_NOTIFICATION);
+    }
+
     void notifySpeakerphone() {
         if (mSpeakerphoneIcon == null) {
             mSpeakerphoneIcon = mStatusBar.addIcon("speakerphone",
@@ -567,7 +612,7 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
         RemoteViews contentView = new RemoteViews(mContext.getPackageName(),
                                                    R.layout.ongoing_call_notification);
         contentView.setImageViewResource(R.id.icon, expandedViewIcon);
-        
+
         // if the connection is valid, then build what we need for the
         // first line of notification information, and start the chronometer.
         // Otherwise, don't bother and just stick with line 2.
@@ -599,7 +644,7 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
             }
 
             if (DBG) log("- Updating expanded view: line 1 '" + expandedViewLine1 + "'");
-    
+
             // Text line #1 is actually a Chronometer, not a plain TextView.
             // We format the elapsed time of the current call into a line like
             // "Ongoing call (01:23)".
@@ -610,26 +655,26 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
         } else if (DBG) {
             log("updateInCallNotification: connection is null, call status not updated.");
         }
-        
-        // display conference call string if this call is a conference 
+
+        // display conference call string if this call is a conference
         // call, otherwise display the connection information.
-        
-        // TODO: it may not make sense for every point to make separate 
+
+        // TODO: it may not make sense for every point to make separate
         // checks for isConferenceCall, so we need to think about
         // possibly including this in startGetCallerInfo or some other
         // common point.
-        String expandedViewLine2 = ""; 
+        String expandedViewLine2 = "";
         if (PhoneUtils.isConferenceCall(currentCall)) {
             // if this is a conference call, just use that as the caller name.
             expandedViewLine2 = mContext.getString(R.string.card_title_conf_call);
         } else {
             // Start asynchronous call to get the compact name.
-            PhoneUtils.CallerInfoToken cit = 
+            PhoneUtils.CallerInfoToken cit =
                 PhoneUtils.startGetCallerInfo (mContext, currentCall, this, contentView);
             // Line 2 of the expanded view (smaller text):
             expandedViewLine2 = PhoneUtils.getCompactNameFromCallerInfo(cit.currentInfo, mContext);
         }
-        
+
         if (DBG) log("- Updating expanded view: line 2 '" + expandedViewLine2 + "'");
         contentView.setTextViewText(R.id.text2, expandedViewLine2);
         notification.contentView = contentView;
@@ -657,12 +702,12 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
 
     /**
      * Implemented for CallerInfoAsyncQuery.OnQueryCompleteListener interface.
-     * refreshes the contentView when called. 
+     * refreshes the contentView when called.
      */
     public void onQueryComplete(int token, Object cookie, CallerInfo ci){
         if (DBG) log("callerinfo query complete, updating ui.");
 
-        ((RemoteViews) cookie).setTextViewText(R.id.text2, 
+        ((RemoteViews) cookie).setTextViewText(R.id.text2,
                 PhoneUtils.getCompactNameFromCallerInfo(ci, mContext));
     }
 
@@ -695,7 +740,7 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
             int resId = android.R.drawable.stat_notify_voicemail;
 
             // This Notification can get a lot fancier once we have more
-            // information about the current voicemail messages. 
+            // information about the current voicemail messages.
             // (For example, the current voicemail system can't tell
             // us the caller-id or timestamp of a message, or tell us the
             // message count.)
@@ -763,7 +808,7 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
             Intent intent = new Intent(Intent.ACTION_CALL,
                     Uri.fromParts("voicemail", "", null));
             PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0);
-            
+
             Notification notification = new Notification(
                     resId,  // icon
                     null, // tickerText
@@ -783,7 +828,7 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
             notification.ledARGB = 0xff00ff00;
             notification.ledOnMS = 500;
             notification.ledOffMS = 2000;
-            
+
             mNotificationMgr.notify(
                     VOICEMAIL_NOTIFICATION,
                     notification);
@@ -803,12 +848,12 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
             // If Unconditional Call Forwarding (forward all calls) for VOICE
             // is enabled, just show a notification.  We'll default to expanded
             // view for now, so the there is less confusion about the icon.  If
-            // it is deemed too weird to have CF indications as expanded views, 
+            // it is deemed too weird to have CF indications as expanded views,
             // then we'll flip the flag back.
 
-            // TODO: We may want to take a look to see if the notification can 
-            // display the target to forward calls to.  This will require some 
-            // effort though, since there are multiple layers of messages that 
+            // TODO: We may want to take a look to see if the notification can
+            // display the target to forward calls to.  This will require some
+            // effort though, since there are multiple layers of messages that
             // will need to propagate that information.
 
             Notification notification;
index 147b179..5b43012 100644 (file)
@@ -45,11 +45,13 @@ import android.os.SystemClock;
 import android.os.SystemProperties;
 import android.preference.PreferenceManager;
 import android.provider.Settings.System;
+import android.telephony.ServiceState;
 import android.util.Config;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.widget.Toast;
 
+import com.android.internal.telephony.cdma.EriInfo;
 import com.android.internal.telephony.IccCard;
 import com.android.internal.telephony.MmiCode;
 import com.android.internal.telephony.Phone;
@@ -91,6 +93,7 @@ public class PhoneApp extends Application {
     private static final int EVENT_UPDATE_INCALL_NOTIFICATION = 9;
     private static final int EVENT_DATA_ROAMING_DISCONNECTED = 10;
     private static final int EVENT_DATA_ROAMING_OK = 11;
+    private static final int EVENT_UNSOL_CDMA_INFO_RECORD = 12;
 
     // The MMI codes are also used by the InCallScreen.
     public static final int MMI_INITIATE = 51;
@@ -286,6 +289,10 @@ public class PhoneApp extends Application {
                         }
                     }
                     break;
+
+                case EVENT_UNSOL_CDMA_INFO_RECORD:
+                    //TODO: handle message here;
+                    break;
             }
         }
     };
@@ -363,6 +370,8 @@ public class PhoneApp extends Application {
             intentFilter.addAction(Intent.ACTION_BATTERY_LOW);
             intentFilter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
             intentFilter.addAction(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
+            intentFilter.addAction(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
+            intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_ENTERED);
             registerReceiver(mReceiver, intentFilter);
 
             // Use a separate receiver for ACTION_MEDIA_BUTTON broadcasts,
@@ -409,6 +418,9 @@ public class PhoneApp extends Application {
 
         // start with the default value to set the mute state.
         mShouldRestoreMuteOnInCallResume = false;
+
+        //Register for Cdma Information Records
+        phone.registerCdmaInformationRecord(mHandler, EVENT_UNSOL_CDMA_INFO_RECORD, null);
    }
 
     /**
@@ -920,6 +932,15 @@ public class PhoneApp extends Application {
         }
     }
 
+
+    /**
+     * Send ECBM Exit Request
+     */
+
+    void sendEcbmExitRequest() {
+            mHandler.sendEmptyMessage(EVENT_UPDATE_INCALL_NOTIFICATION);
+    }
+
     /**
      * @return true if a wired headset is currently plugged in.
      *
@@ -1078,6 +1099,15 @@ public class PhoneApp extends Application {
                 String newPhone = intent.getStringExtra(Phone.PHONE_NAME_KEY);
                 Log.d(LOG_TAG, "Radio technology switched. Now " + newPhone + " is active.");
                 initForNewRadioTechnology();
+            } else if (action.equals(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED)) {
+                handleServiceStateChanged(intent);
+            } else if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_ENTERED)) {
+                Log.d(LOG_TAG, "Emergency Callback Mode arrived in PhoneApp.");
+                // Send Intend to start ECBM application
+                Intent EcbmAlarm = new Intent(Intent.ACTION_MAIN, null);
+                EcbmAlarm.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                EcbmAlarm.setClassName("com.android.phone", EmergencyCallbackMode.class.getName());
+                startActivity(EcbmAlarm);
             }
         }
     }
@@ -1118,4 +1148,47 @@ public class PhoneApp extends Application {
             }
         }
     }
+
+    private void handleServiceStateChanged(Intent intent) {
+        // If service just returned, start sending out the queued messages
+        ServiceState ss = ServiceState.newFromBundle(intent.getExtras());
+
+        boolean hasService = true;
+        boolean isCdma = false;
+        String eriText = "";
+
+        if (ss != null) {
+            int state = ss.getState();
+            switch (state) {
+                case ServiceState.STATE_OUT_OF_SERVICE:
+                case ServiceState.STATE_POWER_OFF:
+                    hasService = false;
+                    break;
+            }
+        } else {
+            hasService = false;
+        }
+
+        if(ss.getRadioTechnology() == ServiceState.RADIO_TECHNOLOGY_1xRTT
+                || ss.getRadioTechnology() == ServiceState.RADIO_TECHNOLOGY_EVDO_0
+                || ss.getRadioTechnology() == ServiceState.RADIO_TECHNOLOGY_EVDO_A
+                || ss.getRadioTechnology() == ServiceState.RADIO_TECHNOLOGY_IS95A
+                || ss.getRadioTechnology() == ServiceState.RADIO_TECHNOLOGY_IS95B) {
+            isCdma = true;
+        }
+
+        if (!isCdma) eriText = "";
+
+        if (!hasService) {
+            eriText = EriInfo.SEARCHING_TEXT;
+        } else {
+            eriText = phone.getCdmaEriText();
+        }
+
+        if (eriText != null) {
+            EriTextWidgetProvider mEriTextWidgetProvider = EriTextWidgetProvider.getInstance();
+            mEriTextWidgetProvider.performUpdate(this, eriText);
+        }
+
+    }
 }
index 6ecc69c..bc1ed43 100644 (file)
@@ -538,7 +538,7 @@ public class PhoneInterfaceManager extends ITelephony.Stub {
                 android.Manifest.permission.CONTROL_LOCATION_UPDATES, null);
         mPhone.enableLocationUpdates();
     }
-    
+
     public void disableLocationUpdates() {
         mApp.enforceCallingOrSelfPermission(
                 android.Manifest.permission.CONTROL_LOCATION_UPDATES, null);
@@ -551,16 +551,16 @@ public class PhoneInterfaceManager extends ITelephony.Stub {
             mApp.enforceCallingOrSelfPermission(
                     android.Manifest.permission.ACCESS_FINE_LOCATION, null);
         } catch (SecurityException e) {
-            // If we have ACCESS_FINE_LOCATION permission, skip the check 
-            // for ACCESS_COARSE_LOCATION 
-            // A failure should throw the SecurityException from 
+            // If we have ACCESS_FINE_LOCATION permission, skip the check
+            // for ACCESS_COARSE_LOCATION
+            // A failure should throw the SecurityException from
             // ACCESS_COARSE_LOCATION since this is the weaker precondition
             mApp.enforceCallingOrSelfPermission(
                     android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
-        }            
+        }
 
         ArrayList<NeighboringCellInfo> cells = null;
-    
+
         try {
             cells = (ArrayList<NeighboringCellInfo>) sendRequest(
                     CMD_HANDLE_NEIGHBORING_CELL, null);
@@ -602,7 +602,7 @@ public class PhoneInterfaceManager extends ITelephony.Stub {
         mApp.enforceCallingOrSelfPermission(android.Manifest.permission.CALL_PHONE, null);
     }
 
-    
+
     private String createTelUrl(String number) {
         if (TextUtils.isEmpty(number)) {
             return null;
@@ -624,6 +624,28 @@ public class PhoneInterfaceManager extends ITelephony.Stub {
             return GSM_PHONE;
         }
     }
-}
 
+    /**
+     * Returns the CDMA ERI icon index to display
+     */
+    public int getCdmaEriIconIndex() {
+        return mPhone.getCdmaEriIconIndex();
+    }
 
+    /**
+     * Returns the CDMA ERI icon mode,
+     * 0 - ON
+     * 1 - FLASHING
+     */
+    public int getCdmaEriIconMode() {
+        return mPhone.getCdmaEriIconMode();
+    }
+
+    /**
+     * Returns the CDMA ERI text,
+     */
+    public String getCdmaEriText() {
+        return mPhone.getCdmaEriText();
+    }
+
+}
index d8621e2..aa02df6 100644 (file)
@@ -20,14 +20,18 @@ import android.app.AlertDialog;
 import android.app.Dialog;
 import android.app.KeyguardManager;
 import android.app.ProgressDialog;
+import android.content.ComponentName;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
+import android.content.ServiceConnection;
 import android.media.AudioManager;
 import android.net.Uri;
 import android.os.AsyncResult;
 import android.os.Handler;
+import android.os.IBinder;
 import android.os.Message;
+import android.os.RemoteException;
 import android.provider.Contacts;
 import android.telephony.PhoneNumberUtils;
 import android.text.TextUtils;
@@ -44,6 +48,7 @@ import com.android.internal.telephony.CallStateException;
 import com.android.internal.telephony.CallerInfo;
 import com.android.internal.telephony.CallerInfoAsyncQuery;
 import com.android.internal.telephony.Connection;
+import com.android.internal.telephony.IExtendedNetworkService;
 import com.android.internal.telephony.MmiCode;
 import com.android.internal.telephony.Phone;
 
@@ -51,13 +56,6 @@ import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 
-import com.android.internal.telephony.IExtendedNetworkService;
-import android.content.ServiceConnection;
-import android.os.IBinder;
-import android.content.ComponentName;
-import android.os.RemoteException;
-
-
 /**
  * Misc utilities for the Phone app.
  */
index 054497e..ef77917 100644 (file)
@@ -200,7 +200,7 @@ public class Settings extends PreferenceActivity implements DialogInterface.OnCl
                     case Phone.NT_MODE_CDMA:
                         modemNetworkMode = Phone.NT_MODE_CDMA;
                         break;
-                        case Phone.NT_MODE_GSM_UMTS:
+                    case Phone.NT_MODE_GSM_UMTS:
                         modemNetworkMode = Phone.NT_MODE_GSM_UMTS;
                         break;
                     case Phone.NT_MODE_WCDMA_ONLY:
@@ -343,7 +343,7 @@ public class Settings extends PreferenceActivity implements DialogInterface.OnCl
     private void UpdatePreferredNetworkModeSummary(int NetworkMode) {
         switch(NetworkMode) {
             case Phone.NT_MODE_WCDMA_PREF:
-                // TELECA:TODO Make all of these strings come from res/values/strings.xml.
+                // 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: