コード例 #1
0
 /** @return all available cell information or null if none. */
 public List<CellInfo> getAllCellInfo() {
   CellInfoResult result = new CellInfoResult();
   if (VDBG) log("SST.getAllCellInfo(): E");
   int ver = mCi.getRilVersion();
   if (ver >= 8) {
     if (isCallerOnDifferentThread()) {
       if ((SystemClock.elapsedRealtime() - mLastCellInfoListTime)
           > LAST_CELL_INFO_LIST_MAX_AGE_MS) {
         Message msg = obtainMessage(EVENT_GET_CELL_INFO_LIST, result);
         synchronized (result.lockObj) {
           result.list = null;
           mCi.getCellInfoList(msg);
           try {
             result.lockObj.wait(5000);
           } catch (InterruptedException e) {
             e.printStackTrace();
           }
         }
       } else {
         if (DBG) log("SST.getAllCellInfo(): return last, back to back calls");
         result.list = mLastCellInfoList;
       }
     } else {
       if (DBG) log("SST.getAllCellInfo(): return last, same thread can't block");
       result.list = mLastCellInfoList;
     }
   } else {
     if (DBG) log("SST.getAllCellInfo(): not implemented");
     result.list = null;
   }
   synchronized (result.lockObj) {
     if (result.list != null) {
       if (DBG) log("SST.getAllCellInfo(): X size=" + result.list.size() + " list=" + result.list);
       return result.list;
     } else {
       if (DBG) log("SST.getAllCellInfo(): X size=0 list=null");
       return null;
     }
   }
 }
コード例 #2
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;
    }
  }