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

Commit 32d5a36b authored by James.cf Lin's avatar James.cf Lin
Browse files

Call the new added UCE APIs instead because of the UCE APIs modification

Bug: 180126217
Test: atest ImsServiceTest RcsUceAdapterTest EabControllerTest
Merged-In: I22a455b043a6e76e3d35a6b37d022c44003d2454
Change-Id: I22a455b043a6e76e3d35a6b37d022c44003d2454
parent 3e3026b0
Loading
Loading
Loading
Loading
+11 −16
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import com.android.ims.rcs.uce.UceController.UceControllerCallback;
import com.android.internal.annotations.VisibleForTesting;

import java.time.Instant;
import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.GregorianCalendar;
@@ -376,7 +377,14 @@ public class EabControllerImpl implements EabController {
            rcsContactPresenceTupleBuilder.setServiceCapabilities(serviceCapabilities);
        }
        if (timeStamp != null) {
            rcsContactPresenceTupleBuilder.setTimestamp(timeStamp);
            try {
                Instant instant = Instant.ofEpochSecond(Long.parseLong(timeStamp));
                rcsContactPresenceTupleBuilder.setTime(instant);
            } catch (NumberFormatException ex) {
                Log.w(TAG, "Create presence tuple: NumberFormatException");
            } catch (DateTimeParseException e) {
                Log.w(TAG, "Create presence tuple: parse timestamp failed");
            }
        }

        return rcsContactPresenceTupleBuilder.build();
@@ -557,21 +565,8 @@ public class EabControllerImpl implements EabController {

            // Using the current timestamp if the timestamp doesn't populate
            Long timestamp;
            if (tuple.getTimestamp() != null) {
                try {
                    Time time = new Time();
                    time.parse3339(tuple.getTimestamp());

                    GregorianCalendar date = new GregorianCalendar(
                            time.year, time.month, time.monthDay,
                            time.hour, time.minute, time.second);
                    date.setTimeZone(TimeZone.getTimeZone("UTC"));
                    timestamp = date.getTime().getTime() / 1000;
                } catch (TimeFormatException ex) {
                    Log.d(TAG, "Fail on parsing the timestamp. "
                            + "Timestamp: " + tuple.getTimestamp());
                    timestamp = Instant.now().getEpochSecond();
                }
            if (tuple.getTime() != null) {
                timestamp = tuple.getTime().getEpochSecond();
            } else {
                timestamp = Instant.now().getEpochSecond();
            }
+10 −1
Original line number Diff line number Diff line
@@ -41,6 +41,9 @@ import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.List;

import org.xmlpull.v1.XmlPullParser;
@@ -201,7 +204,13 @@ public class PidfParser {
        // Timestamp
        String timestamp = PidfParserUtils.getTupleTimestamp(tuple);
        if (!TextUtils.isEmpty(timestamp)) {
            builder.setTimestamp(timestamp);
            try {
                Instant instant = DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(
                        timestamp, Instant::from);
                builder.setTime(instant);
            } catch (DateTimeParseException e) {
                Log.w(LOG_TAG, "getRcsContactPresenceTuple: Parse timestamp failed " + e);
            }
        }

        // Set service description
+3 −0
Original line number Diff line number Diff line
@@ -100,6 +100,9 @@ public class PublishProcessorState {
    // Get the delay time to allow to execute the publish request.
    public long getDelayTimeToAllowPublish() {
        synchronized (mLock) {
            if (mAllowedTimestamp == null) {
                mAllowedTimestamp = Instant.now();
            }
            // Setup the delay to the time which publish request is allowed to execute.
            long delayTime = ChronoUnit.MILLIS.between(Instant.now(), mAllowedTimestamp);
            if (delayTime < 0) {
+11 −21
Original line number Diff line number Diff line
@@ -49,7 +49,8 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.text.SimpleDateFormat;
import java.time.temporal.ChronoUnit;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
@@ -153,11 +154,9 @@ public class EabControllerTest extends ImsTestBase {
        GregorianCalendar date = new GregorianCalendar();
        date.setTimeZone(TimeZone.getTimeZone("UTC"));
        date.add(Calendar.DATE, -120);
        String timestamp = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX")
                .format(date.getTime());

        List<RcsContactUceCapability> contactList = new ArrayList<>();
        contactList.add(createPresenceNonRcsCapability(timestamp));
        contactList.add(createPresenceNonRcsCapability(Instant.now()));

        mEabController.saveCapabilities(contactList);

@@ -177,11 +176,7 @@ public class EabControllerTest extends ImsTestBase {
        // Set non-rcs capabilities expiration to 119 days
        mBundle.putInt(KEY_NON_RCS_CAPABILITIES_CACHE_EXPIRATION_SEC_INT, 119 * 24 * 60 * 60);
        // Set timestamp to 120 days age
        GregorianCalendar date = new GregorianCalendar();
        date.setTimeZone(TimeZone.getTimeZone("UTC"));
        date.add(Calendar.DATE, -120);
        String timestamp = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX")
                .format(date.getTime());
        Instant timestamp = Instant.now().minus(120, ChronoUnit.DAYS);

        List<RcsContactUceCapability> contactList = new ArrayList<>();
        contactList.add(createPresenceNonRcsCapability(timestamp));
@@ -288,18 +283,13 @@ public class EabControllerTest extends ImsTestBase {
    }

    private RcsContactUceCapability createPresenceCapability(boolean isExpired) {
        String timestamp;
        GregorianCalendar date = new GregorianCalendar();
        date.setTimeZone(TimeZone.getTimeZone("UTC"));
        Instant timestamp;
        if (isExpired) {
            date.add(Calendar.DATE, -120);
            timestamp = Instant.now().minus(120, ChronoUnit.DAYS);
        } else {
            date.add(Calendar.DATE, 120);
            timestamp = Instant.now().plus(120, ChronoUnit.DAYS);
        }

        timestamp = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX")
                .format(date.getTime());

        RcsContactPresenceTuple.ServiceCapabilities.Builder serviceCapabilitiesBuilder =
                new RcsContactPresenceTuple.ServiceCapabilities.Builder(TEST_AUDIO_CAPABLE,
                        TEST_VIDEO_CAPABLE);
@@ -309,7 +299,7 @@ public class EabControllerTest extends ImsTestBase {
                        .setServiceDescription(TEST_SERVICE_DESCRIPTION)
                        .setContactUri(TEST_CONTACT_URI)
                        .setServiceCapabilities(serviceCapabilitiesBuilder.build())
                        .setTimestamp(timestamp)
                        .setTime(timestamp)
                        .build();

        RcsContactPresenceTuple tupleWithEmptyServiceCapabilities =
@@ -317,7 +307,7 @@ public class EabControllerTest extends ImsTestBase {
                        TEST_SERVICE_VERSION)
                        .setServiceDescription(TEST_SERVICE_DESCRIPTION)
                        .setContactUri(TEST_CONTACT_URI)
                        .setTimestamp(timestamp)
                        .setTime(timestamp)
                        .build();

        RcsContactUceCapability.PresenceBuilder builder =
@@ -328,7 +318,7 @@ public class EabControllerTest extends ImsTestBase {
        return builder.build();
    }

    private RcsContactUceCapability createPresenceNonRcsCapability(String timestamp) {
    private RcsContactUceCapability createPresenceNonRcsCapability(Instant timestamp) {
        RcsContactPresenceTuple.ServiceCapabilities.Builder serviceCapabilitiesBuilder =
                new RcsContactPresenceTuple.ServiceCapabilities.Builder(false, false);
        RcsContactPresenceTuple tupleWithServiceCapabilities =
@@ -337,7 +327,7 @@ public class EabControllerTest extends ImsTestBase {
                        .setServiceDescription(TEST_SERVICE_DESCRIPTION)
                        .setContactUri(TEST_CONTACT_URI)
                        .setServiceCapabilities(serviceCapabilitiesBuilder.build())
                        .setTimestamp(timestamp)
                        .setTime(timestamp)
                        .build();

        RcsContactUceCapability.PresenceBuilder builder =
+8 −8
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ public class PidfParserTest extends ImsTestBase {
        assertEquals("1.0", presenceTuple1.getServiceVersion());
        assertEquals(serviceDescription, presenceTuple1.getServiceDescription());
        assertEquals(Uri.parse(contact), presenceTuple1.getContactUri());
        assertEquals("2001-01-01T01:00:000Z", presenceTuple1.getTimestamp());
        assertEquals("2001-01-01T01:00:00Z", presenceTuple1.getTime().toString());
        assertTrue(presenceTuple1.getServiceCapabilities().isAudioCapable());
        assertFalse(presenceTuple1.getServiceCapabilities().isVideoCapable());
    }
@@ -138,7 +138,7 @@ public class PidfParserTest extends ImsTestBase {
        assertEquals("1.0", presenceTuple1.getServiceVersion());
        assertEquals(serviceDescription1, presenceTuple1.getServiceDescription());
        assertEquals(Uri.parse(contact), presenceTuple1.getContactUri());
        assertEquals("2001-01-01T01:00:000Z", presenceTuple1.getTimestamp());
        assertEquals("2001-01-01T01:00:00Z", presenceTuple1.getTime().toString());
        assertNull(presenceTuple1.getServiceCapabilities());

        // Verify the second tuple information
@@ -149,7 +149,7 @@ public class PidfParserTest extends ImsTestBase {
        assertFalse(presenceTuple2.getServiceCapabilities().isVideoCapable());
        assertEquals(serviceDescription2, presenceTuple2.getServiceDescription());
        assertEquals(Uri.parse(contact), presenceTuple2.getContactUri());
        assertEquals("2001-02-02T01:00:000Z", presenceTuple2.getTimestamp());
        assertEquals("2001-02-02T01:00:00Z", presenceTuple2.getTime().toString());
        assertNotNull(presenceTuple2.getServiceCapabilities());
        assertEquals(isAudioSupported, presenceTuple2.getServiceCapabilities().isAudioCapable());
        assertEquals(isVideoSupported, presenceTuple2.getServiceCapabilities().isVideoCapable());
@@ -236,7 +236,7 @@ public class PidfParserTest extends ImsTestBase {
                .append("<caps:video>").append(isVideoSupported).append("</caps:video>")
                .append("</caps:servcaps>")
                .append("<contact>").append(contact).append("</contact>")
                .append("<timestamp>2001-01-01T01:00:000Z</timestamp>")
                .append("<timestamp>2001-01-01T01:00:00.00Z</timestamp>")
                .append("</tuple></presence>");
        return pidfBuilder.toString();
    }
@@ -258,7 +258,7 @@ public class PidfParserTest extends ImsTestBase {
                + "<op:description>" + serviceDescription1 + "</op:description>"
                + "</op:service-description>"
                + "<contact>" + contact + "</contact>"
                + "<timestamp>2001-01-01T01:00:000Z</timestamp>"
                + "<timestamp>2001-01-01T01:00:00.00Z</timestamp>"
                + "</tuple>"
                // tuple 2
                + "<tuple id=\"a1\">"
@@ -276,7 +276,7 @@ public class PidfParserTest extends ImsTestBase {
                + "<caps:video>" + videoSupported + "</caps:video>"
                + "</caps:servcaps>"
                + "<contact>" + contact + "</contact>"
                + "<timestamp>2001-02-02T01:00:000Z</timestamp>"
                + "<timestamp>2001-02-02T01:00:00.00Z</timestamp>"
                + "</tuple>"
                + "</presence>";
    }
@@ -289,7 +289,7 @@ public class PidfParserTest extends ImsTestBase {
        final String basicStatus = RcsContactPresenceTuple.TUPLE_BASIC_STATUS_OPEN;
        final String version = "1.0";
        final String description = "description test";
        final String nowTime = Instant.now().toString();
        final Instant nowTime = Instant.now();

        // init the capabilities
        ServiceCapabilities.Builder servCapsBuilder =
@@ -301,7 +301,7 @@ public class PidfParserTest extends ImsTestBase {
                basicStatus, RcsContactPresenceTuple.SERVICE_ID_MMTEL, version);
        tupleBuilder.setContactUri(contact)
                .setServiceDescription(description)
                .setTimestamp(nowTime)
                .setTime(nowTime)
                .setServiceCapabilities(servCapsBuilder.build());

        PresenceBuilder presenceBuilder = new PresenceBuilder(contact,