Example usage for android.content.pm InstrumentationInfo InstrumentationInfo

List of usage examples for android.content.pm InstrumentationInfo InstrumentationInfo

Introduction

In this page you can find the example usage for android.content.pm InstrumentationInfo InstrumentationInfo.

Prototype

public InstrumentationInfo() 

Source Link

Usage

From source file:android.content.pm.PackageParser.java

private Instrumentation parseInstrumentation(Package owner, Resources res, XmlPullParser parser,
        AttributeSet attrs, String[] outError) throws XmlPullParserException, IOException {
    TypedArray sa = res.obtainAttributes(attrs,
            com.android.internal.R.styleable.AndroidManifestInstrumentation);

    if (mParseInstrumentationArgs == null) {
        mParseInstrumentationArgs = new ParsePackageItemArgs(owner, outError,
                com.android.internal.R.styleable.AndroidManifestInstrumentation_name,
                com.android.internal.R.styleable.AndroidManifestInstrumentation_label,
                com.android.internal.R.styleable.AndroidManifestInstrumentation_icon,
                com.android.internal.R.styleable.AndroidManifestInstrumentation_logo,
                com.android.internal.R.styleable.AndroidManifestInstrumentation_banner);
        mParseInstrumentationArgs.tag = "<instrumentation>";
    }/*from  w w  w.ja  v  a2 s.  c  o  m*/

    mParseInstrumentationArgs.sa = sa;

    Instrumentation a = new Instrumentation(mParseInstrumentationArgs, new InstrumentationInfo());
    if (outError[0] != null) {
        sa.recycle();
        mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return null;
    }

    String str;
    // Note: don't allow this value to be a reference to a resource
    // that may change.
    str = sa.getNonResourceString(
            com.android.internal.R.styleable.AndroidManifestInstrumentation_targetPackage);
    a.info.targetPackage = str != null ? str.intern() : null;

    a.info.handleProfiling = sa
            .getBoolean(com.android.internal.R.styleable.AndroidManifestInstrumentation_handleProfiling, false);

    a.info.functionalTest = sa
            .getBoolean(com.android.internal.R.styleable.AndroidManifestInstrumentation_functionalTest, false);

    sa.recycle();

    if (a.info.targetPackage == null) {
        outError[0] = "<instrumentation> does not specify targetPackage";
        mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return null;
    }

    if (!parseAllMetaData(res, parser, attrs, "<instrumentation>", a, outError)) {
        mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
        return null;
    }

    owner.instrumentation.add(a);

    return a;
}