示例#1
0
  /**
   * Whether Show 4g for LTE SIM.
   *
   * @param serviceState All sim card servicestate.
   * @return true show 4g for LTE SIM card.
   */
  public boolean isShow4GForLTE(ServiceState[] serviceState) {
    boolean show4GForLTE = false;
    if (is4GDataEnabled() && is4GUiccCard()) {
      if (mServiceState != null && serviceState != null) {
        boolean nLtePsConnect = false;
        for (int i = 0; i < serviceState.length; i++) {
          if (i != getSvlteSlot()
              && serviceState[i] != null
              && serviceState[i].getDataRegState() == ServiceState.STATE_IN_SERVICE) {
            Log.d(TAG, "isShow4GForLTE: serviceState[" + i + "] = " + serviceState[i]);
            nLtePsConnect = true;
            break;
          }
        }

        if (mServiceState.getVoiceRegState() == ServiceState.STATE_IN_SERVICE
            && mServiceState.getDataRegState() != ServiceState.STATE_IN_SERVICE
            && nLtePsConnect) {
          show4GForLTE = true;
        } else {
          show4GForLTE = false;
        }
      }
    }

    Log.d(
        TAG,
        "isShow4GForLTE: mServiceState = " + mServiceState + ", show4GForLTE = " + show4GForLTE);
    return show4GForLTE;
  }
示例#2
0
  private void updateServiceState(ServiceState serviceState) {
    int state = serviceState.getState();
    String display = mRes.getString(R.string.radioInfo_unknown);

    switch (state) {
      case ServiceState.STATE_IN_SERVICE:
        display = mRes.getString(R.string.radioInfo_service_in);
        break;
      case ServiceState.STATE_OUT_OF_SERVICE:
      case ServiceState.STATE_EMERGENCY_ONLY:
        display = mRes.getString(R.string.radioInfo_service_out);
        break;
      case ServiceState.STATE_POWER_OFF:
        display = mRes.getString(R.string.radioInfo_service_off);
        break;
    }

    setSummaryText(KEY_SERVICE_STATE, display);

    if (serviceState.getRoaming()) {
      setSummaryText(KEY_ROAMING_STATE, mRes.getString(R.string.radioInfo_roaming_in));
    } else {
      setSummaryText(KEY_ROAMING_STATE, mRes.getString(R.string.radioInfo_roaming_not));
    }
    setSummaryText(KEY_OPERATOR_NAME, serviceState.getOperatorAlphaLong());
  }
 private void handleServiceStateChanged(Intent intent) {
   // If service just returned, start sending out the queued messages
   ServiceState serviceState = ServiceState.newFromBundle(intent.getExtras());
   if (serviceState.getState() == ServiceState.STATE_IN_SERVICE) {
     sendFirstQueuedMessage();
   }
 }
    public void handleMessage(Message msg) {
      switch (msg.what) {
        case EVENT_SERVICE_STATE_CHANGED:
          {
            if (DBG) Log.d(TAG, "EVENT_SERVICE_STATE_CHANGED");
            // make the initial call attempt after the radio is turned on.
            ServiceState state = (ServiceState) ((AsyncResult) msg.obj).result;
            if (DBG) Log.d(TAG, "EVENT_SERVICE_STATE_CHANGED: state = " + state);
            if (state.getState() != ServiceState.STATE_POWER_OFF) {
              EmergencyCallInfo eci = (EmergencyCallInfo) ((AsyncResult) msg.obj).userObj;
              // deregister for the service state change events.
              eci.phone.unregisterForServiceStateChanged(this);
              removeMessages(EVENT_SERVICE_STATE_CHANGED);
              eci.dialog.dismiss();

              if (DBG) Log.d(TAG, "About to (re)launch InCallScreen: " + eci.intent);
              eci.app.startActivity(eci.intent);
            }
          }
          break;

        case EVENT_TIMEOUT_EMERGENCY_CALL:
          {
            if (DBG) Log.d(TAG, "EVENT_TIMEOUT_EMERGENCY_CALL...");
            // repeated call after the timeout period.
            EmergencyCallInfo eci = (EmergencyCallInfo) msg.obj;
            eci.dialog.dismiss();

            if (DBG) Log.d(TAG, "About to (re)launch InCallScreen: " + eci.intent);
            eci.app.startActivity(eci.intent);
          }
          break;
      }
    }
示例#5
0
  private void updateServiceState(ServiceState serviceState) {
    int state = serviceState.getState();
    String display = mRes.getString(R.string.radioInfo_unknown);

    switch (state) {
      case ServiceState.STATE_IN_SERVICE:
        display = mRes.getString(R.string.radioInfo_service_in);
        break;
      case ServiceState.STATE_OUT_OF_SERVICE:
      case ServiceState.STATE_EMERGENCY_ONLY:
        display = mRes.getString(R.string.radioInfo_service_out);
        break;
      case ServiceState.STATE_POWER_OFF:
        display = mRes.getString(R.string.radioInfo_service_off);
        break;
    }

    setSummaryText(KEY_SERVICE_STATE, display);

    if (serviceState.getRoaming()) {
      setSummaryText(KEY_ROAMING_STATE, mRes.getString(R.string.radioInfo_roaming_in));
    } else {
      setSummaryText(KEY_ROAMING_STATE, mRes.getString(R.string.radioInfo_roaming_not));
    }
    Preference p = findPreference(KEY_OPERATOR_NAME);
    String op = serviceState.getOperatorAlphaLong();
    if (TextUtils.isEmpty(op)) {
      op = this.getResources().getString(R.string.device_info_default);
    }
    if (p != null) {
      mExt.updateServiceState(p, serviceState.getOperatorAlphaLong());
    }
  }
示例#6
0
  private void handleServiceStateChanged(Intent intent) {
    /**
     * This used to handle updating EriTextWidgetProvider this routine and and listening for
     * ACTION_SERVICE_STATE_CHANGED intents could be removed. But leaving just in case it might be
     * needed in the near future.
     */

    // If service just returned, start sending out the queued messages
    ServiceState ss = ServiceState.newFromBundle(intent.getExtras());

    boolean hasService = true;
    boolean isCdma = false;
    String eriText = "";

    if (ss != null) {
      int state = ss.getState();
      switch (state) {
        case ServiceState.STATE_OUT_OF_SERVICE:
        case ServiceState.STATE_POWER_OFF:
          hasService = false;
          break;
      }
    } else {
      hasService = false;
    }
  }
示例#7
0
    @Override
    public void handleMessage(Message msg) {
      Status status = mStatus.get();
      if (status == null) {
        return;
      }

      switch (msg.what) {
        case EVENT_SIGNAL_STRENGTH_CHANGED:
          status.updateSignalStrength();
          break;

        case EVENT_SERVICE_STATE_CHANGED:
          ServiceState serviceState = status.mPhoneStateReceiver.getServiceState();
          status.updateServiceState(serviceState);
          // SWISTART
          if (ServiceState.STATE_IN_SERVICE == serviceState.getState())
            sendEmptyMessageDelayed(EVENT_UPDATE_PHONE_TYPE, 5000);
          // SWISTOP
          break;

        case EVENT_UPDATE_STATS:
          status.updateTimes();
          sendEmptyMessageDelayed(EVENT_UPDATE_STATS, 1000);
          break;
          // SWISTART
        case EVENT_UPDATE_PHONE_TYPE:
          status.updatePhoneType();
          break;
          // SWISTART
      }
    }
 /**
  * Notify all mDataConnectionRatChangeRegistrants using an AsyncResult in msg.obj where
  * AsyncResult#result contains the new RAT as an Integer Object.
  */
 protected void notifyDataRegStateRilRadioTechnologyChanged() {
   int rat = mSS.getRilDataRadioTechnology();
   int drs = mSS.getDataRegState();
   if (DBG) log("notifyDataRegStateRilRadioTechnologyChanged: drs=" + drs + " rat=" + rat);
   mPhoneBase.setSystemProperty(
       TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
       ServiceState.rilRadioTechnologyToString(rat));
   mDataRegStateOrRatChangedRegistrants.notifyResult(new Pair<Integer, Integer>(drs, rat));
 }
 /**
  * Some operators have been known to report registration failure data only devices, to fix that
  * use DataRegState.
  */
 protected void useDataRegStateForDataOnlyDevices() {
   if (mVoiceCapable == false) {
     if (DBG) {
       log(
           "useDataRegStateForDataOnlyDevice: VoiceRegState="
               + mNewSS.getVoiceRegState()
               + " DataRegState="
               + mNewSS.getDataRegState());
     }
     // TODO: Consider not lying and instead have callers know the difference.
     mNewSS.setVoiceRegState(mNewSS.getDataRegState());
   }
 }
 public String getOperatorState() {
   if (mTelephonyManager == null) {
     return null;
   }
   if (mServiceState == null || mServiceState.getState() == ServiceState.STATE_OUT_OF_SERVICE) {
     return mContext.getString(R.string.pie_phone_status_no_service);
   }
   if (mServiceState.getState() == ServiceState.STATE_POWER_OFF) {
     return mContext.getString(R.string.pie_phone_status_airplane_mode);
   }
   if (mServiceState.isEmergencyOnly()) {
     return mContext.getString(R.string.pie_phone_status_emergency_only);
   }
   return mServiceState.getOperatorAlphaLong();
 }
 protected void updatePhoneObject() {
   if (mPhoneBase
       .getContext()
       .getResources()
       .getBoolean(com.android.internal.R.bool.config_switch_phone_on_voice_reg_state_change)) {
     // If the phone is not registered on a network, no need to update.
     boolean isRegistered =
         mSS.getVoiceRegState() == ServiceState.STATE_IN_SERVICE
             || mSS.getVoiceRegState() == ServiceState.STATE_EMERGENCY_ONLY;
     if (!isRegistered) {
       Rlog.d(LOG_TAG, "updatePhoneObject: Ignore update");
       return;
     }
     mPhoneBase.updatePhoneObject(mSS.getRilVoiceRadioTechnology());
   }
 }
示例#12
0
 /**
  * Pick the best slot for ECC. The best slot should be radio on and in service, if not, it should
  * be on radio, else GEMINI_SIM_1.
  *
  * @param phone
  * @param number
  * @return
  */
 public static int pickBestSlotForEmergencyCall(Phone phone, String number) {
   Assert.assertNotNull(phone);
   if (GeminiUtils.isGeminiSupport()) {
     GeminiPhone gPhone = (GeminiPhone) phone;
     final int[] geminiSlots = GeminiUtils.getSlots();
     final int count = geminiSlots.length;
     boolean[] isRadioOn = new boolean[count];
     for (int i = 0; i < count; i++) {
       isRadioOn[i] = gPhone.isRadioOnGemini(geminiSlots[i]);
       int state =
           ServiceState.newFromBundle(
                   PhoneGlobals.getInstance().phoneMgrEx.getServiceState(geminiSlots[i]))
               .getState();
       if (isRadioOn[i] && state == ServiceState.STATE_IN_SERVICE) {
         // the slot is radio on & state is in service
         PhoneLog.d(
             TAG, "pickBestSlotForEmergencyCallm, radio on & in service, slot:" + geminiSlots[i]);
         return geminiSlots[i];
       }
     }
     for (int i = 0; i < count; i++) {
       if (isRadioOn[i]) {
         // the slot is radio on
         PhoneLog.d(TAG, "pickBestSlotForEmergencyCallm, radio on, slot:" + geminiSlots[i]);
         return geminiSlots[i];
       }
     }
   }
   PhoneLog.d(TAG, "pickBestSlotForEmergencyCallm, no gemini");
   return GeminiUtils.getDefaultSlot();
 }
  /**
   * Registration point for combined roaming off combined roaming is true when roaming is true and
   * ONS differs SPN
   *
   * @param h handler to notify
   * @param what what code of message when delivered
   * @param obj placed in Message.obj
   */
  public void registerForRoamingOff(Handler h, int what, Object obj) {
    Registrant r = new Registrant(h, what, obj);
    mRoamingOffRegistrants.add(r);

    if (!ss.getRoaming()) {
      r.notifyRegistrant();
    }
  }
  /**
   * Registration point for transition into network attached.
   *
   * @param h handler to notify
   * @param what what code of message when delivered
   * @param obj in Message.obj
   */
  public void registerForNetworkAttached(Handler h, int what, Object obj) {
    Registrant r = new Registrant(h, what, obj);

    mNetworkAttachedRegistrants.add(r);
    if (ss.getState() == ServiceState.STATE_IN_SERVICE) {
      r.notifyRegistrant();
    }
  }
  /**
   * Registration point for combined roaming on of mobile data combined roaming is true when roaming
   * is true and ONS differs SPN
   *
   * @param h handler to notify
   * @param what what code of message when delivered
   * @param obj placed in Message.obj
   */
  public void registerForDataRoamingOn(Handler h, int what, Object obj) {
    Registrant r = new Registrant(h, what, obj);
    mDataRoamingOnRegistrants.add(r);

    if (mSS.getDataRoaming()) {
      r.notifyRegistrant();
    }
  }
 @Override
 public void onServiceStateChanged(ServiceState serviceState) {
   final boolean inAirplaneMode = serviceState.getState() == ServiceState.STATE_POWER_OFF;
   mAirplaneState = inAirplaneMode ? ToggleAction.State.On : ToggleAction.State.Off;
   if (mAirplaneModeOn != null && mAdapter != null) {
     mAirplaneModeOn.updateState(mAirplaneState);
     mAdapter.notifyDataSetChanged();
   }
 }
 public void onServiceStateChanged(ServiceState paramServiceState) {
   bzk localbzk = b;
   if (paramServiceState.getState() == 0) {}
   for (boolean bool = true; ; bool = false) {
     a = bool;
     a.a();
     return;
   }
 }
示例#18
0
  private void deleteAndCreatePhone(int newVoiceRadioTech) {

    String outgoingPhoneName = "Unknown";
    Phone oldPhone = mActivePhone;

    if (oldPhone != null) {
      outgoingPhoneName = ((PhoneBase) oldPhone).getPhoneName();
    }

    logd(
        "Switching Voice Phone : "
            + outgoingPhoneName
            + " >>> "
            + (ServiceState.isGsm(newVoiceRadioTech) ? "GSM" : "CDMA"));

    if (oldPhone != null) {
      CallManager.getInstance().unregisterPhone(oldPhone);
      logd("Disposing old phone..");
      oldPhone.dispose();
    }

    // Give the garbage collector a hint to start the garbage collection
    // asap NOTE this has been disabled since radio technology change could
    // happen during e.g. a multimedia playing and could slow the system.
    // Tests needs to be done to see the effects of the GC call here when
    // system is busy.
    // System.gc();

    if (ServiceState.isCdma(newVoiceRadioTech)) {
      mActivePhone = PhoneFactory.getCdmaPhone();
    } else if (ServiceState.isGsm(newVoiceRadioTech)) {
      mActivePhone = PhoneFactory.getGsmPhone();
    }

    if (oldPhone != null) {
      oldPhone.removeReferences();
    }

    if (mActivePhone != null) {
      CallManager.getInstance().registerPhone(mActivePhone);
    }

    oldPhone = null;
  }
    /**
     * Callback invoked when there is any change to any SubscriptionInfo. Typically this method
     * would invoke {@link SubscriptionManager#getActiveSubscriptionInfoList}
     */
    @Override
    public void onSubscriptionsChanged() {
      if (DBG) log("SubscriptionListener.onSubscriptionInfoChanged");
      // Set the network type, in case the radio does not restore it.
      int subId = mPhoneBase.getSubId();
      if (mPreviousSubId.getAndSet(subId) != subId) {
        if (SubscriptionManager.isValidSubscriptionId(subId)) {
          Context context = mPhoneBase.getContext();
          int networkType = PhoneFactory.calculatePreferredNetworkType(context, subId);
          mCi.setPreferredNetworkType(networkType, null);

          mPhoneBase.notifyCallForwardingIndicator();

          boolean skipRestoringSelection =
              context
                  .getResources()
                  .getBoolean(com.android.internal.R.bool.skip_restoring_network_selection);
          if (!skipRestoringSelection) {
            // restore the previous network selection.
            mPhoneBase.restoreSavedNetworkSelection(null);
          }

          mPhoneBase.setSystemProperty(
              TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
              ServiceState.rilRadioTechnologyToString(mSS.getRilDataRadioTechnology()));

          if (mSpnUpdatePending) {
            mSubscriptionController.setPlmnSpn(
                mPhoneBase.getPhoneId(), mCurShowPlmn, mCurPlmn, mCurShowSpn, mCurSpn);
            mSpnUpdatePending = false;
          }

          // Remove old network selection sharedPreferences since SP key names are now
          // changed to include subId. This will be done only once when upgrading from an
          // older build that did not include subId in the names.
          SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
          String oldNetworkSelectionName = sp.getString(PhoneBase.NETWORK_SELECTION_NAME_KEY, "");
          String oldNetworkSelection = sp.getString(PhoneBase.NETWORK_SELECTION_KEY, "");
          if (!TextUtils.isEmpty(oldNetworkSelectionName)
              || !TextUtils.isEmpty(oldNetworkSelection)) {
            SharedPreferences.Editor editor = sp.edit();
            editor.putString(PhoneBase.NETWORK_SELECTION_NAME_KEY + subId, oldNetworkSelectionName);
            editor.putString(PhoneBase.NETWORK_SELECTION_KEY + subId, oldNetworkSelection);
            editor.remove(PhoneBase.NETWORK_SELECTION_NAME_KEY);
            editor.remove(PhoneBase.NETWORK_SELECTION_KEY);
            editor.commit();
          }
        }
      }
    }
示例#20
0
 /**
  * Get the current ServiceState.
  *
  * @param phone
  * @param slotId
  * @return
  */
 public static ServiceState getServiceState(Phone phone, int slotId) {
   Assert.assertNotNull(phone);
   ServiceState serviceState = null;
   if (GeminiUtils.isGeminiSupport()) {
     PhoneLog.d(TAG, "[getServiceState], slotId = " + slotId);
     if (GeminiUtils.isValidSlot(slotId)) {
       serviceState =
           ServiceState.newFromBundle(
               PhoneGlobals.getInstance().phoneMgrEx.getServiceState(slotId));
     }
   } else {
     serviceState = phone.getServiceState();
   }
   return serviceState;
 }
示例#21
0
 /**
  * Whether the Lte data connected.
  *
  * @param serviceState The Service State include the LTE register state
  * @return true data connected.
  */
 public boolean isLteDataConnected(ServiceState serviceState) {
   boolean bLteDataConnected = false;
   if (serviceState != null) {
     bLteDataConnected =
         (serviceState.getDataRegState() == ServiceState.STATE_IN_SERVICE)
             && (mDataState == TelephonyManager.DATA_CONNECTED);
   }
   Log.d(
       TAG,
       "isLteDataConnected, bLteDataConnected="
           + bLteDataConnected
           + " serviceState="
           + serviceState);
   return bLteDataConnected;
 }
 /**
  * Clean up existing voice and data connection then turn off radio power.
  *
  * <p>Hang up the existing voice calls to decrease call drop rate.
  */
 public void powerOffRadioSafely(DcTrackerBase dcTracker) {
   synchronized (this) {
     if (!mPendingRadioPowerOffAfterDataOff) {
       // In some network, deactivate PDP connection cause releasing of RRC connection,
       // which MM/IMSI detaching request needs. Without this detaching, network can
       // not release the network resources previously attached.
       // So we are avoiding data detaching on these networks.
       String[] networkNotClearData =
           mPhoneBase
               .getContext()
               .getResources()
               .getStringArray(com.android.internal.R.array.networks_not_clear_data);
       String currentNetwork = mSS.getOperatorNumeric();
       if ((networkNotClearData != null) && (currentNetwork != null)) {
         for (int i = 0; i < networkNotClearData.length; i++) {
           if (currentNetwork.equals(networkNotClearData[i])) {
             // Don't clear data connection for this carrier
             if (DBG) log("Not disconnecting data for " + currentNetwork);
             hangupAndPowerOff();
             return;
           }
         }
       }
       // To minimize race conditions we call cleanUpAllConnections on
       // both if else paths instead of before this isDisconnected test.
       if (dcTracker.isDisconnected()) {
         // To minimize race conditions we do this after isDisconnected
         dcTracker.cleanUpAllConnections(Phone.REASON_RADIO_TURNED_OFF);
         if (DBG) log("Data disconnected, turn off radio right away.");
         hangupAndPowerOff();
       } else {
         dcTracker.cleanUpAllConnections(Phone.REASON_RADIO_TURNED_OFF);
         Message msg = Message.obtain(this);
         msg.what = EVENT_SET_RADIO_POWER_OFF;
         msg.arg1 = ++mPendingRadioPowerOffAfterDataOffTag;
         if (sendMessageDelayed(msg, 30000)) {
           if (DBG) log("Wait upto 30s for data to disconnect, then turn off radio.");
           mPendingRadioPowerOffAfterDataOff = true;
         } else {
           log("Cannot send delayed Msg, turn off radio right away.");
           hangupAndPowerOff();
         }
       }
     }
   }
 }
示例#23
0
        @Override
        public void onServiceStateChanged(ServiceState serviceState) {
          if (serviceState.getState() == ServiceState.STATE_IN_SERVICE) {
            int current_international = (Util.isInternational(SinkholeService.this) ? 1 : 0);
            Log.i(TAG, "In service international=" + current_international);

            if (last_international != current_international) {
              Log.i(TAG, "New international=" + current_international);
              last_international = current_international;

              SharedPreferences prefs =
                  PreferenceManager.getDefaultSharedPreferences(SinkholeService.this);
              if (prefs.getBoolean("national_roaming", false))
                reload(null, "service state changed", SinkholeService.this);
            }
          }
        }
示例#24
0
    @Override
    public void onServiceStateChanged(ServiceState serviceState) {
      int state = serviceState.getState();

      switch (state) {
        case ServiceState.STATE_IN_SERVICE:
        case ServiceState.STATE_OUT_OF_SERVICE:
        case ServiceState.STATE_EMERGENCY_ONLY:
        case ServiceState.STATE_POWER_OFF:
          ContentObject co = mContentManager.addRFStateObject(state);
          if (mActivityHandler != null)
            mActivityHandler.obtainMessage(Constants.MESSAGE_RF_STATE_RECEIVED, co).sendToTarget();
          // send to device
          if (co != null) sendContentsToDevice(co);
          else deleteEmergencyOfDevice(EmergencyObject.EMERGENCY_TYPE_RF_STATE);
          break;
      }
    }
  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);
  }
示例#26
0
 /**
  * if slotId is valid, check the slot's service state, else check all slots' service sate.
  *
  * @return true if the slot is power off
  */
 public static boolean isSlotPowerOff(Phone phone, int slotId) {
   Assert.assertNotNull(phone);
   if (GeminiUtils.isGeminiSupport()) {
     GeminiPhone gPhone = (GeminiPhone) phone;
     if (GeminiUtils.isValidSlot(slotId)) {
       ServiceState serviceState =
           ServiceState.newFromBundle(
               PhoneGlobals.getInstance().phoneMgrEx.getServiceState(slotId));
       return serviceState.getState() == ServiceState.STATE_POWER_OFF;
     }
     int[] geminiSlots = GeminiUtils.getSlots();
     for (int gs : geminiSlots) {
       ServiceState serviceState =
           ServiceState.newFromBundle(PhoneGlobals.getInstance().phoneMgrEx.getServiceState(gs));
       if (serviceState.getState() != ServiceState.STATE_POWER_OFF) {
         return false;
       }
     }
     return true;
   }
   return phone.getServiceState().getState() == ServiceState.STATE_POWER_OFF;
 }
示例#27
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);
  }
示例#28
0
 @Override
 public void onServiceStateChanged(ServiceState serviceState) {
   mServiceState = serviceState.getState();
   updateServiceState(serviceState);
 }
  @Override
  public void onServiceStateChanged(ServiceState serviceState) {
    int state = serviceState.getState();
    if (state == mPreviousState
        || (state != ServiceState.STATE_IN_SERVICE
            && mPreviousState != ServiceState.STATE_IN_SERVICE)) {
      // Only interested in state changes or transitioning into or out of "in service".
      // Otherwise just quit.
      mPreviousState = state;
      return;
    }

    if (state == ServiceState.STATE_IN_SERVICE) {
      VoicemailStatusQueryHelper voicemailStatusQueryHelper =
          new VoicemailStatusQueryHelper(mContext);
      if (voicemailStatusQueryHelper.isVoicemailSourceConfigured(mPhoneAccount)) {
        if (!voicemailStatusQueryHelper.isNotificationsChannelActive(mPhoneAccount)) {
          Log.v(TAG, "Notifications channel is active for " + mPhoneAccount.getId());
          VoicemailContract.Status.setStatus(
              mContext,
              mPhoneAccount,
              VoicemailContract.Status.CONFIGURATION_STATE_OK,
              VoicemailContract.Status.DATA_CHANNEL_STATE_OK,
              VoicemailContract.Status.NOTIFICATION_CHANNEL_STATE_OK);
          PhoneGlobals.getInstance()
              .clearMwiIndicator(PhoneUtils.getSubIdForPhoneAccountHandle(mPhoneAccount));
        }
      }

      if (OmtpVvmSourceManager.getInstance(mContext).isVvmSourceRegistered(mPhoneAccount)) {
        Log.v(TAG, "Signal returned: requesting resync for " + mPhoneAccount.getId());
        LocalLogHelper.log(TAG, "Signal returned: requesting resync for " + mPhoneAccount.getId());
        // If the source is already registered, run a full sync in case something was missed
        // while signal was down.
        Intent serviceIntent =
            OmtpVvmSyncService.getSyncIntent(
                mContext,
                OmtpVvmSyncService.SYNC_FULL_SYNC,
                mPhoneAccount,
                true /* firstAttempt */);
        mContext.startService(serviceIntent);
      } else {
        Log.v(TAG, "Signal returned: reattempting activation for " + mPhoneAccount.getId());
        LocalLogHelper.log(
            TAG, "Signal returned: reattempting activation for " + mPhoneAccount.getId());
        // Otherwise initiate an activation because this means that an OMTP source was
        // recognized but either the activation text was not successfully sent or a response
        // was not received.
        OmtpVvmCarrierConfigHelper carrierConfigHelper =
            new OmtpVvmCarrierConfigHelper(
                mContext, PhoneUtils.getSubIdForPhoneAccountHandle(mPhoneAccount));
        carrierConfigHelper.startActivation();
      }
    } else {
      Log.v(TAG, "Notifications channel is inactive for " + mPhoneAccount.getId());
      mContext.stopService(
          OmtpVvmSyncService.getSyncIntent(
              mContext, OmtpVvmSyncService.SYNC_FULL_SYNC, mPhoneAccount, true /* firstAttempt */));

      if (!OmtpVvmSourceManager.getInstance(mContext).isVvmSourceRegistered(mPhoneAccount)) {
        return;
      }

      VoicemailContract.Status.setStatus(
          mContext,
          mPhoneAccount,
          VoicemailContract.Status.CONFIGURATION_STATE_OK,
          VoicemailContract.Status.DATA_CHANNEL_STATE_NO_CONNECTION,
          VoicemailContract.Status.NOTIFICATION_CHANNEL_STATE_NO_CONNECTION);
    }
    mPreviousState = state;
  }
 @Override
 public void onServiceStateChanged(ServiceState serviceState) {
   if (serviceState.getState() == ServiceState.STATE_IN_SERVICE) {
     handleInService();
   }
 }