TestConferenceEventPackageParserpublic 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 | mInputStreamThe 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.
mInputStream = inputStream;
|
Methods Summary |
---|
public com.android.ims.ImsConferenceState | parse()Parses the conference event package XML file and returns an
{@link com.android.ims.ImsConferenceState} instance containing the participants described in
the XML file.
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.Bundle | parseParticipant(org.xmlpull.v1.XmlPullParser parser)Parses a participant record from a conference event package XML file.
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;
|
|