com.android.xml.AndroidManifest Java Examples

The following examples show how to use com.android.xml.AndroidManifest. 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: AndroidManifestParser.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Processes the service/receiver/provider nodes.
 * @param attributes the attributes for the activity node.
 * @param superClassName the fully qualified name of the super class that this
 * node is representing
 */
private void processNode(Attributes attributes, String superClassName) {
    // lets get the class name, and check it if required.
    String serviceName = getAttributeValue(attributes, AndroidManifest.ATTRIBUTE_NAME,
            true /* hasNamespace */);
    if (serviceName != null) {
        serviceName = AndroidManifest.combinePackageAndClassName(mManifestData.mPackage,
                serviceName);

        if (mErrorHandler != null) {
            mErrorHandler.checkClass(mLocator, serviceName, superClassName,
                    false /* testVisibility */);
        }
    }

    String processName = getAttributeValue(attributes, AndroidManifest.ATTRIBUTE_PROCESS,
            true /* hasNamespace */);
    if (processName != null) {
        mManifestData.addProcessName(processName);
    }
}
 
Example #2
Source File: AndroidManifestParser.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
/**
 * Processes the supports-screens node.
 *
 * @param attributes the attributes for the supports-screens node.
 */
private void processUsesConfiguration(Attributes attributes) {
    mManifestData.mUsesConfiguration = new UsesConfiguration();

    mManifestData.mUsesConfiguration.mReqFiveWayNav = getAttributeBooleanValue(
            attributes,
            AndroidManifest.ATTRIBUTE_REQ_5WAYNAV, true /*hasNamespace*/);
    mManifestData.mUsesConfiguration.mReqNavigation = Navigation.getEnum(
            getAttributeValue(attributes,
                    AndroidManifest.ATTRIBUTE_REQ_NAVIGATION, true /*hasNamespace*/));
    mManifestData.mUsesConfiguration.mReqHardKeyboard = getAttributeBooleanValue(
            attributes,
            AndroidManifest.ATTRIBUTE_REQ_HARDKEYBOARD, true /*hasNamespace*/);
    mManifestData.mUsesConfiguration.mReqKeyboardType = Keyboard.getEnum(
            getAttributeValue(attributes,
                    AndroidManifest.ATTRIBUTE_REQ_KEYBOARDTYPE, true /*hasNamespace*/));
    mManifestData.mUsesConfiguration.mReqTouchScreen = TouchScreen.getEnum(
            getAttributeValue(attributes,
                    AndroidManifest.ATTRIBUTE_REQ_TOUCHSCREEN, true /*hasNamespace*/));
}
 
Example #3
Source File: AndroidManifestParser.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
/**
 * Processes the supports-screens node.
 *
 * @param attributes the attributes for the supports-screens node.
 */
private void processSupportsScreensNode(Attributes attributes) {
    mManifestData.mSupportsScreensFromManifest = new SupportsScreens();

    mManifestData.mSupportsScreensFromManifest.setResizeable(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_RESIZEABLE, true /*hasNamespace*/));

    mManifestData.mSupportsScreensFromManifest.setAnyDensity(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_ANYDENSITY, true /*hasNamespace*/));

    mManifestData.mSupportsScreensFromManifest.setSmallScreens(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_SMALLSCREENS, true /*hasNamespace*/));

    mManifestData.mSupportsScreensFromManifest.setNormalScreens(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_NORMALSCREENS, true /*hasNamespace*/));

    mManifestData.mSupportsScreensFromManifest.setLargeScreens(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_LARGESCREENS, true /*hasNamespace*/));
}
 
Example #4
Source File: AndroidManifestParser.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
/**
 * Processes the instrumentation node.
 *
 * @param attributes the attributes for the instrumentation node.
 */
private void processInstrumentationNode(Attributes attributes) {
    // lets get the class name, and check it if required.
    String instrumentationName = getAttributeValue(attributes,
            AndroidManifest.ATTRIBUTE_NAME,
            true /* hasNamespace */);
    if (instrumentationName != null) {
        String instrClassName
                = combinePackageAndClassName(mManifestData.mPackage, instrumentationName);
        String targetPackage = getAttributeValue(attributes,
                AndroidManifest.ATTRIBUTE_TARGET_PACKAGE,
                true /* hasNamespace */);
        mManifestData.mInstrumentations.add(
                new Instrumentation(instrClassName, targetPackage));
        mManifestData.mKeepClasses.add(
                new ManifestData.KeepClass(
                        instrClassName, null, AndroidManifest.NODE_INSTRUMENTATION));
        if (mErrorHandler != null) {
            mErrorHandler.checkClass(mLocator, instrClassName,
                    SdkConstants.CLASS_INSTRUMENTATION, true /* testVisibility */);
        }
    }
}
 
Example #5
Source File: AndroidManifestParser.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Processes the supports-screens node.
 * @param attributes the attributes for the supports-screens node.
 */
private void processUsesConfiguration(Attributes attributes) {
    mManifestData.mUsesConfiguration = new UsesConfiguration();

    mManifestData.mUsesConfiguration.mReqFiveWayNav = getAttributeBooleanValue(
            attributes,
            AndroidManifest.ATTRIBUTE_REQ_5WAYNAV, true /*hasNamespace*/);
    mManifestData.mUsesConfiguration.mReqNavigation = Navigation.getEnum(
            getAttributeValue(attributes,
                    AndroidManifest.ATTRIBUTE_REQ_NAVIGATION, true /*hasNamespace*/));
    mManifestData.mUsesConfiguration.mReqHardKeyboard = getAttributeBooleanValue(
            attributes,
            AndroidManifest.ATTRIBUTE_REQ_HARDKEYBOARD, true /*hasNamespace*/);
    mManifestData.mUsesConfiguration.mReqKeyboardType = Keyboard.getEnum(
            getAttributeValue(attributes,
                    AndroidManifest.ATTRIBUTE_REQ_KEYBOARDTYPE, true /*hasNamespace*/));
    mManifestData.mUsesConfiguration.mReqTouchScreen = TouchScreen.getEnum(
            getAttributeValue(attributes,
                    AndroidManifest.ATTRIBUTE_REQ_TOUCHSCREEN, true /*hasNamespace*/));
}
 
Example #6
Source File: AndroidManifestParser.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Processes the supports-screens node.
 * @param attributes the attributes for the supports-screens node.
 */
private void processSupportsScreensNode(Attributes attributes) {
    mManifestData.mSupportsScreensFromManifest = new SupportsScreens();

    mManifestData.mSupportsScreensFromManifest.setResizeable(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_RESIZEABLE, true /*hasNamespace*/));

    mManifestData.mSupportsScreensFromManifest.setAnyDensity(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_ANYDENSITY, true /*hasNamespace*/));

    mManifestData.mSupportsScreensFromManifest.setSmallScreens(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_SMALLSCREENS, true /*hasNamespace*/));

    mManifestData.mSupportsScreensFromManifest.setNormalScreens(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_NORMALSCREENS, true /*hasNamespace*/));

    mManifestData.mSupportsScreensFromManifest.setLargeScreens(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_LARGESCREENS, true /*hasNamespace*/));
}
 
Example #7
Source File: AndroidManifestParser.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Processes the instrumentation node.
 * @param attributes the attributes for the instrumentation node.
 */
private void processInstrumentationNode(Attributes attributes) {
    // lets get the class name, and check it if required.
    String instrumentationName = getAttributeValue(attributes,
            AndroidManifest.ATTRIBUTE_NAME,
            true /* hasNamespace */);
    if (instrumentationName != null) {
        String instrClassName = AndroidManifest.combinePackageAndClassName(
                mManifestData.mPackage, instrumentationName);
        String targetPackage = getAttributeValue(attributes,
                AndroidManifest.ATTRIBUTE_TARGET_PACKAGE,
                true /* hasNamespace */);
        mManifestData.mInstrumentations.add(
                new Instrumentation(instrClassName, targetPackage));
        if (mErrorHandler != null) {
            mErrorHandler.checkClass(mLocator, instrClassName,
                    SdkConstants.CLASS_INSTRUMENTATION, true /* testVisibility */);
        }
    }
}
 
Example #8
Source File: AndroidManifestParser.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Processes the service/receiver/provider nodes.
 * @param attributes the attributes for the activity node.
 * @param superClassName the fully qualified name of the super class that this
 * node is representing
 */
private void processNode(Attributes attributes, String superClassName) {
    // lets get the class name, and check it if required.
    String serviceName = getAttributeValue(attributes, AndroidManifest.ATTRIBUTE_NAME,
            true /* hasNamespace */);
    if (serviceName != null) {
        serviceName = AndroidManifest.combinePackageAndClassName(mManifestData.mPackage,
                serviceName);

        if (mErrorHandler != null) {
            mErrorHandler.checkClass(mLocator, serviceName, superClassName,
                    false /* testVisibility */);
        }
    }

    String processName = getAttributeValue(attributes, AndroidManifest.ATTRIBUTE_PROCESS,
            true /* hasNamespace */);
    if (processName != null) {
        mManifestData.addProcessName(processName);
    }
}
 
Example #9
Source File: AndroidManifestParser.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Processes the supports-screens node.
 * @param attributes the attributes for the supports-screens node.
 */
private void processUsesConfiguration(Attributes attributes) {
    mManifestData.mUsesConfiguration = new UsesConfiguration();

    mManifestData.mUsesConfiguration.mReqFiveWayNav = getAttributeBooleanValue(
            attributes,
            AndroidManifest.ATTRIBUTE_REQ_5WAYNAV, true /*hasNamespace*/);
    mManifestData.mUsesConfiguration.mReqNavigation = Navigation.getEnum(
            getAttributeValue(attributes,
                    AndroidManifest.ATTRIBUTE_REQ_NAVIGATION, true /*hasNamespace*/));
    mManifestData.mUsesConfiguration.mReqHardKeyboard = getAttributeBooleanValue(
            attributes,
            AndroidManifest.ATTRIBUTE_REQ_HARDKEYBOARD, true /*hasNamespace*/);
    mManifestData.mUsesConfiguration.mReqKeyboardType = Keyboard.getEnum(
            getAttributeValue(attributes,
                    AndroidManifest.ATTRIBUTE_REQ_KEYBOARDTYPE, true /*hasNamespace*/));
    mManifestData.mUsesConfiguration.mReqTouchScreen = TouchScreen.getEnum(
            getAttributeValue(attributes,
                    AndroidManifest.ATTRIBUTE_REQ_TOUCHSCREEN, true /*hasNamespace*/));
}
 
Example #10
Source File: AndroidManifestParser.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Processes the supports-screens node.
 * @param attributes the attributes for the supports-screens node.
 */
private void processSupportsScreensNode(Attributes attributes) {
    mManifestData.mSupportsScreensFromManifest = new SupportsScreens();

    mManifestData.mSupportsScreensFromManifest.setResizeable(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_RESIZEABLE, true /*hasNamespace*/));

    mManifestData.mSupportsScreensFromManifest.setAnyDensity(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_ANYDENSITY, true /*hasNamespace*/));

    mManifestData.mSupportsScreensFromManifest.setSmallScreens(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_SMALLSCREENS, true /*hasNamespace*/));

    mManifestData.mSupportsScreensFromManifest.setNormalScreens(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_NORMALSCREENS, true /*hasNamespace*/));

    mManifestData.mSupportsScreensFromManifest.setLargeScreens(getAttributeBooleanValue(
            attributes, AndroidManifest.ATTRIBUTE_LARGESCREENS, true /*hasNamespace*/));
}
 
Example #11
Source File: AndroidManifestParser.java    From java-n-IDE-for-Android with Apache License 2.0 6 votes vote down vote up
/**
 * Processes the instrumentation node.
 * @param attributes the attributes for the instrumentation node.
 */
private void processInstrumentationNode(Attributes attributes) {
    // lets get the class name, and check it if required.
    String instrumentationName = getAttributeValue(attributes,
            AndroidManifest.ATTRIBUTE_NAME,
            true /* hasNamespace */);
    if (instrumentationName != null) {
        String instrClassName = AndroidManifest.combinePackageAndClassName(
                mManifestData.mPackage, instrumentationName);
        String targetPackage = getAttributeValue(attributes,
                AndroidManifest.ATTRIBUTE_TARGET_PACKAGE,
                true /* hasNamespace */);
        mManifestData.mInstrumentations.add(
                new Instrumentation(instrClassName, targetPackage));
        if (mErrorHandler != null) {
            mErrorHandler.checkClass(mLocator, instrClassName,
                    SdkConstants.CLASS_INSTRUMENTATION, true /* testVisibility */);
        }
    }
}
 
Example #12
Source File: ElementsTrimmer.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private static Integer getGlEsVersion(XmlElement xmlElement) {
    Attr glEsVersion = xmlElement.getXml()
            .getAttributeNodeNS(ANDROID_URI, AndroidManifest.ATTRIBUTE_GLESVERSION);
    if (glEsVersion == null) {
        return null;
    }
    return getHexValue(glEsVersion);
}
 
Example #13
Source File: PreValidator.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private static void validateManifestAttribute(
        MergingReport.Builder mergingReport, XmlElement manifest, XmlDocument.Type fileType) {
    Attr attributeNode = manifest.getXml().getAttributeNode(AndroidManifest.ATTRIBUTE_PACKAGE);
    // it's ok for an overlay to not have a package name, it's not ok for a main manifest
    // and it's a warning for a library.
    if (attributeNode == null && fileType != XmlDocument.Type.OVERLAY) {
        manifest.addMessage(mergingReport,
                fileType == XmlDocument.Type.MAIN ? ERROR : WARNING,
                String.format(
                    "Missing 'package' declaration in manifest at %1$s",
                    manifest.printPosition()));
    }
}
 
Example #14
Source File: AndroidManifestParser.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Processes the activity node.
 * @param attributes the attributes for the activity node.
 */
private void processActivityNode(Attributes attributes) {
    // lets get the activity name, and add it to the list
    String activityName = getAttributeValue(attributes, AndroidManifest.ATTRIBUTE_NAME,
            true /* hasNamespace */);
    if (activityName != null) {
        activityName = AndroidManifest.combinePackageAndClassName(mManifestData.mPackage,
                activityName);

        // get the exported flag.
        String exportedStr = getAttributeValue(attributes,
                AndroidManifest.ATTRIBUTE_EXPORTED, true);
        boolean exported = exportedStr == null ||
                exportedStr.toLowerCase(Locale.US).equals("true"); //$NON-NLS-1$
        mCurrentActivity = new Activity(activityName, exported);
        mManifestData.mActivities.add(mCurrentActivity);

        if (mErrorHandler != null) {
            mErrorHandler.checkClass(mLocator, activityName, SdkConstants.CLASS_ACTIVITY,
                    true /* testVisibility */);
        }
    } else {
        // no activity found! Aapt will output an error,
        // so we don't have to do anything
        mCurrentActivity = null;
    }

    String processName = getAttributeValue(attributes, AndroidManifest.ATTRIBUTE_PROCESS,
            true /* hasNamespace */);
    if (processName != null) {
        mManifestData.addProcessName(processName);
    }
}
 
Example #15
Source File: PreValidator.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private static void validateManifestAttribute(
        MergingReport.Builder mergingReport, XmlElement manifest, XmlDocument.Type fileType) {
    Attr attributeNode = manifest.getXml().getAttributeNode(AndroidManifest.ATTRIBUTE_PACKAGE);
    // it's ok for an overlay to not have a package name, it's not ok for a main manifest
    // and it's a warning for a library.
    if (attributeNode == null && fileType != XmlDocument.Type.OVERLAY) {
        manifest.addMessage(mergingReport,
                fileType == XmlDocument.Type.MAIN ? ERROR : WARNING,
                String.format(
                    "Missing 'package' declaration in manifest at %1$s",
                    manifest.printPosition()));
    }
}
 
Example #16
Source File: ElementsTrimmer.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
private static Integer getGlEsVersion(XmlElement xmlElement) {
    Attr glEsVersion = xmlElement.getXml()
            .getAttributeNodeNS(ANDROID_URI, AndroidManifest.ATTRIBUTE_GLESVERSION);
    if (glEsVersion == null) {
        return null;
    }
    return getHexValue(glEsVersion);
}
 
Example #17
Source File: AndroidManifestParser.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
public static ManifestData parse(IAbstractFolder projectFolder)
        throws SAXException, IOException, StreamException, ParserConfigurationException {
    IAbstractFile manifestFile = AndroidManifest.getManifest(projectFolder);
    if (manifestFile == null) {
        throw new FileNotFoundException();
    }

    return parse(manifestFile, true, null);
}
 
Example #18
Source File: AndroidManifestParser.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public static ManifestData parse(IAbstractFolder projectFolder)
        throws SAXException, IOException, StreamException, ParserConfigurationException {
    IAbstractFile manifestFile = AndroidManifest.getManifest(projectFolder);
    if (manifestFile == null) {
        throw new FileNotFoundException();
    }

    return parse(manifestFile, true, null);
}
 
Example #19
Source File: AndroidManifestParser.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
/**
 * Processes the service/receiver/provider nodes.
 *
 * @param attributes the attributes for the activity node.
 * @param superClassName the fully qualified name of the super class
 * that this
 * @param localName the tag of the node node is representing
 */
private void processNode(Attributes attributes, String superClassName, String localName) {
    // lets get the class name, and check it if required.
    String serviceName = getAttributeValue(attributes, AndroidManifest.ATTRIBUTE_NAME,
            true /* hasNamespace */);
    if (serviceName != null) {
        serviceName = combinePackageAndClassName(mManifestData.mPackage, serviceName);

        if (mErrorHandler != null) {
            mErrorHandler.checkClass(mLocator, serviceName, superClassName,
                    false /* testVisibility */);
        }
    }

    String processName = getAttributeValue(attributes, AndroidManifest.ATTRIBUTE_PROCESS,
            true /* hasNamespace */);
    if (processName != null) {
        mManifestData.addProcessName(processName);
    }

    if (processName == null || processName.isEmpty()) {
        processName = mManifestData.getDefaultProcess();
    }

    if (serviceName != null) {
        mManifestData.mKeepClasses.add(
                new ManifestData.KeepClass(serviceName, processName, localName));
    }
}
 
Example #20
Source File: AndroidManifestParser.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Processes the activity node.
 * @param attributes the attributes for the activity node.
 */
private void processActivityNode(Attributes attributes) {
    // lets get the activity name, and add it to the list
    String activityName = getAttributeValue(attributes, AndroidManifest.ATTRIBUTE_NAME,
            true /* hasNamespace */);
    if (activityName != null) {
        activityName = AndroidManifest.combinePackageAndClassName(mManifestData.mPackage,
                activityName);

        // get the exported flag.
        String exportedStr = getAttributeValue(attributes,
                AndroidManifest.ATTRIBUTE_EXPORTED, true);
        boolean exported = exportedStr == null ||
                exportedStr.toLowerCase(Locale.US).equals("true"); //$NON-NLS-1$
        mCurrentActivity = new Activity(activityName, exported);
        mManifestData.mActivities.add(mCurrentActivity);

        if (mErrorHandler != null) {
            mErrorHandler.checkClass(mLocator, activityName, SdkConstants.CLASS_ACTIVITY,
                    true /* testVisibility */);
        }
    } else {
        // no activity found! Aapt will output an error,
        // so we don't have to do anything
        mCurrentActivity = null;
    }

    String processName = getAttributeValue(attributes, AndroidManifest.ATTRIBUTE_PROCESS,
            true /* hasNamespace */);
    if (processName != null) {
        mManifestData.addProcessName(processName);
    }
}
 
Example #21
Source File: AARLibrary.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Extracts the package name from the Android Archive without needing to unzip it to a location
 * in the file system
 *
 * @param zip the input stream reading from the Android Archive.
 * @return the package name declared in the archive's AndroidManifest.xml.
 * @throws IOException if reading the input stream fails.
 */
private String extractPackageName(ZipFile zip) throws IOException {
  ZipEntry entry = zip.getEntry("AndroidManifest.xml");
  if (entry == null) {
    throw new IllegalArgumentException(zip.getName() + " does not contain AndroidManifest.xml");
  }
  try {
    ZipEntryWrapper wrapper = new ZipEntryWrapper(zip.getInputStream(entry));
    // the following call will automatically close the input stream opened above
    return AndroidManifest.getPackage(wrapper);
  } catch(StreamException|XPathExpressionException e) {
    throw new IOException("Exception processing AndroidManifest.xml", e);
  }
}
 
Example #22
Source File: AndroidManifestParser.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
/**
 * Processes the application node.
 *
 * @param attributes the attributes for the application node.
 */
private void processApplicationNode(Attributes attributes) {
    String value
            = getAttributeValue(
                    attributes, AndroidManifest.ATTRIBUTE_PROCESS, true /* hasNamespace */);
    if (value != null) {
        mManifestData.addProcessName(value);
        mManifestData.mDefaultProcess = value;
    }

    value
            = getAttributeValue(
                    attributes,
                    AndroidManifest.ATTRIBUTE_DEBUGGABLE,
                    true /* hasNamespace*/);
    if (value != null) {
        mManifestData.mDebuggable = Boolean.parseBoolean(value);
    }

    value
            = getAttributeValue(
                    attributes,
                    AndroidManifest.ATTRIBUTE_THEME,
                    true /* hasNamespace*/);
    if (value != null) {
        mManifestData.theme = value;
    }

    value
            = getAttributeValue(
                    attributes, AndroidManifest.ATTRIBUTE_NAME, true /* hasNamespace*/);

    if (value != null) {
        mManifestData.mKeepClasses.add(
                new ManifestData.KeepClass(
                        combinePackageAndClassName(mManifestData.mPackage, value),
                        null,
                        AndroidManifest.NODE_APPLICATION));
    }

    value
            = getAttributeValue(
                    attributes,
                    AndroidManifest.ATTRIBUTE_BACKUP_AGENT,
                    true /* hasNamespace*/);

    if (value != null) {
        mManifestData.mKeepClasses.add(
                new ManifestData.KeepClass(
                        combinePackageAndClassName(mManifestData.mPackage, value),
                        null,
                        AndroidManifest.ATTRIBUTE_BACKUP_AGENT));
    }
}
 
Example #23
Source File: AndroidManifestParser.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
/**
 * Processes the activity node.
 *
 * @param attributes the attributes for the activity node.
 */
private void processActivityNode(Attributes attributes) {
    // lets get the activity name, and add it to the list
    String activityName = getAttributeValue(attributes, AndroidManifest.ATTRIBUTE_NAME,
            true /* hasNamespace */);
    if (activityName != null) {
        activityName = combinePackageAndClassName(mManifestData.mPackage, activityName);

        // get the exported flag.
        String exportedStr = getAttributeValue(attributes,
                AndroidManifest.ATTRIBUTE_EXPORTED, true);
        boolean exported = exportedStr == null
                || exportedStr.toLowerCase(Locale.US).equals("true"); //$NON-NLS-1$
        mCurrentActivity = new Activity(activityName, exported);

        String themeName = getAttributeValue(attributes,
                AndroidManifest.ATTRIBUTE_THEME, true);
        mCurrentActivity.setTheme(themeName);
        mManifestData.mActivities.add(mCurrentActivity);

        if (mErrorHandler != null) {
            mErrorHandler.checkClass(mLocator, activityName, SdkConstants.CLASS_ACTIVITY,
                    true /* testVisibility */);
        }
    } else {
        // no activity found! Aapt will output an error,
        // so we don't have to do anything
        mCurrentActivity = null;
    }

    String processName = getAttributeValue(attributes, AndroidManifest.ATTRIBUTE_PROCESS,
            true /* hasNamespace */);
    if (processName != null) {
        mManifestData.addProcessName(processName);
    }

    if (processName == null || processName.isEmpty()) {
        processName = mManifestData.getDefaultProcess();
    }

    if (activityName != null) {
        mManifestData.mKeepClasses.add(
                new ManifestData.KeepClass(
                        activityName, processName, AndroidManifest.NODE_ACTIVITY));
    }
}