Merge "Add RIL_UNSOL_RIL_CONNECTED and pass radio technology + 2 to setupDataCall." into honeycomb-LTE

This commit is contained in:
Wink Saville
2011-04-07 16:49:02 -07:00
committed by Android (Google) Code Review
7 changed files with 97 additions and 3 deletions

View File

@@ -71,6 +71,7 @@ public abstract class BaseCommands implements CommandsInterface {
protected RegistrantList mCdmaSubscriptionChangedRegistrants = new RegistrantList();
protected RegistrantList mCdmaPrlChangedRegistrants = new RegistrantList();
protected RegistrantList mExitEmergencyCallbackModeRegistrants = new RegistrantList();
protected RegistrantList mRilConnectedRegistrants = new RegistrantList();
protected Registrant mSMSRegistrant;
protected Registrant mNITZTimeRegistrant;
@@ -96,7 +97,8 @@ public abstract class BaseCommands implements CommandsInterface {
protected int mCdmaSubscription;
// Type of Phone, GSM or CDMA. Set by CDMAPhone or GSMPhone.
protected int mPhoneType;
// RIL Version
protected int mRilVersion = -1;
public BaseCommands(Context context) {
mContext = context; // May be null (if so we won't log statistics)
@@ -639,6 +641,25 @@ public abstract class BaseCommands implements CommandsInterface {
mExitEmergencyCallbackModeRegistrants.remove(h);
}
/**
* {@inheritDoc}
*/
@Override
public void registerForRilConnected(Handler h, int what, Object obj) {
Log.d(LOG_TAG, "registerForRilConnected h=" + h + " w=" + what);
Registrant r = new Registrant (h, what, obj);
mRilConnectedRegistrants.add(r);
if (mRilVersion != -1) {
Log.d(LOG_TAG, "Notifying: ril connected mRilVersion=" + mRilVersion);
r.notifyRegistrant(new AsyncResult(null, new Integer(mRilVersion), null));
}
}
@Override
public void unregisterForRilConnected(Handler h) {
mRilConnectedRegistrants.remove(h);
}
//***** Protected Methods
/**
* Store new RadioState and send notification based on the changes

View File

@@ -604,6 +604,20 @@ public interface CommandsInterface {
void registerForExitEmergencyCallbackMode(Handler h, int what, Object obj);
void unregisterForExitEmergencyCallbackMode(Handler h);
/**
* Registers the handler for RIL_UNSOL_RIL_CONNECT events.
*
* When ril connects or disconnects a message is sent to the registrant
* which contains an AsyncResult, ar, in msg.obj. The ar.result is an
* Integer which is the version of the ril or -1 if the ril disconnected.
*
* @param h Handler for notification message.
* @param what User-defined message code.
* @param obj User object.
*/
void registerForRilConnected(Handler h, int what, Object obj);
void unregisterForRilConnected(Handler h);
/**
* Supply the ICC PIN to the ICC card
*

View File

@@ -194,6 +194,7 @@ public abstract class DataConnection extends HierarchicalStateMachine {
protected static final int EVENT_GET_LAST_FAIL_DONE = 4;
protected static final int EVENT_DEACTIVATE_DONE = 5;
protected static final int EVENT_DISCONNECT = 6;
protected static final int EVENT_RIL_CONNECTED = 7;
//***** Tag IDs for EventLog
protected static final int EVENT_LOG_BAD_DNS_ADDRESS = 50100;
@@ -202,6 +203,7 @@ public abstract class DataConnection extends HierarchicalStateMachine {
protected ApnSetting mApn;
protected int mTag;
protected PhoneBase phone;
protected int mRilVersion = -1;
protected int cid;
protected LinkProperties mLinkProperties = new LinkProperties();
protected LinkCapabilities mCapabilities = new LinkCapabilities();
@@ -320,6 +322,16 @@ public abstract class DataConnection extends HierarchicalStateMachine {
clearSettings();
}
protected int getRadioTechnology(int defaultRadioTechnology) {
int radioTechnology;
if (mRilVersion < 6) {
radioTechnology = defaultRadioTechnology;
} else {
radioTechnology = phone.getServiceState().getRadioTechnology() + 2;
}
return radioTechnology;
}
/*
* **************************************************************************
* Begin Members and methods owned by DataConnectionTracker but stored
@@ -472,6 +484,14 @@ public abstract class DataConnection extends HierarchicalStateMachine {
* The parent state for all other states.
*/
private class DcDefaultState extends HierarchicalState {
@Override
protected void enter() {
phone.mCM.registerForRilConnected(getHandler(), EVENT_RIL_CONNECTED, null);
}
@Override
protected void exit() {
phone.mCM.unregisterForRilConnected(getHandler());
}
@Override
protected boolean processMessage(Message msg) {
AsyncResult ar;
@@ -497,6 +517,20 @@ public abstract class DataConnection extends HierarchicalStateMachine {
notifyDisconnectCompleted((DisconnectParams) msg.obj);
break;
case EVENT_RIL_CONNECTED:
ar = (AsyncResult)msg.obj;
if (ar.exception == null) {
mRilVersion = (Integer)ar.result;
if (DBG) {
log("DcDefaultState: msg.what=EVENT_RIL_CONNECTED mRilVersion=" +
mRilVersion);
}
} else {
log("Unexpected exception on EVENT_RIL_CONNECTED");
mRilVersion = -1;
}
break;
default:
if (DBG) {
log("DcDefaultState: shouldn't happen but ignore msg.what=" + msg.what);

View File

@@ -605,6 +605,9 @@ public final class RIL extends BaseCommands implements CommandsInterface {
}} catch (Throwable tr) {
Log.e(LOG_TAG,"Uncaught exception", tr);
}
/* We're disconnected so we don't know the ril version */
notifyRegistrantsRilConnectionChanged(-1);
}
}
@@ -2468,6 +2471,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
case RIL_UNSOL_CDMA_SUBSCRIPTION_CHANGED: ret = responseInts(p); break;
case RIL_UNSOl_CDMA_PRL_CHANGED: ret = responseInts(p); break;
case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break;
case RIL_UNSOL_RIL_CONNECTED: ret = responseInts(p); break;
default:
throw new RuntimeException("Unrecognized unsol response: " + response);
@@ -2798,6 +2802,25 @@ public final class RIL extends BaseCommands implements CommandsInterface {
new AsyncResult (null, null, null));
}
break;
case RIL_UNSOL_RIL_CONNECTED: {
if (RILJ_LOGD) unsljLogRet(response, ret);
notifyRegistrantsRilConnectionChanged(((int[])ret)[0]);
break;
}
}
}
/**
* Notifiy all registrants that the ril has connected or disconnected.
*
* @param rilVer is the version of the ril or -1 if disconnected.
*/
private void notifyRegistrantsRilConnectionChanged(int rilVer) {
mRilVersion = rilVer;
if (mRilConnectedRegistrants != null) {
mRilConnectedRegistrants.notifyRegistrants(
new AsyncResult (null, new Integer(rilVer), null));
}
}
@@ -3535,6 +3558,7 @@ public final class RIL extends BaseCommands implements CommandsInterface {
case RIL_UNSOL_CDMA_SUBSCRIPTION_CHANGED: return "CDMA_SUBSCRIPTION_CHANGED";
case RIL_UNSOl_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED";
case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED";
default: return "<unknown reponse>";
}
}

View File

@@ -289,4 +289,5 @@ cat include/telephony/ril.h | \
int RIL_UNSOL_CDMA_SUBSCRIPTION_CHANGED = 1031;
int RIL_UNSOl_CDMA_PRL_CHANGED = 1032;
int RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE = 1033;
int RIL_UNSOL_RIL_CONNECTED = 1034;
}

View File

@@ -84,7 +84,7 @@ public class CdmaDataConnection extends DataConnection {
Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp);
msg.obj = cp;
phone.mCM.setupDataCall(
Integer.toString(RILConstants.SETUP_DATA_TECH_CDMA),
Integer.toString(getRadioTechnology(RILConstants.SETUP_DATA_TECH_CDMA)),
Integer.toString(dataProfile),
null, null, null,
Integer.toString(RILConstants.SETUP_DATA_AUTH_PAP_CHAP),

View File

@@ -102,7 +102,7 @@ public class GsmDataConnection extends DataConnection {
}
phone.mCM.setupDataCall(
Integer.toString(RILConstants.SETUP_DATA_TECH_GSM),
Integer.toString(getRadioTechnology(RILConstants.SETUP_DATA_TECH_GSM)),
Integer.toString(mProfileId),
mApn.apn, mApn.user, mApn.password,
Integer.toString(authType),