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

Commit 50d99e60 authored by Alex Buynytskyy's avatar Alex Buynytskyy
Browse files

Correct parsing of application/profileable tag + cts.

Bug: 160244186
Test: atest PackageManagerShellCommandIncrementalTest
Change-Id: I60de8c5300818a2c14c8532b29a023d1b0e0f5b5
parent 5741b83f
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -1704,13 +1704,6 @@ public class PackageParser {
                        minSdkVersion = attrs.getAttributeIntValue(i, DEFAULT_MIN_SDK_VERSION);
                    }
                }
            } else if (TAG_PROFILEABLE.equals(parser.getName())) {
                for (int i = 0; i < attrs.getAttributeCount(); ++i) {
                    final String attr = attrs.getAttributeName(i);
                    if ("shell".equals(attr)) {
                        profilableByShell = attrs.getAttributeBooleanValue(i, profilableByShell);
                    }
                }
            }
        }

+24 −7
Original line number Diff line number Diff line
@@ -398,6 +398,30 @@ public class ApkLiteParseUtils {
                            break;
                    }
                }

                final int innerDepth = parser.getDepth();
                int innerType;
                while ((innerType = parser.next()) != XmlPullParser.END_DOCUMENT
                        && (innerType != XmlPullParser.END_TAG || parser.getDepth() > innerDepth)) {
                    if (innerType == XmlPullParser.END_TAG || innerType == XmlPullParser.TEXT) {
                        continue;
                    }

                    if (parser.getDepth() != innerDepth + 1) {
                        // Search only under <application>.
                        continue;
                    }

                    if (PackageParser.TAG_PROFILEABLE.equals(parser.getName())) {
                        for (int i = 0; i < attrs.getAttributeCount(); ++i) {
                            final String attr = attrs.getAttributeName(i);
                            if ("shell".equals(attr)) {
                                profilableByShell = attrs.getAttributeBooleanValue(i,
                                        profilableByShell);
                            }
                        }
                    }
                }
            } else if (PackageParser.TAG_OVERLAY.equals(parser.getName())) {
                for (int i = 0; i < attrs.getAttributeCount(); ++i) {
                    final String attr = attrs.getAttributeName(i);
@@ -435,13 +459,6 @@ public class ApkLiteParseUtils {
                        minSdkVersion = attrs.getAttributeIntValue(i, DEFAULT_MIN_SDK_VERSION);
                    }
                }
            } else if (PackageParser.TAG_PROFILEABLE.equals(parser.getName())) {
                for (int i = 0; i < attrs.getAttributeCount(); ++i) {
                    final String attr = attrs.getAttributeName(i);
                    if ("shell".equals(attr)) {
                        profilableByShell = attrs.getAttributeBooleanValue(i, profilableByShell);
                    }
                }
            }
        }