Example #1
0
 /** Expand sendBurstDtmf method for GEMINI. */
 public static void sendBurstDtmf(String dtmfString, int on, int off, Message onComplete) {
   if (PhoneGlobals.getPhone() instanceof GeminiPhone) {
     final int cdmaSlot = GeminiUtils.getCDMASlot();
     Phone cdmaPhone = ((GeminiPhone) PhoneGlobals.getPhone()).getPhonebyId(cdmaSlot);
     cdmaPhone.sendBurstDtmf(dtmfString, on, off, onComplete);
   } else {
     CallManager.getInstance().sendBurstDtmf(dtmfString, on, off, onComplete);
   }
 }
 public static boolean isValidCondition() {
   if (PhoneConstants.State.IDLE == PhoneGlobals.getInstance().mCM.getState()) {
     return false;
   }
   if (!PhoneGlobals.getInstance().mCM.hasActiveRingingCall()
       && !PhoneGlobals.getInstance().mCM.hasActiveFgCall()) {
     return false;
   }
   if (PhoneGlobals.getInstance().mCM.hasActiveBgCall()) {
     return false;
   }
   return true;
 }
Example #3
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();
 }
Example #4
0
  /**
   * whether the specified slot id radio off.
   *
   * @param slot
   * @param context
   * @return
   */
  public static boolean isRadioOffBySlot(int slot, Context context) {
    boolean isRadioOff = true;
    Phone phone = PhoneGlobals.getPhone();
    if (phone instanceof GeminiPhone) {
      GeminiPhone dualPhone = (GeminiPhone) phone;
      isRadioOff = !dualPhone.isRadioOnGemini(slot);
    } else {
      isRadioOff = phone.getServiceState().getState() == ServiceState.STATE_POWER_OFF;
    }

    return isRadioOff || GeminiUtils.isAllRadioOff(context);
  }
Example #5
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;
 }
Example #6
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;
 }
Example #7
0
 /**
  * get network operator name, read from SystemProperties.
  *
  * @see PROPERTY_OPERATOR_GEMINI
  * @return
  */
 public static String getNetworkOperatorName() {
   String operatorName = null;
   if (GeminiUtils.isGeminiSupport()) {
     GeminiPhone gphone = (GeminiPhone) PhoneGlobals.getInstance().phone;
     final int[] geminiSlots = GeminiUtils.getSlots();
     for (int i = 0; i < geminiSlots.length; i++) {
       if (gphone.getPhonebyId(geminiSlots[i]).getState() != PhoneConstants.State.IDLE) {
         operatorName = SystemProperties.get(GeminiConstants.PROPERTY_OPERATOR_ALPHAS[i]);
         PhoneLog.d(
             TAG,
             "getNetworkOperatorName operatorName:" + operatorName + ", slotId:" + geminiSlots[i]);
         break;
       }
     }
     // Give a chance for get mmi information
     if (operatorName == null
         && PhoneGlobals.getInstance().mCM.getState() == PhoneConstants.State.IDLE) {
       for (int i = 0; i < geminiSlots.length; i++) {
         if (gphone.getPhonebyId(geminiSlots[i]).getPendingMmiCodes().size() != 0) {
           operatorName = SystemProperties.get(GeminiConstants.PROPERTY_OPERATOR_ALPHAS[i]);
           PhoneLog.d(
               TAG,
               "getNetworkOperatorName operatorName:"
                   + operatorName
                   + ", slotId:"
                   + geminiSlots[i]);
           break;
         }
       }
     }
   } else {
     operatorName = SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_ALPHA);
   }
   PhoneLog.d(TAG, "getNetworkOperatorName operatorName = " + operatorName);
   return operatorName;
 }
Example #8
0
  @Override
  protected int beforeExecute() {
    super.beforeExecute();
    int retval = ICommand.RESULT_OK;
    mCallManager = PhoneGlobals.getInstance().mCM;
    if (mCallManager.getState() != PhoneConstants.State.OFFHOOK
        || !PhoneUtils.okToRecordVoice(mCallManager)) {
      retval = ICommand.RESULT_ABORT;
      log("!!!beforeExecute call state is not offhook or can not record!!!");
    } else {
      mIsRecording = PhoneRecorder.isRecording();
    }

    return retval;
  }
 public static boolean canMuteRinger() {
   return PhoneGlobals.getInstance().ringer.isRinging();
 }
  @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;
  }