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

Commit 5f987608 authored by James.cf Lin's avatar James.cf Lin Committed by Automerger Merge Worker
Browse files

Fix the status of tuple cannot be parsed because there are some whitespace...

Fix the status of tuple cannot be parsed because there are some whitespace characters before the Basic tag am: e587196f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/net/ims/+/14831527

Change-Id: Icc0d6f342f6cd4fe943bfb68927191b2798acce1
parents be33cfad e587196f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -17,8 +17,10 @@
package com.android.ims.rcs.uce.presence.pidfparser.pidf;

import android.annotation.StringDef;
import android.util.Log;

import com.android.ims.rcs.uce.presence.pidfparser.ElementBase;
import com.android.ims.rcs.uce.util.UceUtils;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -32,6 +34,8 @@ import java.lang.annotation.RetentionPolicy;
 * The "basic" element of the pidf.
 */
public class Basic extends ElementBase {
    private static final String LOG_TAG = UceUtils.getLogPrefix() + "Basic";

    /** The name of this element */
    public static final String ELEMENT_NAME = "basic";

@@ -104,6 +108,8 @@ public class Basic extends ElementBase {
            } else {
                mBasic = null;
            }
        } else {
            Log.d(LOG_TAG, "The eventType is not TEXT=" + eventType);
        }

        // Move to the end tag.
+9 −2
Original line number Diff line number Diff line
@@ -16,7 +16,10 @@

package com.android.ims.rcs.uce.presence.pidfparser.pidf;

import android.util.Log;

import com.android.ims.rcs.uce.presence.pidfparser.ElementBase;
import com.android.ims.rcs.uce.util.UceUtils;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -28,6 +31,8 @@ import java.io.IOException;
 * The "status" element of the pidf.
 */
public class Status extends ElementBase {
    private static final String LOG_TAG = UceUtils.getLogPrefix() + "Status";

    /** The name of this element */
    public static final String ELEMENT_NAME = "status";

@@ -76,14 +81,16 @@ public class Status extends ElementBase {
            throw new XmlPullParserException("Incorrect element: " + namespace + ", " + name);
        }

        // Move to the next event to get the Basic tag.
        int eventType = parser.next();
        // Move to the next tag to get the Basic element.
        int eventType = parser.nextTag();

        // Get the value if the event type is text.
        if (eventType == XmlPullParser.START_TAG) {
            Basic basic = new Basic();
            basic.parse(parser);
            mBasic = basic;
        } else {
            Log.d(LOG_TAG, "The eventType is not START_TAG=" + eventType);
        }

        // Move to the end tag.
+97 −55
Original line number Diff line number Diff line
@@ -129,21 +129,37 @@ public class PidfParserTest extends ImsTestBase {
                .setContactUri(Uri.parse(contact));

        final RcsContactPresenceTuple.Builder tuple3Builder = new RcsContactPresenceTuple.Builder(
                "open",
                "org.openmobilealliance:ChatSession",
                "2.0");
        tuple3Builder.setServiceDescription("Session Mode Messaging")
                .setContactUri(Uri.parse(contact));

        final RcsContactPresenceTuple.Builder tuple4Builder = new RcsContactPresenceTuple.Builder(
                "open",
                "org.openmobilealliance:File-Transfer",
                "1.0");
        tuple4Builder.setServiceDescription("File Transfer")
                .setContactUri(Uri.parse(contact));

        final RcsContactPresenceTuple.Builder tuple5Builder = new RcsContactPresenceTuple.Builder(
                "open",
                "org.3gpp.urn:urn-7:3gpp-service.ims.icsi.mmtel",
                "1.0");
        tuple3Builder.setServiceDescription("VoLTE service");
        tuple5Builder.setServiceDescription("VoLTE service");
        ServiceCapabilities.Builder capBuilder = new ServiceCapabilities.Builder(true, true);
        tuple3Builder.setServiceCapabilities(capBuilder.build())
        tuple5Builder.setServiceCapabilities(capBuilder.build())
                .setContactUri(Uri.parse(contact));

        final List<RcsContactPresenceTuple> expectedTupleList = new ArrayList<>(3);
        final List<RcsContactPresenceTuple> expectedTupleList = new ArrayList<>(5);
        expectedTupleList.add(tuple1Builder.build());
        expectedTupleList.add(tuple2Builder.build());
        expectedTupleList.add(tuple3Builder.build());
        expectedTupleList.add(tuple4Builder.build());
        expectedTupleList.add(tuple5Builder.build());

        // Create the newline included PIDF data
        String pidfData = getPidfDataWithNewlineCharacters(contact);
        String pidfData = getPidfDataWithNewlineAndWhitespaceCharacters();

        // Convert to the class RcsContactUceCapability
        RcsContactUceCapability capabilities = PidfParser.getRcsContactUceCapability(pidfData);
@@ -330,25 +346,25 @@ public class PidfParserTest extends ImsTestBase {
        return pidfBuilder.toString();
    }

    private String getPidfDataWithNewlineCharacters(String contact) {
    private String getPidfDataWithNewlineAndWhitespaceCharacters() {
        String pidf = "<presence xmlns=\"urn:ietf:params:xml:ns:pidf\" "
                        + "xmlns:op=\"urn:oma:xml:prs:pidf:oma-pres\" "
                        + "xmlns:b=\"urn:ietf:params:xml:ns:pidf:caps\" "
                + "entity=\"" + contact + "\">\n"
                // The first tuple
                + "<tuple id=\"DiscoveryPres\">\n"
                + "<status>\n"
                + "<basic>open</basic>\n"
                + "</status>\n"
                + "<op:service-description>\n"
                + "<op:service-id>"
                        + "org.3gpp.urn:urn-7:3gpp-application.ims.iari.rcse.dp</op:service-id>\n"
                + "<op:version>1.0</op:version>\n"
                + "<op:description>DiscoveryPresence</op:description>\n"
                + "</op:service-description>\n"
                + "<contact>tel:+11234567890</contact>\n"
                + "</tuple>\n"
                // The second tuple
                        + "entity=\"tel:+11234567890\">\n"
                // Tuple: Discovery
                + "   <tuple id=\"DiscoveryPres\">\n\t"
                + "     <status>\n\t"
                + "       <basic>open</basic>\n\t"
                + "     </status>\n\t"
                + "     <op:service-description>\n\t"
                + "       <op:service-id>org.3gpp.urn:urn-7:3gpp-application.ims.iari.rcse.dp"
                                + "</op:service-id>\n\t"
                + "       <op:version>1.0</op:version>\n\t"
                + "       <op:description>DiscoveryPresence</op:description>\n\t"
                + "     </op:service-description>\n\t"
                + "     <contact>tel:+11234567890</contact>\n\t"
                + "   </tuple>\n\t"
                // Tuple: VoLTE
                + "   <tuple id=\"VoLTE\">\n"
                + "     <status>\n"
                + "       <basic>open</basic>\n"
@@ -363,13 +379,14 @@ public class PidfParserTest extends ImsTestBase {
                + "       </b:duplex>\n"
                + "     </b:servcaps>\n"
                + "     <op:service-description>\n"
                + "<op:service-id>org.3gpp.urn:urn-7:3gpp-service.ims.icsi.mmtel</op:service-id>\n"
                + "       <op:service-id>org.3gpp.urn:urn-7:3gpp-service.ims.icsi.mmtel"
                                + "</op:service-id>\n"
                + "       <op:version>1.0</op:version>\n"
                + "       <op:description>VoLTE service</op:description>\n"
                + "     </op:service-description>\n"
                + "     <contact>tel:+11234567890</contact>\n"
                + "   </tuple>\n"
                // The third tuple
                // Tuple: Standalone Message
                + "   <tuple id=\"StandaloneMsg\">\n"
                + "     <status>\n"
                + "       <basic>open</basic>\n"
@@ -381,7 +398,32 @@ public class PidfParserTest extends ImsTestBase {
                + "     </op:service-description>\n"
                + "     <contact>tel:+11234567890</contact>\n"
                + "   </tuple>\n"
                // Tuple: Session Mode Message
                + "   <tuple id=\"SessModeMessa\">\n"
                + "     <status>\n"
                + "       <basic>open</basic>\n"
                + "     </status>\n"
                + "     <op:service-description>\n"
                + "       <op:service-id>org.openmobilealliance:ChatSession</op:service-id>\n"
                + "       <op:version>2.0</op:version>\n"
                + "       <op:description>Session Mode Messaging</op:description>\n"
                + "     </op:service-description>\n"
                + "     <contact>tel:+11234567890</contact>\n"
                + "   </tuple>\n"
                // Tuple: File Transfer
                + "   <tuple id=\"FileTransfer\">\n"
                + "     <status>\n"
                + "       <basic>open</basic>\n"
                + "     </status>\n"
                + "     <op:service-description>\n"
                + "       <op:service-id>org.openmobilealliance:File-Transfer</op:service-id>\n"
                + "       <op:version>1.0</op:version>\n"
                + "       <op:description>File Transfer</op:description>\n"
                + "     </op:service-description>\n"
                + "     <contact>tel:+11234567890</contact>\n"
                + "   </tuple>\n"
                + " </presence>";

        return pidf;
    }