Beispiel #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());
  }