Пример #1
0
 /**
  * Get the user public address
  *
  * @return Public address
  */
 public String getPublicAddress() {
   String addr = getPublicUri();
   String displayName = mRcsSettings.getUserProfileImsDisplayName();
   if (TextUtils.isEmpty(displayName)) {
     return addr;
   }
   PhoneNumber number = ContactUtil.getValidPhoneNumberFromUri(addr);
   if (number == null) {
     return formatAddressWithDisplayName(displayName, addr);
   }
   ContactId me = ContactUtil.createContactIdFromValidatedData(number);
   if (displayName.equals(me.toString())) {
     /* Do no insert display name if it is equal to the international number */
     return addr;
   }
   return formatAddressWithDisplayName(displayName, me);
 }
  /**
   * Read the security header from REGISTER response
   *
   * @param response Response
   * @throws PayloadException
   */
  public void readSecurityHeader(SipResponse response) throws PayloadException {
    SipURI sipUri = getSipUri(response.getHeaders(SipUtils.HEADER_P_ASSOCIATED_URI));

    String user = sipUri.getUser();
    PhoneNumber number = ContactUtil.getValidPhoneNumberFromUri(user);
    if (number == null) {
      throw new PayloadException(
          new StringBuilder("Can't read a SIP-URI from the P-Associated-URI header: invalid user '")
              .append(user)
              .append("'")
              .toString());
    }
    UserProfile profile = ImsModule.getImsUserProfile();
    profile.setUsername(ContactUtil.createContactIdFromValidatedData(number));
    profile.setHomeDomain(sipUri.getHost());
    profile.setXdmServerLogin(
        PhoneUtils.SIP_URI_HEADER + sipUri.getUser() + "@" + sipUri.getHost());
  }
 private void cacheData() {
   Cursor cursor = null;
   try {
     cursor = mMessagingLog.getGroupChatData(mChatId);
     if (!cursor.moveToNext()) {
       throw new ServerApiPersistentStorageException(
           new StringBuilder("Data not found for group chat ").append(mChatId).toString());
     }
     mSubject = cursor.getString(cursor.getColumnIndexOrThrow(GroupChatData.KEY_SUBJECT));
     mDirection =
         Direction.valueOf(
             cursor.getInt(cursor.getColumnIndexOrThrow(GroupChatData.KEY_DIRECTION)));
     String contact = cursor.getString(cursor.getColumnIndexOrThrow(GroupChatData.KEY_CONTACT));
     if (contact != null) {
       mContact = ContactUtil.createContactIdFromTrustedData(contact);
     }
     mTimestamp = cursor.getLong(cursor.getColumnIndexOrThrow(GroupChatData.KEY_TIMESTAMP));
   } finally {
     if (cursor != null) {
       cursor.close();
     }
   }
 }