List of usage examples for android.content.res TypedArray getBoolean
public boolean getBoolean(@StyleableRes int index, boolean defValue)
From source file:android.content.pm.PackageParser.java
/** * Parse the {@code application} XML tree at the current parse location in a * <em>split APK</em> manifest. * <p>//w w w . j a v a 2 s .c o m * Note that split APKs have many more restrictions on what they're capable * of doing, so many valid features of a base APK have been carefully * omitted here. */ private boolean parseSplitApplication(Package owner, Resources res, XmlPullParser parser, AttributeSet attrs, int flags, int splitIndex, String[] outError) throws XmlPullParserException, IOException { TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestApplication); if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_hasCode, true)) { owner.splitFlags[splitIndex] |= ApplicationInfo.FLAG_HAS_CODE; } final int innerDepth = parser.getDepth(); int type; while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth)) { if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { continue; } String tagName = parser.getName(); if (tagName.equals("activity")) { Activity a = parseActivity(owner, res, parser, attrs, flags, outError, false, owner.baseHardwareAccelerated); if (a == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.activities.add(a); } else if (tagName.equals("receiver")) { Activity a = parseActivity(owner, res, parser, attrs, flags, outError, true, false); if (a == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.receivers.add(a); } else if (tagName.equals("service")) { Service s = parseService(owner, res, parser, attrs, flags, outError); if (s == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.services.add(s); } else if (tagName.equals("provider")) { Provider p = parseProvider(owner, res, parser, attrs, flags, outError); if (p == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.providers.add(p); } else if (tagName.equals("activity-alias")) { Activity a = parseActivityAlias(owner, res, parser, attrs, flags, outError); if (a == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.activities.add(a); } else if (parser.getName().equals("meta-data")) { // note: application meta-data is stored off to the side, so it can // remain null in the primary copy (we like to avoid extra copies because // it can be large) if ((owner.mAppMetaData = parseMetaData(res, parser, attrs, owner.mAppMetaData, outError)) == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } } else if (tagName.equals("uses-library")) { sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestUsesLibrary); // Note: don't allow this value to be a reference to a resource // that may change. String lname = sa .getNonResourceString(com.android.internal.R.styleable.AndroidManifestUsesLibrary_name); boolean req = sa.getBoolean(com.android.internal.R.styleable.AndroidManifestUsesLibrary_required, true); sa.recycle(); if (lname != null) { lname = lname.intern(); if (req) { // Upgrade to treat as stronger constraint owner.usesLibraries = ArrayUtils.add(owner.usesLibraries, lname); owner.usesOptionalLibraries = ArrayUtils.remove(owner.usesOptionalLibraries, lname); } else { // Ignore if someone already defined as required if (!ArrayUtils.contains(owner.usesLibraries, lname)) { owner.usesOptionalLibraries = ArrayUtils.add(owner.usesOptionalLibraries, lname); } } } XmlUtils.skipCurrentTag(parser); } else if (tagName.equals("uses-package")) { // Dependencies for app installers; we don't currently try to // enforce this. XmlUtils.skipCurrentTag(parser); } else { if (!RIGID_PARSER) { Slog.w(TAG, "Unknown element under <application>: " + tagName + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } else { outError[0] = "Bad element under <application>: " + tagName; mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } } } return true; }
From source file:com.facebook.litho.InternalNode.java
void applyAttributes(TypedArray a) { for (int i = 0, size = a.getIndexCount(); i < size; i++) { final int attr = a.getIndex(i); if (attr == R.styleable.ComponentLayout_android_layout_width) { int width = a.getLayoutDimension(attr, -1); // We don't support WRAP_CONTENT or MATCH_PARENT so no-op for them if (width >= 0) { widthPx(width);/*w ww. ja v a2 s . c o m*/ } } else if (attr == R.styleable.ComponentLayout_android_layout_height) { int height = a.getLayoutDimension(attr, -1); // We don't support WRAP_CONTENT or MATCH_PARENT so no-op for them if (height >= 0) { heightPx(height); } } else if (attr == R.styleable.ComponentLayout_android_paddingLeft) { paddingPx(LEFT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingTop) { paddingPx(TOP, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingRight) { paddingPx(RIGHT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingBottom) { paddingPx(BOTTOM, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingStart && SUPPORTS_RTL) { paddingPx(START, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_paddingEnd && SUPPORTS_RTL) { paddingPx(END, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_padding) { paddingPx(ALL, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginLeft) { marginPx(LEFT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginTop) { marginPx(TOP, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginRight) { marginPx(RIGHT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginBottom) { marginPx(BOTTOM, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginStart && SUPPORTS_RTL) { marginPx(START, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_marginEnd && SUPPORTS_RTL) { marginPx(END, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_layout_margin) { marginPx(ALL, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_importantForAccessibility && SDK_INT >= JELLY_BEAN) { importantForAccessibility(a.getInt(attr, 0)); } else if (attr == R.styleable.ComponentLayout_android_duplicateParentState) { duplicateParentState(a.getBoolean(attr, false)); } else if (attr == R.styleable.ComponentLayout_android_background) { if (TypedArrayUtils.isColorAttribute(a, R.styleable.ComponentLayout_android_background)) { backgroundColor(a.getColor(attr, 0)); } else { backgroundRes(a.getResourceId(attr, -1)); } } else if (attr == R.styleable.ComponentLayout_android_foreground) { if (TypedArrayUtils.isColorAttribute(a, R.styleable.ComponentLayout_android_foreground)) { foregroundColor(a.getColor(attr, 0)); } else { foregroundRes(a.getResourceId(attr, -1)); } } else if (attr == R.styleable.ComponentLayout_android_contentDescription) { contentDescription(a.getString(attr)); } else if (attr == R.styleable.ComponentLayout_flex_direction) { flexDirection(YogaFlexDirection.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_wrap) { wrap(YogaWrap.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_justifyContent) { justifyContent(YogaJustify.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_alignItems) { alignItems(YogaAlign.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_alignSelf) { alignSelf(YogaAlign.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex_positionType) { positionType(YogaPositionType.fromInt(a.getInteger(attr, 0))); } else if (attr == R.styleable.ComponentLayout_flex) { final float flex = a.getFloat(attr, -1); if (flex >= 0f) { flex(flex); } } else if (attr == R.styleable.ComponentLayout_flex_left) { positionPx(LEFT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_flex_top) { positionPx(TOP, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_flex_right) { positionPx(RIGHT, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_flex_bottom) { positionPx(BOTTOM, a.getDimensionPixelOffset(attr, 0)); } else if (attr == R.styleable.ComponentLayout_flex_layoutDirection) { final int layoutDirection = a.getInteger(attr, -1); layoutDirection(YogaDirection.fromInt(layoutDirection)); } } }
From source file:android.content.pm.PackageParser.java
private FeatureInfo parseUsesFeature(Resources res, AttributeSet attrs) throws XmlPullParserException, IOException { FeatureInfo fi = new FeatureInfo(); TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestUsesFeature); // Note: don't allow this value to be a reference to a resource // that may change. fi.name = sa.getNonResourceString(com.android.internal.R.styleable.AndroidManifestUsesFeature_name); if (fi.name == null) { fi.reqGlEsVersion = sa.getInt(com.android.internal.R.styleable.AndroidManifestUsesFeature_glEsVersion, FeatureInfo.GL_ES_VERSION_UNDEFINED); }/*from w w w .ja va 2s . c om*/ if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestUsesFeature_required, true)) { fi.flags |= FeatureInfo.FLAG_REQUIRED; } sa.recycle(); return fi; }
From source file:android.content.pm.PackageParser.java
private boolean parseIntent(Resources res, XmlPullParser parser, AttributeSet attrs, boolean allowGlobs, boolean allowAutoVerify, IntentInfo outInfo, String[] outError) throws XmlPullParserException, IOException { TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestIntentFilter); int priority = sa.getInt(com.android.internal.R.styleable.AndroidManifestIntentFilter_priority, 0); outInfo.setPriority(priority);//from w w w . j a va2s .com TypedValue v = sa.peekValue(com.android.internal.R.styleable.AndroidManifestIntentFilter_label); if (v != null && (outInfo.labelRes = v.resourceId) == 0) { outInfo.nonLocalizedLabel = v.coerceToString(); } outInfo.icon = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestIntentFilter_icon, 0); outInfo.logo = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestIntentFilter_logo, 0); outInfo.banner = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestIntentFilter_banner, 0); if (allowAutoVerify) { outInfo.setAutoVerify( sa.getBoolean(com.android.internal.R.styleable.AndroidManifestIntentFilter_autoVerify, false)); } sa.recycle(); int outerDepth = parser.getDepth(); int type; while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { continue; } String nodeName = parser.getName(); if (nodeName.equals("action")) { String value = attrs.getAttributeValue(ANDROID_RESOURCES, "name"); if (value == null || value == "") { outError[0] = "No value supplied for <android:name>"; return false; } XmlUtils.skipCurrentTag(parser); outInfo.addAction(value); } else if (nodeName.equals("category")) { String value = attrs.getAttributeValue(ANDROID_RESOURCES, "name"); if (value == null || value == "") { outError[0] = "No value supplied for <android:name>"; return false; } XmlUtils.skipCurrentTag(parser); outInfo.addCategory(value); } else if (nodeName.equals("data")) { sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestData); String str = sa.getNonConfigurationString( com.android.internal.R.styleable.AndroidManifestData_mimeType, 0); if (str != null) { try { outInfo.addDataType(str); } catch (IntentFilter.MalformedMimeTypeException e) { outError[0] = e.toString(); sa.recycle(); return false; } } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_scheme, 0); if (str != null) { outInfo.addDataScheme(str); } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_ssp, 0); if (str != null) { outInfo.addDataSchemeSpecificPart(str, PatternMatcher.PATTERN_LITERAL); } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_sspPrefix, 0); if (str != null) { outInfo.addDataSchemeSpecificPart(str, PatternMatcher.PATTERN_PREFIX); } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_sspPattern, 0); if (str != null) { if (!allowGlobs) { outError[0] = "sspPattern not allowed here; ssp must be literal"; return false; } outInfo.addDataSchemeSpecificPart(str, PatternMatcher.PATTERN_SIMPLE_GLOB); } String host = sa .getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_host, 0); String port = sa .getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_port, 0); if (host != null) { outInfo.addDataAuthority(host, port); } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_path, 0); if (str != null) { outInfo.addDataPath(str, PatternMatcher.PATTERN_LITERAL); } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_pathPrefix, 0); if (str != null) { outInfo.addDataPath(str, PatternMatcher.PATTERN_PREFIX); } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestData_pathPattern, 0); if (str != null) { if (!allowGlobs) { outError[0] = "pathPattern not allowed here; path must be literal"; return false; } outInfo.addDataPath(str, PatternMatcher.PATTERN_SIMPLE_GLOB); } sa.recycle(); XmlUtils.skipCurrentTag(parser); } else if (!RIGID_PARSER) { Slog.w(TAG, "Unknown element under <intent-filter>: " + parser.getName() + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); } else { outError[0] = "Bad element under <intent-filter>: " + parser.getName(); return false; } } outInfo.hasDefault = outInfo.hasCategory(Intent.CATEGORY_DEFAULT); if (DEBUG_PARSER) { final StringBuilder cats = new StringBuilder("Intent d="); cats.append(outInfo.hasDefault); cats.append(", cat="); final Iterator<String> it = outInfo.categoriesIterator(); if (it != null) { while (it.hasNext()) { cats.append(' '); cats.append(it.next()); } } Slog.d(TAG, cats.toString()); } return true; }
From source file:android.content.pm.PackageParser.java
/** * Parse the {@code application} XML tree at the current parse location in a * <em>base APK</em> manifest. * <p>/* ww w . j av a 2 s . c o m*/ * When adding new features, carefully consider if they should also be * supported by split APKs. */ private boolean parseBaseApplication(Package owner, Resources res, XmlPullParser parser, AttributeSet attrs, int flags, String[] outError) throws XmlPullParserException, IOException { final ApplicationInfo ai = owner.applicationInfo; final String pkgName = owner.applicationInfo.packageName; TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestApplication); String name = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_name, 0); if (name != null) { ai.className = buildClassName(pkgName, name, outError); if (ai.className == null) { sa.recycle(); mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } } String manageSpaceActivity = sa.getNonConfigurationString( com.android.internal.R.styleable.AndroidManifestApplication_manageSpaceActivity, Configuration.NATIVE_CONFIG_VERSION); if (manageSpaceActivity != null) { ai.manageSpaceActivityName = buildClassName(pkgName, manageSpaceActivity, outError); } boolean allowBackup = sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_allowBackup, true); if (allowBackup) { ai.flags |= ApplicationInfo.FLAG_ALLOW_BACKUP; // backupAgent, killAfterRestore, fullBackupContent and restoreAnyVersion are only // relevant if backup is possible for the given application. String backupAgent = sa.getNonConfigurationString( com.android.internal.R.styleable.AndroidManifestApplication_backupAgent, Configuration.NATIVE_CONFIG_VERSION); if (backupAgent != null) { ai.backupAgentName = buildClassName(pkgName, backupAgent, outError); if (DEBUG_BACKUP) { Slog.v(TAG, "android:backupAgent = " + ai.backupAgentName + " from " + pkgName + "+" + backupAgent); } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_killAfterRestore, true)) { ai.flags |= ApplicationInfo.FLAG_KILL_AFTER_RESTORE; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_restoreAnyVersion, false)) { ai.flags |= ApplicationInfo.FLAG_RESTORE_ANY_VERSION; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_fullBackupOnly, false)) { ai.flags |= ApplicationInfo.FLAG_FULL_BACKUP_ONLY; } } TypedValue v = sa .peekValue(com.android.internal.R.styleable.AndroidManifestApplication_fullBackupContent); if (v != null && (ai.fullBackupContent = v.resourceId) == 0) { if (DEBUG_BACKUP) { Slog.v(TAG, "fullBackupContent specified as boolean=" + (v.data == 0 ? "false" : "true")); } // "false" => -1, "true" => 0 ai.fullBackupContent = (v.data == 0 ? -1 : 0); } if (DEBUG_BACKUP) { Slog.v(TAG, "fullBackupContent=" + ai.fullBackupContent + " for " + pkgName); } } TypedValue v = sa.peekValue(com.android.internal.R.styleable.AndroidManifestApplication_label); if (v != null && (ai.labelRes = v.resourceId) == 0) { ai.nonLocalizedLabel = v.coerceToString(); } ai.icon = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_icon, 0); ai.logo = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_logo, 0); ai.banner = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_banner, 0); ai.theme = sa.getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_theme, 0); ai.descriptionRes = sa .getResourceId(com.android.internal.R.styleable.AndroidManifestApplication_description, 0); if ((flags & PARSE_IS_SYSTEM) != 0) { if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_persistent, false)) { ai.flags |= ApplicationInfo.FLAG_PERSISTENT; } } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_requiredForAllUsers, false)) { owner.mRequiredForAllUsers = true; } String restrictedAccountType = sa .getString(com.android.internal.R.styleable.AndroidManifestApplication_restrictedAccountType); if (restrictedAccountType != null && restrictedAccountType.length() > 0) { owner.mRestrictedAccountType = restrictedAccountType; } String requiredAccountType = sa .getString(com.android.internal.R.styleable.AndroidManifestApplication_requiredAccountType); if (requiredAccountType != null && requiredAccountType.length() > 0) { owner.mRequiredAccountType = requiredAccountType; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_debuggable, false)) { ai.flags |= ApplicationInfo.FLAG_DEBUGGABLE; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_vmSafeMode, false)) { ai.flags |= ApplicationInfo.FLAG_VM_SAFE_MODE; } owner.baseHardwareAccelerated = sa.getBoolean( com.android.internal.R.styleable.AndroidManifestApplication_hardwareAccelerated, owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH); if (owner.baseHardwareAccelerated) { ai.flags |= ApplicationInfo.FLAG_HARDWARE_ACCELERATED; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_hasCode, true)) { ai.flags |= ApplicationInfo.FLAG_HAS_CODE; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_allowTaskReparenting, false)) { ai.flags |= ApplicationInfo.FLAG_ALLOW_TASK_REPARENTING; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_allowClearUserData, true)) { ai.flags |= ApplicationInfo.FLAG_ALLOW_CLEAR_USER_DATA; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_testOnly, false)) { ai.flags |= ApplicationInfo.FLAG_TEST_ONLY; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_largeHeap, false)) { ai.flags |= ApplicationInfo.FLAG_LARGE_HEAP; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_usesCleartextTraffic, true)) { ai.flags |= ApplicationInfo.FLAG_USES_CLEARTEXT_TRAFFIC; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_supportsRtl, false /* default is no RTL support*/)) { ai.flags |= ApplicationInfo.FLAG_SUPPORTS_RTL; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_multiArch, false)) { ai.flags |= ApplicationInfo.FLAG_MULTIARCH; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_extractNativeLibs, true)) { ai.flags |= ApplicationInfo.FLAG_EXTRACT_NATIVE_LIBS; } String str; str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestApplication_permission, 0); ai.permission = (str != null && str.length() > 0) ? str.intern() : null; if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.FROYO) { str = sa.getNonConfigurationString( com.android.internal.R.styleable.AndroidManifestApplication_taskAffinity, Configuration.NATIVE_CONFIG_VERSION); } else { // Some older apps have been seen to use a resource reference // here that on older builds was ignored (with a warning). We // need to continue to do this for them so they don't break. str = sa.getNonResourceString(com.android.internal.R.styleable.AndroidManifestApplication_taskAffinity); } ai.taskAffinity = buildTaskAffinityName(ai.packageName, ai.packageName, str, outError); if (outError[0] == null) { CharSequence pname; if (owner.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.FROYO) { pname = sa.getNonConfigurationString( com.android.internal.R.styleable.AndroidManifestApplication_process, Configuration.NATIVE_CONFIG_VERSION); } else { // Some older apps have been seen to use a resource reference // here that on older builds was ignored (with a warning). We // need to continue to do this for them so they don't break. pname = sa .getNonResourceString(com.android.internal.R.styleable.AndroidManifestApplication_process); } ai.processName = buildProcessName(ai.packageName, null, pname, flags, mSeparateProcesses, outError); ai.enabled = sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_enabled, true); if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_isGame, false)) { ai.flags |= ApplicationInfo.FLAG_IS_GAME; } if (false) { if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestApplication_cantSaveState, false)) { ai.privateFlags |= ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE; // A heavy-weight application can not be in a custom process. // We can do direct compare because we intern all strings. if (ai.processName != null && ai.processName != ai.packageName) { outError[0] = "cantSaveState applications can not use custom processes"; } } } } ai.uiOptions = sa.getInt(com.android.internal.R.styleable.AndroidManifestApplication_uiOptions, 0); sa.recycle(); if (outError[0] != null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } final int innerDepth = parser.getDepth(); int type; while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > innerDepth)) { if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { continue; } String tagName = parser.getName(); if (tagName.equals("activity")) { Activity a = parseActivity(owner, res, parser, attrs, flags, outError, false, owner.baseHardwareAccelerated); if (a == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.activities.add(a); } else if (tagName.equals("receiver")) { Activity a = parseActivity(owner, res, parser, attrs, flags, outError, true, false); if (a == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.receivers.add(a); } else if (tagName.equals("service")) { Service s = parseService(owner, res, parser, attrs, flags, outError); if (s == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.services.add(s); } else if (tagName.equals("provider")) { Provider p = parseProvider(owner, res, parser, attrs, flags, outError); if (p == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.providers.add(p); } else if (tagName.equals("activity-alias")) { Activity a = parseActivityAlias(owner, res, parser, attrs, flags, outError); if (a == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } owner.activities.add(a); } else if (parser.getName().equals("meta-data")) { // note: application meta-data is stored off to the side, so it can // remain null in the primary copy (we like to avoid extra copies because // it can be large) if ((owner.mAppMetaData = parseMetaData(res, parser, attrs, owner.mAppMetaData, outError)) == null) { mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } } else if (tagName.equals("library")) { sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestLibrary); // Note: don't allow this value to be a reference to a resource // that may change. String lname = sa .getNonResourceString(com.android.internal.R.styleable.AndroidManifestLibrary_name); sa.recycle(); if (lname != null) { lname = lname.intern(); if (!ArrayUtils.contains(owner.libraryNames, lname)) { owner.libraryNames = ArrayUtils.add(owner.libraryNames, lname); } } XmlUtils.skipCurrentTag(parser); } else if (tagName.equals("uses-library")) { sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestUsesLibrary); // Note: don't allow this value to be a reference to a resource // that may change. String lname = sa .getNonResourceString(com.android.internal.R.styleable.AndroidManifestUsesLibrary_name); boolean req = sa.getBoolean(com.android.internal.R.styleable.AndroidManifestUsesLibrary_required, true); sa.recycle(); if (lname != null) { lname = lname.intern(); if (req) { owner.usesLibraries = ArrayUtils.add(owner.usesLibraries, lname); } else { owner.usesOptionalLibraries = ArrayUtils.add(owner.usesOptionalLibraries, lname); } } XmlUtils.skipCurrentTag(parser); } else if (tagName.equals("uses-package")) { // Dependencies for app installers; we don't currently try to // enforce this. XmlUtils.skipCurrentTag(parser); } else { if (!RIGID_PARSER) { Slog.w(TAG, "Unknown element under <application>: " + tagName + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } else { outError[0] = "Bad element under <application>: " + tagName; mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } } } modifySharedLibrariesForBackwardCompatibility(owner); if (hasDomainURLs(owner)) { owner.applicationInfo.privateFlags |= ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS; } else { owner.applicationInfo.privateFlags &= ~ApplicationInfo.PRIVATE_FLAG_HAS_DOMAIN_URLS; } return true; }
From source file:android.content.pm.PackageParser.java
private Activity parseActivity(Package owner, Resources res, XmlPullParser parser, AttributeSet attrs, int flags, String[] outError, boolean receiver, boolean hardwareAccelerated) throws XmlPullParserException, IOException { TypedArray sa = res.obtainAttributes(attrs, R.styleable.AndroidManifestActivity); if (mParseActivityArgs == null) { mParseActivityArgs = new ParseComponentArgs(owner, outError, R.styleable.AndroidManifestActivity_name, R.styleable.AndroidManifestActivity_label, R.styleable.AndroidManifestActivity_icon, R.styleable.AndroidManifestActivity_logo, R.styleable.AndroidManifestActivity_banner, mSeparateProcesses, R.styleable.AndroidManifestActivity_process, R.styleable.AndroidManifestActivity_description, R.styleable.AndroidManifestActivity_enabled); }//from ww w .j a v a 2 s . c om mParseActivityArgs.tag = receiver ? "<receiver>" : "<activity>"; mParseActivityArgs.sa = sa; mParseActivityArgs.flags = flags; Activity a = new Activity(mParseActivityArgs, new ActivityInfo()); if (outError[0] != null) { sa.recycle(); return null; } boolean setExported = sa.hasValue(R.styleable.AndroidManifestActivity_exported); if (setExported) { a.info.exported = sa.getBoolean(R.styleable.AndroidManifestActivity_exported, false); } a.info.theme = sa.getResourceId(R.styleable.AndroidManifestActivity_theme, 0); a.info.uiOptions = sa.getInt(R.styleable.AndroidManifestActivity_uiOptions, a.info.applicationInfo.uiOptions); String parentName = sa.getNonConfigurationString(R.styleable.AndroidManifestActivity_parentActivityName, Configuration.NATIVE_CONFIG_VERSION); if (parentName != null) { String parentClassName = buildClassName(a.info.packageName, parentName, outError); if (outError[0] == null) { a.info.parentActivityName = parentClassName; } else { Log.e(TAG, "Activity " + a.info.name + " specified invalid parentActivityName " + parentName); outError[0] = null; } } String str; str = sa.getNonConfigurationString(R.styleable.AndroidManifestActivity_permission, 0); if (str == null) { a.info.permission = owner.applicationInfo.permission; } else { a.info.permission = str.length() > 0 ? str.toString().intern() : null; } str = sa.getNonConfigurationString(R.styleable.AndroidManifestActivity_taskAffinity, Configuration.NATIVE_CONFIG_VERSION); a.info.taskAffinity = buildTaskAffinityName(owner.applicationInfo.packageName, owner.applicationInfo.taskAffinity, str, outError); a.info.flags = 0; if (sa.getBoolean(R.styleable.AndroidManifestActivity_multiprocess, false)) { a.info.flags |= ActivityInfo.FLAG_MULTIPROCESS; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_finishOnTaskLaunch, false)) { a.info.flags |= ActivityInfo.FLAG_FINISH_ON_TASK_LAUNCH; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_clearTaskOnLaunch, false)) { a.info.flags |= ActivityInfo.FLAG_CLEAR_TASK_ON_LAUNCH; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_noHistory, false)) { a.info.flags |= ActivityInfo.FLAG_NO_HISTORY; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_alwaysRetainTaskState, false)) { a.info.flags |= ActivityInfo.FLAG_ALWAYS_RETAIN_TASK_STATE; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_stateNotNeeded, false)) { a.info.flags |= ActivityInfo.FLAG_STATE_NOT_NEEDED; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_excludeFromRecents, false)) { a.info.flags |= ActivityInfo.FLAG_EXCLUDE_FROM_RECENTS; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_allowTaskReparenting, (owner.applicationInfo.flags & ApplicationInfo.FLAG_ALLOW_TASK_REPARENTING) != 0)) { a.info.flags |= ActivityInfo.FLAG_ALLOW_TASK_REPARENTING; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_finishOnCloseSystemDialogs, false)) { a.info.flags |= ActivityInfo.FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_showOnLockScreen, false) || sa.getBoolean(R.styleable.AndroidManifestActivity_showForAllUsers, false)) { a.info.flags |= ActivityInfo.FLAG_SHOW_FOR_ALL_USERS; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_immersive, false)) { a.info.flags |= ActivityInfo.FLAG_IMMERSIVE; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_primaryUserOnly, false)) { a.info.flags |= ActivityInfo.FLAG_PRIMARY_USER_ONLY; } if (!receiver) { if (sa.getBoolean(R.styleable.AndroidManifestActivity_hardwareAccelerated, hardwareAccelerated)) { a.info.flags |= ActivityInfo.FLAG_HARDWARE_ACCELERATED; } a.info.launchMode = sa.getInt(R.styleable.AndroidManifestActivity_launchMode, ActivityInfo.LAUNCH_MULTIPLE); a.info.documentLaunchMode = sa.getInt(R.styleable.AndroidManifestActivity_documentLaunchMode, ActivityInfo.DOCUMENT_LAUNCH_NONE); a.info.maxRecents = sa.getInt(R.styleable.AndroidManifestActivity_maxRecents, ActivityManager.getDefaultAppRecentsLimitStatic()); a.info.configChanges = sa.getInt(R.styleable.AndroidManifestActivity_configChanges, 0); a.info.softInputMode = sa.getInt(R.styleable.AndroidManifestActivity_windowSoftInputMode, 0); a.info.persistableMode = sa.getInteger(R.styleable.AndroidManifestActivity_persistableMode, ActivityInfo.PERSIST_ROOT_ONLY); if (sa.getBoolean(R.styleable.AndroidManifestActivity_allowEmbedded, false)) { a.info.flags |= ActivityInfo.FLAG_ALLOW_EMBEDDED; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_autoRemoveFromRecents, false)) { a.info.flags |= ActivityInfo.FLAG_AUTO_REMOVE_FROM_RECENTS; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_relinquishTaskIdentity, false)) { a.info.flags |= ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY; } if (sa.getBoolean(R.styleable.AndroidManifestActivity_resumeWhilePausing, false)) { a.info.flags |= ActivityInfo.FLAG_RESUME_WHILE_PAUSING; } a.info.resizeable = sa.getBoolean(R.styleable.AndroidManifestActivity_resizeableActivity, false); if (a.info.resizeable) { // Fixed screen orientation isn't supported with resizeable activities. a.info.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; } else { a.info.screenOrientation = sa.getInt(R.styleable.AndroidManifestActivity_screenOrientation, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } a.info.lockTaskLaunchMode = sa.getInt(R.styleable.AndroidManifestActivity_lockTaskMode, 0); } else { a.info.launchMode = ActivityInfo.LAUNCH_MULTIPLE; a.info.configChanges = 0; if (sa.getBoolean(R.styleable.AndroidManifestActivity_singleUser, false)) { a.info.flags |= ActivityInfo.FLAG_SINGLE_USER; if (a.info.exported && (flags & PARSE_IS_PRIVILEGED) == 0) { Slog.w(TAG, "Activity exported request ignored due to singleUser: " + a.className + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); a.info.exported = false; setExported = true; } } } sa.recycle(); if (receiver && (owner.applicationInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0) { // A heavy-weight application can not have receives in its main process // We can do direct compare because we intern all strings. if (a.info.processName == owner.packageName) { outError[0] = "Heavy-weight applications can not have receivers in main process"; } } if (outError[0] != null) { return null; } int outerDepth = parser.getDepth(); int type; while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { continue; } if (parser.getName().equals("intent-filter")) { ActivityIntentInfo intent = new ActivityIntentInfo(a); if (!parseIntent(res, parser, attrs, true, true, intent, outError)) { return null; } if (intent.countActions() == 0) { Slog.w(TAG, "No actions in intent filter at " + mArchiveSourcePath + " " + parser.getPositionDescription()); } else { a.intents.add(intent); } } else if (!receiver && parser.getName().equals("preferred")) { ActivityIntentInfo intent = new ActivityIntentInfo(a); if (!parseIntent(res, parser, attrs, false, false, intent, outError)) { return null; } if (intent.countActions() == 0) { Slog.w(TAG, "No actions in preferred at " + mArchiveSourcePath + " " + parser.getPositionDescription()); } else { if (owner.preferredActivityFilters == null) { owner.preferredActivityFilters = new ArrayList<ActivityIntentInfo>(); } owner.preferredActivityFilters.add(intent); } } else if (parser.getName().equals("meta-data")) { if ((a.metaData = parseMetaData(res, parser, attrs, a.metaData, outError)) == null) { return null; } } else { if (!RIGID_PARSER) { Slog.w(TAG, "Problem in package " + mArchiveSourcePath + ":"); if (receiver) { Slog.w(TAG, "Unknown element under <receiver>: " + parser.getName() + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); } else { Slog.w(TAG, "Unknown element under <activity>: " + parser.getName() + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); } XmlUtils.skipCurrentTag(parser); continue; } else { if (receiver) { outError[0] = "Bad element under <receiver>: " + parser.getName(); } else { outError[0] = "Bad element under <activity>: " + parser.getName(); } return null; } } } if (!setExported) { a.info.exported = a.intents.size() > 0; } return a; }
From source file:android.content.pm.PackageParser.java
private Service parseService(Package owner, Resources res, XmlPullParser parser, AttributeSet attrs, int flags, String[] outError) throws XmlPullParserException, IOException { TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestService); if (mParseServiceArgs == null) { mParseServiceArgs = new ParseComponentArgs(owner, outError, com.android.internal.R.styleable.AndroidManifestService_name, com.android.internal.R.styleable.AndroidManifestService_label, com.android.internal.R.styleable.AndroidManifestService_icon, com.android.internal.R.styleable.AndroidManifestService_logo, com.android.internal.R.styleable.AndroidManifestService_banner, mSeparateProcesses, com.android.internal.R.styleable.AndroidManifestService_process, com.android.internal.R.styleable.AndroidManifestService_description, com.android.internal.R.styleable.AndroidManifestService_enabled); mParseServiceArgs.tag = "<service>"; }//from w w w . ja va 2 s .c o m mParseServiceArgs.sa = sa; mParseServiceArgs.flags = flags; Service s = new Service(mParseServiceArgs, new ServiceInfo()); if (outError[0] != null) { sa.recycle(); return null; } boolean setExported = sa.hasValue(com.android.internal.R.styleable.AndroidManifestService_exported); if (setExported) { s.info.exported = sa.getBoolean(com.android.internal.R.styleable.AndroidManifestService_exported, false); } String str = sa .getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestService_permission, 0); if (str == null) { s.info.permission = owner.applicationInfo.permission; } else { s.info.permission = str.length() > 0 ? str.toString().intern() : null; } s.info.flags = 0; if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestService_stopWithTask, false)) { s.info.flags |= ServiceInfo.FLAG_STOP_WITH_TASK; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestService_isolatedProcess, false)) { s.info.flags |= ServiceInfo.FLAG_ISOLATED_PROCESS; } if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestService_singleUser, false)) { s.info.flags |= ServiceInfo.FLAG_SINGLE_USER; if (s.info.exported && (flags & PARSE_IS_PRIVILEGED) == 0) { Slog.w(TAG, "Service exported request ignored due to singleUser: " + s.className + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); s.info.exported = false; setExported = true; } } sa.recycle(); if ((owner.applicationInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0) { // A heavy-weight application can not have services in its main process // We can do direct compare because we intern all strings. if (s.info.processName == owner.packageName) { outError[0] = "Heavy-weight applications can not have services in main process"; return null; } } int outerDepth = parser.getDepth(); int type; while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { continue; } if (parser.getName().equals("intent-filter")) { ServiceIntentInfo intent = new ServiceIntentInfo(s); if (!parseIntent(res, parser, attrs, true, false, intent, outError)) { return null; } s.intents.add(intent); } else if (parser.getName().equals("meta-data")) { if ((s.metaData = parseMetaData(res, parser, attrs, s.metaData, outError)) == null) { return null; } } else { if (!RIGID_PARSER) { Slog.w(TAG, "Unknown element under <service>: " + parser.getName() + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } else { outError[0] = "Bad element under <service>: " + parser.getName(); return null; } } } if (!setExported) { s.info.exported = s.intents.size() > 0; } return s; }
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 ww w . jav a2 s. co 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; }
From source file:com.appunite.list.AbsHorizontalListView.java
public AbsHorizontalListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); initAbsListView();//from w w w. j a v a2s . c o m TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AbsListView, defStyle, 0); Drawable d = a.getDrawable(R.styleable.AbsListView_listSelector); if (d != null) { setSelector(d); } mDrawSelectorOnTop = a.getBoolean(R.styleable.AbsListView_drawSelectorOnTop, false); boolean stackFromRight = a.getBoolean(R.styleable.AbsListView_stackFromBottom, false); setStackFromRight(stackFromRight); boolean scrollingCacheEnabled = a.getBoolean(R.styleable.AbsListView_scrollingCache, true); setScrollingCacheEnabled(scrollingCacheEnabled); boolean useTextFilter = a.getBoolean(R.styleable.AbsListView_textFilterEnabled, false); setTextFilterEnabled(useTextFilter); int transcriptMode = a.getInt(R.styleable.AbsListView_transcriptMode, TRANSCRIPT_MODE_DISABLED); setTranscriptMode(transcriptMode); int color = a.getColor(R.styleable.AbsListView_cacheColorHint, 0); setCacheColorHint(color); boolean smoothScrollbar = a.getBoolean(R.styleable.AbsListView_smoothScrollbar, true); setSmoothScrollbarEnabled(smoothScrollbar); setChoiceMode(a.getInt(R.styleable.AbsListView_choiceMode, CHOICE_MODE_NONE)); a.recycle(); }
From source file:android.content.pm.PackageParser.java
private Provider parseProvider(Package owner, Resources res, XmlPullParser parser, AttributeSet attrs, int flags, String[] outError) throws XmlPullParserException, IOException { TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestProvider); if (mParseProviderArgs == null) { mParseProviderArgs = new ParseComponentArgs(owner, outError, com.android.internal.R.styleable.AndroidManifestProvider_name, com.android.internal.R.styleable.AndroidManifestProvider_label, com.android.internal.R.styleable.AndroidManifestProvider_icon, com.android.internal.R.styleable.AndroidManifestProvider_logo, com.android.internal.R.styleable.AndroidManifestProvider_banner, mSeparateProcesses, com.android.internal.R.styleable.AndroidManifestProvider_process, com.android.internal.R.styleable.AndroidManifestProvider_description, com.android.internal.R.styleable.AndroidManifestProvider_enabled); mParseProviderArgs.tag = "<provider>"; }//from w ww . j a v a2 s. c om mParseProviderArgs.sa = sa; mParseProviderArgs.flags = flags; Provider p = new Provider(mParseProviderArgs, new ProviderInfo()); if (outError[0] != null) { sa.recycle(); return null; } boolean providerExportedDefault = false; if (owner.applicationInfo.targetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR1) { // For compatibility, applications targeting API level 16 or lower // should have their content providers exported by default, unless they // specify otherwise. providerExportedDefault = true; } p.info.exported = sa.getBoolean(com.android.internal.R.styleable.AndroidManifestProvider_exported, providerExportedDefault); String cpname = sa .getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestProvider_authorities, 0); p.info.isSyncable = sa.getBoolean(com.android.internal.R.styleable.AndroidManifestProvider_syncable, false); String permission = sa .getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestProvider_permission, 0); String str = sa.getNonConfigurationString( com.android.internal.R.styleable.AndroidManifestProvider_readPermission, 0); if (str == null) { str = permission; } if (str == null) { p.info.readPermission = owner.applicationInfo.permission; } else { p.info.readPermission = str.length() > 0 ? str.toString().intern() : null; } str = sa.getNonConfigurationString(com.android.internal.R.styleable.AndroidManifestProvider_writePermission, 0); if (str == null) { str = permission; } if (str == null) { p.info.writePermission = owner.applicationInfo.permission; } else { p.info.writePermission = str.length() > 0 ? str.toString().intern() : null; } p.info.grantUriPermissions = sa .getBoolean(com.android.internal.R.styleable.AndroidManifestProvider_grantUriPermissions, false); p.info.multiprocess = sa.getBoolean(com.android.internal.R.styleable.AndroidManifestProvider_multiprocess, false); p.info.initOrder = sa.getInt(com.android.internal.R.styleable.AndroidManifestProvider_initOrder, 0); p.info.flags = 0; if (sa.getBoolean(com.android.internal.R.styleable.AndroidManifestProvider_singleUser, false)) { p.info.flags |= ProviderInfo.FLAG_SINGLE_USER; if (p.info.exported && (flags & PARSE_IS_PRIVILEGED) == 0) { Slog.w(TAG, "Provider exported request ignored due to singleUser: " + p.className + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); p.info.exported = false; } } sa.recycle(); if ((owner.applicationInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0) { // A heavy-weight application can not have providers in its main process // We can do direct compare because we intern all strings. if (p.info.processName == owner.packageName) { outError[0] = "Heavy-weight applications can not have providers in main process"; return null; } } if (cpname == null) { outError[0] = "<provider> does not include authorities attribute"; return null; } if (cpname.length() <= 0) { outError[0] = "<provider> has empty authorities attribute"; return null; } p.info.authority = cpname.intern(); if (!parseProviderTags(res, parser, attrs, p, outError)) { return null; } return p; }