public int dispatchWapPdu(byte[] pdu,IWapPushManager wapPushMan){
  if (false)   Log.d(LOG_TAG,"Rx: " + IccUtils.bytesToHexString(pdu));
  int index=0;
  int transactionId=pdu[index++] & 0xFF;
  int pduType=pdu[index++] & 0xFF;
  int headerLength=0;
  if ((pduType != WspTypeDecoder.PDU_TYPE_PUSH) && (pduType != WspTypeDecoder.PDU_TYPE_CONFIRMED_PUSH)) {
    if (false)     Log.w(LOG_TAG,"Received non-PUSH WAP PDU. Type = " + pduType);
    return Intents.RESULT_SMS_HANDLED;
  }
  WspTypeDecoder pduDecoder=new WspTypeDecoder(pdu);
  if (pduDecoder.decodeUintvarInteger(index) == false) {
    if (false)     Log.w(LOG_TAG,"Received PDU. Header Length error.");
    return Intents.RESULT_SMS_GENERIC_ERROR;
  }
  headerLength=(int)pduDecoder.getValue32();
  index+=pduDecoder.getDecodedDataLength();
  int headerStartIndex=index;
  if (pduDecoder.decodeContentType(index) == false) {
    if (false)     Log.w(LOG_TAG,"Received PDU. Header Content-Type error.");
    return Intents.RESULT_SMS_GENERIC_ERROR;
  }
  String mimeType=pduDecoder.getValueString();
  long binaryContentType=pduDecoder.getValue32();
  index+=pduDecoder.getDecodedDataLength();
  byte[] header=new byte[headerLength];
  System.arraycopy(pdu,headerStartIndex,header,0,header.length);
  byte[] intentData;
  if (mimeType != null && mimeType.equals(WspTypeDecoder.CONTENT_TYPE_B_PUSH_CO)) {
    intentData=pdu;
  }
 else {
    int dataIndex=headerStartIndex + headerLength;
    intentData=new byte[pdu.length - dataIndex];
    System.arraycopy(pdu,dataIndex,intentData,0,intentData.length);
  }
  if (pduDecoder.seekXWapApplicationId(index,index + headerLength - 1)) {
    index=(int)pduDecoder.getValue32();
    pduDecoder.decodeXWapApplicationId(index);
    String wapAppId=pduDecoder.getValueString();
    if (wapAppId == null) {
      wapAppId=Integer.toString((int)pduDecoder.getValue32());
    }
    String contentType=((mimeType == null) ? Long.toString(binaryContentType) : mimeType);
    if (false)     Log.v(LOG_TAG,"appid found: " + wapAppId + ":"+ contentType);
    try {
      boolean processFurther=true;
      if (wapPushMan == null) {
        if (false)         Log.w(LOG_TAG,"wap push manager not found!");
      }
 else {
        Intent intent=new Intent();
        intent.putExtra("transactionId",transactionId);
        intent.putExtra("pduType",pduType);
        intent.putExtra("header",header);
        intent.putExtra("data",intentData);
        intent.putExtra("contentTypeParameters",pduDecoder.getContentParameters());
        int procRet=wapPushMan.processMessage(wapAppId,contentType,intent);
        if (false)         Log.v(LOG_TAG,"procRet:" + procRet);
        if ((procRet & WapPushManagerParams.MESSAGE_HANDLED) > 0 && (procRet & WapPushManagerParams.FURTHER_PROCESSING) == 0) {
          processFurther=false;
        }
      }
      if (!processFurther) {
        return Intents.RESULT_SMS_HANDLED;
      }
    }
 catch (    RemoteException e) {
      if (false)       Log.w(LOG_TAG,"remote func failed...");
    }
  }
  if (false)   Log.v(LOG_TAG,"fall back to existing handler");
  return Activity.RESULT_OK;
}

public int dispatchWapPdu ( byte [ ] pdu , IWapPushManager wapPushMan ) { if ( false ) Log . d ( LOG_TAG , "Rx: " + IccUtils . bytesToHexString ( pdu ) ) ; int index = 0 ; int transactionId = pdu [ index ++ ] & 0xFF ; int pduType = pdu [ index ++ ] & 0xFF ; int headerLength = 0 ; if ( ( pduType != WspTypeDecoder . PDU_TYPE_PUSH ) && ( pduType != WspTypeDecoder . PDU_TYPE_CONFIRMED_PUSH ) ) { if ( false ) Log . w ( LOG_TAG , "Received non-PUSH WAP PDU. Type = " + pduType ) ; return Intents . RESULT_SMS_HANDLED ; } WspTypeDecoder pduDecoder = new WspTypeDecoder ( pdu ) ; if ( pduDecoder . decodeUintvarInteger ( index ) == false ) { if ( false ) Log . w ( LOG_TAG , "Received PDU. Header Length error." ) ; return Intents . RESULT_SMS_GENERIC_ERROR ; } headerLength = ( int ) pduDecoder . getValue32 ( ) ; index += pduDecoder . getDecodedDataLength ( ) ; int headerStartIndex = index ; if ( pduDecoder . decodeContentType ( index ) == false ) { if ( false ) Log . w ( LOG_TAG , "Received PDU. Header Content-Type error." ) ; return Intents . RESULT_SMS_GENERIC_ERROR ; } String mimeType = pduDecoder . getValueString ( ) ; long binaryContentType = pduDecoder . getValue32 ( ) ; index += pduDecoder . getDecodedDataLength ( ) ; byte [ ] header = new byte [ headerLength ] ; System . arraycopy ( pdu , headerStartIndex , header , 0 , header . length ) ; byte [ ] intentData ; if ( mimeType != null && mimeType . equals ( WspTypeDecoder . CONTENT_TYPE_B_PUSH_CO ) ) { intentData = pdu ; } else { int dataIndex = headerStartIndex + headerLength ; intentData = new byte [ pdu . length - dataIndex ] ; System . arraycopy ( pdu , dataIndex , intentData , 0 , intentData . length ) ; } if ( pduDecoder . seekXWapApplicationId ( index , index + headerLength - 1 ) ) { index = ( int ) pduDecoder . getValue32 ( ) ; pduDecoder . decodeXWapApplicationId ( index ) ; String wapAppId = pduDecoder . getValueString ( ) ; if ( wapAppId == null ) { wapAppId = Integer . toString ( ( int ) pduDecoder . getValue32 ( ) ) ; } String contentType = ( ( mimeType == null ) ? Long . toString ( binaryContentType ) : mimeType ) ; if ( false ) Log . v ( LOG_TAG , "appid found: " + wapAppId + ":" + contentType ) ; try { boolean processFurther = true ; if ( wapPushMan == null ) { if ( false ) Log . w ( LOG_TAG , "wap push manager not found!" ) ; } else { Intent intent = new Intent ( ) ; intent . putExtra ( "transactionId" , transactionId ) ; intent . putExtra ( "pduType" , pduType ) ; intent . putExtra ( "header" , header ) ; intent . putExtra ( "data" , intentData ) ; intent . putExtra ( "contentTypeParameters" , pduDecoder . getContentParameters ( ) ) ; int procRet = wapPushMan . processMessage ( wapAppId , contentType , intent ) ; if ( false ) Log . v ( LOG_TAG , "procRet:" + procRet ) ; if ( ( procRet & WapPushManagerParams . MESSAGE_HANDLED ) > 0 && ( procRet & WapPushManagerParams . FURTHER_PROCESSING ) == 0 ) { processFurther = false ; } } if ( ! processFurther ) { return Intents . RESULT_SMS_HANDLED ; } } catch ( RemoteException e ) { if ( false ) Log . w ( LOG_TAG , "remote func failed..." ) ; } } if ( false ) Log . v ( LOG_TAG , "fall back to existing handler" ) ; return Activity . RESULT_OK ; }
copied from wappushoversms . the code flow is not changed from the original .
