Throw XmlParserException when client tag cannot be found when parsing
slice permissions. There are three call-sites of SliceClientPermissions#createFrom: 1) SlicePermissionManager#writeBackup and SlicePermissionManager#readRestore ensures the client tag exists before calling SliceClientPermissions#createFrom. 2) SlicePermissionManager#getClient is expecting Exception from SliceClientPermissions#createFrom when it fails to parse the xml, and creates clean permission object accordingly. This CL ensures an exception was thrown when the xml parsing cannot be completed. Bug: 121144871 Test: run test suite in forrest frameworks/base/services/tests/uiservicestests/src/com/android/server/slice Change-Id: Id7a239f16b95d16ba17bf651d474dec86492ef47
This commit is contained in:
@@ -160,6 +160,9 @@ public class SliceClientPermissions implements DirtyTracker, Persistable {
|
||||
// Get to the beginning of the provider.
|
||||
while (parser.getEventType() != XmlPullParser.START_TAG
|
||||
|| !TAG_CLIENT.equals(parser.getName())) {
|
||||
if (parser.getEventType() == XmlPullParser.END_DOCUMENT) {
|
||||
throw new XmlPullParserException("Can't find client tag in xml");
|
||||
}
|
||||
parser.next();
|
||||
}
|
||||
int depth = parser.getDepth();
|
||||
@@ -173,6 +176,9 @@ public class SliceClientPermissions implements DirtyTracker, Persistable {
|
||||
parser.next();
|
||||
|
||||
while (parser.getDepth() > depth) {
|
||||
if (parser.getEventType() == XmlPullParser.END_DOCUMENT) {
|
||||
return provider;
|
||||
}
|
||||
if (parser.getEventType() == XmlPullParser.START_TAG
|
||||
&& TAG_AUTHORITY.equals(parser.getName())) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user