예제 #1
0
 /** Start client socket and connect with server. */
 private void openClient() {
   Xlog.v(TAG, "enter startClient");
   if (null != mClientSocket && mClientSocket.isConnected()) {
     Xlog.d(TAG, "localSocket has started, return");
     return;
   }
   try {
     mClientSocket = new Socket("127.0.0.1", SERVER_PORT);
     mClientSocket.setSoTimeout(SOCKET_TIME_OUT_TIME);
     mDataOutput = new DataOutputStream(mClientSocket.getOutputStream());
     mDataInput = new DataInputStream(mClientSocket.getInputStream());
   } catch (UnknownHostException e) {
     Xlog.w(TAG, e.getMessage());
   } catch (IOException e) {
     Xlog.w(TAG, e.getMessage());
   }
 }
  @Override
  protected boolean checkUpgradePackage() {
    if (mHandler != null) {
      mHandler.sendEmptyMessage(SystemUpdateService.MSG_UNZIP_LODING);
    }

    if (!checkSdCard()) {
      Xlog.w(TAG, "[checkUpgradePackage], checkSdCardOk fail");
      return false;
    }

    if (!unzipInstallFile()) {
      Xlog.w(TAG, "[checkUpgradePackage], unzipInstallFile fail");
      return false;
    }

    return true;
  }
예제 #3
0
 public static final int w(String tag, String msg, Throwable tr) {
   int result;
   if (SR_XLOG_ENABLED) {
     result = Xlog.w(tag, msg, tr);
   } else {
     result = Log.w(tag, msg, tr);
   }
   return result;
 }
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    Xlog.w(TAG, "event.getFlages()" + event.getFlags());
    switch (keyCode) {
      case KeyEvent.KEYCODE_BACK:
        Xlog.w(TAG, "onKeyDown, keycode is KEYCODE_BACK");
        if (!mDownloadInfo.getIfNeedRefreshMenu()) {

          if (mDownloadInfo.getActivityID() < 0) {
            mGoToMainEntry = true;
            SdPkgInstallActivity.this.startActivity(new Intent(this, MainEntry.class));
          }
        }
        break;
      default:
        break;
    }
    return super.onKeyDown(keyCode, event);
  }
예제 #5
0
 private static void setPlayerBuffering(boolean playerBuffering) {
   /// M: TEARDOWN message handled before BUFFERING_START message lead to mHTML5VideoView is
   // null. @ {
   if (mHTML5VideoView != null) {
     mHTML5VideoView.setPlayerBuffering(playerBuffering);
   } else {
     Xlog.w(LOGTAG, "HTML5VideoView is null, skip setPlayerBuffering");
   }
   /// @ }
 }
예제 #6
0
 /**
  * Prepare to call function by EM native server
  *
  * @param functionId Functional ID
  * @return True if call function success
  */
 public boolean startCallFunctionStringReturn(int functionId) {
   boolean result = false;
   mSocket = new Client();
   mSocket.startClient();
   try {
     mSocket.writeFunctionNo(String.valueOf(functionId));
     result = true;
   } catch (IOException e) {
     Xlog.w(TAG, "StartCallFunctionStringReturnEXP " + e.getMessage());
     result = false;
   }
   return result;
 }
예제 #7
0
 public static void end() {
   /// M: TEARDOWN message handled before ENDED message lead to mHTML5VideoView is null. @ {
   if (mHTML5VideoView != null) {
     mHTML5VideoView.showControllerInFullScreen();
   } else {
     Xlog.w(LOGTAG, "HTML5VideoView is null, skip showControllerInFullScreen");
   }
   /// @ }
   if (mCurrentProxy != null) {
     if (isVideoSelfEnded) mCurrentProxy.dispatchOnEnded();
     else mCurrentProxy.dispatchOnPaused();
   }
   isVideoSelfEnded = false;
 }
예제 #8
0
  private void initSimState() {
    if (FeatureOption.MTK_GEMINI_SUPPORT) {
      Intent it = getIntent();
      mSimId = it.getIntExtra("simId", SIM_CARD_UNDEFINED);
      if (SIMInfo.getInsertedSIMCount(this) > 1) {
        SIMInfo siminfo = SIMInfo.getSIMInfoBySlot(this, mSimId);
        if (siminfo != null) {
          setTitle(siminfo.mDisplayName);
        }
      }
      Xlog.d(TAG, "GEMINI_SIM_ID_KEY = " + mSimId);
    } else {
      Xlog.w(TAG, "Not support GEMINI");
      mSimId = SIM_CARD_SINGLE;
    }
    switch (mSimId) {
      case SIM_CARD_SINGLE:
        mUri = Telephony.Carriers.CONTENT_URI;
        mNumeric = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "-1");
        mDefaultApnUri = DEFAULTAPN_URI;
        mRestoreCarrierUri = PREFERAPN_URI;
        break;
      case SIM_CARD_1:
        mUri = Telephony.Carriers.SIM1Carriers.CONTENT_URI;
        mNumeric = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "-1");
        mDefaultApnUri = DEFAULTAPN_URI_GEMINI_SIM1;
        mRestoreCarrierUri = PREFERAPN_URI_GEMINI_SIM1;
        break;
      case SIM_CARD_2:
        mUri = Telephony.Carriers.SIM2Carriers.CONTENT_URI;
        mNumeric = SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC_2, "-1");
        mDefaultApnUri = DEFAULTAPN_URI_GEMINI_SIM2;
        mRestoreCarrierUri = PREFERAPN_URI_GEMINI_SIM2;
        break;

      default:
        Xlog.i(TAG, "Incorrect sim id ");
        if (FeatureOption.MTK_GEMINI_SUPPORT) {
          Intent intent = new Intent();
          intent.setClassName("com.android.phone", "com.mediatek.settings.MultipleSimActivity");
          intent.putExtra("TARGET_CLASS", "com.android.settings.ApnSettings");
          startActivity(intent);
        }
        finish();
        break;
    }

    Xlog.d(TAG, "mNumeric " + mNumeric);
    Xlog.d(TAG, "mUri = " + mUri);
  }
예제 #9
0
 private String getUsbMode() {
   String result = null;
   StringBuilder strBuilder = new StringBuilder();
   strBuilder.append("cat ");
   strBuilder.append(mPortFile);
   Xlog.v(TAG, "get current dramc cmd: " + strBuilder.toString());
   try {
     if (ShellExe.RESULT_SUCCESS == ShellExe.execCommand(strBuilder.toString(), true)) {
       result = ShellExe.getOutput();
     }
   } catch (IOException e) {
     Xlog.w(TAG, "get current dramc IOException: " + e.getMessage());
   }
   return result;
 }
예제 #10
0
 /** Invoked when "Stop" button clicked */
 private void onClickBtnRxStop() {
   // long i4RxCntOk = -1;
   // long i4RxCntFcsErr = -1;
   // long i4RxPer = -1;
   // long[] i4Rx = new long[2];
   long[] u4Value = new long[1];
   mHandler.removeMessages(HANDLER_EVENT_RX);
   for (int i = 0; i < WAIT_COUNT; i++) {
     u4Value[0] = EMWifi.setATParam(ATPARAM_INDEX_COMMAND, 0);
     if (u4Value[0] == 0) {
       break;
     } else {
       SystemClock.sleep(WAIT_COUNT);
       Xlog.w(TAG, "stop Rx test failed at the " + i + "times try");
     }
   }
   setViewEnabled(true);
 }
예제 #11
0
 /**
  * Send command to socket server.
  *
  * @param command Command need to send
  */
 public void sendCommand(String command) {
   Xlog.v(TAG, "enter sendCommand");
   String sendComm = "$" + command + "*" + calcCS(command);
   Xlog.v(TAG, "Send command: " + sendComm);
   if (!mSendThread.isAlive()) {
     Xlog.v(TAG, "sendThread is not alive");
     mSendThread.start();
   }
   if (command.equals(sendComm) || mCommandQueue.contains(sendComm)) {
     Xlog.v(TAG, "send command return because of hasn't handle the same");
     return;
   }
   try {
     mCommandQueue.put(sendComm);
   } catch (InterruptedException ie) {
     Xlog.w(TAG, "send command interrupted:" + ie.getMessage());
   }
 }
예제 #12
0
  private boolean restoreDefaultApn() {
    Xlog.w(TAG, "restore Default Apn.");
    showDialog(DIALOG_RESTORE_DEFAULTAPN);
    mRestoreDefaultApnMode = true;

    if (mRestoreApnUiHandler == null) {
      mRestoreApnUiHandler = new RestoreApnUiHandler();
    }

    if (mRestoreApnProcessHandler == null || mRestoreDefaultApnThread == null) {
      mRestoreDefaultApnThread = new HandlerThread("Restore default APN Handler: Process Thread");
      mRestoreDefaultApnThread.start();
      mRestoreApnProcessHandler =
          new RestoreApnProcessHandler(mRestoreDefaultApnThread.getLooper(), mRestoreApnUiHandler);
    }

    mRestoreApnProcessHandler.sendEmptyMessage(EVENT_RESTORE_DEFAULTAPN_START);
    return true;
  }
예제 #13
0
 private boolean isUsbConnected() {
   String result = null;
   boolean isConnected = false;
   StringBuilder strBuilder = new StringBuilder();
   strBuilder.append("cat ");
   strBuilder.append(USB_CONNECT_STATE);
   Xlog.v(TAG, "isUsbConnected cmd: " + strBuilder.toString());
   try {
     if (ShellExe.RESULT_SUCCESS == ShellExe.execCommand(strBuilder.toString(), true)) {
       result = ShellExe.getOutput();
       if (result.equals(USB_CONFIGURED) || result.equals(USB_CONNECT)) {
         isConnected = true;
       }
     }
   } catch (IOException e) {
     Xlog.w(TAG, "get current dramc IOException: " + e.getMessage());
   }
   return isConnected;
 }
        @Override
        public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();
          if (Util.Action.ACTION_MEDIA_MOUNT_UPDATEUI.equals(action)) {
            // M: Add by mtk80800, sd card mounted, reminder user to refresh
            showDialog(DIALOG_SDCARDMOUNTED);

          } else if (Util.Action.ACTION_MEDIA_UNMOUNT_UPDATEUI.equals(action)) {
            // M: Add by mtk80800, sdcard unmount, reset download info and finish this activity
            String path = (String) intent.getExtra("storagePath");
            if (mPath.contains(path)) {
              Xlog.w(TAG, "SDcard unmount, finish activity");
              if (mDownloadInfo.getActivityID() < 0) {
                Toast.makeText(context, R.string.sdcard_unmount, Toast.LENGTH_LONG).show();
              }
              SdPkgInstallActivity.this.finish();
            }
          }
        }
예제 #15
0
 /** Stop client socket and disconnect with server. */
 private void closeClient() {
   Xlog.v(TAG, "enter closeClient");
   try {
     if (null != mDataInput) {
       mDataInput.close();
     }
     if (null != mDataOutput) {
       mDataOutput.close();
     }
     if (null != mClientSocket) {
       mClientSocket.close();
     }
   } catch (IOException e) {
     Xlog.w(TAG, "closeClient IOException: " + e.getMessage());
   } finally {
     mClientSocket = null;
     mDataInput = null;
     mDataOutput = null;
   }
 }
예제 #16
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.networkmode_switching);
    mSimType = getIntent().getIntExtra("mSimType", PhoneConstants.GEMINI_SIM_1);

    if (FeatureOption.MTK_GEMINI_SUPPORT) {
      mGeminiPhone = (GeminiPhone) PhoneFactory.getDefaultPhone();
    } else {
      mPhone = PhoneFactory.getDefaultPhone();
    }
    mPreferredNetworkSpinner = (Spinner) findViewById(R.id.networkModeSwitching);
    mModemType = getModemType();
    if (mModemType == MODEM_TD) {
      // No "CDMA preferred" for TD
      mNetworkTypeValues = new int[] {GSM_ONLY, WCDMA_ONLY, GSM_WCDMA_AUTO};
      ArrayAdapter<String> adapter =
          new ArrayAdapter<String>(
              this,
              android.R.layout.simple_spinner_item,
              getResources().getStringArray(R.array.mTddNetworkLabels));
      adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      mPreferredNetworkSpinner.setAdapter(adapter);
    } else if (mModemType == MODEM_FDD) {
      mNetworkTypeValues = new int[] {WCDMA_PREFERRED, GSM_ONLY, WCDMA_ONLY, GSM_WCDMA_AUTO};
      ArrayAdapter<String> adapter =
          new ArrayAdapter<String>(
              this,
              android.R.layout.simple_spinner_item,
              getResources().getStringArray(R.array.mWcdmaNetworkLabels));
      adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
      mPreferredNetworkSpinner.setAdapter(adapter);
    } else {
      //            mPreferredNetworkSpinner.setEnabled(false);
      Xlog.w(TAG, "Isn't TD/WCDMA modem: " + mModemType);
    }

    mPreferredNetworkSpinner.setOnItemSelectedListener(mPreferredNetworkHandler);
  }
예제 #17
0
    @Override
    public void handleMessage(Message msg) {
      switch (msg.what) {
        case MSG_CHECK_RESULT:
          final boolean result = waitForState(mModeVal, 2000);
          runOnUiThread(
              new Runnable() {
                @Override
                public void run() {
                  updateStatus(VAL_USB.equals(mModeVal));
                  enableUsbUartSwitch(true);
                  showDialog(
                      null, getString(R.string.uart_usb_switch_set) + (result ? SUCCESS : FAIL));
                }
              });

          break;
        default:
          Xlog.w(TAG, "mWorkerHandler Unknown msg: " + msg.what);
          break;
      }
      super.handleMessage(msg);
    }
예제 #18
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   if (ChipSupport.MTK_6595_SUPPORT == ChipSupport.getChip()
       || ChipSupport.MTK_6795_SUPPORT == ChipSupport.getChip()) {
     mPortFile = FILE_PORT_MODE_2;
   }
   if (!new File(mPortFile).exists()) {
     Toast.makeText(this, R.string.uart_usb_switch_notsupport, Toast.LENGTH_SHORT).show();
     Xlog.w(TAG, "Port mode file not exist");
     finish();
     return;
   }
   setContentView(R.layout.uart_usb_switch);
   mTvCurrent = (TextView) findViewById(R.id.uart_usb_switch_current_mode);
   mRgMode = (RadioGroup) findViewById(R.id.uart_usb_switch_mode);
   mRbUsb = (RadioButton) findViewById(R.id.uart_usb_switch_mode_usb);
   mRbUart = (RadioButton) findViewById(R.id.uart_usb_switch_mode_uart);
   mWorkerThread = new HandlerThread(TAG);
   mWorkerThread.start();
   mWorkerHandler = new WorkerHandler(mWorkerThread.getLooper());
   showDialog(DIALOG_USB_WARNING);
 }
예제 #19
0
  public void run() {
    Xlog.d(MmsApp.TXN_TAG, "NotificationTransaction: run()");
    DownloadManager downloadManager = DownloadManager.getInstance();
    // boolean autoDownload = downloadManager.isAuto();
    // boolean dataSuspended = (MmsApp.getApplication().getTelephonyManager().getDataState() ==
    //        TelephonyManager.DATA_SUSPENDED);
    boolean autoDownload = false;
    boolean dataSuspended = false;
    // add for gemini
    if (FeatureOption.MTK_GEMINI_SUPPORT) {
      autoDownload = downloadManager.isAuto(mSimId);
      int datastate =
          MmsApp.getApplication()
              .getTelephonyManager()
              .getDataStateGemini(SIMInfo.getSlotById(mContext, mSimId));
      dataSuspended =
          (datastate == TelephonyManager.DATA_SUSPENDED
              || datastate == TelephonyManager.DATA_DISCONNECTED);
    } else {
      autoDownload = downloadManager.isAuto();
      dataSuspended =
          (MmsApp.getApplication().getTelephonyManager().getDataState()
              == TelephonyManager.DATA_SUSPENDED);
    }

    try {
      if (LOCAL_LOGV) {
        Log.v(TAG, "Notification transaction launched: " + this);
      }

      // By default, we set status to STATUS_DEFERRED because we
      // should response MMSC with STATUS_DEFERRED when we cannot
      // download a MM immediately.
      int status = STATUS_DEFERRED;

      // Check expiry state
      Date CurrentDate = new Date(System.currentTimeMillis());
      Date ExpiryDate = new Date(mNotificationInd.getExpiry() * 1000);
      Xlog.d(
          MmsApp.TXN_TAG,
          "expiry time="
              + ExpiryDate.toLocaleString()
              + "\t current="
              + CurrentDate.toLocaleString());

      // MTK_OP01_PROTECT_START
      /*
      String optr = SystemProperties.get("ro.operator.optr");
      if (optr.equals("OP01")) {
          // Check Message size
          int msgSize = 0;
          Cursor cursor = SqliteWrapper.query(mContext, mContext.getContentResolver(),
                           mUri, new String[] {Mms.MESSAGE_SIZE}, null, null, null);
          if (cursor != null && cursor.getCount() == 1 && cursor.moveToFirst()) {
              try{
                  msgSize = cursor.getInt(0);
                  Xlog.v(MmsApp.TXN_TAG, "msg Size = " + msgSize);
              }finally{
                  cursor.close();
              }
          }

          String netWorkType = null;
          int slotId = -1;
          if (FeatureOption.MTK_GEMINI_SUPPORT) {
              // convert sim id to slot id
              slotId = SIMInfo.getSlotById(mContext, mSimId);
              netWorkType = SystemProperties.get(slotId == 0 ?
                      TelephonyProperties.PROPERTY_CS_NETWORK_TYPE : TelephonyProperties.PROPERTY_CS_NETWORK_TYPE_2);
          } else {
              netWorkType = SystemProperties.get(TelephonyProperties.PROPERTY_CS_NETWORK_TYPE);
          }

          boolean bTDNetwork = Integer.parseInt(netWorkType) > 2 ? true : false;
          if ((!bTDNetwork && MmsConfig.getReceiveMmsLimitFor2G() < msgSize/1024)
                  || (bTDNetwork && MmsConfig.getReceiveMmsLimitForTD() < msgSize/1024)) {
              Xlog.v(MmsApp.TXN_TAG, "Message size exceed limitation, rejected.");

              status = STATUS_REJECTED;
              sendNotifyRespInd(status);
              return;
          }
      }
      */
      // MTK_OP01_PROTECT_END
      // Don't try to download when data is suspended, as it will fail, so defer download
      if (!autoDownload || dataSuspended) {
        Xlog.d(
            MmsApp.TXN_TAG,
            "Not autoDownload! autoDonwload=" + autoDownload + ", dataSuspended=" + dataSuspended);
        if (FeatureOption.MTK_GEMINI_SUPPORT) {
          downloadManager.markState(mUri, DownloadManager.STATE_UNSTARTED, mSimId);
        } else {
          downloadManager.markState(mUri, DownloadManager.STATE_UNSTARTED);
        }
        sendNotifyRespInd(status);
        return;
      }

      if (FeatureOption.MTK_GEMINI_SUPPORT) {
        downloadManager.markState(mUri, DownloadManager.STATE_DOWNLOADING, mSimId);
      } else {
        downloadManager.markState(mUri, DownloadManager.STATE_DOWNLOADING);
      }

      if (LOCAL_LOGV) {
        Log.v(TAG, "Content-Location: " + mContentLocation);
      }

      byte[] retrieveConfData = null;
      // We should catch exceptions here to response MMSC
      // with STATUS_DEFERRED.
      try {
        Xlog.d(MmsApp.TXN_TAG, "NotificationTransaction: before getpdu");
        retrieveConfData = getPdu(mContentLocation);
        Xlog.d(MmsApp.TXN_TAG, "NotificationTransaction: after getpdu");
      } catch (IOException e) {
        mTransactionState.setState(FAILED);
      }

      if (retrieveConfData != null) {
        GenericPdu pdu = new PduParser(retrieveConfData).parse();
        if ((pdu == null) || (pdu.getMessageType() != MESSAGE_TYPE_RETRIEVE_CONF)) {
          Log.e(TAG, "Invalid M-RETRIEVE.CONF PDU.");
          mTransactionState.setState(FAILED);
          status = STATUS_UNRECOGNIZED;
        } else {
          // Save the received PDU (must be a M-RETRIEVE.CONF).
          PduPersister p = PduPersister.getPduPersister(mContext);
          Uri uri = p.persist(pdu, Inbox.CONTENT_URI);
          Xlog.d(MmsApp.TXN_TAG, "PDU Saved, Uri=" + uri + "\nDelete Notify Ind, Uri=" + mUri);
          // add for gemini
          if (FeatureOption.MTK_GEMINI_SUPPORT) {
            ContentResolver cr = mContext.getContentResolver();
            ContentValues values = new ContentValues(1);
            values.put(Mms.SIM_ID, mSimId);
            SqliteWrapper.update(mContext, cr, uri, values, null, null);
          }

          // set message size
          int messageSize = retrieveConfData.length;
          ContentValues sizeValue = new ContentValues();
          sizeValue.put(Mms.MESSAGE_SIZE, messageSize);
          SqliteWrapper.update(mContext, mContext.getContentResolver(), uri, sizeValue, null, null);

          // We have successfully downloaded the new MM. Delete the
          // M-NotifyResp.ind from Inbox.
          String notifId = mUri.getLastPathSegment();
          String msgId = uri.getLastPathSegment();
          if (!notifId.equals(msgId)) {
            SqliteWrapper.delete(mContext, mContext.getContentResolver(), mUri, null, null);
          }
          // Notify observers with newly received MM.
          mUri = uri;
          status = STATUS_RETRIEVED;
        }
      } else {
        Xlog.e(MmsApp.TXN_TAG, "retrieveConfData is null");
        mTransactionState.setState(FAILED);
        status = STATUS_UNRECOGNIZED;
      }

      // Check the status and update the result state of this Transaction.
      switch (status) {
        case STATUS_RETRIEVED:
          mTransactionState.setState(SUCCESS);
          break;
        case STATUS_DEFERRED:
          // STATUS_DEFERRED, may be a failed immediate retrieval.
          if (mTransactionState.getState() == INITIALIZED) {
            mTransactionState.setState(SUCCESS);
          }
          break;
      }
      // if the status is STATUS_UNRECOGNIZED, this happened when we don't get mms pdu from server,
      // this may be a server problem or network problem.
      // our policy is will retry later, so we must response a deferred status not this one.
      // otherwise the server may delete this mms, and when we retry it, it's another mms created by
      // server to
      // inform us that the old mms is not exist yet.
      if (status == STATUS_UNRECOGNIZED) {
        status = STATUS_DEFERRED;
      }
      sendNotifyRespInd(status);

      // Make sure this thread isn't over the limits in message count.
      Recycler.getMmsRecycler().deleteOldMessagesInSameThreadAsMessage(mContext, mUri);
    } catch (Throwable t) {
      Log.e(TAG, Log.getStackTraceString(t));
      if (null != mUri) {
        Recycler.getMmsRecycler().deleteOldMessagesInSameThreadAsMessage(mContext, mUri);
      }
    } finally {
      mTransactionState.setContentUri(mUri);
      if (!autoDownload /*|| dataSuspended*/ /*comment this case for 81452*/) {
        // Always mark the transaction successful for deferred
        // download since any error here doesn't make sense.
        mTransactionState.setState(SUCCESS);
      }
      if (mTransactionState.getState() != SUCCESS) {
        mTransactionState.setState(FAILED);
        Xlog.w(MmsApp.TXN_TAG, "NotificationTransaction failed.");
      }
      notifyObservers();
    }
  }
예제 #20
0
    @Override
    protected Void doInBackground(Intent... intents) {
      Intent intent = intents[0];
      Xlog.d(
          MmsApp.TXN_TAG,
          "do In Background, slotId=" + intent.getIntExtra(Phone.GEMINI_SIM_ID_KEY, 0));
      // Get raw PDU push-data from the message and parse it
      byte[] pushData = intent.getByteArrayExtra("data");
      PduParser parser = new PduParser(pushData);
      GenericPdu pdu = parser.parse();

      if (null == pdu) {
        Log.e(TAG, "Invalid PUSH data");
        return null;
      }

      PduPersister p = PduPersister.getPduPersister(mContext);
      ContentResolver cr = mContext.getContentResolver();
      int type = pdu.getMessageType();
      long threadId = -1;

      try {
        switch (type) {
          case MESSAGE_TYPE_DELIVERY_IND:
            Xlog.d(MmsApp.TXN_TAG, "type=MESSAGE_TYPE_DELIVERY_IND");
          case MESSAGE_TYPE_READ_ORIG_IND:
            {
              if (type == MESSAGE_TYPE_READ_ORIG_IND) {
                Xlog.d(MmsApp.TXN_TAG, "type=MESSAGE_TYPE_READ_ORIG_IND");
              }
              threadId = findThreadId(mContext, pdu, type);
              if (threadId == -1) {
                // The associated SendReq isn't found, therefore skip
                // processing this PDU.
                break;
              }

              Uri uri = p.persist(pdu, Inbox.CONTENT_URI);
              // Update thread ID for ReadOrigInd & DeliveryInd.
              ContentValues values = new ContentValues(1);
              values.put(Mms.THREAD_ID, threadId);
              SqliteWrapper.update(mContext, cr, uri, values, null, null);
              break;
            }
          case MESSAGE_TYPE_NOTIFICATION_IND:
            {
              Xlog.d(MmsApp.TXN_TAG, "type=MESSAGE_TYPE_NOTIFICATION_IND");
              NotificationInd nInd = (NotificationInd) pdu;

              if (MmsConfig.getTransIdEnabled()) {
                byte[] contentLocation = nInd.getContentLocation();
                if ('=' == contentLocation[contentLocation.length - 1]) {
                  byte[] transactionId = nInd.getTransactionId();
                  byte[] contentLocationWithId =
                      new byte[contentLocation.length + transactionId.length];
                  System.arraycopy(
                      contentLocation, 0, contentLocationWithId, 0, contentLocation.length);
                  System.arraycopy(
                      transactionId,
                      0,
                      contentLocationWithId,
                      contentLocation.length,
                      transactionId.length);
                  nInd.setContentLocation(contentLocationWithId);
                }
              }

              if (!isDuplicateNotification(mContext, nInd)) {
                Uri uri = p.persist(pdu, Inbox.CONTENT_URI);
                // add for gemini
                if (FeatureOption.MTK_GEMINI_SUPPORT) {
                  // update pdu
                  ContentValues values = new ContentValues(2);
                  SIMInfo si =
                      SIMInfo.getSIMInfoBySlot(
                          mContext, intent.getIntExtra(Phone.GEMINI_SIM_ID_KEY, -1));
                  if (null == si) {
                    Xlog.e(
                        MmsApp.TXN_TAG,
                        "PushReceiver:SIMInfo is null for slot "
                            + intent.getIntExtra(Phone.GEMINI_SIM_ID_KEY, -1));
                    break;
                  }
                  values.put(Mms.SIM_ID, si.mSimId);
                  values.put(WapPush.SERVICE_ADDR, intent.getStringExtra(WapPush.SERVICE_ADDR));
                  SqliteWrapper.update(mContext, cr, uri, values, null, null);
                  Xlog.d(
                      MmsApp.TXN_TAG,
                      "save notification slotId="
                          + intent.getIntExtra(Phone.GEMINI_SIM_ID_KEY, 0)
                          + "\tsimId="
                          + si.mSimId
                          + "\tsc="
                          + intent.getStringExtra(WapPush.SERVICE_ADDR)
                          + "\taddr="
                          + intent.getStringExtra(WapPush.ADDR));

                  // update pending messages
                  long msgId = 0;
                  Cursor cursor =
                      SqliteWrapper.query(
                          mContext,
                          mContext.getContentResolver(),
                          uri,
                          new String[] {Mms._ID},
                          null,
                          null,
                          null);
                  if (cursor != null && cursor.getCount() == 1 && cursor.moveToFirst()) {
                    try {
                      msgId = cursor.getLong(0);
                      Xlog.d(MmsApp.TXN_TAG, "msg id = " + msgId);
                    } finally {
                      cursor.close();
                    }
                  }

                  Uri.Builder uriBuilder = PendingMessages.CONTENT_URI.buildUpon();
                  uriBuilder.appendQueryParameter("protocol", "mms");
                  uriBuilder.appendQueryParameter("message", String.valueOf(msgId));
                  Cursor pendingCs =
                      SqliteWrapper.query(
                          mContext,
                          mContext.getContentResolver(),
                          uriBuilder.build(),
                          null,
                          null,
                          null,
                          null);
                  if (pendingCs != null) {
                    try {
                      if ((pendingCs.getCount() == 1) && pendingCs.moveToFirst()) {
                        ContentValues valuesforPending = new ContentValues();
                        valuesforPending.put(PendingMessages.SIM_ID, si.mSimId);
                        int columnIndex = pendingCs.getColumnIndexOrThrow(PendingMessages._ID);
                        long id = pendingCs.getLong(columnIndex);
                        SqliteWrapper.update(
                            mContext,
                            mContext.getContentResolver(),
                            PendingMessages.CONTENT_URI,
                            valuesforPending,
                            PendingMessages._ID + "=" + id,
                            null);
                      } else {
                        Xlog.w(
                            MmsApp.TXN_TAG,
                            "can not find message to set pending sim id, msgId=" + msgId);
                      }
                    } finally {
                      pendingCs.close();
                    }
                  }
                } else {
                  ContentValues value = new ContentValues(1);
                  value.put(WapPush.SERVICE_ADDR, intent.getStringExtra(WapPush.SERVICE_ADDR));
                  SqliteWrapper.update(mContext, cr, uri, value, null, null);
                  Xlog.d(
                      MmsApp.TXN_TAG,
                      "save notification,"
                          + "\tsc="
                          + intent.getStringExtra(WapPush.SERVICE_ADDR)
                          + "\taddr="
                          + intent.getStringExtra(WapPush.ADDR));
                }

                // Start service to finish the notification transaction.
                Intent svc = new Intent(mContext, TransactionService.class);
                svc.putExtra(TransactionBundle.URI, uri.toString());
                svc.putExtra(
                    TransactionBundle.TRANSACTION_TYPE, Transaction.NOTIFICATION_TRANSACTION);
                if (FeatureOption.MTK_GEMINI_SUPPORT) {
                  SIMInfo si =
                      SIMInfo.getSIMInfoBySlot(
                          mContext, intent.getIntExtra(Phone.GEMINI_SIM_ID_KEY, -1));
                  if (null == si) {
                    Xlog.e(
                        MmsApp.TXN_TAG,
                        "PushReceiver: SIMInfo is null for slot "
                            + intent.getIntExtra(Phone.GEMINI_SIM_ID_KEY, -1));
                    break;
                  }
                  int simId = (int) si.mSimId;
                  svc.putExtra(Phone.GEMINI_SIM_ID_KEY, simId);
                  // svc.putExtra(Phone.GEMINI_SIM_ID_KEY,
                  // intent.getIntExtra(Phone.GEMINI_SIM_ID_KEY, 0));
                }
                mContext.startService(svc);
              } else if (LOCAL_LOGV) {
                Log.v(
                    TAG,
                    "Skip downloading duplicate message: " + new String(nInd.getContentLocation()));
              }
              break;
            }
          default:
            Log.e(TAG, "Received unrecognized PDU.");
        }
      } catch (MmsException e) {
        Log.e(TAG, "Failed to save the data from PUSH: type=" + type, e);
      } catch (RuntimeException e) {
        Log.e(TAG, "Unexpected RuntimeException.", e);
      } finally {
        raisePriority(mContext, false);
        Xlog.d(MmsApp.TXN_TAG, "Normal priority");
      }

      if (LOCAL_LOGV) {
        Log.v(TAG, "PUSH Intent processed.");
      }

      return null;
    }