Java Code Examples for soot.jimple.infoflow.android.axml.AXmlNode#getChildrenWithTag()
The following examples show how to use
soot.jimple.infoflow.android.axml.AXmlNode#getChildrenWithTag() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProcessManifest.java From JAADAS with GNU General Public License v3.0 | 5 votes |
private void collectIntentFilters(AXmlNode node) { String componentName = (String) node.getAttribute("name").getValue(); if(node.getChildrenWithTag("intent-filter").size() != 0) { List<IntentFilter> intentFilters = new ArrayList<>(); List<AXmlNode> currentFilters = node.getChildrenWithTag("intent-filter"); for(AXmlNode filter: currentFilters) { IntentFilter intentFilter = new IntentFilter(); //collect action List<AXmlNode> actionNodes = filter.getChildrenWithTag("action"); //assume action size == 1 List<String> actions = new ArrayList<>(); for(AXmlNode actionNode: actionNodes) { actions.add((String) actionNode.getAttribute("name").getValue()); } List<AXmlNode> categoryNodes = filter.getChildrenWithTag("category"); //assume action size == 1 List<String> categories = new ArrayList<>(); for(AXmlNode categoryNode: categoryNodes) { categories.add((String) categoryNode.getAttribute("name").getValue()); } intentFilter.setActions(actions); intentFilter.setCategories(categories); intentFilters.add(intentFilter); } this.filters.put(expandClassName(componentName), intentFilters); } else{ this.filters.put(expandClassName(componentName), Collections.<IntentFilter>emptyList()); } }
Example 2
Source File: UpdateManifestAndCodeForWaitPDP.java From DroidForce with GNU Lesser General Public License v2.1 | 4 votes |
/** * Get the name of the main activity in the AndroidManifest.xml file * @param apkFileLocation * @return */ public static String getMainActivityName(String apkFileLocation) { String mainActivityName = null; try { ProcessManifest pm = new ProcessManifest(apkFileLocation); AXmlHandler axmlh = pm.getAXml(); // Find main activity and remove main intent-filter List<AXmlNode> anodes = axmlh.getNodesWithTag("activity"); for (AXmlNode an: anodes) { boolean hasMain = false; boolean hasLauncher = false; AXmlNode filter = null; AXmlAttribute aname = an.getAttribute("name"); String aval = (String)aname.getValue(); System.out.println("activity: "+ aval); for (AXmlNode ch : an.getChildren()) { System.out.println("children: "+ ch); } List<AXmlNode> fnodes = an.getChildrenWithTag("intent-filter"); for (AXmlNode fn: fnodes) { hasMain = false; hasLauncher = false; // check action List<AXmlNode> acnodes = fn.getChildrenWithTag("action"); for (AXmlNode acn: acnodes) { AXmlAttribute acname = acn.getAttribute("name"); String acval = (String)acname.getValue(); System.out.println("action: "+ acval); if (acval.equals("android.intent.action.MAIN")) { hasMain = true; } } // check category List<AXmlNode> catnodes = fn.getChildrenWithTag("category"); for (AXmlNode catn: catnodes) { AXmlAttribute catname = catn.getAttribute("name"); String catval = (String)catname.getValue(); System.out.println("category: "+ catval); if (catval.equals("android.intent.category.LAUNCHER")) { hasLauncher = true; filter = fn; } } if (hasLauncher && hasMain) { break; } } if (hasLauncher && hasMain) { // replace name with the activity waiting for the connection to the PDP System.out.println("main activity is: "+ aval); System.out.println("excluding filter: "+ filter); filter.exclude(); mainActivityName = aval; break; } } } catch (IOException | XmlPullParserException ex) { System.err.println("Could not read Android manifest file: " + ex.getMessage()); throw new RuntimeException(ex); } return mainActivityName; }