Exemplo n.º 1
0
  // ***** Class Methods
  public PhoneProxy(Phone phone) {
    mActivePhone = phone;
    mResetModemOnRadioTechnologyChange =
        SystemProperties.getBoolean(TelephonyProperties.PROPERTY_RESET_ON_RADIO_TECH_CHANGE, false);
    mIccSmsInterfaceManagerProxy =
        new IccSmsInterfaceManagerProxy(phone.getIccSmsInterfaceManager());
    mIccPhoneBookInterfaceManagerProxy =
        new IccPhoneBookInterfaceManagerProxy(phone.getIccPhoneBookInterfaceManager());
    mPhoneSubInfoProxy = new PhoneSubInfoProxy(phone.getPhoneSubInfo());
    mCommandsInterface = ((PhoneBase) mActivePhone).mCM;

    mCommandsInterface.registerForRilConnected(this, EVENT_RIL_CONNECTED, null);
    mCommandsInterface.registerForOn(this, EVENT_RADIO_ON, null);
    mCommandsInterface.registerForVoiceRadioTechChanged(this, EVENT_VOICE_RADIO_TECH_CHANGED, null);
  }
Exemplo n.º 2
0
  protected void pollCallsWhenSafe() {
    mNeedsPoll = true;

    if (checkNoOperationsPending()) {
      mLastRelevantPoll = obtainMessage(EVENT_POLL_CALLS_RESULT);
      mCi.getCurrentCalls(mLastRelevantPoll);
    }
  }
Exemplo n.º 3
0
 protected ServiceStateTracker(PhoneBase phoneBase, CommandsInterface ci, CellInfo cellInfo) {
   mPhoneBase = phoneBase;
   mCellInfo = cellInfo;
   cm = ci;
   mUiccController = UiccController.getInstance();
   mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null);
   cm.setOnSignalStrengthUpdate(this, EVENT_SIGNAL_STRENGTH_UPDATE, null);
 }
Exemplo n.º 4
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;
     }
   }
 }
Exemplo n.º 5
0
  protected ServiceStateTracker(PhoneBase phoneBase, CommandsInterface ci, CellInfo cellInfo) {
    mPhoneBase = phoneBase;
    mCellInfo = cellInfo;
    mCi = ci;
    mVoiceCapable =
        mPhoneBase
            .getContext()
            .getResources()
            .getBoolean(com.android.internal.R.bool.config_voice_capable);
    mUiccController = UiccController.getInstance();
    mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null);
    mCi.setOnSignalStrengthUpdate(this, EVENT_SIGNAL_STRENGTH_UPDATE, null);
    mCi.registerForCellInfoList(this, EVENT_UNSOL_CELL_INFO_LIST, null);

    mSubscriptionController = SubscriptionController.getInstance();
    mSubscriptionManager = SubscriptionManager.from(phoneBase.getContext());
    mSubscriptionManager.addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);

    mPhoneBase.setSystemProperty(
        TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
        ServiceState.rilRadioTechnologyToString(ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN));
    mCi.registerForImsNetworkStateChanged(this, EVENT_IMS_STATE_CHANGED, null);
  }
Exemplo n.º 6
0
 /**
  * Routine called from dial to check if the number is a test Emergency number and if so remap the
  * number. This allows a short emergency number to be remapped to a regular number for testing how
  * the frameworks handles emergency numbers without actually calling an emergency number.
  *
  * <p>This is not a full test and is not a substitute for testing real emergency numbers but can
  * be useful.
  *
  * <p>To use this feature set a system property ril.test.emergencynumber to a pair of numbers
  * separated by a colon. If the first number matches the number parameter this routine returns the
  * second number. Example:
  *
  * <p>ril.test.emergencynumber=112:1-123-123-45678
  *
  * <p>To test Dial 112 take call then hang up on MO device to enter ECM see RIL#processSolicited
  * RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND
  *
  * @param dialString to test if it should be remapped
  * @return the same number or the remapped number.
  */
 protected String checkForTestEmergencyNumber(String dialString) {
   String testEn = SystemProperties.get("ril.test.emergencynumber");
   if (DBG_POLL) {
     log("checkForTestEmergencyNumber: dialString=" + dialString + " testEn=" + testEn);
   }
   if (!TextUtils.isEmpty(testEn)) {
     String values[] = testEn.split(":");
     log("checkForTestEmergencyNumber: values.length=" + values.length);
     if (values.length == 2) {
       if (values[0].equals(android.tedongle.PhoneNumberUtils.stripSeparators(dialString))) {
         mCi.testingEmergencyCall();
         log("checkForTestEmergencyNumber: remap " + dialString + " to " + values[1]);
         dialString = values[1];
       }
     }
   }
   return dialString;
 }
Exemplo n.º 7
0
  @Override
  public void handleMessage(Message msg) {
    AsyncResult ar = (AsyncResult) msg.obj;
    switch (msg.what) {
      case EVENT_RADIO_ON:
        /* Proactively query voice radio technologies */
        mCommandsInterface.getVoiceRadioTechnology(
            this.obtainMessage(EVENT_REQUEST_VOICE_RADIO_TECH_DONE));
        break;

      case EVENT_RIL_CONNECTED:
        if (ar.exception == null && ar.result != null) {
          mRilVersion = (Integer) ar.result;
        } else {
          logd("Unexpected exception on EVENT_RIL_CONNECTED");
          mRilVersion = -1;
        }
        break;

      case EVENT_VOICE_RADIO_TECH_CHANGED:
      case EVENT_REQUEST_VOICE_RADIO_TECH_DONE:
        if (ar.exception == null) {
          if ((ar.result != null) && (((int[]) ar.result).length != 0)) {
            int newVoiceTech = ((int[]) ar.result)[0];
            updatePhoneObject(newVoiceTech);
          } else {
            loge("Voice Radio Technology event " + msg.what + " has no tech!");
          }
        } else {
          loge("Voice Radio Technology event " + msg.what + " exception!" + ar.exception);
        }
        break;

      default:
        loge("Error! This handler was not registered for this message type. Message: " + msg.what);
        break;
    }
    super.handleMessage(msg);
  }
Exemplo n.º 8
0
 public void dispose() {
   mCommandsInterface.unregisterForOn(this);
   mCommandsInterface.unregisterForVoiceRadioTechChanged(this);
   mCommandsInterface.unregisterForRilConnected(this);
 }
Exemplo n.º 9
0
  private void updatePhoneObject(int newVoiceRadioTech) {

    if (mActivePhone != null) {
      if (mRilVersion == 6 && getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE) {
        /*
         * On v6 RIL, when LTE_ON_CDMA is TRUE, always create CDMALTEPhone
         * irrespective of the voice radio tech reported.
         */
        if (mActivePhone.getPhoneType() == PHONE_TYPE_CDMA) {
          logd(
              "LTE ON CDMA property is set. Use CDMA Phone"
                  + " newVoiceRadioTech = "
                  + newVoiceRadioTech
                  + " Active Phone = "
                  + mActivePhone.getPhoneName());
          return;
        } else {
          logd(
              "LTE ON CDMA property is set. Switch to CDMALTEPhone"
                  + " newVoiceRadioTech = "
                  + newVoiceRadioTech
                  + " Active Phone = "
                  + mActivePhone.getPhoneName());
          newVoiceRadioTech = ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT;
        }
      } else {
        if ((ServiceState.isCdma(newVoiceRadioTech)
                && mActivePhone.getPhoneType() == PHONE_TYPE_CDMA)
            || (ServiceState.isGsm(newVoiceRadioTech)
                && mActivePhone.getPhoneType() == PHONE_TYPE_GSM)) {
          // Nothing changed. Keep phone as it is.
          logd(
              "Ignoring voice radio technology changed message."
                  + " newVoiceRadioTech = "
                  + newVoiceRadioTech
                  + " Active Phone = "
                  + mActivePhone.getPhoneName());
          return;
        }
      }
    }

    if (newVoiceRadioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) {
      // We need some voice phone object to be active always, so never
      // delete the phone without anything to replace it with!
      logd(
          "Ignoring voice radio technology changed message. newVoiceRadioTech = Unknown."
              + " Active Phone = "
              + mActivePhone.getPhoneName());
      return;
    }

    boolean oldPowerState = false; // old power state to off
    if (mResetModemOnRadioTechnologyChange) {
      if (mCommandsInterface.getRadioState().isOn()) {
        oldPowerState = true;
        logd("Setting Radio Power to Off");
        mCommandsInterface.setRadioPower(false, null);
      }
    }

    deleteAndCreatePhone(newVoiceRadioTech);

    if (mResetModemOnRadioTechnologyChange && oldPowerState) { // restore power state
      logd("Resetting Radio");
      mCommandsInterface.setRadioPower(oldPowerState, null);
    }

    // Set the new interfaces in the proxy's
    mIccSmsInterfaceManagerProxy.setmIccSmsInterfaceManager(
        mActivePhone.getIccSmsInterfaceManager());
    mIccPhoneBookInterfaceManagerProxy.setmIccPhoneBookInterfaceManager(
        mActivePhone.getIccPhoneBookInterfaceManager());
    mPhoneSubInfoProxy.setmPhoneSubInfo(this.mActivePhone.getPhoneSubInfo());

    mCommandsInterface = ((PhoneBase) mActivePhone).mCM;

    // Send an Intent to the PhoneApp that we had a radio technology change
    Intent intent = new Intent(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
    intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
    intent.putExtra(Phone.PHONE_NAME_KEY, mActivePhone.getPhoneName());
    ActivityManagerNative.broadcastStickyIntent(intent, null);
  }
Exemplo n.º 10
0
 public void disableLocationUpdates() {
   mWantContinuousLocationUpdates = false;
   if (!mWantSingleLocationUpdate && !mWantContinuousLocationUpdates) {
     cm.setLocationUpdates(false, null);
   }
 }
Exemplo n.º 11
0
 protected void disableSingleLocationUpdate() {
   mWantSingleLocationUpdate = false;
   if (!mWantSingleLocationUpdate && !mWantContinuousLocationUpdates) {
     cm.setLocationUpdates(false, null);
   }
 }
Exemplo n.º 12
0
 public void enableLocationUpdates() {
   if (mWantSingleLocationUpdate || mWantContinuousLocationUpdates) return;
   mWantContinuousLocationUpdates = true;
   cm.setLocationUpdates(true, obtainMessage(EVENT_LOCATION_UPDATES_ENABLED));
 }
Exemplo n.º 13
0
 /**
  * Re-register network by toggling preferred network type. This is a work-around to deregister and
  * register network since there is no ril api to set COPS=2 (deregister) only.
  *
  * @param onComplete is dispatched when this is complete. it will be an AsyncResult, and
  *     onComplete.obj.exception will be non-null on failure.
  */
 public void reRegisterNetwork(Message onComplete) {
   cm.getPreferredNetworkType(obtainMessage(EVENT_GET_PREFERRED_NETWORK_TYPE, onComplete));
 }
Exemplo n.º 14
0
 public void dispose() {
   cm.unSetOnSignalStrengthUpdate(this);
 }
Exemplo n.º 15
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;
    }
  }
Exemplo n.º 16
0
 public void dispose() {
   mCi.unSetOnSignalStrengthUpdate(this);
   mUiccController.unregisterForIccChanged(this);
   mCi.unregisterForCellInfoList(this);
   mSubscriptionManager.removeOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
 }