Exemplo n.º 1
0
  @Override
  public void handleMessage(Message msg) {
    switch (msg.what) {
      case EVENT_SET_RADIO_POWER_OFF:
        synchronized (this) {
          if (mPendingRadioPowerOffAfterDataOff
              && (msg.arg1 == mPendingRadioPowerOffAfterDataOffTag)) {
            if (DBG) log("EVENT_SET_RADIO_OFF, turn radio off now.");
            hangupAndPowerOff();
            mPendingRadioPowerOffAfterDataOffTag += 1;
            mPendingRadioPowerOffAfterDataOff = false;
          } else {
            log(
                "EVENT_SET_RADIO_OFF is stale arg1="
                    + msg.arg1
                    + "!= tag="
                    + mPendingRadioPowerOffAfterDataOffTag);
          }
        }
        break;

      case EVENT_ICC_CHANGED:
        onUpdateIccAvailability();
        break;

      case EVENT_GET_CELL_INFO_LIST:
        {
          AsyncResult ar = (AsyncResult) msg.obj;
          CellInfoResult result = (CellInfoResult) ar.userObj;
          synchronized (result.lockObj) {
            if (ar.exception != null) {
              log("EVENT_GET_CELL_INFO_LIST: error ret null, e=" + ar.exception);
              result.list = null;
            } else {
              result.list = (List<CellInfo>) ar.result;

              if (VDBG) {
                log(
                    "EVENT_GET_CELL_INFO_LIST: size="
                        + result.list.size()
                        + " list="
                        + result.list);
              }
            }
            mLastCellInfoListTime = SystemClock.elapsedRealtime();
            mLastCellInfoList = result.list;
            result.lockObj.notify();
          }
          break;
        }

      case EVENT_UNSOL_CELL_INFO_LIST:
        {
          AsyncResult ar = (AsyncResult) msg.obj;
          if (ar.exception != null) {
            log("EVENT_UNSOL_CELL_INFO_LIST: error ignoring, e=" + ar.exception);
          } else {
            List<CellInfo> list = (List<CellInfo>) ar.result;
            if (DBG) {
              log("EVENT_UNSOL_CELL_INFO_LIST: size=" + list.size() + " list=" + list);
            }
            mLastCellInfoListTime = SystemClock.elapsedRealtime();
            mLastCellInfoList = list;
            mPhoneBase.notifyCellInfo(list);
          }
          break;
        }

      case EVENT_IMS_STATE_CHANGED: // received unsol
        mCi.getImsRegistrationState(this.obtainMessage(EVENT_IMS_STATE_DONE));
        break;

      case EVENT_IMS_STATE_DONE:
        AsyncResult ar = (AsyncResult) msg.obj;
        if (ar.exception == null) {
          int[] responseArray = (int[]) ar.result;
          mImsRegistered = (responseArray[0] == 1) ? true : false;
        }
        break;

      default:
        log("Unhandled message with number: " + msg.what);
        break;
    }
  }