Merge change 22940 into eclair

* changes:
  Fix bug 2040024 phone rings only once sometimes.
This commit is contained in:
Android (Google) Code Review
2009-08-28 13:30:18 -07:00
7 changed files with 428 additions and 389 deletions

View File

@@ -1388,7 +1388,7 @@ public interface Phone {
*/ */
String getIccSerialNumber(); String getIccSerialNumber();
//***** CDMA support methods /* CDMA support methods */
/* /*
* TODO(Moto) TODO(Teleca): can getCdmaMin, getEsn, getMeid use more generic calls * TODO(Moto) TODO(Teleca): can getCdmaMin, getEsn, getMeid use more generic calls

View File

@@ -31,7 +31,6 @@ import android.os.SystemProperties;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.Settings; import android.provider.Settings;
import android.telephony.ServiceState; import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; 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 String LOG_TAG = "PHONE";
private static final boolean LOCAL_DEBUG = true; 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) // 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"; 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; protected static final int EVENT_RADIO_AVAILABLE = 1;
/** Supplementary Service Notification received. */ /** Supplementary Service Notification received. */
protected static final int EVENT_SSN = 2; 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_SET_CALL_FORWARD_DONE = 12;
protected static final int EVENT_GET_CALL_FORWARD_DONE = 13; 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 = 14;
protected static final int EVENT_CALL_RING_CONTINUE = 15;
// Used to intercept the carrier selection calls so that // Used to intercept the carrier selection calls so that
// we can save the values. // we can save the values.
protected static final int EVENT_SET_NETWORK_MANUAL_COMPLETE = 15; protected static final int EVENT_SET_NETWORK_MANUAL_COMPLETE = 16;
protected static final int EVENT_SET_NETWORK_AUTOMATIC_COMPLETE = 16; protected static final int EVENT_SET_NETWORK_AUTOMATIC_COMPLETE = 17;
protected static final int EVENT_SET_CLIR_COMPLETE = 17; protected static final int EVENT_SET_CLIR_COMPLETE = 18;
protected static final int EVENT_REGISTERED_TO_NETWORK = 18; protected static final int EVENT_REGISTERED_TO_NETWORK = 19;
protected static final int EVENT_SET_VM_NUMBER_DONE = 19; protected static final int EVENT_SET_VM_NUMBER_DONE = 20;
// Events for CDMA support // Events for CDMA support
protected static final int EVENT_GET_DEVICE_IDENTITY_DONE = 20; protected static final int EVENT_GET_DEVICE_IDENTITY_DONE = 21;
protected static final int EVENT_RUIM_RECORDS_LOADED = 21; protected static final int EVENT_RUIM_RECORDS_LOADED = 22;
protected static final int EVENT_NV_READY = 22; protected static final int EVENT_NV_READY = 23;
protected static final int EVENT_SET_ENHANCED_VP = 23; protected static final int EVENT_SET_ENHANCED_VP = 24;
protected static final int EVENT_EMERGENCY_CALLBACK_MODE_ENTER = 24; protected static final int EVENT_EMERGENCY_CALLBACK_MODE_ENTER = 25;
protected static final int EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE = 25; protected static final int EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE = 26;
// Key used to read/write current CLIR setting // Key used to read/write current CLIR setting
public static final String CLIR_KEY = "clir_key"; 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) // 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"; public static final String DNS_SERVER_CHECK_DISABLED_KEY = "dns_server_check_disabled_key";
//***** Instance Variables /* Instance Variables */
public CommandsInterface mCM; public CommandsInterface mCM;
protected IccFileHandler mIccFileHandler; protected IccFileHandler mIccFileHandler;
boolean mDnsCheckDisabled = false; boolean mDnsCheckDisabled = false;
public DataConnectionTracker mDataConnection; public DataConnectionTracker mDataConnection;
boolean mDoesRilSendMultipleCallRing;
int mCallRingContinueToken = 0;
int mCallRingDelay;
/** /**
* Set a system property, unless we're in unit test mode * 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, * @param notifier An instance of DefaultPhoneNotifier,
* unless unit testing. * unless unit testing.
*/ */
protected PhoneBase(PhoneNotifier notifier, Context context) { protected PhoneBase(PhoneNotifier notifier, Context context, CommandsInterface ci) {
this(notifier, context, false); this(notifier, context, ci, false);
} }
/** /**
@@ -185,11 +189,12 @@ public abstract class PhoneBase implements Phone {
* @param unitTestMode when true, prevents notifications * @param unitTestMode when true, prevents notifications
* of state change events * of state change events
*/ */
protected PhoneBase(PhoneNotifier notifier, Context context, protected PhoneBase(PhoneNotifier notifier, Context context, CommandsInterface ci,
boolean unitTestMode) { boolean unitTestMode) {
this.mNotifier = notifier; this.mNotifier = notifier;
this.mContext = context; this.mContext = context;
mLooper = Looper.myLooper(); mLooper = Looper.myLooper();
mCM = ci;
setPropertiesByCarrier(); setPropertiesByCarrier();
@@ -197,6 +202,70 @@ public abstract class PhoneBase implements Phone {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
mDnsCheckDisabled = sp.getBoolean(DNS_SERVER_CHECK_DISABLED_KEY, false); 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. // Inherited documentation suffices.
@@ -290,16 +359,6 @@ public abstract class PhoneBase implements Phone {
mCM.unregisterForInCallVoicePrivacyOff(h); 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. // Inherited documentation suffices.
public void registerForIncomingRing( public void registerForIncomingRing(
Handler h, int what, Object obj) { 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 * Retrieves the IccFileHandler of the Phone instance
*/ */
public abstract IccFileHandler getIccFileHandler(); public abstract IccFileHandler getIccFileHandler();
/*
* Retrieves the Handler of the Phone instance
*/
public Handler getHandler() {
return this;
}
/** /**
* Query the status of the CDMA roaming preference * Query the status of the CDMA roaming preference
@@ -902,4 +967,39 @@ public abstract class PhoneBase implements Phone {
mDataConnection.setState(dcState); mDataConnection.setState(dcState);
notifyDataConnection(null); 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);
}
}
} }

View File

@@ -120,4 +120,14 @@ public interface TelephonyProperties
*/ */
static final String PROPERTY_DISABLE_CALL = "ro.telephony.disable-call"; 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";
} }

View File

@@ -26,7 +26,6 @@ import android.database.SQLException;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncResult; import android.os.AsyncResult;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.PowerManager.WakeLock; import android.os.PowerManager.WakeLock;
@@ -35,7 +34,6 @@ import android.os.RegistrantList;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.Settings;
import android.provider.Telephony; import android.provider.Telephony;
import android.telephony.CellLocation; import android.telephony.CellLocation;
import android.telephony.PhoneNumberUtils; 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 RESTART_ECM_TIMER = 0; // restart Ecm timer
static final int CANCEL_ECM_TIMER = 1; // cancel Ecm timer static final int CANCEL_ECM_TIMER = 1; // cancel Ecm timer
//***** Instance Variables // Instance Variables
CdmaCallTracker mCT; CdmaCallTracker mCT;
CdmaSMSDispatcher mSMS; CdmaSMSDispatcher mSMS;
CdmaServiceStateTracker mSST; CdmaServiceStateTracker mSST;
RuimFileHandler mRuimFileHandler; RuimFileHandler mRuimFileHandler;
RuimRecords mRuimRecords; RuimRecords mRuimRecords;
RuimCard mRuimCard; RuimCard mRuimCard;
MyHandler h;
RuimPhoneBookInterfaceManager mRuimPhoneBookInterfaceManager; RuimPhoneBookInterfaceManager mRuimPhoneBookInterfaceManager;
RuimSmsInterfaceManager mRuimSmsInterfaceManager; RuimSmsInterfaceManager mRuimSmsInterfaceManager;
PhoneSubInfo mSubInfo; PhoneSubInfo mSubInfo;
EriManager mEriManager; EriManager mEriManager;
WakeLock mWakeLock; WakeLock mWakeLock;
// mNvLoadedRegistrants are informed after the EVENT_NV_READY // mNvLoadedRegistrants are informed after the EVENT_NV_READY
private RegistrantList mNvLoadedRegistrants = new RegistrantList(); private RegistrantList mNvLoadedRegistrants = new RegistrantList();
@@ -139,17 +137,14 @@ public class CDMAPhone extends PhoneBase {
Registrant mPostDialHandler; Registrant mPostDialHandler;
//***** Constructors // Constructors
public CDMAPhone(Context context, CommandsInterface ci, PhoneNotifier notifier) { public CDMAPhone(Context context, CommandsInterface ci, PhoneNotifier notifier) {
this(context,ci,notifier, false); this(context,ci,notifier, false);
} }
public CDMAPhone(Context context, CommandsInterface ci, PhoneNotifier notifier, public CDMAPhone(Context context, CommandsInterface ci, PhoneNotifier notifier,
boolean unitTestMode) { boolean unitTestMode) {
super(notifier, context, unitTestMode); super(notifier, context, ci, unitTestMode);
h = new MyHandler();
mCM = ci;
mCM.setPhoneType(RILConstants.CDMA_PHONE); mCM.setPhoneType(RILConstants.CDMA_PHONE);
mCT = new CdmaCallTracker(this); mCT = new CdmaCallTracker(this);
@@ -164,15 +159,14 @@ public class CDMAPhone extends PhoneBase {
mSubInfo = new PhoneSubInfo(this); mSubInfo = new PhoneSubInfo(this);
mEriManager = new EriManager(this, context, EriManager.ERI_FROM_XML); mEriManager = new EriManager(this, context, EriManager.ERI_FROM_XML);
mCM.registerForAvailable(h, EVENT_RADIO_AVAILABLE, null); mCM.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);
mRuimRecords.registerForRecordsLoaded(h, EVENT_RUIM_RECORDS_LOADED, null); mRuimRecords.registerForRecordsLoaded(this, EVENT_RUIM_RECORDS_LOADED, null);
mCM.registerForOffOrNotAvailable(h, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null); mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
mCM.registerForOn(h, EVENT_RADIO_ON, null); mCM.registerForOn(this, EVENT_RADIO_ON, null);
mCM.setOnSuppServiceNotification(h, EVENT_SSN, null); mCM.setOnSuppServiceNotification(this, EVENT_SSN, null);
mCM.setOnCallRing(h, EVENT_CALL_RING, null); mSST.registerForNetworkAttach(this, EVENT_REGISTERED_TO_NETWORK, null);
mSST.registerForNetworkAttach(h, EVENT_REGISTERED_TO_NETWORK, null); mCM.registerForNVReady(this, EVENT_NV_READY, null);
mCM.registerForNVReady(h, EVENT_NV_READY, null); mCM.setEmergencyCallbackMode(this, EVENT_EMERGENCY_CALLBACK_MODE_ENTER, null);
mCM.setEmergencyCallbackMode(h, EVENT_EMERGENCY_CALLBACK_MODE_ENTER, null);
PowerManager pm PowerManager pm
= (PowerManager) context.getSystemService(Context.POWER_SERVICE); = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
@@ -207,23 +201,23 @@ public class CDMAPhone extends PhoneBase {
// Updates MCC MNC device configuration information // Updates MCC MNC device configuration information
updateMccMncConfiguration(operatorNumeric); updateMccMncConfiguration(operatorNumeric);
// Notify voicemails. // Notify voicemails.
notifier.notifyMessageWaitingChanged(this); notifier.notifyMessageWaitingChanged(this);
} }
public void dispose() { public void dispose() {
synchronized(PhoneProxy.lockForRadioTechnologyChange) { synchronized(PhoneProxy.lockForRadioTechnologyChange) {
super.dispose();
//Unregister from all former registered events //Unregister from all former registered events
mRuimRecords.unregisterForRecordsLoaded(h); //EVENT_RUIM_RECORDS_LOADED mRuimRecords.unregisterForRecordsLoaded(this); //EVENT_RUIM_RECORDS_LOADED
mCM.unregisterForAvailable(h); //EVENT_RADIO_AVAILABLE mCM.unregisterForAvailable(this); //EVENT_RADIO_AVAILABLE
mCM.unregisterForOffOrNotAvailable(h); //EVENT_RADIO_OFF_OR_NOT_AVAILABLE mCM.unregisterForOffOrNotAvailable(this); //EVENT_RADIO_OFF_OR_NOT_AVAILABLE
mCM.unregisterForOn(h); //EVENT_RADIO_ON mCM.unregisterForOn(this); //EVENT_RADIO_ON
mCM.unregisterForNVReady(h); //EVENT_NV_READY mCM.unregisterForNVReady(this); //EVENT_NV_READY
mSST.unregisterForNetworkAttach(h); //EVENT_REGISTERED_TO_NETWORK mSST.unregisterForNetworkAttach(this); //EVENT_REGISTERED_TO_NETWORK
mCM.unSetOnSuppServiceNotification(h); mCM.unSetOnSuppServiceNotification(this);
mCM.unSetOnCallRing(h);
//Force all referenced classes to unregister their former registered events //Force all referenced classes to unregister their former registered events
mCT.dispose(); mCT.dispose();
@@ -262,8 +256,6 @@ public class CDMAPhone extends PhoneBase {
} }
} }
//***** Overridden from Phone
public ServiceState getServiceState() { public ServiceState getServiceState() {
return mSST.ss; return mSST.ss;
} }
@@ -701,7 +693,7 @@ public class CDMAPhone extends PhoneBase {
Message onComplete) { Message onComplete) {
Message resp; Message resp;
mVmNumber = voiceMailNumber; 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); mRuimRecords.setVoiceMailNumber(alphaTag, mVmNumber, resp);
} }
@@ -826,14 +818,6 @@ public class CDMAPhone extends PhoneBase {
super.notifyNewRingingConnectionP(c); 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) { /*package*/ void notifyDisconnect(Connection cn) {
mDisconnectRegistrants.notifyResult(cn); mDisconnectRegistrants.notifyResult(cn);
} }
@@ -883,7 +867,7 @@ public class CDMAPhone extends PhoneBase {
mWakeLock.release(); mWakeLock.release();
} }
// Send a message which will invoke handleExitEmergencyCallbackMode // 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) { private void handleEnterEmergencyCallbackMode(Message msg) {
@@ -902,7 +886,7 @@ public class CDMAPhone extends PhoneBase {
// if no one invokes exitEmergencyCallbackMode() directly. // if no one invokes exitEmergencyCallbackMode() directly.
long delayInMillis = SystemProperties.getLong( long delayInMillis = SystemProperties.getLong(
TelephonyProperties.PROPERTY_ECM_EXIT_TIMER, DEFAULT_ECM_EXIT_TIMER_VALUE); 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 // We don't want to go to sleep while in Ecm
mWakeLock.acquire(); mWakeLock.acquire();
} }
@@ -915,7 +899,7 @@ public class CDMAPhone extends PhoneBase {
+ ar.exception + mIsPhoneInEcmState); + ar.exception + mIsPhoneInEcmState);
} }
// Remove pending exit Ecm runnable, if any // Remove pending exit Ecm runnable, if any
h.removeCallbacks(mExitEcmRunnable); removeCallbacks(mExitEcmRunnable);
if (mEcmExitRespRegistrant != null) { if (mEcmExitRespRegistrant != null) {
mEcmExitRespRegistrant.notifyRegistrant(ar); mEcmExitRespRegistrant.notifyRegistrant(ar);
@@ -941,13 +925,13 @@ public class CDMAPhone extends PhoneBase {
void handleTimerInEmergencyCallbackMode(int action) { void handleTimerInEmergencyCallbackMode(int action) {
switch(action) { switch(action) {
case CANCEL_ECM_TIMER: case CANCEL_ECM_TIMER:
h.removeCallbacks(mExitEcmRunnable); removeCallbacks(mExitEcmRunnable);
mEcmTimerResetRegistrants.notifyResult(new Boolean(true)); mEcmTimerResetRegistrants.notifyResult(new Boolean(true));
break; break;
case RESTART_ECM_TIMER: case RESTART_ECM_TIMER:
long delayInMillis = SystemProperties.getLong( long delayInMillis = SystemProperties.getLong(
TelephonyProperties.PROPERTY_ECM_EXIT_TIMER, DEFAULT_ECM_EXIT_TIMER_VALUE); TelephonyProperties.PROPERTY_ECM_EXIT_TIMER, DEFAULT_ECM_EXIT_TIMER_VALUE);
h.postDelayed(mExitEcmRunnable, delayInMillis); postDelayed(mExitEcmRunnable, delayInMillis);
mEcmTimerResetRegistrants.notifyResult(new Boolean(false)); mEcmTimerResetRegistrants.notifyResult(new Boolean(false));
break; break;
default: default:
@@ -969,123 +953,108 @@ public class CDMAPhone extends PhoneBase {
mEcmTimerResetRegistrants.remove(h); mEcmTimerResetRegistrants.remove(h);
} }
//***** Inner Classes @Override
class MyHandler extends Handler { public void handleMessage(Message msg) {
MyHandler() { AsyncResult ar;
} Message onComplete;
MyHandler(Looper l) { switch(msg.what) {
super(l); case EVENT_RADIO_AVAILABLE: {
} mCM.getBasebandVersion(obtainMessage(EVENT_GET_BASEBAND_VERSION_DONE));
@Override mCM.getDeviceIdentity(obtainMessage(EVENT_GET_DEVICE_IDENTITY_DONE));
public void handleMessage(Message msg) { }
AsyncResult ar; break;
Message onComplete;
switch(msg.what) { case EVENT_GET_BASEBAND_VERSION_DONE:{
case EVENT_RADIO_AVAILABLE: { ar = (AsyncResult)msg.obj;
mCM.getBasebandVersion(obtainMessage(EVENT_GET_BASEBAND_VERSION_DONE));
mCM.getDeviceIdentity(obtainMessage(EVENT_GET_DEVICE_IDENTITY_DONE)); if (ar.exception != null) {
break;
} }
break;
case EVENT_GET_BASEBAND_VERSION_DONE:{ if (DBG) Log.d(LOG_TAG, "Baseband version: " + ar.result);
ar = (AsyncResult)msg.obj; setSystemProperty(TelephonyProperties.PROPERTY_BASEBAND_VERSION, (String)ar.result);
}
break;
if (ar.exception != null) { case EVENT_GET_DEVICE_IDENTITY_DONE:{
break; ar = (AsyncResult)msg.obj;
}
if (DBG) Log.d(LOG_TAG, "Baseband version: " + ar.result); if (ar.exception != null) {
setSystemProperty(TelephonyProperties.PROPERTY_BASEBAND_VERSION, (String)ar.result); break;
} }
break; String[] respId = (String[])ar.result;
mEsn = respId[2];
mMeid = respId[3];
}
break;
case EVENT_GET_DEVICE_IDENTITY_DONE:{ case EVENT_EMERGENCY_CALLBACK_MODE_ENTER:{
ar = (AsyncResult)msg.obj; handleEnterEmergencyCallbackMode(msg);
}
break;
if (ar.exception != null) { case EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE:{
break; handleExitEmergencyCallbackMode(msg);
} }
String[] respId = (String[])ar.result; break;
mEsn = respId[2];
mMeid = respId[3]; 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_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_REGISTERED_TO_NETWORK:{
Log.d(LOG_TAG, "Event EVENT_REGISTERED_TO_NETWORK Received");
}
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();
} }
break; setSystemProperty(TelephonyProperties.PROPERTY_INECM_MODE,"false");
}
break;
case EVENT_EMERGENCY_CALLBACK_MODE_ENTER:{ case EVENT_SET_VM_NUMBER_DONE:{
handleEnterEmergencyCallbackMode(msg); ar = (AsyncResult)msg.obj;
if (IccException.class.isInstance(ar.exception)) {
storeVoiceMailNumber(mVmNumber);
ar.exception = null;
} }
break; onComplete = (Message) ar.userObj;
if (onComplete != null) {
AsyncResult.forMessage(onComplete, ar.result, ar.exception);
onComplete.sendToTarget();
}
}
break;
case EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE:{ default:{
handleExitEmergencyCallbackMode(msg); super.handleMessage(msg);
}
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_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_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_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");
}
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();
}
}
break;
default:{
throw new RuntimeException("unexpected event not handled");
}
} }
} }
} }
@@ -1137,13 +1106,6 @@ public class CDMAPhone extends PhoneBase {
super.setSystemProperty(property, value); super.setSystemProperty(property, value);
} }
/**
* {@inheritDoc}
*/
public Handler getHandler() {
return h;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@@ -146,7 +146,7 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
}; };
//***** Constructor /* Constructor */
CdmaDataConnectionTracker(CDMAPhone p) { CdmaDataConnectionTracker(CDMAPhone p) {
super(p); super(p);
@@ -174,7 +174,9 @@ public final class CdmaDataConnectionTracker extends DataConnectionTracker {
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
filter.addAction(WifiManager.WIFI_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; mDataConnectionTracker = this;

View File

@@ -23,13 +23,11 @@ import android.database.SQLException;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncResult; import android.os.AsyncResult;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.os.Registrant; import android.os.Registrant;
import android.os.RegistrantList; import android.os.RegistrantList;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.Settings;
import android.provider.Telephony; import android.provider.Telephony;
import android.telephony.CellLocation; import android.telephony.CellLocation;
import android.telephony.PhoneNumberUtils; 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 // 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"; public static final String VM_SIM_IMSI = "vm_sim_imsi_key";
//***** Instance Variables // Instance Variables
GsmCallTracker mCT; GsmCallTracker mCT;
GsmServiceStateTracker mSST; GsmServiceStateTracker mSST;
GsmSMSDispatcher mSMS; GsmSMSDispatcher mSMS;
SIMRecords mSIMRecords; SIMRecords mSIMRecords;
SimCard mSimCard; SimCard mSimCard;
StkService mStkService; StkService mStkService;
MyHandler h;
ArrayList <GsmMmiCode> mPendingMMIs = new ArrayList<GsmMmiCode>(); ArrayList <GsmMmiCode> mPendingMMIs = new ArrayList<GsmMmiCode>();
SimPhoneBookInterfaceManager mSimPhoneBookIntManager; SimPhoneBookInterfaceManager mSimPhoneBookIntManager;
SimSmsInterfaceManager mSimSmsIntManager; SimSmsInterfaceManager mSimSmsIntManager;
@@ -129,7 +126,7 @@ public class GSMPhone extends PhoneBase {
private String mVmNumber; private String mVmNumber;
//***** Constructors // Constructors
public public
GSMPhone (Context context, CommandsInterface ci, PhoneNotifier notifier) { GSMPhone (Context context, CommandsInterface ci, PhoneNotifier notifier) {
@@ -138,9 +135,7 @@ public class GSMPhone extends PhoneBase {
public public
GSMPhone (Context context, CommandsInterface ci, PhoneNotifier notifier, boolean unitTestMode) { GSMPhone (Context context, CommandsInterface ci, PhoneNotifier notifier, boolean unitTestMode) {
super(notifier, context, unitTestMode); super(notifier, context, ci, unitTestMode);
h = new MyHandler();
mCM = ci;
if (ci instanceof SimulatedRadioControl) { if (ci instanceof SimulatedRadioControl) {
mSimulatedRadioControl = (SimulatedRadioControl) ci; mSimulatedRadioControl = (SimulatedRadioControl) ci;
@@ -162,14 +157,13 @@ public class GSMPhone extends PhoneBase {
mStkService = StkService.getInstance(mCM, mSIMRecords, mContext, mStkService = StkService.getInstance(mCM, mSIMRecords, mContext,
(SIMFileHandler)mIccFileHandler, mSimCard); (SIMFileHandler)mIccFileHandler, mSimCard);
mCM.registerForAvailable(h, EVENT_RADIO_AVAILABLE, null); mCM.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null);
mSIMRecords.registerForRecordsLoaded(h, EVENT_SIM_RECORDS_LOADED, null); mSIMRecords.registerForRecordsLoaded(this, EVENT_SIM_RECORDS_LOADED, null);
mCM.registerForOffOrNotAvailable(h, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null); mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null);
mCM.registerForOn(h, EVENT_RADIO_ON, null); mCM.registerForOn(this, EVENT_RADIO_ON, null);
mCM.setOnUSSD(h, EVENT_USSD, null); mCM.setOnUSSD(this, EVENT_USSD, null);
mCM.setOnSuppServiceNotification(h, EVENT_SSN, null); mCM.setOnSuppServiceNotification(this, EVENT_SSN, null);
mCM.setOnCallRing(h, EVENT_CALL_RING, null); mSST.registerForNetworkAttach(this, EVENT_REGISTERED_TO_NETWORK, null);
mSST.registerForNetworkAttach(h, EVENT_REGISTERED_TO_NETWORK, null);
if (false) { if (false) {
try { try {
@@ -212,15 +206,16 @@ public class GSMPhone extends PhoneBase {
public void dispose() { public void dispose() {
synchronized(PhoneProxy.lockForRadioTechnologyChange) { synchronized(PhoneProxy.lockForRadioTechnologyChange) {
super.dispose();
//Unregister from all former registered events //Unregister from all former registered events
mCM.unregisterForAvailable(h); //EVENT_RADIO_AVAILABLE mCM.unregisterForAvailable(this); //EVENT_RADIO_AVAILABLE
mSIMRecords.unregisterForRecordsLoaded(h); //EVENT_SIM_RECORDS_LOADED mSIMRecords.unregisterForRecordsLoaded(this); //EVENT_SIM_RECORDS_LOADED
mCM.unregisterForOffOrNotAvailable(h); //EVENT_RADIO_OFF_OR_NOT_AVAILABLE mCM.unregisterForOffOrNotAvailable(this); //EVENT_RADIO_OFF_OR_NOT_AVAILABLE
mCM.unregisterForOn(h); //EVENT_RADIO_ON mCM.unregisterForOn(this); //EVENT_RADIO_ON
mSST.unregisterForNetworkAttach(h); //EVENT_REGISTERED_TO_NETWORK mSST.unregisterForNetworkAttach(this); //EVENT_REGISTERED_TO_NETWORK
mCM.unSetOnUSSD(h); mCM.unSetOnUSSD(this);
mCM.unSetOnSuppServiceNotification(h); mCM.unSetOnSuppServiceNotification(this);
mCM.unSetOnCallRing(h);
mPendingMMIs.clear(); mPendingMMIs.clear();
@@ -258,8 +253,6 @@ public class GSMPhone extends PhoneBase {
} }
//***** Overridden from Phone
public ServiceState public ServiceState
getServiceState() { getServiceState() {
return mSST.ss; return mSST.ss;
@@ -391,14 +384,6 @@ public class GSMPhone extends PhoneBase {
super.notifyNewRingingConnectionP(c); super.notifyNewRingingConnectionP(c);
} }
/**
* Notifiy registrants of a RING event.
*/
void notifyIncomingRing() {
AsyncResult ar = new AsyncResult(null, this, null);
mIncomingRingRegistrants.notifyRegistrants(ar);
}
/*package*/ void /*package*/ void
notifyDisconnect(Connection cn) { notifyDisconnect(Connection cn) {
mDisconnectRegistrants.notifyResult(cn); mDisconnectRegistrants.notifyResult(cn);
@@ -917,7 +902,7 @@ public class GSMPhone extends PhoneBase {
Message resp; Message resp;
mVmNumber = voiceMailNumber; 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); 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."); if (LOCAL_DEBUG) Log.d(LOG_TAG, "requesting call forwarding query.");
Message resp; Message resp;
if (commandInterfaceCFReason == CF_REASON_UNCONDITIONAL) { if (commandInterfaceCFReason == CF_REASON_UNCONDITIONAL) {
resp = h.obtainMessage(EVENT_GET_CALL_FORWARD_DONE, onComplete); resp = obtainMessage(EVENT_GET_CALL_FORWARD_DONE, onComplete);
} else { } else {
resp = onComplete; resp = onComplete;
} }
@@ -974,7 +959,7 @@ public class GSMPhone extends PhoneBase {
Message resp; Message resp;
if (commandInterfaceCFReason == CF_REASON_UNCONDITIONAL) { 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); isCfEnable(commandInterfaceCFAction) ? 1 : 0, 0, onComplete);
} else { } else {
resp = onComplete; resp = onComplete;
@@ -995,7 +980,7 @@ public class GSMPhone extends PhoneBase {
public void setOutgoingCallerIdDisplay(int commandInterfaceCLIRMode, public void setOutgoingCallerIdDisplay(int commandInterfaceCLIRMode,
Message onComplete) { Message onComplete) {
mCM.setCLIR(commandInterfaceCLIRMode, 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) { public void getCallWaiting(Message onComplete) {
@@ -1043,7 +1028,7 @@ public class GSMPhone extends PhoneBase {
nsm.operatorAlphaLong = ""; nsm.operatorAlphaLong = "";
// get the message // 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) if (LOCAL_DEBUG)
Log.d(LOG_TAG, "wrapping and sending message to connect automatically"); Log.d(LOG_TAG, "wrapping and sending message to connect automatically");
@@ -1061,7 +1046,7 @@ public class GSMPhone extends PhoneBase {
nsm.operatorAlphaLong = network.operatorAlphaLong; nsm.operatorAlphaLong = network.operatorAlphaLong;
// get the message // 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); mCM.setNetworkSelectionModeManual(network.operatorNumeric, msg);
} }
@@ -1247,178 +1232,163 @@ public class GSMPhone extends PhoneBase {
} }
} }
//***** Inner Classes @Override
public void handleMessage (Message msg) {
AsyncResult ar;
Message onComplete;
class MyHandler extends Handler { switch (msg.what) {
MyHandler() { case EVENT_RADIO_AVAILABLE: {
} mCM.getBasebandVersion(
obtainMessage(EVENT_GET_BASEBAND_VERSION_DONE));
MyHandler(Looper l) { mCM.getIMEI(obtainMessage(EVENT_GET_IMEI_DONE));
super(l); mCM.getIMEISV(obtainMessage(EVENT_GET_IMEISV_DONE));
} }
break;
public void case EVENT_RADIO_ON:
handleMessage (Message msg) { break;
AsyncResult ar;
Message onComplete;
switch (msg.what) { case EVENT_REGISTERED_TO_NETWORK:
case EVENT_RADIO_AVAILABLE: { syncClirSetting();
mCM.getBasebandVersion( break;
obtainMessage(EVENT_GET_BASEBAND_VERSION_DONE));
mCM.getIMEI(obtainMessage(EVENT_GET_IMEI_DONE)); case EVENT_SIM_RECORDS_LOADED:
mCM.getIMEISV(obtainMessage(EVENT_GET_IMEISV_DONE)); 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);
}
break;
case EVENT_GET_BASEBAND_VERSION_DONE:
ar = (AsyncResult)msg.obj;
if (ar.exception != null) {
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;
if (ar.exception != null) {
break;
}
mImei = (String)ar.result;
break;
case EVENT_GET_IMEISV_DONE:
ar = (AsyncResult)msg.obj;
if (ar.exception != null) {
break;
}
mImeiSv = (String)ar.result;
break;
case EVENT_USSD:
ar = (AsyncResult)msg.obj;
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");
}
}
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.
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; break;
case EVENT_RADIO_ON: 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; break;
case EVENT_REGISTERED_TO_NETWORK:
syncClirSetting();
break;
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);
}
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; break;
case EVENT_GET_BASEBAND_VERSION_DONE: // handle the select network completion callbacks.
ar = (AsyncResult)msg.obj; case EVENT_SET_NETWORK_MANUAL_COMPLETE:
case EVENT_SET_NETWORK_AUTOMATIC_COMPLETE:
if (ar.exception != null) { handleSetSelectNetwork((AsyncResult) msg.obj);
break;
}
if (LOCAL_DEBUG) Log.d(LOG_TAG, "Baseband version: " + ar.result);
setSystemProperty(PROPERTY_BASEBAND_VERSION, (String)ar.result);
break; break;
case EVENT_GET_IMEI_DONE: case EVENT_SET_CLIR_COMPLETE:
ar = (AsyncResult)msg.obj; ar = (AsyncResult)msg.obj;
if (ar.exception == null) {
if (ar.exception != null) { saveClirSetting(msg.arg1);
break; }
} onComplete = (Message) ar.userObj;
if (onComplete != null) {
mImei = (String)ar.result; AsyncResult.forMessage(onComplete, ar.result, ar.exception);
onComplete.sendToTarget();
}
break; break;
case EVENT_GET_IMEISV_DONE: default:
ar = (AsyncResult)msg.obj; super.handleMessage(msg);
if (ar.exception != null) {
break;
}
mImeiSv = (String)ar.result;
break;
case EVENT_USSD:
ar = (AsyncResult)msg.obj;
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");
}
}
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.
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_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_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;
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;
}
} }
} }
@@ -1530,13 +1500,6 @@ public class GSMPhone extends PhoneBase {
return mSimPhoneBookIntManager; return mSimPhoneBookIntManager;
} }
/**
* {@inheritDoc}
*/
public Handler getHandler(){
return h;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@@ -222,7 +222,9 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
filter.addAction(WifiManager.WIFI_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; mDataConnectionTracker = this;