/* Sets the default subscription. If only one phone instance is active that
   * subscription is set as default subscription. If both phone instances
   * are active the first instance "0" is set as default subscription
   */
  public static void setDefaultSubscription(int subId) {
    SystemProperties.set(PROPERTY_DEFAULT_SUBSCRIPTION, Integer.toString(subId));
    int phoneId = SubscriptionController.getInstance().getPhoneId(subId);

    synchronized (sLockProxyPhones) {
      // Set the default phone in base class
      if (phoneId >= 0 && phoneId < sProxyPhones.length) {
        sProxyPhone = sProxyPhones[phoneId];
        sCommandsInterface = sCommandsInterfaces[phoneId];
        sMadeDefaults = true;
      }
    }

    // Update MCC MNC device configuration information
    String defaultMccMnc = TelephonyManager.getDefault().getSimOperatorNumericForPhone(phoneId);
    if (DBG) Rlog.d(LOG_TAG, "update mccmnc=" + defaultMccMnc);
    MccTable.updateMccMncConfiguration(sContext, defaultMccMnc, false);

    // Broadcast an Intent for default sub change
    Intent intent = new Intent(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED);
    intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
    SubscriptionManager.putPhoneIdAndSubIdExtra(intent, phoneId);
    Rlog.d(
        LOG_TAG,
        "setDefaultSubscription : " + subId + " Broadcasting Default Subscription Changed...");
    sContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
  }
Ejemplo n.º 2
0
  private void parseSmsDeliver(PduParser p, int firstByte) {
    mReplyPathPresent = (firstByte & 0x80) == 0x80;

    mOriginatingAddress = p.getAddress();

    if (mOriginatingAddress != null) {
      if (VDBG) Rlog.v(LOG_TAG, "SMS originating address: " + mOriginatingAddress.address);
    }

    // TP-Protocol-Identifier (TP-PID)
    // TS 23.040 9.2.3.9
    mProtocolIdentifier = p.getByte();

    // TP-Data-Coding-Scheme
    // see TS 23.038
    mDataCodingScheme = p.getByte();

    if (VDBG) {
      Rlog.v(
          LOG_TAG,
          "SMS TP-PID:" + mProtocolIdentifier + " data coding scheme: " + mDataCodingScheme);
    }

    mScTimeMillis = p.getSCTimestampMillis();

    if (VDBG) Rlog.d(LOG_TAG, "SMS SC timestamp: " + mScTimeMillis);

    boolean hasUserDataHeader = (firstByte & 0x40) == 0x40;

    parseUserData(p, hasUserDataHeader);
  }
  /**
   * Returns the tpdu from the pdu
   *
   * @return the tpdu for the message.
   * @hide
   */
  public byte[] getTpdu(String format) {
    Rlog.d(LOG_TAG, "call getTpdu with format: " + format);
    byte[] pdu = this.getPdu();
    if (format.equals(FORMAT_3GPP)) {
      if (pdu == null) {
        Rlog.d(LOG_TAG, "pdu is null");
        return null;
      }

      int smsc_len = (pdu[0] & 0xff) + 1;
      int tpdu_len = pdu.length - smsc_len;
      byte[] tpdu = new byte[tpdu_len];

      try {
        System.arraycopy(pdu, smsc_len, tpdu, 0, tpdu.length);
        return tpdu;
      } catch (ArrayIndexOutOfBoundsException e) {
        Rlog.e(LOG_TAG, "Out of boudns");
        return null;
      }
    } else if (format.equals(FORMAT_3GPP2)) {
      return pdu;
    }

    return super.getTpdu();
  }
Ejemplo n.º 4
0
  /**
   * Create an SmsMessage from an SMS EF record.
   *
   * @param index Index of SMS record. This should be index in ArrayList returned by
   *     SmsManager.getAllMessagesFromSim + 1.
   * @param data Record data.
   * @return An SmsMessage representing the record.
   * @hide
   */
  public static SmsMessage createFromEfRecord(int index, byte[] data) {
    try {
      SmsMessage msg = new SmsMessage();

      msg.mIndexOnIcc = index;

      // First byte is status: RECEIVED_READ, RECEIVED_UNREAD, STORED_SENT,
      // or STORED_UNSENT
      // See TS 51.011 10.5.3
      if ((data[0] & 1) == 0) {
        Rlog.w(LOG_TAG, "SMS parsing failed: Trying to parse a free record");
        return null;
      } else {
        msg.mStatusOnIcc = data[0] & 0x07;
      }

      int size = data.length - 1;

      // Note: Data may include trailing FF's.  That's OK; message
      // should still parse correctly.
      byte[] pdu = new byte[size];
      System.arraycopy(data, 1, pdu, 0, size);
      msg.parsePdu(pdu);
      return msg;
    } catch (RuntimeException ex) {
      Rlog.e(LOG_TAG, "SMS PDU parsing failed: ", ex);
      return null;
    }
  }
Ejemplo n.º 5
0
  /**
   * @return a geographical description string for the specified number.
   * @see com.android.i18n.phonenumbers.PhoneNumberOfflineGeocoder
   */
  private static String getGeoDescription(Context context, String number) {
    if (VDBG) Rlog.v(TAG, "getGeoDescription('" + number + "')...");

    if (TextUtils.isEmpty(number)) {
      return null;
    }

    PhoneNumberUtil util = PhoneNumberUtil.getInstance();
    PhoneNumberOfflineGeocoder geocoder = PhoneNumberOfflineGeocoder.getInstance();

    Locale locale = context.getResources().getConfiguration().locale;
    String countryIso = getCurrentCountryIso(context, locale);
    PhoneNumber pn = null;
    try {
      if (VDBG) Rlog.v(TAG, "parsing '" + number + "' for countryIso '" + countryIso + "'...");
      pn = util.parse(number, countryIso);
      if (VDBG) Rlog.v(TAG, "- parsed number: " + pn);
    } catch (NumberParseException e) {
      Rlog.w(TAG, "getGeoDescription: NumberParseException for incoming number '" + number + "'");
    }

    if (pn != null) {
      String description = geocoder.getDescriptionForNumber(pn, locale);
      if (VDBG) Rlog.v(TAG, "- got description: '" + description + "'");
      return description;
    } else {
      return null;
    }
  }
  private void onUpdateIccAvailability() {
    if (mUiccController == null) {
      return;
    }

    UiccCardApplication newUiccApplication = getUiccCardApplication();

    UiccCardApplication app = mUiccApplication.get();
    if (app != newUiccApplication) {
      if (app != null) {
        Rlog.d(TAG, "Removing stale icc objects.");
        if (mIccRecords.get() != null) {
          mIccRecords.get().unregisterForNewSms(this);
        }
        mIccRecords.set(null);
        mUiccApplication.set(null);
      }
      if (newUiccApplication != null) {
        Rlog.d(TAG, "New Uicc application found");
        mUiccApplication.set(newUiccApplication);
        mIccRecords.set(newUiccApplication.getIccRecords());
        if (mIccRecords.get() != null) {
          mIccRecords.get().registerForNewSms(this, EVENT_NEW_ICC_SMS, null);
        }
      }
    }
  }
 /**
  * Set audio parameter "wb_amr" for HD-Voice (Wideband AMR).
  *
  * @param state: 0 = unsupported, 1 = supported. REQUIRED FOR JF FAMILY THIS SETS THE INFORMATION
  *     CRASHES WITHOUT THIS FUNCTION part of the new csd binary
  */
 private void setWbAmr(int state) {
   if (state == 1) {
     Rlog.d(RILJ_LOG_TAG, "setWbAmr(): setting audio parameter - wb_amr=on");
     mAudioManager.setParameters("wide_voice_enable=true");
   } else if (state == 0) {
     Rlog.d(RILJ_LOG_TAG, "setWbAmr(): setting audio parameter - wb_amr=off");
     mAudioManager.setParameters("wide_voice_enable=false");
   }
 }
  @Override
  protected void processUnsolicited(Parcel p) {
    Object ret;
    int dataPosition = p.dataPosition(); // save off position within the Parcel
    int response = p.readInt();

    switch (response) {
      case RIL_UNSOL_RIL_CONNECTED: // Fix for NV/RUIM setting on CDMA SIM devices
        // skip getcdmascriptionsource as if qualcomm handles it in the ril binary
        ret = responseInts(p);
        setRadioPower(false, null);
        setPreferredNetworkType(mPreferredNetworkType, null);
        int cdmaSubscription =
            Settings.Global.getInt(
                mContext.getContentResolver(), Settings.Global.CDMA_SUBSCRIPTION_MODE, -1);
        if (cdmaSubscription != -1) {
          setCdmaSubscriptionSource(mCdmaSubscription, null);
        }
        setCellInfoListRate(Integer.MAX_VALUE, null);
        notifyRegistrantsRilConnectionChanged(((int[]) ret)[0]);
        break;
      case RIL_UNSOL_NITZ_TIME_RECEIVED:
        handleNitzTimeReceived(p);
        break;
        // SAMSUNG STATES
      case SamsungExynos4RIL.RIL_UNSOL_AM:
        ret = responseString(p);
        String amString = (String) ret;
        Rlog.d(RILJ_LOG_TAG, "Executing AM: " + amString);

        try {
          Runtime.getRuntime().exec("am " + amString);
        } catch (IOException e) {
          e.printStackTrace();
          Rlog.e(RILJ_LOG_TAG, "am " + amString + " could not be executed.");
        }
        break;
      case SamsungExynos4RIL.RIL_UNSOL_RESPONSE_HANDOVER:
        ret = responseVoid(p);
        break;
      case 1036:
        ret = responseVoid(p);
        break;
      case SamsungExynos4RIL.RIL_UNSOL_WB_AMR_STATE:
        ret = responseInts(p);
        setWbAmr(((int[]) ret)[0]);
        break;
      default:
        // Rewind the Parcel
        p.setDataPosition(dataPosition);

        // Forward responses that we are not overriding to the super class
        super.processUnsolicited(p);
        return;
    }
  }
 /**
  * Create an SmsMessage from a raw PDU.
  *
  * @param pdu raw data for creating short message
  * @param simId SIM ID
  */
 public static GeminiSmsMessage createFromPdu(byte[] pdu, int simId) {
   String format = GeminiSmsMessage.getSmsFormat(simId);
   Rlog.d(LOG_TAG, "create SmsMessage from pdu with format " + format);
   SmsMessage sms = createFromPdu(pdu, format);
   if (sms != null) {
     return new GeminiSmsMessage(sms, simId);
   } else {
     Rlog.d(LOG_TAG, "fail to create SmsMessage from pdu");
     return null;
   }
 }
Ejemplo n.º 10
0
 /** Create an SmsMessage from a raw PDU. */
 public static SmsMessage createFromPdu(byte[] pdu) {
   try {
     SmsMessage msg = new SmsMessage();
     msg.parsePdu(pdu);
     return msg;
   } catch (RuntimeException ex) {
     Rlog.e(LOG_TAG, "SMS PDU parsing failed: ", ex);
     return null;
   } catch (OutOfMemoryError e) {
     Rlog.e(LOG_TAG, "SMS PDU parsing failed with out of memory: ", e);
     return null;
   }
 }
 private void readFromParcel(Parcel in) {
   dialogSize = in.readInt();
   Rlog.d(TAG, "readFromParcel size = " + dialogSize);
   if (dialogSize < 0) {
     return;
   }
   callInfo = new ArrayList<String[]>();
   for (int i = 0; i < dialogSize; i++) {
     String[] info = new String[INDEX_MAX];
     info = in.createStringArray(); // read each string[]
     callInfo.add(info);
   }
   Rlog.d(TAG, "readFromParcel - " + toString());
 }
  /* Returns User SMS Prompt property,  enabled or not */
  public static boolean isSMSPromptEnabled() {
    boolean prompt = false;
    int value = 0;
    try {
      value =
          Settings.Global.getInt(
              sContext.getContentResolver(), Settings.Global.MULTI_SIM_SMS_PROMPT);
    } catch (SettingNotFoundException snfe) {
      Rlog.e(LOG_TAG, "Settings Exception Reading Dual Sim SMS Prompt Values");
    }
    prompt = (value == 0) ? false : true;
    Rlog.d(LOG_TAG, "SMS Prompt option:" + prompt);

    return prompt;
  }
  // Workaround for Samsung CDMA "ring of death" bug:
  //
  // Symptom: As soon as the phone receives notice of an incoming call, an
  // audible "old fashioned ring" is emitted through the earpiece and
  // persists through the duration of the call, or until reboot if the call
  // isn't answered.
  //
  // Background: The CDMA telephony stack implements a number of "signal info
  // tones" that are locally generated by ToneGenerator and mixed into the
  // voice call path in response to radio RIL_UNSOL_CDMA_INFO_REC requests.
  // One of these tones, IS95_CONST_IR_SIG_IS54B_L, is requested by the
  // radio just prior to notice of an incoming call when the voice call
  // path is muted. CallNotifier is responsible for stopping all signal
  // tones (by "playing" the TONE_CDMA_SIGNAL_OFF tone) upon receipt of a
  // "new ringing connection", prior to unmuting the voice call path.
  //
  // Problem: CallNotifier's incoming call path is designed to minimize
  // latency to notify users of incoming calls ASAP. Thus,
  // SignalInfoTonePlayer requests are handled asynchronously by spawning a
  // one-shot thread for each. Unfortunately the ToneGenerator API does
  // not provide a mechanism to specify an ordering on requests, and thus,
  // unexpected thread interleaving may result in ToneGenerator processing
  // them in the opposite order that CallNotifier intended. In this case,
  // playing the "signal off" tone first, followed by playing the "old
  // fashioned ring" indefinitely.
  //
  // Solution: An API change to ToneGenerator is required to enable
  // SignalInfoTonePlayer to impose an ordering on requests (i.e., drop any
  // request that's older than the most recent observed). Such a change,
  // or another appropriate fix should be implemented in AOSP first.
  //
  // Workaround: Intercept RIL_UNSOL_CDMA_INFO_REC requests from the radio,
  // check for a signal info record matching IS95_CONST_IR_SIG_IS54B_L, and
  // drop it so it's never seen by CallNotifier. If other signal tones are
  // observed to cause this problem, they should be dropped here as well.
  @Override
  protected void notifyRegistrantsCdmaInfoRec(CdmaInformationRecords infoRec) {
    final int response = RIL_UNSOL_CDMA_INFO_REC;

    if (infoRec.record instanceof CdmaSignalInfoRec) {
      CdmaSignalInfoRec sir = (CdmaSignalInfoRec) infoRec.record;
      if (sir != null
          && sir.isPresent
          && sir.signalType == SignalToneUtil.IS95_CONST_IR_SIGNAL_IS54B
          && sir.alertPitch == SignalToneUtil.IS95_CONST_IR_ALERT_MED
          && sir.signal == SignalToneUtil.IS95_CONST_IR_SIG_IS54B_L) {

        Rlog.d(
            RILJ_LOG_TAG,
            "Dropping \""
                + responseToString(response)
                + " "
                + retToString(response, sir)
                + "\" to prevent \"ring of death\" bug.");
        return;
      }
    }

    super.notifyRegistrantsCdmaInfoRec(infoRec);
  }
Ejemplo n.º 14
0
  /**
   * Parses a SMS-SUBMIT message.
   *
   * @param p A PduParser, cued past the first byte.
   * @param firstByte The first byte of the PDU, which contains MTI, etc.
   */
  private void parseSmsSubmit(PduParser p, int firstByte) {
    mReplyPathPresent = (firstByte & 0x80) == 0x80;

    // TP-MR (TP-Message Reference)
    mMessageRef = p.getByte();

    mRecipientAddress = p.getAddress();

    if (mRecipientAddress != null) {
      if (VDBG) Rlog.v(LOG_TAG, "SMS recipient address: " + mRecipientAddress.address);
    }

    // TP-Protocol-Identifier (TP-PID)
    // TS 23.040 9.2.3.9
    mProtocolIdentifier = p.getByte();

    // TP-Data-Coding-Scheme
    // see TS 23.038
    mDataCodingScheme = p.getByte();

    if (VDBG) {
      Rlog.v(
          LOG_TAG,
          "SMS TP-PID:" + mProtocolIdentifier + " data coding scheme: " + mDataCodingScheme);
    }

    // TP-Validity-Period-Format
    int validityPeriodLength = 0;
    int validityPeriodFormat = ((firstByte >> 3) & 0x3);
    if (0x0 == validityPeriodFormat) /* 00, TP-VP field not present*/ {
      validityPeriodLength = 0;
    } else if (0x2 == validityPeriodFormat) /* 10, TP-VP: relative format*/ {
      validityPeriodLength = 1;
    } else /* other case, 11 or 01, TP-VP: absolute or enhanced format*/ {
      validityPeriodLength = 7;
    }

    // TP-Validity-Period is not used on phone, so just ignore it for now.
    while (validityPeriodLength-- > 0) {
      p.getByte();
    }

    boolean hasUserDataHeader = (firstByte & 0x40) == 0x40;

    parseUserData(p, hasUserDataHeader);
  }
Ejemplo n.º 15
0
 /** @return The ISO 3166-1 two letters country code of the country the user is in. */
 private static String getCurrentCountryIso(Context context, Locale locale) {
   String countryIso = null;
   CountryDetector detector = (CountryDetector) context.getSystemService(Context.COUNTRY_DETECTOR);
   if (detector != null) {
     Country country = detector.detectCountry();
     if (country != null) {
       countryIso = country.getCountryIso();
     } else {
       Rlog.e(TAG, "CountryDetector.detectCountry() returned null.");
     }
   }
   if (countryIso == null) {
     countryIso = locale.getCountry();
     Rlog.w(TAG, "No CountryDetector; falling back to countryIso based on locale: " + countryIso);
   }
   return countryIso;
 }
 /**
  * dialogIds Will have following information - dialogIds[INDEX_DIALOG_ID] - Holds Unique DialogId
  * dialogIds[INDEX_NUMBER] - Holds number/uri dialogIds[INDEX_ISPULLABLE] - Pullable/NonPullable
  * (true, false) dialogIds[INDEX_CALLTYPE] - CallType CallType - volteactive, volteheld, vttxrx,
  * vttx, vtrx, vtheld dialogIds[INDEX_DIRECTION] - Direction of the call (Originator/recipent)
  */
 public QtiViceInfo(List<String[]> dialogIds) {
   if (dialogIds != null) {
     callInfo = new ArrayList<String[]>();
     dialogSize = dialogIds.size();
     callInfo = dialogIds;
     Rlog.d(TAG, "QtiViceInfo const = " + toString());
   }
 }
  private void dumpState() {
    List l;

    Rlog.i(LOG_TAG, "Phone State:" + state);

    Rlog.i(LOG_TAG, "Ringing call: " + ringingCall.toString());

    l = ringingCall.getConnections();
    for (int i = 0, s = l.size(); i < s; i++) {
      Rlog.i(LOG_TAG, l.get(i).toString());
    }

    Rlog.i(LOG_TAG, "Foreground call: " + foregroundCall.toString());

    l = foregroundCall.getConnections();
    for (int i = 0, s = l.size(); i < s; i++) {
      Rlog.i(LOG_TAG, l.get(i).toString());
    }

    Rlog.i(LOG_TAG, "Background call: " + backgroundCall.toString());

    l = backgroundCall.getConnections();
    for (int i = 0, s = l.size(); i < s; i++) {
      Rlog.i(LOG_TAG, l.get(i).toString());
    }
  }
Ejemplo n.º 18
0
  /** Process a MMI PUK code */
  void processCode() {
    try {
      if (isPinPukCommand()) {
        // TODO: This is the same as the code in GsmMmiCode.java,
        // MmiCode should be an abstract or base class and this and
        // other common variables and code should be promoted.

        // sia = old PIN or PUK
        // sib = new PIN
        // sic = new PIN
        String oldPinOrPuk = mSia;
        String newPinOrPuk = mSib;
        int pinLen = newPinOrPuk.length();
        if (isRegister()) {
          if (!newPinOrPuk.equals(mSic)) {
            // password mismatch; return error
            handlePasswordError(com.android.internal.R.string.mismatchPin);
          } else if (pinLen < 4 || pinLen > 8) {
            // invalid length
            handlePasswordError(com.android.internal.R.string.invalidPin);
          } else if (mSc.equals(SC_PIN)
              && mUiccApplication != null
              && mUiccApplication.getState() == AppState.APPSTATE_PUK) {
            // Sim is puk-locked
            handlePasswordError(com.android.internal.R.string.needPuk);
          } else if (mUiccApplication != null) {
            Rlog.d(LOG_TAG, "process mmi service code using UiccApp sc=" + mSc);

            // We have an app and the pre-checks are OK
            if (mSc.equals(SC_PIN)) {
              mUiccApplication.changeIccLockPassword(
                  oldPinOrPuk, newPinOrPuk, obtainMessage(EVENT_SET_COMPLETE, this));
            } else if (mSc.equals(SC_PIN2)) {
              mUiccApplication.changeIccFdnPassword(
                  oldPinOrPuk, newPinOrPuk, obtainMessage(EVENT_SET_COMPLETE, this));
            } else if (mSc.equals(SC_PUK)) {
              mUiccApplication.supplyPuk(
                  oldPinOrPuk, newPinOrPuk, obtainMessage(EVENT_SET_COMPLETE, this));
            } else if (mSc.equals(SC_PUK2)) {
              mUiccApplication.supplyPuk2(
                  oldPinOrPuk, newPinOrPuk, obtainMessage(EVENT_SET_COMPLETE, this));
            } else {
              throw new RuntimeException("Unsupported service code=" + mSc);
            }
          } else {
            throw new RuntimeException("No application mUiccApplicaiton is null");
          }
        } else {
          throw new RuntimeException("Ivalid register/action=" + mAction);
        }
      }
    } catch (RuntimeException exc) {
      mState = State.FAILED;
      mMessage = mContext.getText(com.android.internal.R.string.mmiError);
      mPhone.onMMIDone(this);
    }
  }
Ejemplo n.º 19
0
 /** @hide */
 public static SmsMessage newFromCDS(String line) {
   try {
     SmsMessage msg = new SmsMessage();
     msg.parsePdu(IccUtils.hexStringToBytes(line));
     return msg;
   } catch (RuntimeException ex) {
     Rlog.e(LOG_TAG, "CDS SMS PDU parsing failed: ", ex);
     return null;
   }
 }
Ejemplo n.º 20
0
  /**
   * Get an SMS-SUBMIT PDU for a data message to a destination address &amp; port
   *
   * @param scAddress Service Centre address. null == use default
   * @param destinationAddress the address of the destination for the message
   * @param destinationPort the port to deliver the message to at the destination
   * @param data the data for the message
   * @return a <code>SubmitPdu</code> containing the encoded SC address, if applicable, and the
   *     encoded message. Returns null on encode error.
   */
  public static SubmitPdu getSubmitPdu(
      String scAddress,
      String destinationAddress,
      int destinationPort,
      byte[] data,
      boolean statusReportRequested) {

    SmsHeader.PortAddrs portAddrs = new SmsHeader.PortAddrs();
    portAddrs.destPort = destinationPort;
    portAddrs.origPort = 0;
    portAddrs.areEightBits = false;

    SmsHeader smsHeader = new SmsHeader();
    smsHeader.portAddrs = portAddrs;

    byte[] smsHeaderData = SmsHeader.toByteArray(smsHeader);

    if ((data.length + smsHeaderData.length + 1) > MAX_USER_DATA_BYTES) {
      Rlog.e(
          LOG_TAG,
          "SMS data message may only contain "
              + (MAX_USER_DATA_BYTES - smsHeaderData.length - 1)
              + " bytes");
      return null;
    }

    SubmitPdu ret = new SubmitPdu();
    ByteArrayOutputStream bo =
        getSubmitPduHead(
            scAddress,
            destinationAddress,
            (byte) 0x41, // MTI = SMS-SUBMIT,
            // TP-UDHI = true
            statusReportRequested,
            ret);

    // TP-Data-Coding-Scheme
    // No class, 8 bit data
    bo.write(0x04);

    // (no TP-Validity-Period)

    // Total size
    bo.write(data.length + smsHeaderData.length + 1);

    // User data header
    bo.write(smsHeaderData.length);
    bo.write(smsHeaderData, 0, smsHeaderData.length);

    // User data
    bo.write(data, 0, data.length);

    ret.encodedMessage = bo.toByteArray();
    return ret;
  }
 void hangupAllConnections(GsmCall call) throws CallStateException {
   try {
     int count = call.connections.size();
     for (int i = 0; i < count; i++) {
       GsmConnection cn = (GsmConnection) call.connections.get(i);
       cm.hangupConnection(cn.getGSMIndex(), obtainCompleteMessage());
     }
   } catch (CallStateException ex) {
     Rlog.e(LOG_TAG, "hangupConnectionByIndex caught " + ex);
   }
 }
Ejemplo n.º 22
0
  @Override
  public void handleMessage(Message msg) {
    AsyncResult ar;

    if (msg.what == EVENT_SET_COMPLETE) {
      ar = (AsyncResult) (msg.obj);
      onSetComplete(msg, ar);
    } else {
      Rlog.e(LOG_TAG, "Unexpected reply");
    }
  }
  /** {@inheritDoc} */
  @Override
  protected void sendText(
      String destAddr,
      String scAddr,
      String text,
      PendingIntent sentIntent,
      PendingIntent deliveryIntent,
      Uri messageUri,
      String callingPkg,
      int priority,
      boolean isExpectMore,
      int validityPeriod) {
    SmsMessage.SubmitPdu pdu =
        SmsMessage.getSubmitPdu(scAddr, destAddr, text, (deliveryIntent != null), validityPeriod);
    if (pdu != null) {
      HashMap map = getSmsTrackerMap(destAddr, scAddr, text, pdu);
      SmsTracker tracker =
          getSmsTracker(
              map,
              sentIntent,
              deliveryIntent,
              getFormat(),
              messageUri,
              isExpectMore,
              text /*fullMessageText*/,
              true /*isText*/,
              validityPeriod);

      String carrierPackage = getCarrierAppPackageName();
      if (carrierPackage != null) {
        Rlog.d(TAG, "Found carrier package.");
        TextSmsSender smsSender = new TextSmsSender(tracker);
        smsSender.sendSmsByCarrierApp(carrierPackage, new SmsSenderCallback(smsSender));
      } else {
        Rlog.v(TAG, "No carrier package.");
        sendRawPdu(tracker);
      }
    } else {
      Rlog.e(TAG, "GsmSMSDispatcher.sendText(): getSubmitPdu() returned null");
    }
  }
  /** {@inheritDoc} */
  @Override
  protected void sendSms(SmsTracker tracker) {
    HashMap<String, Object> map = tracker.mData;

    byte pdu[] = (byte[]) map.get("pdu");

    if (tracker.mRetryCount > 0) {
      Rlog.d(
          TAG,
          "sendSms: "
              + " mRetryCount="
              + tracker.mRetryCount
              + " mMessageRef="
              + tracker.mMessageRef
              + " SS="
              + mPhone.getServiceState().getState());

      // per TS 23.040 Section 9.2.3.6:  If TP-MTI SMS-SUBMIT (0x01) type
      //   TP-RD (bit 2) is 1 for retry
      //   and TP-MR is set to previously failed sms TP-MR
      if (((0x01 & pdu[0]) == 0x01)) {
        pdu[0] |= 0x04; // TP-RD
        pdu[1] = (byte) tracker.mMessageRef; // TP-MR
      }
    }
    Rlog.d(
        TAG,
        "sendSms: "
            + " isIms()="
            + isIms()
            + " mRetryCount="
            + tracker.mRetryCount
            + " mImsRetry="
            + tracker.mImsRetry
            + " mMessageRef="
            + tracker.mMessageRef
            + " SS="
            + mPhone.getServiceState().getState());

    sendSmsByPstn(tracker);
  }
Ejemplo n.º 25
0
  protected String getEFPath(int efid, boolean is7FFF) {
    // TODO(): DF_GSM can be 7F20 or 7F21 to handle backward compatibility.
    // Implement this after discussion with OEMs.
    String DF_APP = DF_GSM;

    if ((mParentApp != null)
        && (mParentApp.getType() == IccCardApplicationStatus.AppType.APPTYPE_USIM)) {
      DF_APP = DF_USIM;
    }

    switch (efid) {
      case EF_SMS:
      case EF_SMSP: // [ALPS01206315] Support EF_SMSP
        return /*MF_SIM +*/ DF_TELECOM;

      case EF_ICCID:
        return null;
      case EF_EXT6:
      case EF_MWIS:
      case EF_MBI:
      case EF_SPN:
      case EF_AD:
      case EF_MBDN:
      case EF_PNN:
      case EF_SPDI:
      case EF_SST:
      case EF_CFIS:
      case EF_GID1:
        return /*MF_SIM +*/ DF_APP;

      case EF_MAILBOX_CPHS:
      case EF_VOICE_MAIL_INDICATOR_CPHS:
      case EF_CFF_CPHS:
      case EF_SPN_CPHS:
      case EF_SPN_SHORT_CPHS:
      case EF_INFO_CPHS:
      case EF_CSP_CPHS:
        return MF_SIM + DF_GSM;
      case EF_GID2:
      case EF_ECC:
      case EF_OPL:
        return /*MF_SIM +*/ DF_APP;
      case EF_RAT: // ALPS00302702 RAT balancing (ADF(USIM)/7F66/5F30/EF_RAT)
        return DF_USIM + "7F66" + "5F30";
      case EF_CSIM_IMSIM:
        return MF_SIM + DF_CDMA;
    }
    String path = getCommonIccEFPath(efid);
    if (path == null) {
      Rlog.e(LOG_TAG, "Error: EF Path being returned in null");
    }
    return path;
  }
  /* Gets User preferred SMS subscription setting*/
  public static int getSMSSubscription() {
    int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    try {
      subId =
          Settings.Global.getInt(
              sContext.getContentResolver(), Settings.Global.MULTI_SIM_SMS_SUBSCRIPTION);
    } catch (SettingNotFoundException snfe) {
      Rlog.e(LOG_TAG, "Settings Exception Reading Dual Sim SMS Values");
    }

    return subId;
  }
  public void dispose() {
    // Unregister for all events
    cm.unregisterForCallStateChanged(this);
    cm.unregisterForOn(this);
    cm.unregisterForNotAvailable(this);

    for (GsmConnection c : connections) {
      try {
        if (c != null) hangup(c);
      } catch (CallStateException ex) {
        Rlog.e(LOG_TAG, "unexpected error on hangup during dispose");
      }
    }

    try {
      if (pendingMO != null) hangup(pendingMO);
    } catch (CallStateException ex) {
      Rlog.e(LOG_TAG, "unexpected error on hangup during dispose");
    }

    clearDisconnected();
  }
 /*package*/ void separate(GsmConnection conn) throws CallStateException {
   if (conn.owner != this) {
     throw new CallStateException(
         "GsmConnection " + conn + "does not belong to GsmCallTracker " + this);
   }
   try {
     cm.separateConnection(conn.getGSMIndex(), obtainCompleteMessage(EVENT_SEPARATE_RESULT));
   } catch (CallStateException ex) {
     // Ignore "connection not found"
     // Call may have hung up already
     Rlog.w(LOG_TAG, "GsmCallTracker WARN: separate() on absent connection " + conn);
   }
 }
 public GsmSMSDispatcher(
     PhoneBase phone,
     SmsUsageMonitor usageMonitor,
     ImsSMSDispatcher imsSMSDispatcher,
     GsmInboundSmsHandler gsmInboundSmsHandler) {
   super(phone, usageMonitor, imsSMSDispatcher);
   mCi.setOnSmsStatus(this, EVENT_NEW_SMS_STATUS_REPORT, null);
   mCi.setOnSmsOnSim(this, EVENT_SMS_ON_ICC, null);
   mGsmInboundSmsHandler = gsmInboundSmsHandler;
   mUiccController = UiccController.getInstance();
   mUiccController.registerForIccChanged(this, EVENT_ICC_CHANGED, null);
   Rlog.d(TAG, "GsmSMSDispatcher created");
 }
Ejemplo n.º 30
0
    /**
     * Interprets the user data payload as KSC-5601 characters, and decodes them into a String.
     *
     * @param byteCount the number of bytes in the user data payload
     * @return a String with the decoded characters
     */
    String getUserDataKSC5601(int byteCount) {
      String ret;

      try {
        ret = new String(mPdu, mCur, byteCount, "KSC5601");
      } catch (UnsupportedEncodingException ex) {
        ret = "";
        Rlog.e(LOG_TAG, "implausible UnsupportedEncodingException", ex);
      }

      mCur += byteCount;
      return ret;
    }