soot.jimple.infoflow.android.resources.ARSCFileParser.StringResource Java Examples

The following examples show how to use soot.jimple.infoflow.android.resources.ARSCFileParser.StringResource. 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: LayoutFileParser.java    From LibScout with Apache License 2.0 5 votes vote down vote up
@Override
public void attr(String ns, String name, int resourceId, int type, Object obj) {
    // Is this the target file attribute?
    String tname = name.trim();
    if (tname.equals("layout")) {
        if (type == AxmlVisitor.TYPE_REFERENCE && obj instanceof Integer) {
            // We need to get the target XML file from the binary manifest
            AbstractResource targetRes = resParser.findResource((Integer) obj);
            if (targetRes == null) {
                logger.trace(Utils.INDENT + "Target resource " + obj + " for layout include not found");
                return;
            }    
            if (!(targetRes instanceof StringResource)) {
                logger.trace(Utils.INDENT + "Invalid target node for include tag in layout XML, was " + targetRes.getClass().getName());
                return;
            }    
            String targetFile = ((StringResource) targetRes).getValue();

            // If we have already processed the target file, we can
            // simply copy the callbacks we have found there
            if (callbackMethods.containsKey(targetFile))
                for (String callback : callbackMethods.get(targetFile))
                    addCallbackMethod(layoutFile, callback);
            else {
                // We need to record a dependency to resolve later
                MapUtils.addToSet(includeDependencies, targetFile, layoutFile);
            }    
        }    
    }    

    super.attr(ns, name, resourceId, type, obj);
}
 
Example #2
Source File: LayoutFileParser.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Parses the attributes required for a layout file inclusion
 * @param layoutFile The full path and file name of the file being parsed
 * @param rootNode The AXml node containing the attributes
 */
private void parseIncludeAttributes(String layoutFile, AXmlNode rootNode) {
	for (Entry<String, AXmlAttribute<?>> entry : rootNode.getAttributes().entrySet()) {
		String attrName = entry.getKey().trim();
		AXmlAttribute<?> attr = entry.getValue();
		
   		if (attrName.equals("layout")) {
   			if ((attr.getType() == AxmlVisitor.TYPE_REFERENCE || attr.getType() == AxmlVisitor.TYPE_INT_HEX)
   					&& attr.getValue() instanceof Integer) {
   				// We need to get the target XML file from the binary manifest
   				AbstractResource targetRes = resParser.findResource((Integer) attr.getValue());
   				if (targetRes == null) {
   					System.err.println("Target resource " + attr.getValue() + " for layout include not found");
   					return;
   				}
   				if (!(targetRes instanceof StringResource)) {
   					System.err.println("Invalid target node for include tag in layout XML, was "
   							+ targetRes.getClass().getName());
   					return;
   				}
   				String targetFile = ((StringResource) targetRes).getValue();
   				
   				// If we have already processed the target file, we can
   				// simply copy the callbacks we have found there
       			if (callbackMethods.containsKey(targetFile))
       				for (String callback : callbackMethods.get(targetFile))
       					addCallbackMethod(layoutFile, callback);
       			else {
       				// We need to record a dependency to resolve later
       				addToMapSet(includeDependencies, targetFile, layoutFile);
       			}
   			}
   		}
	}
}