@Test public void testReadAxml() throws Exception { File pFile = new File("./test-apk/error.apk"); Parser parser = new Parser(pFile); ManifestInfo manifestInfo = parser.getManifestInfo(); System.out.println(manifestInfo); }
private void readAxml(final byte[] androidManifestData) throws IOException { manifestInfo = new ManifestInfo(); String key = null; AxmlParser parser = new AxmlParser(androidManifestData); final byte FLAG_DEFAULT = -1; final byte FLAG_ACTIVITY = 0; final byte FLAG_RECEIVER = 1; byte flag = FLAG_DEFAULT; out: while (true) { int event = parser.next(); switch (event) { case AxmlParser.START_FILE: break; case AxmlParser.END_FILE: break out; case AxmlParser.START_TAG: String tagName = parser.getName(); switch (tagName) { case "manifest": parseTagManifest(parser); break; case "application": parseTagApplication(parser); break; case "uses-permission": parseTagPermission(parser); break; case "activity": case "activity-alias": key = parseTagActivity(parser); if (key != null) { flag = FLAG_ACTIVITY; } else { flag = FLAG_DEFAULT; } break; case "service": parseTagService(parser); break; case "receiver": key = parseTagReceiver(parser); if (key != null) { flag = FLAG_RECEIVER; } else { flag = FLAG_DEFAULT; } break; case "action": if (flag == FLAG_ACTIVITY) { parseTagAction(parser, manifestInfo.activities.get(key)); } else if (flag == FLAG_RECEIVER) { parseTagAction(parser, manifestInfo.receivers.get(key)); } break; case "category": if (flag == FLAG_ACTIVITY) { parseTagCategory(parser, manifestInfo.activities.get(key)); } else if (flag == FLAG_RECEIVER) { parseTagCategory(parser, manifestInfo.receivers.get(key)); } break; case "meta-data": parseTagMetaData(parser); break; } case AxmlParser.END_TAG: } } ArrayList<String> permArr = new ArrayList<>(manifestInfo.permissions); Collections.sort(permArr); manifestInfo.requestedPermissions = permArr; Collections.sort(manifestInfo.services); }
Parser { private void readAxml(final byte[] androidManifestData) throws IOException { manifestInfo = new ManifestInfo(); String key = null; AxmlParser parser = new AxmlParser(androidManifestData); final byte FLAG_DEFAULT = -1; final byte FLAG_ACTIVITY = 0; final byte FLAG_RECEIVER = 1; byte flag = FLAG_DEFAULT; out: while (true) { int event = parser.next(); switch (event) { case AxmlParser.START_FILE: break; case AxmlParser.END_FILE: break out; case AxmlParser.START_TAG: String tagName = parser.getName(); switch (tagName) { case "manifest": parseTagManifest(parser); break; case "application": parseTagApplication(parser); break; case "uses-permission": parseTagPermission(parser); break; case "activity": case "activity-alias": key = parseTagActivity(parser); if (key != null) { flag = FLAG_ACTIVITY; } else { flag = FLAG_DEFAULT; } break; case "service": parseTagService(parser); break; case "receiver": key = parseTagReceiver(parser); if (key != null) { flag = FLAG_RECEIVER; } else { flag = FLAG_DEFAULT; } break; case "action": if (flag == FLAG_ACTIVITY) { parseTagAction(parser, manifestInfo.activities.get(key)); } else if (flag == FLAG_RECEIVER) { parseTagAction(parser, manifestInfo.receivers.get(key)); } break; case "category": if (flag == FLAG_ACTIVITY) { parseTagCategory(parser, manifestInfo.activities.get(key)); } else if (flag == FLAG_RECEIVER) { parseTagCategory(parser, manifestInfo.receivers.get(key)); } break; case "meta-data": parseTagMetaData(parser); break; } case AxmlParser.END_TAG: } } ArrayList<String> permArr = new ArrayList<>(manifestInfo.permissions); Collections.sort(permArr); manifestInfo.requestedPermissions = permArr; Collections.sort(manifestInfo.services); } }
Parser { private void readAxml(final byte[] androidManifestData) throws IOException { manifestInfo = new ManifestInfo(); String key = null; AxmlParser parser = new AxmlParser(androidManifestData); final byte FLAG_DEFAULT = -1; final byte FLAG_ACTIVITY = 0; final byte FLAG_RECEIVER = 1; byte flag = FLAG_DEFAULT; out: while (true) { int event = parser.next(); switch (event) { case AxmlParser.START_FILE: break; case AxmlParser.END_FILE: break out; case AxmlParser.START_TAG: String tagName = parser.getName(); switch (tagName) { case "manifest": parseTagManifest(parser); break; case "application": parseTagApplication(parser); break; case "uses-permission": parseTagPermission(parser); break; case "activity": case "activity-alias": key = parseTagActivity(parser); if (key != null) { flag = FLAG_ACTIVITY; } else { flag = FLAG_DEFAULT; } break; case "service": parseTagService(parser); break; case "receiver": key = parseTagReceiver(parser); if (key != null) { flag = FLAG_RECEIVER; } else { flag = FLAG_DEFAULT; } break; case "action": if (flag == FLAG_ACTIVITY) { parseTagAction(parser, manifestInfo.activities.get(key)); } else if (flag == FLAG_RECEIVER) { parseTagAction(parser, manifestInfo.receivers.get(key)); } break; case "category": if (flag == FLAG_ACTIVITY) { parseTagCategory(parser, manifestInfo.activities.get(key)); } else if (flag == FLAG_RECEIVER) { parseTagCategory(parser, manifestInfo.receivers.get(key)); } break; case "meta-data": parseTagMetaData(parser); break; } case AxmlParser.END_TAG: } } ArrayList<String> permArr = new ArrayList<>(manifestInfo.permissions); Collections.sort(permArr); manifestInfo.requestedPermissions = permArr; Collections.sort(manifestInfo.services); } Parser(File pFile);  Parser(byte[] axmlBytes, byte[] arscBytes); }
Parser { private void readAxml(final byte[] androidManifestData) throws IOException { manifestInfo = new ManifestInfo(); String key = null; AxmlParser parser = new AxmlParser(androidManifestData); final byte FLAG_DEFAULT = -1; final byte FLAG_ACTIVITY = 0; final byte FLAG_RECEIVER = 1; byte flag = FLAG_DEFAULT; out: while (true) { int event = parser.next(); switch (event) { case AxmlParser.START_FILE: break; case AxmlParser.END_FILE: break out; case AxmlParser.START_TAG: String tagName = parser.getName(); switch (tagName) { case "manifest": parseTagManifest(parser); break; case "application": parseTagApplication(parser); break; case "uses-permission": parseTagPermission(parser); break; case "activity": case "activity-alias": key = parseTagActivity(parser); if (key != null) { flag = FLAG_ACTIVITY; } else { flag = FLAG_DEFAULT; } break; case "service": parseTagService(parser); break; case "receiver": key = parseTagReceiver(parser); if (key != null) { flag = FLAG_RECEIVER; } else { flag = FLAG_DEFAULT; } break; case "action": if (flag == FLAG_ACTIVITY) { parseTagAction(parser, manifestInfo.activities.get(key)); } else if (flag == FLAG_RECEIVER) { parseTagAction(parser, manifestInfo.receivers.get(key)); } break; case "category": if (flag == FLAG_ACTIVITY) { parseTagCategory(parser, manifestInfo.activities.get(key)); } else if (flag == FLAG_RECEIVER) { parseTagCategory(parser, manifestInfo.receivers.get(key)); } break; case "meta-data": parseTagMetaData(parser); break; } case AxmlParser.END_TAG: } } ArrayList<String> permArr = new ArrayList<>(manifestInfo.permissions); Collections.sort(permArr); manifestInfo.requestedPermissions = permArr; Collections.sort(manifestInfo.services); } Parser(File pFile);  Parser(byte[] axmlBytes, byte[] arscBytes); ManifestInfo getManifestInfo(); }
Parser { private void readAxml(final byte[] androidManifestData) throws IOException { manifestInfo = new ManifestInfo(); String key = null; AxmlParser parser = new AxmlParser(androidManifestData); final byte FLAG_DEFAULT = -1; final byte FLAG_ACTIVITY = 0; final byte FLAG_RECEIVER = 1; byte flag = FLAG_DEFAULT; out: while (true) { int event = parser.next(); switch (event) { case AxmlParser.START_FILE: break; case AxmlParser.END_FILE: break out; case AxmlParser.START_TAG: String tagName = parser.getName(); switch (tagName) { case "manifest": parseTagManifest(parser); break; case "application": parseTagApplication(parser); break; case "uses-permission": parseTagPermission(parser); break; case "activity": case "activity-alias": key = parseTagActivity(parser); if (key != null) { flag = FLAG_ACTIVITY; } else { flag = FLAG_DEFAULT; } break; case "service": parseTagService(parser); break; case "receiver": key = parseTagReceiver(parser); if (key != null) { flag = FLAG_RECEIVER; } else { flag = FLAG_DEFAULT; } break; case "action": if (flag == FLAG_ACTIVITY) { parseTagAction(parser, manifestInfo.activities.get(key)); } else if (flag == FLAG_RECEIVER) { parseTagAction(parser, manifestInfo.receivers.get(key)); } break; case "category": if (flag == FLAG_ACTIVITY) { parseTagCategory(parser, manifestInfo.activities.get(key)); } else if (flag == FLAG_RECEIVER) { parseTagCategory(parser, manifestInfo.receivers.get(key)); } break; case "meta-data": parseTagMetaData(parser); break; } case AxmlParser.END_TAG: } } ArrayList<String> permArr = new ArrayList<>(manifestInfo.permissions); Collections.sort(permArr); manifestInfo.requestedPermissions = permArr; Collections.sort(manifestInfo.services); } Parser(File pFile);  Parser(byte[] axmlBytes, byte[] arscBytes); ManifestInfo getManifestInfo();  }