diff options
Diffstat (limited to 'telephony/java')
10 files changed, 462 insertions, 390 deletions
diff --git a/telephony/java/android/telephony/SmsManager.java b/telephony/java/android/telephony/SmsManager.java index 598f945..14b1563 100644 --- a/telephony/java/android/telephony/SmsManager.java +++ b/telephony/java/android/telephony/SmsManager.java @@ -421,4 +421,6 @@ public final class SmsManager { static public final int RESULT_ERROR_NULL_PDU = 3; /** Failed because service is currently unavailable */ static public final int RESULT_ERROR_NO_SERVICE = 4; + /** Failed because we reached the sending queue limit. {@hide} */ + static public final int RESULT_ERROR_LIMIT_EXCEEDED = 5; } diff --git a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java index 79c4b41..ece708a 100644 --- a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java @@ -280,16 +280,8 @@ public abstract class DataConnectionTracker extends Handler { if (!dataEnabled[apnId]) { dataEnabled[apnId] = true; enabledCount++; - if (enabledCount == 1) { - if (onTrySetupData(null) == false) { - // failed to setup data - note we can't optimize by only adj - // these after a successfull call. dataEnabled must be set - // prior or we think data is not available. - dataEnabled[apnId] = false; - enabledCount--; - } - } } + onTrySetupData(null); } else { // disable if (dataEnabled[apnId]) { diff --git a/telephony/java/com/android/internal/telephony/Phone.java b/telephony/java/com/android/internal/telephony/Phone.java index 3f9744f..e818175 100644 --- a/telephony/java/com/android/internal/telephony/Phone.java +++ b/telephony/java/com/android/internal/telephony/Phone.java @@ -1388,7 +1388,7 @@ public interface Phone { */ String getIccSerialNumber(); - //***** CDMA support methods + /* CDMA support methods */ /* * TODO(Moto) TODO(Teleca): can getCdmaMin, getEsn, getMeid use more generic calls diff --git a/telephony/java/com/android/internal/telephony/PhoneBase.java b/telephony/java/com/android/internal/telephony/PhoneBase.java index 9edb4c2..e340f85 100644 --- a/telephony/java/com/android/internal/telephony/PhoneBase.java +++ b/telephony/java/com/android/internal/telephony/PhoneBase.java @@ -31,7 +31,6 @@ import android.os.SystemProperties; import android.preference.PreferenceManager; import android.provider.Settings; import android.telephony.ServiceState; -import android.telephony.SignalStrength; import android.text.TextUtils; import android.util.Log; @@ -55,7 +54,7 @@ import java.util.Locale; * */ -public abstract class PhoneBase implements Phone { +public abstract class PhoneBase extends Handler implements Phone { private static final String LOG_TAG = "PHONE"; private static final boolean LOCAL_DEBUG = true; @@ -68,7 +67,7 @@ public abstract class PhoneBase implements Phone { // Key used to read/write "disable data connection on boot" pref (used for testing) public static final String DATA_DISABLED_ON_BOOT_KEY = "disabled_on_boot_key"; - //***** Event Constants + /* Event Constants */ protected static final int EVENT_RADIO_AVAILABLE = 1; /** Supplementary Service Notification received. */ protected static final int EVENT_SSN = 2; @@ -84,20 +83,22 @@ public abstract class PhoneBase implements Phone { protected static final int EVENT_SET_CALL_FORWARD_DONE = 12; protected static final int EVENT_GET_CALL_FORWARD_DONE = 13; protected static final int EVENT_CALL_RING = 14; + protected static final int EVENT_CALL_RING_CONTINUE = 15; + // Used to intercept the carrier selection calls so that // we can save the values. - protected static final int EVENT_SET_NETWORK_MANUAL_COMPLETE = 15; - protected static final int EVENT_SET_NETWORK_AUTOMATIC_COMPLETE = 16; - protected static final int EVENT_SET_CLIR_COMPLETE = 17; - protected static final int EVENT_REGISTERED_TO_NETWORK = 18; - protected static final int EVENT_SET_VM_NUMBER_DONE = 19; + protected static final int EVENT_SET_NETWORK_MANUAL_COMPLETE = 16; + protected static final int EVENT_SET_NETWORK_AUTOMATIC_COMPLETE = 17; + protected static final int EVENT_SET_CLIR_COMPLETE = 18; + protected static final int EVENT_REGISTERED_TO_NETWORK = 19; + protected static final int EVENT_SET_VM_NUMBER_DONE = 20; // Events for CDMA support - protected static final int EVENT_GET_DEVICE_IDENTITY_DONE = 20; - protected static final int EVENT_RUIM_RECORDS_LOADED = 21; - protected static final int EVENT_NV_READY = 22; - protected static final int EVENT_SET_ENHANCED_VP = 23; - protected static final int EVENT_EMERGENCY_CALLBACK_MODE_ENTER = 24; - protected static final int EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE = 25; + protected static final int EVENT_GET_DEVICE_IDENTITY_DONE = 21; + protected static final int EVENT_RUIM_RECORDS_LOADED = 22; + protected static final int EVENT_NV_READY = 23; + protected static final int EVENT_SET_ENHANCED_VP = 24; + protected static final int EVENT_EMERGENCY_CALLBACK_MODE_ENTER = 25; + protected static final int EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE = 26; // Key used to read/write current CLIR setting public static final String CLIR_KEY = "clir_key"; @@ -105,11 +106,14 @@ public abstract class PhoneBase implements Phone { // Key used to read/write "disable DNS server check" pref (used for testing) public static final String DNS_SERVER_CHECK_DISABLED_KEY = "dns_server_check_disabled_key"; - //***** Instance Variables + /* Instance Variables */ public CommandsInterface mCM; protected IccFileHandler mIccFileHandler; boolean mDnsCheckDisabled = false; public DataConnectionTracker mDataConnection; + boolean mDoesRilSendMultipleCallRing; + int mCallRingContinueToken = 0; + int mCallRingDelay; /** * Set a system property, unless we're in unit test mode @@ -172,8 +176,8 @@ public abstract class PhoneBase implements Phone { * @param notifier An instance of DefaultPhoneNotifier, * unless unit testing. */ - protected PhoneBase(PhoneNotifier notifier, Context context) { - this(notifier, context, false); + protected PhoneBase(PhoneNotifier notifier, Context context, CommandsInterface ci) { + this(notifier, context, ci, false); } /** @@ -185,11 +189,12 @@ public abstract class PhoneBase implements Phone { * @param unitTestMode when true, prevents notifications * of state change events */ - protected PhoneBase(PhoneNotifier notifier, Context context, + protected PhoneBase(PhoneNotifier notifier, Context context, CommandsInterface ci, boolean unitTestMode) { this.mNotifier = notifier; this.mContext = context; mLooper = Looper.myLooper(); + mCM = ci; setPropertiesByCarrier(); @@ -197,6 +202,70 @@ public abstract class PhoneBase implements Phone { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); mDnsCheckDisabled = sp.getBoolean(DNS_SERVER_CHECK_DISABLED_KEY, false); + mCM.setOnCallRing(this, EVENT_CALL_RING, null); + + /** + * Some RIL's don't always send RIL_UNSOL_CALL_RING so it needs + * to be generated locally. Ideally all ring tones should be loops + * and this wouldn't be necessary. But to minimize changes to upper + * layers it is requested that it be generated by lower layers. + * + * By default old phones won't have the property set but do generate + * the RIL_UNSOL_CALL_RING so the default if there is no property is + * true. + */ + mDoesRilSendMultipleCallRing = SystemProperties.getBoolean( + TelephonyProperties.PROPERTY_RIL_SENDS_MULTIPLE_CALL_RING, true); + Log.d(LOG_TAG, "mDoesRilSendMultipleCallRing=" + mDoesRilSendMultipleCallRing); + + mCallRingDelay = SystemProperties.getInt( + TelephonyProperties.PROPERTY_CALL_RING_DELAY, 3000); + Log.d(LOG_TAG, "mCallRingDelay=" + mCallRingDelay); + } + + public void dispose() { + synchronized(PhoneProxy.lockForRadioTechnologyChange) { + mCM.unSetOnCallRing(this); + } + } + + /** + * When overridden the derived class needs to call + * super.handleMessage(msg) so this method has a + * a chance to process the message. + * + * @param msg + */ + @Override + public void handleMessage(Message msg) { + AsyncResult ar; + + switch(msg.what) { + case EVENT_CALL_RING: + Log.d(LOG_TAG, "Event EVENT_CALL_RING Received state=" + getState()); + ar = (AsyncResult)msg.obj; + if (ar.exception == null) { + Phone.State state = getState(); + if ((!mDoesRilSendMultipleCallRing) + && ((state == Phone.State.RINGING) || (state == Phone.State.IDLE))) { + mCallRingContinueToken += 1; + sendIncomingCallRingNotification(mCallRingContinueToken); + } else { + notifyIncomingRing(); + } + } + break; + + case EVENT_CALL_RING_CONTINUE: + Log.d(LOG_TAG, "Event EVENT_CALL_RING_CONTINUE Received stat=" + getState()); + if (getState() == Phone.State.RINGING) { + sendIncomingCallRingNotification(msg.arg1); + } + break; + + default: + throw new RuntimeException("unexpected event not handled"); + } } // Inherited documentation suffices. @@ -290,16 +359,6 @@ public abstract class PhoneBase implements Phone { mCM.unregisterForInCallVoicePrivacyOff(h); } - /** - * Notifiy registrants of a new ringing Connection. - * Subclasses of Phone probably want to replace this with a - * version scoped to their packages - */ - protected void notifyNewRingingConnectionP(Connection cn) { - AsyncResult ar = new AsyncResult(null, cn, null); - mNewRingingConnectionRegistrants.notifyRegistrants(ar); - } - // Inherited documentation suffices. public void registerForIncomingRing( Handler h, int what, Object obj) { @@ -553,16 +612,22 @@ public abstract class PhoneBase implements Phone { } } - /* - * Retrieves the Handler of the Phone instance + /** + * Get state */ - public abstract Handler getHandler(); + public abstract Phone.State getState(); /** * Retrieves the IccFileHandler of the Phone instance */ public abstract IccFileHandler getIccFileHandler(); + /* + * Retrieves the Handler of the Phone instance + */ + public Handler getHandler() { + return this; + } /** * Query the status of the CDMA roaming preference @@ -902,4 +967,39 @@ public abstract class PhoneBase implements Phone { mDataConnection.setState(dcState); notifyDataConnection(null); } + + /** + * Notifiy registrants of a new ringing Connection. + * Subclasses of Phone probably want to replace this with a + * version scoped to their packages + */ + protected void notifyNewRingingConnectionP(Connection cn) { + AsyncResult ar = new AsyncResult(null, cn, null); + mNewRingingConnectionRegistrants.notifyRegistrants(ar); + } + + /** + * Notify registrants of a RING event. + */ + private void notifyIncomingRing() { + AsyncResult ar = new AsyncResult(null, this, null); + mIncomingRingRegistrants.notifyRegistrants(ar); + } + + /** + * Send the incoming call Ring notification if conditions are right. + */ + private void sendIncomingCallRingNotification(int token) { + if (!mDoesRilSendMultipleCallRing && (token == mCallRingContinueToken)) { + Log.d(LOG_TAG, "Sending notifyIncomingRing"); + notifyIncomingRing(); + sendMessageDelayed( + obtainMessage(EVENT_CALL_RING_CONTINUE, token, 0), mCallRingDelay); + } else { + Log.d(LOG_TAG, "Ignoring ring notification request," + + " mDoesRilSendMultipleCallRing=" + mDoesRilSendMultipleCallRing + + " token=" + token + + " mCallRingContinueToken=" + mCallRingContinueToken); + } + } } diff --git a/telephony/java/com/android/internal/telephony/SMSDispatcher.java b/telephony/java/com/android/internal/telephony/SMSDispatcher.java index d66c20b..bbfc6c9 100644 --- a/telephony/java/com/android/internal/telephony/SMSDispatcher.java +++ b/telephony/java/com/android/internal/telephony/SMSDispatcher.java @@ -61,6 +61,7 @@ import static android.telephony.SmsManager.RESULT_ERROR_GENERIC_FAILURE; import static android.telephony.SmsManager.RESULT_ERROR_NO_SERVICE; import static android.telephony.SmsManager.RESULT_ERROR_NULL_PDU; import static android.telephony.SmsManager.RESULT_ERROR_RADIO_OFF; +import static android.telephony.SmsManager.RESULT_ERROR_LIMIT_EXCEEDED; public abstract class SMSDispatcher extends Handler { @@ -105,6 +106,9 @@ public abstract class SMSDispatcher extends Handler { /** Alert is timeout */ static final protected int EVENT_ALERT_TIMEOUT = 9; + /** Stop the sending */ + static final protected int EVENT_STOP_SENDING = 10; + protected Phone mPhone; protected Context mContext; protected ContentResolver mResolver; @@ -120,6 +124,8 @@ public abstract class SMSDispatcher extends Handler { private static final int SEND_RETRY_DELAY = 2000; /** single part SMS */ private static final int SINGLE_PART_SMS = 1; + /** Message sending queue limit */ + private static final int MO_MSG_QUEUE_LIMIT = 5; /** * Message reference for a CONCATENATED_8_BIT_REFERENCE or @@ -130,7 +136,7 @@ public abstract class SMSDispatcher extends Handler { private SmsCounter mCounter; - private SmsTracker mSTracker; + private ArrayList mSTrackers = new ArrayList(MO_MSG_QUEUE_LIMIT); /** Wake lock to ensure device stays awake while dispatching the SMS intent. */ private PowerManager.WakeLock mWakeLock; @@ -214,7 +220,6 @@ public abstract class SMSDispatcher extends Handler { mContext = phone.getContext(); mResolver = mContext.getContentResolver(); mCm = phone.mCM; - mSTracker = null; createWakelock(); @@ -330,17 +335,41 @@ public abstract class SMSDispatcher extends Handler { case EVENT_ALERT_TIMEOUT: ((AlertDialog)(msg.obj)).dismiss(); msg.obj = null; - mSTracker = null; + if (mSTrackers.isEmpty() == false) { + try { + SmsTracker sTracker = (SmsTracker)mSTrackers.remove(0); + sTracker.mSentIntent.send(RESULT_ERROR_LIMIT_EXCEEDED); + } catch (CanceledException ex) { + Log.e(TAG, "failed to send back RESULT_ERROR_LIMIT_EXCEEDED"); + } + } + if (Config.LOGD) { + Log.d(TAG, "EVENT_ALERT_TIMEOUT, message stop sending"); + } break; case EVENT_SEND_CONFIRMED_SMS: - if (mSTracker!=null) { - if (isMultipartTracker(mSTracker)) { - sendMultipartSms(mSTracker); + if (mSTrackers.isEmpty() == false) { + SmsTracker sTracker = (SmsTracker)mSTrackers.remove(mSTrackers.size() - 1); + if (isMultipartTracker(sTracker)) { + sendMultipartSms(sTracker); } else { - sendSms(mSTracker); + sendSms(sTracker); } - mSTracker = null; + removeMessages(EVENT_ALERT_TIMEOUT, msg.obj); + } + break; + + case EVENT_STOP_SENDING: + if (mSTrackers.isEmpty() == false) { + // Remove the latest one. + try { + SmsTracker sTracker = (SmsTracker)mSTrackers.remove(mSTrackers.size() - 1); + sTracker.mSentIntent.send(RESULT_ERROR_LIMIT_EXCEEDED); + } catch (CanceledException ex) { + Log.e(TAG, "failed to send back RESULT_ERROR_LIMIT_EXCEEDED"); + } + removeMessages(EVENT_ALERT_TIMEOUT, msg.obj); } break; } @@ -693,6 +722,15 @@ public abstract class SMSDispatcher extends Handler { * An SmsTracker for the current message. */ protected void handleReachSentLimit(SmsTracker tracker) { + if (mSTrackers.size() >= MO_MSG_QUEUE_LIMIT) { + // Deny the sending when the queue limit is reached. + try { + tracker.mSentIntent.send(RESULT_ERROR_LIMIT_EXCEEDED); + } catch (CanceledException ex) { + Log.e(TAG, "failed to send back RESULT_ERROR_LIMIT_EXCEEDED"); + } + return; + } Resources r = Resources.getSystem(); @@ -702,13 +740,13 @@ public abstract class SMSDispatcher extends Handler { .setTitle(r.getString(R.string.sms_control_title)) .setMessage(appName + " " + r.getString(R.string.sms_control_message)) .setPositiveButton(r.getString(R.string.sms_control_yes), mListener) - .setNegativeButton(r.getString(R.string.sms_control_no), null) + .setNegativeButton(r.getString(R.string.sms_control_no), mListener) .create(); d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); d.show(); - mSTracker = tracker; + mSTrackers.add(tracker); sendMessageDelayed ( obtainMessage(EVENT_ALERT_TIMEOUT, d), DEFAULT_SMS_TIMOUEOUT); } @@ -819,6 +857,9 @@ public abstract class SMSDispatcher extends Handler { if (which == DialogInterface.BUTTON_POSITIVE) { Log.d(TAG, "click YES to send out sms"); sendMessage(obtainMessage(EVENT_SEND_CONFIRMED_SMS)); + } else if (which == DialogInterface.BUTTON_NEGATIVE) { + Log.d(TAG, "click NO to stop sending"); + sendMessage(obtainMessage(EVENT_STOP_SENDING)); } } }; diff --git a/telephony/java/com/android/internal/telephony/TelephonyProperties.java b/telephony/java/com/android/internal/telephony/TelephonyProperties.java index 60e0a44..de5bbc1 100644 --- a/telephony/java/com/android/internal/telephony/TelephonyProperties.java +++ b/telephony/java/com/android/internal/telephony/TelephonyProperties.java @@ -120,4 +120,14 @@ public interface TelephonyProperties */ static final String PROPERTY_DISABLE_CALL = "ro.telephony.disable-call"; + /** + * Set to true for vendor RIL's that send multiple UNSOL_CALL_RING notifications. + */ + static final String PROPERTY_RIL_SENDS_MULTIPLE_CALL_RING = + "ro.telephony.call_ring.multiple"; + + /** + * The number of milli-seconds between CALL_RING notifications. + */ + static final String PROPERTY_CALL_RING_DELAY = "ro.telephony.call_ring.delay"; } diff --git a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java index 66eb789..ebe3e096 100755 --- a/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java +++ b/telephony/java/com/android/internal/telephony/cdma/CDMAPhone.java @@ -26,7 +26,6 @@ import android.database.SQLException; import android.net.Uri; import android.os.AsyncResult; import android.os.Handler; -import android.os.Looper; import android.os.Message; import android.os.PowerManager; import android.os.PowerManager.WakeLock; @@ -35,7 +34,6 @@ import android.os.RegistrantList; import android.os.RemoteException; import android.os.SystemProperties; import android.preference.PreferenceManager; -import android.provider.Settings; import android.provider.Telephony; import android.telephony.CellLocation; import android.telephony.PhoneNumberUtils; @@ -96,20 +94,20 @@ public class CDMAPhone extends PhoneBase { static final int RESTART_ECM_TIMER = 0; // restart Ecm timer static final int CANCEL_ECM_TIMER = 1; // cancel Ecm timer - //***** Instance Variables + // Instance Variables CdmaCallTracker mCT; CdmaSMSDispatcher mSMS; CdmaServiceStateTracker mSST; RuimFileHandler mRuimFileHandler; RuimRecords mRuimRecords; RuimCard mRuimCard; - MyHandler h; RuimPhoneBookInterfaceManager mRuimPhoneBookInterfaceManager; RuimSmsInterfaceManager mRuimSmsInterfaceManager; PhoneSubInfo mSubInfo; EriManager mEriManager; WakeLock mWakeLock; + // mNvLoadedRegistrants are informed after the EVENT_NV_READY private RegistrantList mNvLoadedRegistrants = new RegistrantList(); @@ -139,17 +137,14 @@ public class CDMAPhone extends PhoneBase { Registrant mPostDialHandler; - //***** Constructors + // Constructors public CDMAPhone(Context context, CommandsInterface ci, PhoneNotifier notifier) { this(context,ci,notifier, false); } public CDMAPhone(Context context, CommandsInterface ci, PhoneNotifier notifier, boolean unitTestMode) { - super(notifier, context, unitTestMode); - - h = new MyHandler(); - mCM = ci; + super(notifier, context, ci, unitTestMode); mCM.setPhoneType(RILConstants.CDMA_PHONE); mCT = new CdmaCallTracker(this); @@ -164,15 +159,14 @@ public class CDMAPhone extends PhoneBase { mSubInfo = new PhoneSubInfo(this); mEriManager = new EriManager(this, context, EriManager.ERI_FROM_XML); - mCM.registerForAvailable(h, EVENT_RADIO_AVAILABLE, null); - mRuimRecords.registerForRecordsLoaded(h, EVENT_RUIM_RECORDS_LOADED, null); - mCM.registerForOffOrNotAvailable(h, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null); - mCM.registerForOn(h, EVENT_RADIO_ON, null); - mCM.setOnSuppServiceNotification(h, EVENT_SSN, null); - mCM.setOnCallRing(h, EVENT_CALL_RING, null); - mSST.registerForNetworkAttach(h, EVENT_REGISTERED_TO_NETWORK, null); - mCM.registerForNVReady(h, EVENT_NV_READY, null); - mCM.setEmergencyCallbackMode(h, EVENT_EMERGENCY_CALLBACK_MODE_ENTER, null); + mCM.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null); + mRuimRecords.registerForRecordsLoaded(this, EVENT_RUIM_RECORDS_LOADED, null); + mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null); + mCM.registerForOn(this, EVENT_RADIO_ON, null); + mCM.setOnSuppServiceNotification(this, EVENT_SSN, null); + mSST.registerForNetworkAttach(this, EVENT_REGISTERED_TO_NETWORK, null); + mCM.registerForNVReady(this, EVENT_NV_READY, null); + mCM.setEmergencyCallbackMode(this, EVENT_EMERGENCY_CALLBACK_MODE_ENTER, null); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); @@ -207,23 +201,23 @@ public class CDMAPhone extends PhoneBase { // Updates MCC MNC device configuration information updateMccMncConfiguration(operatorNumeric); + // Notify voicemails. notifier.notifyMessageWaitingChanged(this); } public void dispose() { synchronized(PhoneProxy.lockForRadioTechnologyChange) { + super.dispose(); //Unregister from all former registered events - mRuimRecords.unregisterForRecordsLoaded(h); //EVENT_RUIM_RECORDS_LOADED - mCM.unregisterForAvailable(h); //EVENT_RADIO_AVAILABLE - mCM.unregisterForOffOrNotAvailable(h); //EVENT_RADIO_OFF_OR_NOT_AVAILABLE - mCM.unregisterForOn(h); //EVENT_RADIO_ON - mCM.unregisterForNVReady(h); //EVENT_NV_READY - mSST.unregisterForNetworkAttach(h); //EVENT_REGISTERED_TO_NETWORK - mCM.unSetOnSuppServiceNotification(h); - mCM.unSetOnCallRing(h); - + mRuimRecords.unregisterForRecordsLoaded(this); //EVENT_RUIM_RECORDS_LOADED + mCM.unregisterForAvailable(this); //EVENT_RADIO_AVAILABLE + mCM.unregisterForOffOrNotAvailable(this); //EVENT_RADIO_OFF_OR_NOT_AVAILABLE + mCM.unregisterForOn(this); //EVENT_RADIO_ON + mCM.unregisterForNVReady(this); //EVENT_NV_READY + mSST.unregisterForNetworkAttach(this); //EVENT_REGISTERED_TO_NETWORK + mCM.unSetOnSuppServiceNotification(this); //Force all referenced classes to unregister their former registered events mCT.dispose(); @@ -262,8 +256,6 @@ public class CDMAPhone extends PhoneBase { } } - - //***** Overridden from Phone public ServiceState getServiceState() { return mSST.ss; } @@ -701,7 +693,7 @@ public class CDMAPhone extends PhoneBase { Message onComplete) { Message resp; mVmNumber = voiceMailNumber; - resp = h.obtainMessage(EVENT_SET_VM_NUMBER_DONE, 0, 0, onComplete); + resp = obtainMessage(EVENT_SET_VM_NUMBER_DONE, 0, 0, onComplete); mRuimRecords.setVoiceMailNumber(alphaTag, mVmNumber, resp); } @@ -826,14 +818,6 @@ public class CDMAPhone extends PhoneBase { super.notifyNewRingingConnectionP(c); } - /** - * Notifiy registrants of a RING event. - */ - void notifyIncomingRing() { - AsyncResult ar = new AsyncResult(null, this, null); - mIncomingRingRegistrants.notifyRegistrants(ar); - } - /*package*/ void notifyDisconnect(Connection cn) { mDisconnectRegistrants.notifyResult(cn); } @@ -883,7 +867,7 @@ public class CDMAPhone extends PhoneBase { mWakeLock.release(); } // Send a message which will invoke handleExitEmergencyCallbackMode - mCM.exitEmergencyCallbackMode(h.obtainMessage(EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE)); + mCM.exitEmergencyCallbackMode(obtainMessage(EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE)); } private void handleEnterEmergencyCallbackMode(Message msg) { @@ -902,7 +886,7 @@ public class CDMAPhone extends PhoneBase { // if no one invokes exitEmergencyCallbackMode() directly. long delayInMillis = SystemProperties.getLong( TelephonyProperties.PROPERTY_ECM_EXIT_TIMER, DEFAULT_ECM_EXIT_TIMER_VALUE); - h.postDelayed(mExitEcmRunnable, delayInMillis); + postDelayed(mExitEcmRunnable, delayInMillis); // We don't want to go to sleep while in Ecm mWakeLock.acquire(); } @@ -915,7 +899,7 @@ public class CDMAPhone extends PhoneBase { + ar.exception + mIsPhoneInEcmState); } // Remove pending exit Ecm runnable, if any - h.removeCallbacks(mExitEcmRunnable); + removeCallbacks(mExitEcmRunnable); if (mEcmExitRespRegistrant != null) { mEcmExitRespRegistrant.notifyRegistrant(ar); @@ -941,13 +925,13 @@ public class CDMAPhone extends PhoneBase { void handleTimerInEmergencyCallbackMode(int action) { switch(action) { case CANCEL_ECM_TIMER: - h.removeCallbacks(mExitEcmRunnable); + removeCallbacks(mExitEcmRunnable); mEcmTimerResetRegistrants.notifyResult(new Boolean(true)); break; case RESTART_ECM_TIMER: long delayInMillis = SystemProperties.getLong( TelephonyProperties.PROPERTY_ECM_EXIT_TIMER, DEFAULT_ECM_EXIT_TIMER_VALUE); - h.postDelayed(mExitEcmRunnable, delayInMillis); + postDelayed(mExitEcmRunnable, delayInMillis); mEcmTimerResetRegistrants.notifyResult(new Boolean(false)); break; default: @@ -969,123 +953,108 @@ public class CDMAPhone extends PhoneBase { mEcmTimerResetRegistrants.remove(h); } - //***** Inner Classes - class MyHandler extends Handler { - MyHandler() { - } + @Override + public void handleMessage(Message msg) { + AsyncResult ar; + Message onComplete; - MyHandler(Looper l) { - super(l); - } + switch(msg.what) { + case EVENT_RADIO_AVAILABLE: { + mCM.getBasebandVersion(obtainMessage(EVENT_GET_BASEBAND_VERSION_DONE)); - @Override - public void handleMessage(Message msg) { - AsyncResult ar; - Message onComplete; + mCM.getDeviceIdentity(obtainMessage(EVENT_GET_DEVICE_IDENTITY_DONE)); + } + break; - switch(msg.what) { - case EVENT_RADIO_AVAILABLE: { - mCM.getBasebandVersion(obtainMessage(EVENT_GET_BASEBAND_VERSION_DONE)); + case EVENT_GET_BASEBAND_VERSION_DONE:{ + ar = (AsyncResult)msg.obj; - mCM.getDeviceIdentity(obtainMessage(EVENT_GET_DEVICE_IDENTITY_DONE)); + if (ar.exception != null) { + break; } - break; - - case EVENT_GET_BASEBAND_VERSION_DONE:{ - ar = (AsyncResult)msg.obj; - - if (ar.exception != null) { - break; - } - if (DBG) Log.d(LOG_TAG, "Baseband version: " + ar.result); - setSystemProperty(TelephonyProperties.PROPERTY_BASEBAND_VERSION, (String)ar.result); - } - break; + if (DBG) Log.d(LOG_TAG, "Baseband version: " + ar.result); + setSystemProperty(TelephonyProperties.PROPERTY_BASEBAND_VERSION, (String)ar.result); + } + break; - case EVENT_GET_DEVICE_IDENTITY_DONE:{ - ar = (AsyncResult)msg.obj; + case EVENT_GET_DEVICE_IDENTITY_DONE:{ + ar = (AsyncResult)msg.obj; - if (ar.exception != null) { - break; - } - String[] respId = (String[])ar.result; - mEsn = respId[2]; - mMeid = respId[3]; + if (ar.exception != null) { + break; } - break; + String[] respId = (String[])ar.result; + mEsn = respId[2]; + mMeid = respId[3]; + } + break; - case EVENT_EMERGENCY_CALLBACK_MODE_ENTER:{ - handleEnterEmergencyCallbackMode(msg); - } - break; + case EVENT_EMERGENCY_CALLBACK_MODE_ENTER:{ + handleEnterEmergencyCallbackMode(msg); + } + break; - case EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE:{ - handleExitEmergencyCallbackMode(msg); - } - break; + case EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE:{ + handleExitEmergencyCallbackMode(msg); + } + break; - case EVENT_RUIM_RECORDS_LOADED:{ - Log.d(LOG_TAG, "Event EVENT_RUIM_RECORDS_LOADED Received"); - } - break; + case EVENT_RUIM_RECORDS_LOADED:{ + Log.d(LOG_TAG, "Event EVENT_RUIM_RECORDS_LOADED Received"); + } + break; - case EVENT_RADIO_OFF_OR_NOT_AVAILABLE:{ - Log.d(LOG_TAG, "Event EVENT_RADIO_OFF_OR_NOT_AVAILABLE Received"); - } - break; + case EVENT_RADIO_OFF_OR_NOT_AVAILABLE:{ + Log.d(LOG_TAG, "Event EVENT_RADIO_OFF_OR_NOT_AVAILABLE Received"); + } + break; - case EVENT_RADIO_ON:{ - Log.d(LOG_TAG, "Event EVENT_RADIO_ON Received"); - } - break; + case EVENT_RADIO_ON:{ + Log.d(LOG_TAG, "Event EVENT_RADIO_ON Received"); + } + break; - case EVENT_SSN:{ - Log.d(LOG_TAG, "Event EVENT_SSN Received"); - } - break; + case EVENT_SSN:{ + Log.d(LOG_TAG, "Event EVENT_SSN Received"); + } + break; - case EVENT_CALL_RING:{ - Log.d(LOG_TAG, "Event EVENT_CALL_RING Received"); - } - break; + case EVENT_REGISTERED_TO_NETWORK:{ + Log.d(LOG_TAG, "Event EVENT_REGISTERED_TO_NETWORK Received"); + } + break; - case EVENT_REGISTERED_TO_NETWORK:{ - Log.d(LOG_TAG, "Event EVENT_REGISTERED_TO_NETWORK Received"); + case EVENT_NV_READY:{ + Log.d(LOG_TAG, "Event EVENT_NV_READY Received"); + //Inform the Service State Tracker + mEriManager.loadEriFile(); + mNvLoadedRegistrants.notifyRegistrants(); + if(mEriManager.isEriFileLoaded()) { + // when the ERI file is loaded + Log.d(LOG_TAG, "ERI read, notify registrants"); + mEriFileLoadedRegistrants.notifyRegistrants(); } - break; + setSystemProperty(TelephonyProperties.PROPERTY_INECM_MODE,"false"); + } + break; - case EVENT_NV_READY:{ - Log.d(LOG_TAG, "Event EVENT_NV_READY Received"); - //Inform the Service State Tracker - mEriManager.loadEriFile(); - mNvLoadedRegistrants.notifyRegistrants(); - if(mEriManager.isEriFileLoaded()) { - // when the ERI file is loaded - Log.d(LOG_TAG, "ERI read, notify registrants"); - mEriFileLoadedRegistrants.notifyRegistrants(); - } - setSystemProperty(TelephonyProperties.PROPERTY_INECM_MODE,"false"); + case EVENT_SET_VM_NUMBER_DONE:{ + ar = (AsyncResult)msg.obj; + if (IccException.class.isInstance(ar.exception)) { + storeVoiceMailNumber(mVmNumber); + ar.exception = null; } - break; - - case EVENT_SET_VM_NUMBER_DONE:{ - ar = (AsyncResult)msg.obj; - if (IccException.class.isInstance(ar.exception)) { - storeVoiceMailNumber(mVmNumber); - ar.exception = null; - } - onComplete = (Message) ar.userObj; - if (onComplete != null) { - AsyncResult.forMessage(onComplete, ar.result, ar.exception); - onComplete.sendToTarget(); - } + onComplete = (Message) ar.userObj; + if (onComplete != null) { + AsyncResult.forMessage(onComplete, ar.result, ar.exception); + onComplete.sendToTarget(); } - break; + } + break; - default:{ - throw new RuntimeException("unexpected event not handled"); - } + default:{ + super.handleMessage(msg); } } } @@ -1140,13 +1109,6 @@ public class CDMAPhone extends PhoneBase { /** * {@inheritDoc} */ - public Handler getHandler() { - return h; - } - - /** - * {@inheritDoc} - */ public IccFileHandler getIccFileHandler() { return this.mIccFileHandler; } diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java index caf5a80..ffaa1cd 100644 --- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java @@ -146,7 +146,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { }; - //***** Constructor + /* Constructor */ CdmaDataConnectionTracker(CDMAPhone p) { super(p); @@ -174,7 +174,9 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); - p.getContext().registerReceiver(mIntentReceiver, filter, null, p.h); + // TODO: Why is this registering the phone as the receiver of the intent + // and not its own handler? + p.getContext().registerReceiver(mIntentReceiver, filter, null, p); mDataConnectionTracker = this; @@ -566,8 +568,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker { private boolean retryAfterDisconnected(String reason) { boolean retry = true; - if ( Phone.REASON_RADIO_TURNED_OFF.equals(reason) || - Phone.REASON_DATA_DISABLED.equals(reason) ) { + if ( Phone.REASON_RADIO_TURNED_OFF.equals(reason) ) { retry = false; } return retry; diff --git a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java index 3c1308b..ac7331e 100755 --- a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java +++ b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java @@ -23,13 +23,11 @@ import android.database.SQLException; import android.net.Uri; import android.os.AsyncResult; import android.os.Handler; -import android.os.Looper; import android.os.Message; import android.os.Registrant; import android.os.RegistrantList; import android.os.SystemProperties; import android.preference.PreferenceManager; -import android.provider.Settings; import android.provider.Telephony; import android.telephony.CellLocation; import android.telephony.PhoneNumberUtils; @@ -98,14 +96,13 @@ public class GSMPhone extends PhoneBase { // Key used to read/write the SIM IMSI used for storing the voice mail public static final String VM_SIM_IMSI = "vm_sim_imsi_key"; - //***** Instance Variables + // Instance Variables GsmCallTracker mCT; GsmServiceStateTracker mSST; GsmSMSDispatcher mSMS; SIMRecords mSIMRecords; SimCard mSimCard; StkService mStkService; - MyHandler h; ArrayList <GsmMmiCode> mPendingMMIs = new ArrayList<GsmMmiCode>(); SimPhoneBookInterfaceManager mSimPhoneBookIntManager; SimSmsInterfaceManager mSimSmsIntManager; @@ -129,7 +126,7 @@ public class GSMPhone extends PhoneBase { private String mVmNumber; - //***** Constructors + // Constructors public GSMPhone (Context context, CommandsInterface ci, PhoneNotifier notifier) { @@ -138,9 +135,7 @@ public class GSMPhone extends PhoneBase { public GSMPhone (Context context, CommandsInterface ci, PhoneNotifier notifier, boolean unitTestMode) { - super(notifier, context, unitTestMode); - h = new MyHandler(); - mCM = ci; + super(notifier, context, ci, unitTestMode); if (ci instanceof SimulatedRadioControl) { mSimulatedRadioControl = (SimulatedRadioControl) ci; @@ -162,14 +157,13 @@ public class GSMPhone extends PhoneBase { mStkService = StkService.getInstance(mCM, mSIMRecords, mContext, (SIMFileHandler)mIccFileHandler, mSimCard); - mCM.registerForAvailable(h, EVENT_RADIO_AVAILABLE, null); - mSIMRecords.registerForRecordsLoaded(h, EVENT_SIM_RECORDS_LOADED, null); - mCM.registerForOffOrNotAvailable(h, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null); - mCM.registerForOn(h, EVENT_RADIO_ON, null); - mCM.setOnUSSD(h, EVENT_USSD, null); - mCM.setOnSuppServiceNotification(h, EVENT_SSN, null); - mCM.setOnCallRing(h, EVENT_CALL_RING, null); - mSST.registerForNetworkAttach(h, EVENT_REGISTERED_TO_NETWORK, null); + mCM.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null); + mSIMRecords.registerForRecordsLoaded(this, EVENT_SIM_RECORDS_LOADED, null); + mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null); + mCM.registerForOn(this, EVENT_RADIO_ON, null); + mCM.setOnUSSD(this, EVENT_USSD, null); + mCM.setOnSuppServiceNotification(this, EVENT_SSN, null); + mSST.registerForNetworkAttach(this, EVENT_REGISTERED_TO_NETWORK, null); if (false) { try { @@ -212,15 +206,16 @@ public class GSMPhone extends PhoneBase { public void dispose() { synchronized(PhoneProxy.lockForRadioTechnologyChange) { + super.dispose(); + //Unregister from all former registered events - mCM.unregisterForAvailable(h); //EVENT_RADIO_AVAILABLE - mSIMRecords.unregisterForRecordsLoaded(h); //EVENT_SIM_RECORDS_LOADED - mCM.unregisterForOffOrNotAvailable(h); //EVENT_RADIO_OFF_OR_NOT_AVAILABLE - mCM.unregisterForOn(h); //EVENT_RADIO_ON - mSST.unregisterForNetworkAttach(h); //EVENT_REGISTERED_TO_NETWORK - mCM.unSetOnUSSD(h); - mCM.unSetOnSuppServiceNotification(h); - mCM.unSetOnCallRing(h); + mCM.unregisterForAvailable(this); //EVENT_RADIO_AVAILABLE + mSIMRecords.unregisterForRecordsLoaded(this); //EVENT_SIM_RECORDS_LOADED + mCM.unregisterForOffOrNotAvailable(this); //EVENT_RADIO_OFF_OR_NOT_AVAILABLE + mCM.unregisterForOn(this); //EVENT_RADIO_ON + mSST.unregisterForNetworkAttach(this); //EVENT_REGISTERED_TO_NETWORK + mCM.unSetOnUSSD(this); + mCM.unSetOnSuppServiceNotification(this); mPendingMMIs.clear(); @@ -258,8 +253,6 @@ public class GSMPhone extends PhoneBase { } - //***** Overridden from Phone - public ServiceState getServiceState() { return mSST.ss; @@ -391,14 +384,6 @@ public class GSMPhone extends PhoneBase { super.notifyNewRingingConnectionP(c); } - /** - * Notifiy registrants of a RING event. - */ - void notifyIncomingRing() { - AsyncResult ar = new AsyncResult(null, this, null); - mIncomingRingRegistrants.notifyRegistrants(ar); - } - /*package*/ void notifyDisconnect(Connection cn) { mDisconnectRegistrants.notifyResult(cn); @@ -917,7 +902,7 @@ public class GSMPhone extends PhoneBase { Message resp; mVmNumber = voiceMailNumber; - resp = h.obtainMessage(EVENT_SET_VM_NUMBER_DONE, 0, 0, onComplete); + resp = obtainMessage(EVENT_SET_VM_NUMBER_DONE, 0, 0, onComplete); mSIMRecords.setVoiceMailNumber(alphaTag, mVmNumber, resp); } @@ -956,7 +941,7 @@ public class GSMPhone extends PhoneBase { if (LOCAL_DEBUG) Log.d(LOG_TAG, "requesting call forwarding query."); Message resp; if (commandInterfaceCFReason == CF_REASON_UNCONDITIONAL) { - resp = h.obtainMessage(EVENT_GET_CALL_FORWARD_DONE, onComplete); + resp = obtainMessage(EVENT_GET_CALL_FORWARD_DONE, onComplete); } else { resp = onComplete; } @@ -974,7 +959,7 @@ public class GSMPhone extends PhoneBase { Message resp; if (commandInterfaceCFReason == CF_REASON_UNCONDITIONAL) { - resp = h.obtainMessage(EVENT_SET_CALL_FORWARD_DONE, + resp = obtainMessage(EVENT_SET_CALL_FORWARD_DONE, isCfEnable(commandInterfaceCFAction) ? 1 : 0, 0, onComplete); } else { resp = onComplete; @@ -995,7 +980,7 @@ public class GSMPhone extends PhoneBase { public void setOutgoingCallerIdDisplay(int commandInterfaceCLIRMode, Message onComplete) { mCM.setCLIR(commandInterfaceCLIRMode, - h.obtainMessage(EVENT_SET_CLIR_COMPLETE, commandInterfaceCLIRMode, 0, onComplete)); + obtainMessage(EVENT_SET_CLIR_COMPLETE, commandInterfaceCLIRMode, 0, onComplete)); } public void getCallWaiting(Message onComplete) { @@ -1043,7 +1028,7 @@ public class GSMPhone extends PhoneBase { nsm.operatorAlphaLong = ""; // get the message - Message msg = h.obtainMessage(EVENT_SET_NETWORK_AUTOMATIC_COMPLETE, nsm); + Message msg = obtainMessage(EVENT_SET_NETWORK_AUTOMATIC_COMPLETE, nsm); if (LOCAL_DEBUG) Log.d(LOG_TAG, "wrapping and sending message to connect automatically"); @@ -1061,7 +1046,7 @@ public class GSMPhone extends PhoneBase { nsm.operatorAlphaLong = network.operatorAlphaLong; // get the message - Message msg = h.obtainMessage(EVENT_SET_NETWORK_MANUAL_COMPLETE, nsm); + Message msg = obtainMessage(EVENT_SET_NETWORK_MANUAL_COMPLETE, nsm); mCM.setNetworkSelectionModeManual(network.operatorNumeric, msg); } @@ -1247,178 +1232,163 @@ public class GSMPhone extends PhoneBase { } } - //***** Inner Classes - - class MyHandler extends Handler { - MyHandler() { - } + @Override + public void handleMessage (Message msg) { + AsyncResult ar; + Message onComplete; - MyHandler(Looper l) { - super(l); - } + switch (msg.what) { + case EVENT_RADIO_AVAILABLE: { + mCM.getBasebandVersion( + obtainMessage(EVENT_GET_BASEBAND_VERSION_DONE)); - public void - handleMessage (Message msg) { - AsyncResult ar; - Message onComplete; - - switch (msg.what) { - case EVENT_RADIO_AVAILABLE: { - mCM.getBasebandVersion( - obtainMessage(EVENT_GET_BASEBAND_VERSION_DONE)); + mCM.getIMEI(obtainMessage(EVENT_GET_IMEI_DONE)); + mCM.getIMEISV(obtainMessage(EVENT_GET_IMEISV_DONE)); + } + break; - mCM.getIMEI(obtainMessage(EVENT_GET_IMEI_DONE)); - mCM.getIMEISV(obtainMessage(EVENT_GET_IMEISV_DONE)); - } - break; + case EVENT_RADIO_ON: + break; - case EVENT_RADIO_ON: + case EVENT_REGISTERED_TO_NETWORK: + syncClirSetting(); break; - case EVENT_REGISTERED_TO_NETWORK: - syncClirSetting(); - break; - - case EVENT_SIM_RECORDS_LOADED: - updateCurrentCarrierInProvider(); + case EVENT_SIM_RECORDS_LOADED: + updateCurrentCarrierInProvider(); - // Check if this is a different SIM than the previous one. If so unset the - // voice mail number. - String imsi = getVmSimImsi(); - if (imsi != null && !getSubscriberId().equals(imsi)) { - storeVoiceMailNumber(null); - setVmSimImsi(null); - } + // Check if this is a different SIM than the previous one. If so unset the + // voice mail number. + String imsi = getVmSimImsi(); + if (imsi != null && !getSubscriberId().equals(imsi)) { + storeVoiceMailNumber(null); + setVmSimImsi(null); + } - break; + break; - case EVENT_GET_BASEBAND_VERSION_DONE: - ar = (AsyncResult)msg.obj; + case EVENT_GET_BASEBAND_VERSION_DONE: + ar = (AsyncResult)msg.obj; - if (ar.exception != null) { - break; - } + if (ar.exception != null) { + break; + } - if (LOCAL_DEBUG) Log.d(LOG_TAG, "Baseband version: " + ar.result); - setSystemProperty(PROPERTY_BASEBAND_VERSION, (String)ar.result); - break; + if (LOCAL_DEBUG) Log.d(LOG_TAG, "Baseband version: " + ar.result); + setSystemProperty(PROPERTY_BASEBAND_VERSION, (String)ar.result); + break; - case EVENT_GET_IMEI_DONE: - ar = (AsyncResult)msg.obj; + case EVENT_GET_IMEI_DONE: + ar = (AsyncResult)msg.obj; - if (ar.exception != null) { - break; - } + if (ar.exception != null) { + break; + } - mImei = (String)ar.result; - break; + mImei = (String)ar.result; + break; - case EVENT_GET_IMEISV_DONE: - ar = (AsyncResult)msg.obj; + case EVENT_GET_IMEISV_DONE: + ar = (AsyncResult)msg.obj; - if (ar.exception != null) { - break; - } + if (ar.exception != null) { + break; + } - mImeiSv = (String)ar.result; - break; + mImeiSv = (String)ar.result; + break; - case EVENT_USSD: - ar = (AsyncResult)msg.obj; + case EVENT_USSD: + ar = (AsyncResult)msg.obj; - String[] ussdResult = (String[]) ar.result; + String[] ussdResult = (String[]) ar.result; - if (ussdResult.length > 1) { - try { - onIncomingUSSD(Integer.parseInt(ussdResult[0]), ussdResult[1]); - } catch (NumberFormatException e) { - Log.w(LOG_TAG, "error parsing USSD"); - } + if (ussdResult.length > 1) { + try { + onIncomingUSSD(Integer.parseInt(ussdResult[0]), ussdResult[1]); + } catch (NumberFormatException e) { + Log.w(LOG_TAG, "error parsing USSD"); } - break; + } + break; - case EVENT_RADIO_OFF_OR_NOT_AVAILABLE: - // Some MMI requests (eg USSD) are not completed - // within the course of a CommandsInterface request - // If the radio shuts off or resets while one of these - // is pending, we need to clean up. + case EVENT_RADIO_OFF_OR_NOT_AVAILABLE: + // Some MMI requests (eg USSD) are not completed + // within the course of a CommandsInterface request + // If the radio shuts off or resets while one of these + // is pending, we need to clean up. - for (int i = 0, s = mPendingMMIs.size() ; i < s; i++) { - if (mPendingMMIs.get(i).isPendingUSSD()) { - mPendingMMIs.get(i).onUssdFinishedError(); - } + for (int i = 0, s = mPendingMMIs.size() ; i < s; i++) { + if (mPendingMMIs.get(i).isPendingUSSD()) { + mPendingMMIs.get(i).onUssdFinishedError(); } + } + break; + + case EVENT_SSN: + ar = (AsyncResult)msg.obj; + SuppServiceNotification not = (SuppServiceNotification) ar.result; + mSsnRegistrants.notifyRegistrants(ar); + break; + + case EVENT_SET_CALL_FORWARD_DONE: + ar = (AsyncResult)msg.obj; + if (ar.exception == null) { + mSIMRecords.setVoiceCallForwardingFlag(1, msg.arg1 == 1); + } + onComplete = (Message) ar.userObj; + if (onComplete != null) { + AsyncResult.forMessage(onComplete, ar.result, ar.exception); + onComplete.sendToTarget(); + } break; - case EVENT_SSN: - ar = (AsyncResult)msg.obj; - SuppServiceNotification not = (SuppServiceNotification) ar.result; - mSsnRegistrants.notifyRegistrants(ar); + case EVENT_SET_VM_NUMBER_DONE: + ar = (AsyncResult)msg.obj; + if (IccVmNotSupportedException.class.isInstance(ar.exception)) { + storeVoiceMailNumber(mVmNumber); + ar.exception = null; + } + onComplete = (Message) ar.userObj; + if (onComplete != null) { + AsyncResult.forMessage(onComplete, ar.result, ar.exception); + onComplete.sendToTarget(); + } break; - case EVENT_SET_CALL_FORWARD_DONE: - ar = (AsyncResult)msg.obj; - if (ar.exception == null) { - mSIMRecords.setVoiceCallForwardingFlag(1, msg.arg1 == 1); - } - onComplete = (Message) ar.userObj; - if (onComplete != null) { - AsyncResult.forMessage(onComplete, ar.result, ar.exception); - onComplete.sendToTarget(); - } - break; - case EVENT_SET_VM_NUMBER_DONE: - ar = (AsyncResult)msg.obj; - if (IccVmNotSupportedException.class.isInstance(ar.exception)) { - storeVoiceMailNumber(mVmNumber); - ar.exception = null; - } - onComplete = (Message) ar.userObj; - if (onComplete != null) { - AsyncResult.forMessage(onComplete, ar.result, ar.exception); - onComplete.sendToTarget(); - } - break; - - - case EVENT_GET_CALL_FORWARD_DONE: - ar = (AsyncResult)msg.obj; - if (ar.exception == null) { - handleCfuQueryResult((CallForwardInfo[])ar.result); - } - onComplete = (Message) ar.userObj; - if (onComplete != null) { - AsyncResult.forMessage(onComplete, ar.result, ar.exception); - onComplete.sendToTarget(); - } - break; + case EVENT_GET_CALL_FORWARD_DONE: + ar = (AsyncResult)msg.obj; + if (ar.exception == null) { + handleCfuQueryResult((CallForwardInfo[])ar.result); + } + onComplete = (Message) ar.userObj; + if (onComplete != null) { + AsyncResult.forMessage(onComplete, ar.result, ar.exception); + onComplete.sendToTarget(); + } + break; - case EVENT_CALL_RING: - ar = (AsyncResult)msg.obj; - if (ar.exception == null) { - notifyIncomingRing(); - } - break; + // handle the select network completion callbacks. + case EVENT_SET_NETWORK_MANUAL_COMPLETE: + case EVENT_SET_NETWORK_AUTOMATIC_COMPLETE: + handleSetSelectNetwork((AsyncResult) msg.obj); + break; - // handle the select network completion callbacks. - case EVENT_SET_NETWORK_MANUAL_COMPLETE: - case EVENT_SET_NETWORK_AUTOMATIC_COMPLETE: - handleSetSelectNetwork((AsyncResult) msg.obj); - break; + case EVENT_SET_CLIR_COMPLETE: + ar = (AsyncResult)msg.obj; + if (ar.exception == null) { + saveClirSetting(msg.arg1); + } + onComplete = (Message) ar.userObj; + if (onComplete != null) { + AsyncResult.forMessage(onComplete, ar.result, ar.exception); + onComplete.sendToTarget(); + } + break; - case EVENT_SET_CLIR_COMPLETE: - ar = (AsyncResult)msg.obj; - if (ar.exception == null) { - saveClirSetting(msg.arg1); - } - onComplete = (Message) ar.userObj; - if (onComplete != null) { - AsyncResult.forMessage(onComplete, ar.result, ar.exception); - onComplete.sendToTarget(); - } - break; - } + default: + super.handleMessage(msg); } } @@ -1533,13 +1503,6 @@ public class GSMPhone extends PhoneBase { /** * {@inheritDoc} */ - public Handler getHandler(){ - return h; - } - - /** - * {@inheritDoc} - */ public IccFileHandler getIccFileHandler(){ return this.mIccFileHandler; } diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java index a9c6fad..0215ab2 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java @@ -222,7 +222,9 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); - p.getContext().registerReceiver(mIntentReceiver, filter, null, p.h); + // TODO: Why is this registering the phone as the receiver of the intent + // and not its own handler? + p.getContext().registerReceiver(mIntentReceiver, filter, null, p); mDataConnectionTracker = this; @@ -1008,8 +1010,7 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker { private boolean retryAfterDisconnected(String reason) { boolean retry = true; - if ( Phone.REASON_RADIO_TURNED_OFF.equals(reason) || - Phone.REASON_DATA_DISABLED.equals(reason) ) { + if ( Phone.REASON_RADIO_TURNED_OFF.equals(reason) ) { retry = false; } return retry; |