Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e563a5ba authored by Brad Ebinger's avatar Brad Ebinger Committed by Automerger Merge Worker
Browse files

Fix a minor logic issue in ag/18176102 am: 6f7c9bb6 am: 04dfd01b am: 862fba0b

parents 6a03323d 862fba0b
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -274,19 +274,15 @@ public class DeviceCapabilityInfo {
    }

    /**
     * Get the IMS associated URI. It will first get the uri of MMTEL if it is not empty, otherwise
     * it will try to get the uri of RCS. The null will be returned if both MMTEL and RCS are empty.
     * Get the first URI from the "p-associated-uri" header included in the IMS registration
     * response.
     * @param preferTelUri If {@code true}, prefer returning the first TEL URI. If no TEL
     *                     URIs exist, this method will still return the preferred (first) SIP URI
     *                     in the header. If {@code false}, we will return the first URI
     *                     in the "p-associated-uri" header, independent of the URI scheme.
     */
    public synchronized Uri getImsAssociatedUri(boolean perferTelUri) {
        if (perferTelUri == false) {
            if (!mRcsAssociatedUris.isEmpty()) {
                return mRcsAssociatedUris.get(0);
            } else if (!mMmtelAssociatedUris.isEmpty()) {
                return mMmtelAssociatedUris.get(0);
            } else {
                return null;
            }
        } else {
    public synchronized Uri getImsAssociatedUri(boolean preferTelUri) {
        if (preferTelUri) {
            if (!mRcsAssociatedUris.isEmpty()) {
                for (Uri rcsAssociatedUri : mRcsAssociatedUris) {
                    if (PhoneAccount.SCHEME_TEL.equalsIgnoreCase(rcsAssociatedUri.getScheme())) {
@@ -301,6 +297,15 @@ public class DeviceCapabilityInfo {
                    }
                }
            }
        }

        // Either we have not found a TEL URI or we do not prefer TEL URIs. Get the first URI from
        // p-associated-uri list.
        if (!mRcsAssociatedUris.isEmpty()) {
            return mRcsAssociatedUris.get(0);
        } else if (!mMmtelAssociatedUris.isEmpty()) {
            return mMmtelAssociatedUris.get(0);
        } else {
            return null;
        }
    }
+16 −4
Original line number Diff line number Diff line
@@ -43,26 +43,34 @@ public class PublishUtils {
    private static final String SCHEME_TEL = "tel";
    private static final String DOMAIN_SEPARATOR = "@";

    /**
     * @return the contact URI of this device for either a PRESENCE or OPTIONS capabilities request.
     * We will first try to use the IMS service associated URIs from the p-associated-uri header
     * in the IMS registration response. If this is not available, we will fall back to using the
     * SIM card information to generate the URI.
     */
    public static Uri getDeviceContactUri(Context context, int subId,
            DeviceCapabilityInfo deviceCap, boolean isForPresence) {
        boolean preferTelUri = false;
        if (isForPresence) {
            preferTelUri = UceUtils.isTelUriForPidfXmlEnabled(context, subId);
        }
        // Get the uri from the IMS associated URI which is provided by the IMS service.
        // Get the uri from the IMS p-associated-uri header which is provided by the IMS service.
        Uri contactUri = deviceCap.getImsAssociatedUri(preferTelUri);
        if (contactUri != null) {
            Log.d(LOG_TAG, "getDeviceContactUri: ims associated uri");
            Uri convertedUri = preferTelUri ? getConvertedTelUri(context, contactUri) : contactUri;
            Log.d(LOG_TAG, "getDeviceContactUri: returning "
                    + (contactUri.equals(convertedUri) ? "found" : "converted")
                    + " ims associated uri");
            return contactUri;
        }

        // No IMS service provided URIs, so generate the contact uri from ISIM.
        TelephonyManager telephonyManager = getTelephonyManager(context, subId);
        if (telephonyManager == null) {
            Log.w(LOG_TAG, "getDeviceContactUri: TelephonyManager is null");
            return null;
        }

        // Get the contact uri from ISIM.
        contactUri = getContactUriFromIsim(telephonyManager);
        if (contactUri != null) {
            Log.d(LOG_TAG, "getDeviceContactUri: impu");
@@ -152,6 +160,10 @@ public class PublishUtils {
        }
    }

    /**
     * @return a TEL URI version of the contact URI if given a SIP URI. If given a TEL URI, this
     * method will return the same value given.
     */
    private static Uri getConvertedTelUri(Context context, Uri contactUri) {
        if (contactUri == null) {
            return null;
+8 −2
Original line number Diff line number Diff line
@@ -123,7 +123,8 @@ public class DeviceCapabilityInfoTest extends ImsTestBase {

        assertEquals(number, telNumber);

        //If there is only SIP URI, check the return uri is null if preferTelUir is true.
        // If there is only SIP URI, this method will still return a SIP URI, since there are no TEL
        // URIs found in the list.
        deviceCapInfo = createDeviceCapabilityInfo();

        uris[0] = Uri.fromParts(PhoneAccount.SCHEME_SIP, telNumber, null);
@@ -132,7 +133,12 @@ public class DeviceCapabilityInfoTest extends ImsTestBase {
        deviceCapInfo.updateRcsAssociatedUri(uris);
        outUri = deviceCapInfo.getImsAssociatedUri(true);

        assertNull(outUri);
        numbers = outUri.getSchemeSpecificPart();
        numberParts = numbers.split("[@;:]");
        number = numberParts[0];

        assertEquals(number, telNumber);

    }

    private DeviceCapabilityInfo createDeviceCapabilityInfo() {