Beispiel #1
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 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);
  }
Beispiel #3
0
  /**
   * Returns the column index to use to find the "person_id" field in the specified cursor, based on
   * the contact URI that was originally queried.
   *
   * <p>This is a helper function for the getCallerInfo() method that takes a Cursor. Looking up the
   * person_id is nontrivial (compared to all the other CallerInfo fields) since the column we need
   * to use depends on what query we originally ran.
   *
   * <p>Watch out: be sure to not do any database access in this method, since it's run from the UI
   * thread (see comments below for more info.)
   *
   * @return the columnIndex to use (with cursor.getLong()) to get the person_id, or -1 if we
   *     couldn't figure out what colum to use.
   *     <p>TODO: Add a unittest for this method. (This is a little tricky to test, since we'll need
   *     a live contacts database to test against, preloaded with at least some phone numbers and
   *     SIP addresses. And we'll probably have to hardcode the column indexes we expect, so the
   *     test might break whenever the contacts schema changes. But we can at least make sure we
   *     handle all the URI patterns we claim to, and that the mime types match what we expect...)
   */
  private static int getColumnIndexForPersonId(Uri contactRef, Cursor cursor) {
    // TODO: This is pretty ugly now, see bug 2269240 for
    // more details. The column to use depends upon the type of URL:
    // - content://com.android.contacts/data/phones ==> use the "contact_id" column
    // - content://com.android.contacts/phone_lookup ==> use the "_ID" column
    // - content://com.android.contacts/data ==> use the "contact_id" column
    // If it's none of the above, we leave columnIndex=-1 which means
    // that the person_id field will be left unset.
    //
    // The logic here *used* to be based on the mime type of contactRef
    // (for example Phone.CONTENT_ITEM_TYPE would tell us to use the
    // RawContacts.CONTACT_ID column).  But looking up the mime type requires
    // a call to context.getContentResolver().getType(contactRef), which
    // isn't safe to do from the UI thread since it can cause an ANR if
    // the contacts provider is slow or blocked (like during a sync.)
    //
    // So instead, figure out the column to use for person_id by just
    // looking at the URI itself.

    if (VDBG) Rlog.v(TAG, "- getColumnIndexForPersonId: contactRef URI = '" + contactRef + "'...");
    // Warning: Do not enable the following logging (due to ANR risk.)
    // if (VDBG) Rlog.v(TAG, "- MIME type: "
    //                 + context.getContentResolver().getType(contactRef));

    String url = contactRef.toString();
    String columnName = null;
    if (url.startsWith("content://com.android.contacts/data/phones")) {
      // Direct lookup in the Phone table.
      // MIME type: Phone.CONTENT_ITEM_TYPE (= "vnd.android.cursor.item/phone_v2")
      if (VDBG) Rlog.v(TAG, "'data/phones' URI; using RawContacts.CONTACT_ID");
      columnName = RawContacts.CONTACT_ID;
    } else if (url.startsWith("content://com.android.contacts/data")) {
      // Direct lookup in the Data table.
      // MIME type: Data.CONTENT_TYPE (= "vnd.android.cursor.dir/data")
      if (VDBG) Rlog.v(TAG, "'data' URI; using Data.CONTACT_ID");
      // (Note Data.CONTACT_ID and RawContacts.CONTACT_ID are equivalent.)
      columnName = Data.CONTACT_ID;
    } else if (url.startsWith("content://com.android.contacts/phone_lookup")) {
      // Lookup in the PhoneLookup table, which provides "fuzzy matching"
      // for phone numbers.
      // MIME type: PhoneLookup.CONTENT_TYPE (= "vnd.android.cursor.dir/phone_lookup")
      if (VDBG) Rlog.v(TAG, "'phone_lookup' URI; using PhoneLookup._ID");
      columnName = PhoneLookup._ID;
    } else {
      Rlog.w(TAG, "Unexpected prefix for contactRef '" + url + "'");
    }
    int columnIndex = (columnName != null) ? cursor.getColumnIndex(columnName) : -1;
    if (VDBG)
      Rlog.v(
          TAG,
          "==> Using column '"
              + columnName
              + "' (columnIndex = "
              + columnIndex
              + ") for person_id lookup...");
    return columnIndex;
  }
  /**
   * 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);
  }
  /** {@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");
    }
  }
 public int getNumOfVoicemails() {
   /*
    * Order of priority if multiple indications are present is 1.UDH,
    *      2.DCS, 3.CPHS.
    * Voice mail count if voice mail present indication is
    * received
    *  1. UDH (or both UDH & DCS): mVoiceMailCount = 0 to 0xff. Ref[TS 23. 040]
    *  2. DCS only: count is unknown mVoiceMailCount= -1
    *  3. CPHS only: count is unknown mVoiceMailCount = 0xff. Ref[GSM-BTR-1-4700]
    * Voice mail clear, mVoiceMailCount = 0.
    */
   if ((!mIsMwi) && isCphsMwiMessage()) {
     if (mOriginatingAddress != null
         && ((GsmSmsAddress) mOriginatingAddress).isCphsVoiceMessageSet()) {
       mVoiceMailCount = 0xff;
     } else {
       mVoiceMailCount = 0;
     }
     Rlog.v(LOG_TAG, "CPHS voice mail message");
   }
   return mVoiceMailCount;
 }
  /** {@inheritDoc} */
  @Override
  protected void sendData(
      String destAddr,
      String scAddr,
      int destPort,
      int origPort,
      byte[] data,
      PendingIntent sentIntent,
      PendingIntent deliveryIntent) {
    SmsMessage.SubmitPdu pdu =
        SmsMessage.getSubmitPdu(
            scAddr, destAddr, destPort, origPort, data, (deliveryIntent != null));
    if (pdu != null) {
      HashMap map = getSmsTrackerMap(destAddr, scAddr, destPort, origPort, data, pdu);
      SmsTracker tracker =
          getSmsTracker(
              map,
              sentIntent,
              deliveryIntent,
              getFormat(),
              null /*messageUri*/,
              false /*isExpectMore*/,
              null /*fullMessageText*/,
              false /*isText*/);

      String carrierPackage = getCarrierAppPackageName();
      if (carrierPackage != null) {
        Rlog.d(TAG, "Found carrier package.");
        DataSmsSender smsSender = new DataSmsSender(tracker);
        smsSender.sendSmsByCarrierApp(carrierPackage, new SmsSenderCallback(smsSender));
      } else {
        Rlog.v(TAG, "No carrier package.");
        sendRawPdu(tracker);
      }
    } else {
      Rlog.e(TAG, "GsmSMSDispatcher.sendData(): getSubmitPdu() returned null");
    }
  }
  /**
   * Parses the User Data of an SMS.
   *
   * @param p The current PduParser.
   * @param hasUserDataHeader Indicates whether a header is present in the User Data.
   */
  private void parseUserData(PduParser p, boolean hasUserDataHeader) {
    boolean hasMessageClass = false;
    boolean userDataCompressed = false;

    int encodingType = ENCODING_UNKNOWN;

    // Look up the data encoding scheme
    if ((mDataCodingScheme & 0x80) == 0) {
      userDataCompressed = (0 != (mDataCodingScheme & 0x20));
      hasMessageClass = (0 != (mDataCodingScheme & 0x10));

      if (userDataCompressed) {
        Rlog.w(
            LOG_TAG,
            "4 - Unsupported SMS data coding scheme "
                + "(compression) "
                + (mDataCodingScheme & 0xff));
      } else {
        switch ((mDataCodingScheme >> 2) & 0x3) {
          case 0: // GSM 7 bit default alphabet
            encodingType = ENCODING_7BIT;
            break;

          case 2: // UCS 2 (16bit)
            encodingType = ENCODING_16BIT;
            break;

          case 1: // 8 bit data
            // Support decoding the user data payload as pack GSM 8-bit (a GSM alphabet string
            // that's stored in 8-bit unpacked format) characters.
            Resources r = Resources.getSystem();
            if (r.getBoolean(au.com.wallaceit.voicemail.R.bool.config_sms_decode_gsm_8bit_data)) {
              encodingType = ENCODING_8BIT;
              break;
            }

          case 3: // reserved
            Rlog.w(LOG_TAG, "1 - Unsupported SMS data coding scheme " + (mDataCodingScheme & 0xff));
            encodingType = ENCODING_8BIT;
            break;
        }
      }
    } else if ((mDataCodingScheme & 0xf0) == 0xf0) {
      hasMessageClass = true;
      userDataCompressed = false;

      if (0 == (mDataCodingScheme & 0x04)) {
        // GSM 7 bit default alphabet
        encodingType = ENCODING_7BIT;
      } else {
        // 8 bit data
        encodingType = ENCODING_8BIT;
      }
    } else if ((mDataCodingScheme & 0xF0) == 0xC0
        || (mDataCodingScheme & 0xF0) == 0xD0
        || (mDataCodingScheme & 0xF0) == 0xE0) {
      // 3GPP TS 23.038 V7.0.0 (2006-03) section 4

      // 0xC0 == 7 bit, don't store
      // 0xD0 == 7 bit, store
      // 0xE0 == UCS-2, store

      if ((mDataCodingScheme & 0xF0) == 0xE0) {
        encodingType = ENCODING_16BIT;
      } else {
        encodingType = ENCODING_7BIT;
      }

      userDataCompressed = false;
      boolean active = ((mDataCodingScheme & 0x08) == 0x08);
      // bit 0x04 reserved

      // VM - If TP-UDH is present, these values will be overwritten
      if ((mDataCodingScheme & 0x03) == 0x00) {
        mIsMwi = true; /* Indicates vmail */
        mMwiSense = active; /* Indicates vmail notification set/clear */
        mMwiDontStore = ((mDataCodingScheme & 0xF0) == 0xC0);

        /* Set voice mail count based on notification bit */
        if (active == true) {
          mVoiceMailCount = -1; // unknown number of messages waiting
        } else {
          mVoiceMailCount = 0; // no unread messages
        }

        Rlog.w(
            LOG_TAG,
            "MWI in DCS for Vmail. DCS = "
                + (mDataCodingScheme & 0xff)
                + " Dont store = "
                + mMwiDontStore
                + " vmail count = "
                + mVoiceMailCount);

      } else {
        mIsMwi = false;
        Rlog.w(LOG_TAG, "MWI in DCS for fax/email/other: " + (mDataCodingScheme & 0xff));
      }
    } else if ((mDataCodingScheme & 0xC0) == 0x80) {
      // 3GPP TS 23.038 V7.0.0 (2006-03) section 4
      // 0x80..0xBF == Reserved coding groups
      if (mDataCodingScheme == 0x84) {
        // This value used for KSC5601 by carriers in Korea.
        encodingType = ENCODING_KSC5601;
      } else {
        Rlog.w(LOG_TAG, "5 - Unsupported SMS data coding scheme " + (mDataCodingScheme & 0xff));
      }
    } else {
      Rlog.w(LOG_TAG, "3 - Unsupported SMS data coding scheme " + (mDataCodingScheme & 0xff));
    }

    // set both the user data and the user data header.
    int count = p.constructUserData(hasUserDataHeader, encodingType == ENCODING_7BIT);
    this.mUserData = p.getUserData();
    this.mUserDataHeader = p.getUserDataHeader();

    /*
     * Look for voice mail indication in TP_UDH TS23.040 9.2.3.24
     * ieid = 1 (0x1) (SPECIAL_SMS_MSG_IND)
     * ieidl =2 octets
     * ieda msg_ind_type = 0x00 (voice mail; discard sms )or
     *                   = 0x80 (voice mail; store sms)
     * msg_count = 0x00 ..0xFF
     */
    if (hasUserDataHeader && (mUserDataHeader.specialSmsMsgList.size() != 0)) {
      for (SmsHeader.SpecialSmsMsg msg : mUserDataHeader.specialSmsMsgList) {
        int msgInd = msg.msgIndType & 0xff;
        /*
         * TS 23.040 V6.8.1 Sec 9.2.3.24.2
         * bits 1 0 : basic message indication type
         * bits 4 3 2 : extended message indication type
         * bits 6 5 : Profile id bit 7 storage type
         */
        if ((msgInd == 0) || (msgInd == 0x80)) {
          mIsMwi = true;
          if (msgInd == 0x80) {
            /* Store message because TP_UDH indicates so*/
            mMwiDontStore = false;
          } else if (mMwiDontStore == false) {
            /* Storage bit is not set by TP_UDH
             * Check for conflict
             * between message storage bit in TP_UDH
             * & DCS. The message shall be stored if either of
             * the one indicates so.
             * TS 23.040 V6.8.1 Sec 9.2.3.24.2
             */
            if (!((((mDataCodingScheme & 0xF0) == 0xD0) || ((mDataCodingScheme & 0xF0) == 0xE0))
                && ((mDataCodingScheme & 0x03) == 0x00))) {
              /* Even DCS did not have voice mail with Storage bit
               * 3GPP TS 23.038 V7.0.0 section 4
               * So clear this flag*/
              mMwiDontStore = true;
            }
          }

          mVoiceMailCount = msg.msgCount & 0xff;

          /*
           * In the event of a conflict between message count setting
           * and DCS then the Message Count in the TP-UDH shall
           * override the indication in the TP-DCS. Set voice mail
           * notification based on count in TP-UDH
           */
          if (mVoiceMailCount > 0) mMwiSense = true;
          else mMwiSense = false;

          Rlog.w(
              LOG_TAG,
              "MWI in TP-UDH for Vmail. Msg Ind = "
                  + msgInd
                  + " Dont store = "
                  + mMwiDontStore
                  + " Vmail count = "
                  + mVoiceMailCount);

          /*
           * There can be only one IE for each type of message
           * indication in TP_UDH. In the event they are duplicated
           * last occurence will be used. Hence the for loop
           */
        } else {
          Rlog.w(
              LOG_TAG,
              "TP_UDH fax/email/" + "extended msg/multisubscriber profile. Msg Ind = " + msgInd);
        }
      } // end of for
    } // end of if UDH

    switch (encodingType) {
      case ENCODING_UNKNOWN:
        mMessageBody = null;
        break;

      case ENCODING_8BIT:
        // Support decoding the user data payload as pack GSM 8-bit (a GSM alphabet string
        // that's stored in 8-bit unpacked format) characters.
        Resources r = Resources.getSystem();
        if (r.getBoolean(au.com.wallaceit.voicemail.R.bool.config_sms_decode_gsm_8bit_data)) {
          mMessageBody = p.getUserDataGSM8bit(count);
        } else {
          mMessageBody = null;
        }
        break;

      case ENCODING_7BIT:
        mMessageBody =
            p.getUserDataGSM7Bit(
                count,
                hasUserDataHeader ? mUserDataHeader.languageTable : 0,
                hasUserDataHeader ? mUserDataHeader.languageShiftTable : 0);
        break;

      case ENCODING_16BIT:
        mMessageBody = p.getUserDataUCS2(count);
        break;

      case ENCODING_KSC5601:
        mMessageBody = p.getUserDataKSC5601(count);
        break;
    }

    if (VDBG) Rlog.v(LOG_TAG, "SMS message body (raw): '" + mMessageBody + "'");

    if (mMessageBody != null) {
      parseMessageBody();
    }

    if (!hasMessageClass) {
      messageClass = MessageClass.UNKNOWN;
    } else {
      switch (mDataCodingScheme & 0x3) {
        case 0:
          messageClass = MessageClass.CLASS_0;
          break;
        case 1:
          messageClass = MessageClass.CLASS_1;
          break;
        case 2:
          messageClass = MessageClass.CLASS_2;
          break;
        case 3:
          messageClass = MessageClass.CLASS_3;
          break;
      }
    }
  }
Beispiel #9
0
  /**
   * getCallerInfo given a phone number, look up in the call-log database for the matching caller id
   * info.
   *
   * @param context the context used to get the ContentResolver
   * @param number the phone number used to lookup caller id
   * @return the CallerInfo which contains the caller id for the given number. The returned
   *     CallerInfo is null if no number is supplied. If a matching number is not found, then a
   *     generic caller info is returned, with all relevant fields empty or null.
   */
  public static CallerInfo getCallerInfo(Context context, String number) {
    if (VDBG) Rlog.v(TAG, "getCallerInfo() based on number...");

    int subId = SubscriptionManager.getDefaultSubId();
    return getCallerInfo(context, number, subId);
  }
Beispiel #10
0
  /**
   * getCallerInfo given a Cursor.
   *
   * @param context the context used to retrieve string constants
   * @param contactRef the URI to attach to this CallerInfo object
   * @param cursor the first object in the cursor is used to build the CallerInfo object.
   * @return the CallerInfo which contains the caller id for the given number. The returned
   *     CallerInfo is null if no number is supplied.
   */
  public static CallerInfo getCallerInfo(Context context, Uri contactRef, Cursor cursor) {
    CallerInfo info = new CallerInfo();
    info.photoResource = 0;
    info.phoneLabel = null;
    info.numberType = 0;
    info.numberLabel = null;
    info.cachedPhoto = null;
    info.isCachedPhotoCurrent = false;
    info.contactExists = false;

    if (VDBG) Rlog.v(TAG, "getCallerInfo() based on cursor...");

    if (cursor != null) {
      if (cursor.moveToFirst()) {
        // TODO: photo_id is always available but not taken
        // care of here. Maybe we should store it in the
        // CallerInfo object as well.

        int columnIndex;

        // Look for the name
        columnIndex = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME);
        if (columnIndex != -1) {
          info.name = cursor.getString(columnIndex);
        }

        // Look for the number
        columnIndex = cursor.getColumnIndex(PhoneLookup.NUMBER);
        if (columnIndex != -1) {
          info.phoneNumber = cursor.getString(columnIndex);
        }

        // Look for the normalized number
        columnIndex = cursor.getColumnIndex(PhoneLookup.NORMALIZED_NUMBER);
        if (columnIndex != -1) {
          info.normalizedNumber = cursor.getString(columnIndex);
        }

        // Look for the label/type combo
        columnIndex = cursor.getColumnIndex(PhoneLookup.LABEL);
        if (columnIndex != -1) {
          int typeColumnIndex = cursor.getColumnIndex(PhoneLookup.TYPE);
          if (typeColumnIndex != -1) {
            info.numberType = cursor.getInt(typeColumnIndex);
            info.numberLabel = cursor.getString(columnIndex);
            info.phoneLabel =
                Phone.getDisplayLabel(context, info.numberType, info.numberLabel).toString();
          }
        }

        // Look for the person_id.
        columnIndex = getColumnIndexForPersonId(contactRef, cursor);
        if (columnIndex != -1) {
          final long contactId = cursor.getLong(columnIndex);
          if (contactId != 0 && !Contacts.isEnterpriseContactId(contactId)) {
            info.contactIdOrZero = contactId;
            if (VDBG) {
              Rlog.v(TAG, "==> got info.contactIdOrZero: " + info.contactIdOrZero);
            }
          }
        } else {
          // No valid columnIndex, so we can't look up person_id.
          Rlog.w(TAG, "Couldn't find contact_id column for " + contactRef);
          // Watch out: this means that anything that depends on
          // person_id will be broken (like contact photo lookups in
          // the in-call UI, for example.)
        }

        // Contact lookupKey
        columnIndex = cursor.getColumnIndex(PhoneLookup.LOOKUP_KEY);
        if (columnIndex != -1) {
          info.lookupKey = cursor.getString(columnIndex);
        }

        // Display photo URI.
        columnIndex = cursor.getColumnIndex(PhoneLookup.PHOTO_URI);
        if ((columnIndex != -1) && (cursor.getString(columnIndex) != null)) {
          info.contactDisplayPhotoUri = Uri.parse(cursor.getString(columnIndex));
        } else {
          info.contactDisplayPhotoUri = null;
        }

        // look for the custom ringtone, create from the string stored
        // in the database.
        columnIndex = cursor.getColumnIndex(PhoneLookup.CUSTOM_RINGTONE);
        if ((columnIndex != -1) && (cursor.getString(columnIndex) != null)) {
          info.contactRingtoneUri = Uri.parse(cursor.getString(columnIndex));
        } else {
          info.contactRingtoneUri = null;
        }

        // look for the send to voicemail flag, set it to true only
        // under certain circumstances.
        columnIndex = cursor.getColumnIndex(PhoneLookup.SEND_TO_VOICEMAIL);
        info.shouldSendToVoicemail = (columnIndex != -1) && ((cursor.getInt(columnIndex)) == 1);
        info.contactExists = true;
      }
      cursor.close();
      cursor = null;
    }

    info.needUpdate = false;
    info.name = normalize(info.name);
    info.contactRefUri = contactRef;

    return info;
  }
Beispiel #11
0
  private EriDisplayInformation getEriDisplayInformation(int roamInd, int defRoamInd) {
    EriDisplayInformation ret;

    // Carrier can use eri.xml to customize any built-in roaming display indications
    if (mIsEriFileLoaded) {
      EriInfo eriInfo = getEriInfo(roamInd);
      if (eriInfo != null) {
        if (VDBG) Rlog.v(LOG_TAG, "ERI roamInd " + roamInd + " found in ERI file");
        ret = new EriDisplayInformation(eriInfo.iconIndex, eriInfo.iconMode, eriInfo.eriText);
        return ret;
      }
    }

    switch (roamInd) {
        // Handling the standard roaming indicator (non-ERI)
      case EriInfo.ROAMING_INDICATOR_ON:
        ret =
            new EriDisplayInformation(
                EriInfo.ROAMING_INDICATOR_ON,
                EriInfo.ROAMING_ICON_MODE_NORMAL,
                mContext.getText(com.android.internal.R.string.roamingText0).toString());
        break;

      case EriInfo.ROAMING_INDICATOR_OFF:
        ret =
            new EriDisplayInformation(
                EriInfo.ROAMING_INDICATOR_OFF,
                EriInfo.ROAMING_ICON_MODE_NORMAL,
                mContext.getText(com.android.internal.R.string.roamingText1).toString());
        break;

      case EriInfo.ROAMING_INDICATOR_FLASH:
        ret =
            new EriDisplayInformation(
                EriInfo.ROAMING_INDICATOR_FLASH,
                EriInfo.ROAMING_ICON_MODE_FLASH,
                mContext.getText(com.android.internal.R.string.roamingText2).toString());
        break;

        // Handling the standard ERI
      case 3:
        ret =
            new EriDisplayInformation(
                roamInd,
                EriInfo.ROAMING_ICON_MODE_NORMAL,
                mContext.getText(com.android.internal.R.string.roamingText3).toString());
        break;

      case 4:
        ret =
            new EriDisplayInformation(
                roamInd,
                EriInfo.ROAMING_ICON_MODE_NORMAL,
                mContext.getText(com.android.internal.R.string.roamingText4).toString());
        break;

      case 5:
        ret =
            new EriDisplayInformation(
                roamInd,
                EriInfo.ROAMING_ICON_MODE_NORMAL,
                mContext.getText(com.android.internal.R.string.roamingText5).toString());
        break;

      case 6:
        ret =
            new EriDisplayInformation(
                roamInd,
                EriInfo.ROAMING_ICON_MODE_NORMAL,
                mContext.getText(com.android.internal.R.string.roamingText6).toString());
        break;

      case 7:
        ret =
            new EriDisplayInformation(
                roamInd,
                EriInfo.ROAMING_ICON_MODE_NORMAL,
                mContext.getText(com.android.internal.R.string.roamingText7).toString());
        break;

      case 8:
        ret =
            new EriDisplayInformation(
                roamInd,
                EriInfo.ROAMING_ICON_MODE_NORMAL,
                mContext.getText(com.android.internal.R.string.roamingText8).toString());
        break;

      case 9:
        ret =
            new EriDisplayInformation(
                roamInd,
                EriInfo.ROAMING_ICON_MODE_NORMAL,
                mContext.getText(com.android.internal.R.string.roamingText9).toString());
        break;

      case 10:
        ret =
            new EriDisplayInformation(
                roamInd,
                EriInfo.ROAMING_ICON_MODE_NORMAL,
                mContext.getText(com.android.internal.R.string.roamingText10).toString());
        break;

      case 11:
        ret =
            new EriDisplayInformation(
                roamInd,
                EriInfo.ROAMING_ICON_MODE_NORMAL,
                mContext.getText(com.android.internal.R.string.roamingText11).toString());
        break;

      case 12:
        ret =
            new EriDisplayInformation(
                roamInd,
                EriInfo.ROAMING_ICON_MODE_NORMAL,
                mContext.getText(com.android.internal.R.string.roamingText12).toString());
        break;

        // Handling the non standard Enhanced Roaming Indicator (roamInd > 63)
      default:
        if (!mIsEriFileLoaded) {
          // ERI file NOT loaded
          if (DBG) Rlog.d(LOG_TAG, "ERI File not loaded");
          if (defRoamInd > 2) {
            if (VDBG) Rlog.v(LOG_TAG, "ERI defRoamInd > 2 ...flashing");
            ret =
                new EriDisplayInformation(
                    EriInfo.ROAMING_INDICATOR_FLASH,
                    EriInfo.ROAMING_ICON_MODE_FLASH,
                    mContext.getText(com.android.internal.R.string.roamingText2).toString());
          } else {
            if (VDBG) Rlog.v(LOG_TAG, "ERI defRoamInd <= 2");
            switch (defRoamInd) {
              case EriInfo.ROAMING_INDICATOR_ON:
                ret =
                    new EriDisplayInformation(
                        EriInfo.ROAMING_INDICATOR_ON,
                        EriInfo.ROAMING_ICON_MODE_NORMAL,
                        mContext.getText(com.android.internal.R.string.roamingText0).toString());
                break;

              case EriInfo.ROAMING_INDICATOR_OFF:
                ret =
                    new EriDisplayInformation(
                        EriInfo.ROAMING_INDICATOR_OFF,
                        EriInfo.ROAMING_ICON_MODE_NORMAL,
                        mContext.getText(com.android.internal.R.string.roamingText1).toString());
                break;

              case EriInfo.ROAMING_INDICATOR_FLASH:
                ret =
                    new EriDisplayInformation(
                        EriInfo.ROAMING_INDICATOR_FLASH,
                        EriInfo.ROAMING_ICON_MODE_FLASH,
                        mContext.getText(com.android.internal.R.string.roamingText2).toString());
                break;

              default:
                ret = new EriDisplayInformation(-1, -1, "ERI text");
            }
          }
        } else {
          // ERI file loaded
          EriInfo eriInfo = getEriInfo(roamInd);
          EriInfo defEriInfo = getEriInfo(defRoamInd);
          if (eriInfo == null) {
            if (VDBG) {
              Rlog.v(
                  LOG_TAG,
                  "ERI roamInd "
                      + roamInd
                      + " not found in ERI file ...using defRoamInd "
                      + defRoamInd);
            }
            if (defEriInfo == null) {
              Rlog.e(LOG_TAG, "ERI defRoamInd " + defRoamInd + " not found in ERI file ...on");
              ret =
                  new EriDisplayInformation(
                      EriInfo.ROAMING_INDICATOR_ON,
                      EriInfo.ROAMING_ICON_MODE_NORMAL,
                      mContext.getText(com.android.internal.R.string.roamingText0).toString());

            } else {
              if (VDBG) {
                Rlog.v(LOG_TAG, "ERI defRoamInd " + defRoamInd + " found in ERI file");
              }
              ret =
                  new EriDisplayInformation(
                      defEriInfo.iconIndex, defEriInfo.iconMode, defEriInfo.eriText);
            }
          } else {
            if (VDBG) Rlog.v(LOG_TAG, "ERI roamInd " + roamInd + " found in ERI file");
            ret = new EriDisplayInformation(eriInfo.iconIndex, eriInfo.iconMode, eriInfo.eriText);
          }
        }
        break;
    }
    if (VDBG) Rlog.v(LOG_TAG, "Displaying ERI " + ret.toString());
    return ret;
  }