FileDocCategorySizeDatePackage
RilMessageDecoder.javaAPI DocAndroid 1.5 API5791Wed May 06 22:42:02 BST 2009com.android.internal.telephony.gsm.stk

RilMessageDecoder

public class RilMessageDecoder extends android.os.HandlerStateMachine
Class used for queuing raw ril messages, decoding them into CommanParams objects and sending the result back to the STK Service.

Fields Summary
private static final int
START
private static final int
CMD_PARAMS_READY
private static RilMessageDecoder
sInstance
private CommandParamsFactory
mCmdParamsFactory
private RilMessage
mCurrentRilMessage
private android.os.Handler
mCaller
private StateStart
mStateStart
private StateCmdParamsReady
mStateCmdParamsReady
Constructors Summary
private RilMessageDecoder(android.os.Handler caller, com.android.internal.telephony.gsm.SIMFileHandler fh)

        super("RilMessageDecoder");
        setDbg(false);
        setInitialState(mStateStart);

        mCaller = caller;
        mCmdParamsFactory = CommandParamsFactory.getInstance(this, fh);
    
Methods Summary
private booleandecodeMessageParams(RilMessage rilMsg)

        boolean decodingStarted;

        mCurrentRilMessage = rilMsg;
        switch(rilMsg.mId) {
        case StkService.MSG_ID_SESSION_END:
        case StkService.MSG_ID_CALL_SETUP:
            mCurrentRilMessage.mResCode = ResultCode.OK;
            sendCmdForExecution(mCurrentRilMessage);
            decodingStarted = false;
            break;
        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);
            } catch (Exception e) {
                // zombie messages are dropped
                StkLog.d(this, "decodeMessageParams dropping zombie messages");
                decodingStarted = false;
                break;
            }
            try {
                // Start asynch parsing of the command parameters.
                mCmdParamsFactory.make(BerTlv.decode(rawData));
                decodingStarted = true;
            } catch (ResultException e) {
                // send to Service for proper RIL communication.
                mCurrentRilMessage.mResCode = e.result();
                sendCmdForExecution(mCurrentRilMessage);
                decodingStarted = false;
            }
            break;
        default:
            decodingStarted = false;
            break;
        }
        return decodingStarted;
    
public static synchronized com.android.internal.telephony.gsm.stk.RilMessageDecodergetInstance(android.os.Handler caller, com.android.internal.telephony.gsm.SIMFileHandler fh)
Get the singleton instance, constructing if necessary.

param
caller
param
fh
return
RilMesssageDecoder


                      
            
        if (sInstance == null) {
            sInstance = new RilMessageDecoder(caller, fh);
        }
        return sInstance;
    
private voidsendCmdForExecution(RilMessage rilMsg)

        Message msg = mCaller.obtainMessage(StkService.MSG_ID_RIL_MSG_DECODED,
                new RilMessage(rilMsg));
        msg.sendToTarget();
    
public voidsendMessageParamsDecoded(ResultCode resCode, CommandParams cmdParams)
The command parameters have been decoded.

param
resCode
param
cmdParams

        Message msg = obtainMessage(RilMessageDecoder.CMD_PARAMS_READY);
        msg.arg1 = resCode.value();
        msg.obj = cmdParams;
        sendMessage(msg);
    
public voidsendStartDecodingMessageParams(RilMessage rilMsg)
Start decoding the message parameters, when complete MSG_ID_RIL_MSG_DECODED will be returned to caller.

param
rilMsg

        Message msg = obtainMessage(START);
        msg.obj = rilMsg;
        sendMessage(msg);