FileDocCategorySizeDatePackage
TestConferenceEventPackageParser.javaAPI DocAndroid 5.1 API5917Thu Mar 12 22:22:54 GMT 2015com.android.internal.telephony.test

TestConferenceEventPackageParser

public class TestConferenceEventPackageParser extends Object
Implements a basic XML parser used to parse test IMS conference event packages which can be injected into the IMS framework via the {@link com.android.internal.telephony.TelephonyTester}.
{@code


tel:+16505551212
Joe Q. Public
sip:+16505551212@ims-test-provider.com
connected


}

Note: This XML format is similar to the information stored in the {@link com.android.ims.ImsConferenceState} parcelable. The {@code status} values expected in the XML are those found in the {@code ImsConferenceState} class (e.g. {@link com.android.ims.ImsConferenceState#STATUS_CONNECTED}).

Place a file formatted similar to above in /data/data/com.android.phone/files/ and invoke the following command while you have an ongoing IMS call:

adb shell am broadcast
-a com.android.internal.telephony.TestConferenceEventPackage
-e filename test.xml

Fields Summary
private static final String
LOG_TAG
private static final String
PARTICIPANT_TAG
private InputStream
mInputStream
The XML input stream to parse.
Constructors Summary
public TestConferenceEventPackageParser(InputStream inputStream)
Constructs an input of the conference event package parser for the given input stream.

param
inputStream The input stream.


                            
       
        mInputStream = inputStream;
    
Methods Summary
public com.android.ims.ImsConferenceStateparse()
Parses the conference event package XML file and returns an {@link com.android.ims.ImsConferenceState} instance containing the participants described in the XML file.

return
The {@link com.android.ims.ImsConferenceState} instance.

        ImsConferenceState conferenceState = new ImsConferenceState();

        XmlPullParser parser;
        try {
            parser = Xml.newPullParser();
            parser.setInput(mInputStream, null);
            parser.nextTag();

            int outerDepth = parser.getDepth();
            while (XmlUtils.nextElementWithin(parser, outerDepth)) {
                if (parser.getName().equals(PARTICIPANT_TAG)) {
                    Log.v(LOG_TAG, "Found participant.");
                    Bundle participant = parseParticipant(parser);
                    conferenceState.mParticipants.put(participant.getString(
                            ImsConferenceState.ENDPOINT), participant);
                }
            }
        } catch (IOException | XmlPullParserException e) {
            Log.e(LOG_TAG, "Failed to read test conference event package from XML file", e);
            return null;
        } finally {
            try {
                mInputStream.close();
            } catch (IOException e) {
                Log.e(LOG_TAG, "Failed to close test conference event package InputStream", e);
                return null;
            }
        }

        return conferenceState;
    
private android.os.BundleparseParticipant(org.xmlpull.v1.XmlPullParser parser)
Parses a participant record from a conference event package XML file.

param
parser The XML parser.
return
{@link Bundle} containing the participant information.

        Bundle bundle = new Bundle();

        String user = "";
        String displayText = "";
        String endpoint = "";
        String status = "";

        int outerDepth = parser.getDepth();
        while (XmlUtils.nextElementWithin(parser, outerDepth)) {
            if (parser.getName().equals(ImsConferenceState.USER)) {
                parser.next();
                user = parser.getText();
            } else if (parser.getName().equals(ImsConferenceState.DISPLAY_TEXT)) {
                parser.next();
                displayText = parser.getText();
            }  else if (parser.getName().equals(ImsConferenceState.ENDPOINT)) {
                parser.next();
                endpoint = parser.getText();
            }  else if (parser.getName().equals(ImsConferenceState.STATUS)) {
                parser.next();
                status = parser.getText();
            }
        }

        Log.v(LOG_TAG, "User: "+user);
        Log.v(LOG_TAG, "DisplayText: "+displayText);
        Log.v(LOG_TAG, "Endpoint: "+endpoint);
        Log.v(LOG_TAG, "Status: "+status);

        bundle.putString(ImsConferenceState.USER, user);
        bundle.putString(ImsConferenceState.DISPLAY_TEXT, displayText);
        bundle.putString(ImsConferenceState.ENDPOINT, endpoint);
        bundle.putString(ImsConferenceState.STATUS, status);

        return bundle;