diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-01-15 16:12:10 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-01-15 16:12:10 -0800 |
commit | 9266c558bf1d21ff647525ff99f7dadbca417309 (patch) | |
tree | 1630b1ba80f4793caf39d865528e662bdb1037fe /telephony/java/com | |
parent | b798689749c64baba81f02e10cf2157c747d6b46 (diff) | |
download | frameworks_base-9266c558bf1d21ff647525ff99f7dadbca417309.zip frameworks_base-9266c558bf1d21ff647525ff99f7dadbca417309.tar.gz frameworks_base-9266c558bf1d21ff647525ff99f7dadbca417309.tar.bz2 |
auto import from //branches/cupcake/...@126645
Diffstat (limited to 'telephony/java/com')
-rw-r--r-- | telephony/java/com/android/internal/telephony/gsm/GSMPhone.java | 6 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/gsm/stk/CommandParamsFactory.java | 53 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/gsm/stk/RilMessageDecoder.java | 76 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/gsm/stk/StkService.java (renamed from telephony/java/com/android/internal/telephony/gsm/stk/Service.java) | 80 |
4 files changed, 119 insertions, 96 deletions
diff --git a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java index 3f4bb5c..f314944 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java +++ b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java @@ -59,7 +59,7 @@ import com.android.internal.telephony.PhoneNotifier; import com.android.internal.telephony.PhoneSubInfo; import com.android.internal.telephony.SimCard; import com.android.internal.telephony.gsm.SimException; -import com.android.internal.telephony.gsm.stk.Service; +import com.android.internal.telephony.gsm.stk.StkService; import com.android.internal.telephony.test.SimulatedRadioControl; import java.io.IOException; @@ -102,7 +102,7 @@ public class GSMPhone extends PhoneBase { SIMFileHandler mSIMFileHandler; SIMRecords mSIMRecords; GsmSimCard mSimCard; - Service mStkService; + StkService mStkService; MyHandler h; ArrayList <GsmMmiCode> mPendingMMIs = new ArrayList<GsmMmiCode>(); SimPhoneBookInterfaceManager mSimPhoneBookIntManager; @@ -182,7 +182,7 @@ public class GSMPhone extends PhoneBase { mSimSmsIntManager = new SimSmsInterfaceManager(this); mSubInfo = new PhoneSubInfo(this); } - mStkService = Service.getInstance(mCM, mSIMRecords, mContext, + mStkService = StkService.getInstance(mCM, mSIMRecords, mContext, mSIMFileHandler, mSimCard); mCM.registerForAvailable(h, EVENT_RADIO_AVAILABLE, null); diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/CommandParamsFactory.java b/telephony/java/com/android/internal/telephony/gsm/stk/CommandParamsFactory.java index 0d56fb7..eb354e9 100644 --- a/telephony/java/com/android/internal/telephony/gsm/stk/CommandParamsFactory.java +++ b/telephony/java/com/android/internal/telephony/gsm/stk/CommandParamsFactory.java @@ -28,7 +28,7 @@ import java.util.List; /** * Factory class, used for decoding raw byte arrays, received from baseband, - * into a CommandParams object. + * into a CommandParams object. * */ class CommandParamsFactory extends Handler { @@ -36,7 +36,7 @@ class CommandParamsFactory extends Handler { private IconLoader mIconLoader; private CommandParams mCmdParams = null; private int mIconLoadState = LOAD_NO_ICON; - private Handler mCaller = null; + private RilMessageDecoder mCaller = null; // constants static final int MSG_ID_LOAD_ICON_DONE = 1; @@ -52,7 +52,7 @@ class CommandParamsFactory extends Handler { static final int REFRESH_NAA_INIT = 0x03; static final int REFRESH_UICC_RESET = 0x04; - static synchronized CommandParamsFactory getInstance(Handler caller, + static synchronized CommandParamsFactory getInstance(RilMessageDecoder caller, SIMFileHandler fh) { if (sInstance != null) { return sInstance; @@ -63,7 +63,7 @@ class CommandParamsFactory extends Handler { return null; } - private CommandParamsFactory(Handler caller, SIMFileHandler fh) { + private CommandParamsFactory(RilMessageDecoder caller, SIMFileHandler fh) { mCaller = caller; mIconLoader = IconLoader.getInstance(this, fh); } @@ -107,7 +107,7 @@ class CommandParamsFactory extends Handler { return; } - // extract command type enumeration from the raw value stored inside + // extract command type enumeration from the raw value stored inside // the Command Details object. AppInterface.CommandType cmdType = AppInterface.CommandType .fromInt(cmdDet.typeOfCommand); @@ -203,18 +203,15 @@ class CommandParamsFactory extends Handler { } private void sendCmdParams(ResultCode resCode) { - Message msg = mCaller.obtainMessage(RilMessageDecoder.CMD_PARAMS_READY); - msg.arg1 = resCode.value(); - msg.obj = mCmdParams; - msg.sendToTarget(); + mCaller.sendMessageParamsDecoded(resCode, mCmdParams); } /** * Search for a COMPREHENSION-TLV object with the given tag from a list - * + * * @param tag A tag to search for * @param ctlvs List of ComprehensionTlv objects used to search in - * + * * @return A ComprehensionTlv object that has the tag value of {@code tag}. * If no object is found with the tag, null is returned. */ @@ -229,10 +226,10 @@ class CommandParamsFactory extends Handler { * list iterated by {@code iter}. {@code iter} points to the object next to * the found object when this method returns. Used for searching the same * list for similar tags, usually item id. - * + * * @param tag A tag to search for * @param iter Iterator for ComprehensionTlv objects used for search - * + * * @return A ComprehensionTlv object that has the tag value of {@code tag}. * If no object is found with the tag, null is returned. */ @@ -250,11 +247,11 @@ class CommandParamsFactory extends Handler { /** * Processes DISPLAY_TEXT proactive command from the SIM card. - * + * * @param cmdDet Command Details container object. * @param ctlvs List of ComprehensionTlv objects following Command Details * object and Device Identities object within the proactive command - * @return true if the command is processing is pending and additional + * @return true if the command is processing is pending and additional * asynchronous processing is required. * @throws ResultException */ @@ -272,7 +269,7 @@ class CommandParamsFactory extends Handler { if (ctlv != null) { textMsg.text = ValueParser.retrieveTextString(ctlv); } - // If the tlv object doesn't exist or the it is a null object reply + // If the tlv object doesn't exist or the it is a null object reply // with command not understood. if (textMsg.text == null) { throw new ResultException(ResultCode.CMD_DATA_NOT_UNDERSTOOD); @@ -311,7 +308,7 @@ class CommandParamsFactory extends Handler { /** * Processes SET_UP_IDLE_MODE_TEXT proactive command from the SIM card. - * + * * @param cmdDet Command Details container object. * @param ctlvs List of ComprehensionTlv objects following Command Details * object and Device Identities object within the proactive command @@ -354,7 +351,7 @@ class CommandParamsFactory extends Handler { /** * Processes GET_INKEY proactive command from the SIM card. - * + * * @param cmdDet Command Details container object. * @param ctlvs List of ComprehensionTlv objects following Command Details * object and Device Identities object within the proactive command @@ -366,7 +363,7 @@ class CommandParamsFactory extends Handler { List<ComprehensionTlv> ctlvs) throws ResultException { StkLog.d(this, "process GetInkey"); - + Input input = new Input(); IconId iconId = null; @@ -404,7 +401,7 @@ class CommandParamsFactory extends Handler { /** * Processes GET_INPUT proactive command from the SIM card. - * + * * @param cmdDet Command Details container object. * @param ctlvs List of ComprehensionTlv objects following Command Details * object and Device Identities object within the proactive command @@ -471,7 +468,7 @@ class CommandParamsFactory extends Handler { /** * Processes REFRESH proactive command from the SIM card. - * + * * @param cmdDet Command Details container object. * @param ctlvs List of ComprehensionTlv objects following Command Details * object and Device Identities object within the proactive command @@ -482,8 +479,8 @@ class CommandParamsFactory extends Handler { StkLog.d(this, "process Refresh"); // REFRESH proactive command is rerouted by the baseband and handled by - // the telephony layer. IDLE TEXT should be removed for a REFRESH command - // with "initialization" or "reset" + // the telephony layer. IDLE TEXT should be removed for a REFRESH command + // with "initialization" or "reset" switch (cmdDet.commandQualifier) { case REFRESH_NAA_INIT_AND_FULL_FILE_CHANGE: case REFRESH_NAA_INIT_AND_FILE_CHANGE: @@ -497,11 +494,11 @@ class CommandParamsFactory extends Handler { /** * Processes SELECT_ITEM proactive command from the SIM card. - * + * * @param cmdDet Command Details container object. * @param ctlvs List of ComprehensionTlv objects following Command Details * object and Device Identities object within the proactive command - * @return true if the command is processing is pending and additional + * @return true if the command is processing is pending and additional * asynchronous processing is required. * @throws ResultException */ @@ -595,7 +592,7 @@ class CommandParamsFactory extends Handler { /** * Processes EVENT_NOTIFY message from baseband. - * + * * @param cmdDet Command Details container object. * @param ctlvs List of ComprehensionTlv objects following Command Details * object and Device Identities object within the proactive command @@ -805,7 +802,7 @@ class CommandParamsFactory extends Handler { /** * Processes SETUP_CALL proactive command from the SIM card. - * + * * @param cmdDet Command Details object retrieved from the proactive command * object * @param ctlvs List of ComprehensionTlv objects following Command Details @@ -866,4 +863,4 @@ class CommandParamsFactory extends Handler { } return false; } -}
\ No newline at end of file +} diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/RilMessageDecoder.java b/telephony/java/com/android/internal/telephony/gsm/stk/RilMessageDecoder.java index c890d1c..5d82473 100644 --- a/telephony/java/com/android/internal/telephony/gsm/stk/RilMessageDecoder.java +++ b/telephony/java/com/android/internal/telephony/gsm/stk/RilMessageDecoder.java @@ -30,6 +30,10 @@ import android.os.Message; */ class RilMessageDecoder extends HandlerStateMachine { + // constants + private static final int START = 1; + private static final int CMD_PARAMS_READY = 2; + // members private static RilMessageDecoder sInstance = null; private CommandParamsFactory mCmdParamsFactory = null; @@ -40,27 +44,61 @@ class RilMessageDecoder extends HandlerStateMachine { private StateStart mStateStart = new StateStart(); private StateCmdParamsReady mStateCmdParamsReady = new StateCmdParamsReady(); - // constants - static final int START = 1; - static final int CMD_PARAMS_READY = 2; - - static synchronized RilMessageDecoder getInstance(Handler caller, SIMFileHandler fh) { + /** + * Get the singleton instance, constructing if necessary. + * + * @param caller + * @param fh + * @return RilMesssageDecoder + */ + public static synchronized RilMessageDecoder getInstance(Handler caller, SIMFileHandler fh) { if (sInstance == null) { sInstance = new RilMessageDecoder(caller, fh); } return sInstance; } + /** + * Start decoding the message parameters, + * when complete MSG_ID_RIL_MSG_DECODED will be returned to caller. + * + * @param rilMsg + */ + public void sendStartDecodingMessageParams(RilMessage rilMsg) { + Message msg = obtainMessage(START); + msg.obj = rilMsg; + sendMessage(msg); + } + + /** + * The command parameters have been decoded. + * + * @param resCode + * @param cmdParams + */ + public void sendMessageParamsDecoded(ResultCode resCode, CommandParams cmdParams) { + Message msg = obtainMessage(RilMessageDecoder.CMD_PARAMS_READY); + msg.arg1 = resCode.value(); + msg.obj = cmdParams; + sendMessage(msg); + } + + private void sendCmdForExecution(RilMessage rilMsg) { + Message msg = mCaller.obtainMessage(StkService.MSG_ID_RIL_MSG_DECODED, + new RilMessage(rilMsg)); + msg.sendToTarget(); + } + private RilMessageDecoder(Handler caller, SIMFileHandler fh) { super("RilMessageDecoder"); setDbg(false); setInitialState(mStateStart); mCaller = caller; - mCmdParamsFactory = CommandParamsFactory.getInstance(this.getHandler(), fh); + mCmdParamsFactory = CommandParamsFactory.getInstance(this, fh); } - class StateStart extends HandlerState { + private class StateStart extends HandlerState { @Override public void processMessage(Message msg) { if (msg.what == START) { if (decodeMessageParams((RilMessage)msg.obj)) { @@ -73,7 +111,7 @@ class RilMessageDecoder extends HandlerStateMachine { } } - class StateCmdParamsReady extends HandlerState { + private class StateCmdParamsReady extends HandlerState { @Override public void processMessage(Message msg) { if (msg.what == CMD_PARAMS_READY) { mCurrentRilMessage.mResCode = ResultCode.fromInt(msg.arg1); @@ -88,26 +126,20 @@ class RilMessageDecoder extends HandlerStateMachine { } } - public void startDecodingMessageParams(RilMessage rilMsg) { - Message msg = obtainMessage(START); - msg.obj = rilMsg; - sendMessage(msg); - } - private boolean decodeMessageParams(RilMessage rilMsg) { boolean decodingStarted; mCurrentRilMessage = rilMsg; switch(rilMsg.mId) { - case Service.MSG_ID_SESSION_END: - case Service.MSG_ID_CALL_SETUP: + case StkService.MSG_ID_SESSION_END: + case StkService.MSG_ID_CALL_SETUP: mCurrentRilMessage.mResCode = ResultCode.OK; sendCmdForExecution(mCurrentRilMessage); decodingStarted = false; break; - case Service.MSG_ID_PROACTIVE_COMMAND: - case Service.MSG_ID_EVENT_NOTIFY: - case Service.MSG_ID_REFRESH: + case StkService.MSG_ID_PROACTIVE_COMMAND: + case StkService.MSG_ID_EVENT_NOTIFY: + case StkService.MSG_ID_REFRESH: byte[] rawData = null; try { rawData = SimUtils.hexStringToBytes((String) rilMsg.mData); @@ -134,10 +166,4 @@ class RilMessageDecoder extends HandlerStateMachine { } return decodingStarted; } - - private void sendCmdForExecution(RilMessage rilMsg) { - Message msg = mCaller.obtainMessage(Service.MSG_ID_RIL_MSG_DECODED, - new RilMessage(rilMsg)); - msg.sendToTarget(); - } } diff --git a/telephony/java/com/android/internal/telephony/gsm/stk/Service.java b/telephony/java/com/android/internal/telephony/gsm/stk/StkService.java index 95602d1..a90e7ea 100644 --- a/telephony/java/com/android/internal/telephony/gsm/stk/Service.java +++ b/telephony/java/com/android/internal/telephony/gsm/stk/StkService.java @@ -38,32 +38,32 @@ import java.util.concurrent.LinkedBlockingQueue; /** * Enumeration for representing the tag value of COMPREHENSION-TLV objects. If * you want to get the actual value, call {@link #value() value} method. - * + * * {@hide} */ enum ComprehensionTlvTag { - COMMAND_DETAILS(0x01), - DEVICE_IDENTITIES(0x02), - RESULT(0x03), - DURATION(0x04), - ALPHA_ID(0x05), - USSD_STRING(0x0a), - TEXT_STRING(0x0d), - TONE(0x0e), - ITEM(0x0f), - ITEM_ID(0x10), - RESPONSE_LENGTH(0x11), - FILE_LIST(0x12), - HELP_REQUEST(0x15), - DEFAULT_TEXT(0x17), - EVENT_LIST(0x19), - ICON_ID(0x1e), - ITEM_ICON_ID_LIST(0x1f), - IMMEDIATE_RESPONSE(0x2b), - LANGUAGE(0x2d), - URL(0x31), - BROWSER_TERMINATION_CAUSE(0x34), - TEXT_ATTRIBUTE(0x50); + COMMAND_DETAILS(0x01), + DEVICE_IDENTITIES(0x02), + RESULT(0x03), + DURATION(0x04), + ALPHA_ID(0x05), + USSD_STRING(0x0a), + TEXT_STRING(0x0d), + TONE(0x0e), + ITEM(0x0f), + ITEM_ID(0x10), + RESPONSE_LENGTH(0x11), + FILE_LIST(0x12), + HELP_REQUEST(0x15), + DEFAULT_TEXT(0x17), + EVENT_LIST(0x19), + ICON_ID(0x1e), + ITEM_ICON_ID_LIST(0x1f), + IMMEDIATE_RESPONSE(0x2b), + LANGUAGE(0x2d), + URL(0x31), + BROWSER_TERMINATION_CAUSE(0x34), + TEXT_ATTRIBUTE(0x50); private int mValue; @@ -73,7 +73,7 @@ enum ComprehensionTlvTag { /** * Returns the actual value of this COMPREHENSION-TLV object. - * + * * @return Actual tag value of this object */ public int value() { @@ -110,13 +110,13 @@ class RilMessage { /** * Class that implements SIM Toolkit Telephony Service. Interacts with the RIL * and application. - * + * * {@hide} */ -public class Service extends Handler implements AppInterface { +public class StkService extends Handler implements AppInterface { // Service members. - private static Service sInstance; + private static StkService sInstance; private CommandsInterface mCmdIf; private SIMRecords mSimRecords; private Context mContext; @@ -146,7 +146,7 @@ public class Service extends Handler implements AppInterface { private static final int DEV_ID_NETWORK = 0x83; /* Intentionally private for singleton */ - private Service(CommandsInterface ci, SIMRecords sr, Context context, + private StkService(CommandsInterface ci, SIMRecords sr, Context context, SIMFileHandler fh, GsmSimCard sc) { if (ci == null || sr == null || context == null || fh == null || sc == null) { @@ -221,7 +221,7 @@ public class Service extends Handler implements AppInterface { /** * Handles RIL_UNSOL_STK_PROACTIVE_COMMAND unsolicited command from RIL. * Sends valid proactive command data to the application using intents. - * + * */ private void handleProactiveCommand(CommandParams cmdParams) { StkLog.d(this, cmdParams.getCommandType().name()); @@ -230,7 +230,7 @@ public class Service extends Handler implements AppInterface { switch (cmdParams.getCommandType()) { case SET_UP_MENU: if (removeMenu(cmdMsg.getMenu())) { - mMenuCmd = null; + mMenuCmd = null; } else { mMenuCmd = cmdMsg; } @@ -238,7 +238,7 @@ public class Service extends Handler implements AppInterface { null); break; case DISPLAY_TEXT: - // when application is not required to respond, send an immediate + // when application is not required to respond, send an immediate // response. if (!cmdMsg.geTextMessage().responseNeeded) { sendTerminalResponse(cmdParams.cmdDet, ResultCode.OK, false, @@ -246,7 +246,7 @@ public class Service extends Handler implements AppInterface { } break; case REFRESH: - // ME side only handles refresh commands which meant to remove IDLE + // ME side only handles refresh commands which meant to remove IDLE // MODE TEXT. cmdParams.cmdDet.typeOfCommand = CommandType.SET_UP_IDLE_MODE_TEXT .value(); @@ -279,7 +279,7 @@ public class Service extends Handler implements AppInterface { /** * Handles RIL_UNSOL_STK_SESSION_END unsolicited command from RIL. - * + * */ private void handleSessionEnd() { StkLog.d(this, "SESSION END"); @@ -430,15 +430,15 @@ public class Service extends Handler implements AppInterface { /** * Used for instantiating the Service from the GsmPhone constructor. - * + * * @param ci CommandsInterface object * @param sr SIMRecords object * @param context phone app context * @param fh SIM file handler - * @param sc GSM SIM card + * @param sc GSM SIM card * @return The only Service object in the system */ - public static Service getInstance(CommandsInterface ci, SIMRecords sr, + public static StkService getInstance(CommandsInterface ci, SIMRecords sr, Context context, SIMFileHandler fh, GsmSimCard sc) { if (sInstance == null) { if (ci == null || sr == null || context == null || fh == null @@ -447,14 +447,14 @@ public class Service extends Handler implements AppInterface { } HandlerThread thread = new HandlerThread("Stk Telephony service"); thread.start(); - sInstance = new Service(ci, sr, context, fh, sc); + sInstance = new StkService(ci, sr, context, fh, sc); } return sInstance; } /** * Used by application to get an AppInterface object. - * + * * @return The only Service object in the system */ public static AppInterface getInstance() { @@ -481,10 +481,10 @@ public class Service extends Handler implements AppInterface { } } } - mMsgDecoder.startDecodingMessageParams(new RilMessage(msg.what, data)); + mMsgDecoder.sendStartDecodingMessageParams(new RilMessage(msg.what, data)); break; case MSG_ID_CALL_SETUP: - mMsgDecoder.startDecodingMessageParams(new RilMessage(msg.what, null)); + mMsgDecoder.sendStartDecodingMessageParams(new RilMessage(msg.what, null)); break; case MSG_ID_SIM_LOADED: break; |