Java Code Examples for com.android.internal.util.XmlUtils#skipCurrentTag()
The following examples show how to use
com.android.internal.util.XmlUtils#skipCurrentTag() .
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: XmlConfigSource.java From cwac-netsecurity with Apache License 2.0 | 6 votes |
private CertificatesEntryRef parseCertificatesEntry(XmlResourceParser parser, boolean defaultOverridePins) throws IOException, XmlPullParserException, ParserException { boolean overridePins = parser.getAttributeBooleanValue(null, "overridePins", defaultOverridePins); int sourceId = parser.getAttributeResourceValue(null, "src", -1); String sourceString = parser.getAttributeValue(null, "src"); CertificateSource source = null; if (sourceString == null) { throw new ParserException(parser, "certificates element missing src attribute"); } if (sourceId != -1) { // TODO: Cache ResourceCertificateSources by sourceId source = new ResourceCertificateSource(sourceId, mContext); } else if ("system".equals(sourceString) || "user".equals(sourceString)) { // MLM treat user as system source = SystemCertificateSource.getInstance(); // } else if ("user".equals(sourceString)) { // source = UserCertificateSource.getInstance(); } else { throw new ParserException(parser, "Unknown certificates src. " + "Should be one of system|user|@resourceVal"); } XmlUtils.skipCurrentTag(parser); return new CertificatesEntryRef(source, overridePins); }
Example 2
Source File: AppOpsService.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
void readPackage(XmlPullParser parser) throws NumberFormatException, XmlPullParserException, IOException { String pkgName = parser.getAttributeValue(null, "n"); 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 tagName = parser.getName(); if (tagName.equals("uid")) { readUid(parser, pkgName); } else { Slog.w(TAG, "Unknown element under <pkg>: " + parser.getName()); XmlUtils.skipCurrentTag(parser); } } }
Example 3
Source File: XmlConfigSource.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private CertificatesEntryRef parseCertificatesEntry(XmlResourceParser parser, boolean defaultOverridePins) throws IOException, XmlPullParserException, ParserException { boolean overridePins = parser.getAttributeBooleanValue(null, "overridePins", defaultOverridePins); int sourceId = parser.getAttributeResourceValue(null, "src", -1); String sourceString = parser.getAttributeValue(null, "src"); CertificateSource source = null; if (sourceString == null) { throw new ParserException(parser, "certificates element missing src attribute"); } if (sourceId != -1) { // TODO: Cache ResourceCertificateSources by sourceId source = new ResourceCertificateSource(sourceId, mContext); } else if ("system".equals(sourceString)) { source = SystemCertificateSource.getInstance(); } else if ("user".equals(sourceString)) { source = UserCertificateSource.getInstance(); } else { throw new ParserException(parser, "Unknown certificates src. " + "Should be one of system|user|@resourceVal"); } XmlUtils.skipCurrentTag(parser); return new CertificatesEntryRef(source, overridePins); }
Example 4
Source File: Resources.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Parse a series of {@link android.R.styleable#Extra <extra>} tags from * an XML file. You call this when you are at the parent tag of the * extra tags, and it will return once all of the child tags have been parsed. * This will call {@link #parseBundleExtra} for each extra tag encountered. * * @param parser The parser from which to retrieve the extras. * @param outBundle A Bundle in which to place all parsed extras. * @throws XmlPullParserException * @throws IOException */ public void parseBundleExtras(XmlResourceParser parser, Bundle outBundle) throws XmlPullParserException, IOException { 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("extra")) { parseBundleExtra("extra", parser, outBundle); XmlUtils.skipCurrentTag(parser); } else { XmlUtils.skipCurrentTag(parser); } } }
Example 5
Source File: DefaultPermissionGrantPolicy.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void parseExceptions(XmlPullParser parser, Map<String, List<DefaultPermissionGrant>> outGrantExceptions) throws IOException, XmlPullParserException { final 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 (TAG_EXCEPTION.equals(parser.getName())) { String packageName = parser.getAttributeValue(null, ATTR_PACKAGE); List<DefaultPermissionGrant> packageExceptions = outGrantExceptions.get(packageName); if (packageExceptions == null) { // The package must be on the system image PackageParser.Package pkg = getSystemPackage(packageName); if (pkg == null) { Log.w(TAG, "Unknown package:" + packageName); XmlUtils.skipCurrentTag(parser); continue; } // The package must support runtime permissions if (!doesPackageSupportRuntimePermissions(pkg)) { Log.w(TAG, "Skipping non supporting runtime permissions package:" + packageName); XmlUtils.skipCurrentTag(parser); continue; } packageExceptions = new ArrayList<>(); outGrantExceptions.put(packageName, packageExceptions); } parsePermission(parser, packageExceptions); } else { Log.e(TAG, "Unknown tag " + parser.getName() + "under <exceptions>"); } } }
Example 6
Source File: AppOpsService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
void readUidOps(XmlPullParser parser) throws NumberFormatException, XmlPullParserException, IOException { final int uid = Integer.parseInt(parser.getAttributeValue(null, "n")); 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 tagName = parser.getName(); if (tagName.equals("op")) { final int code = Integer.parseInt(parser.getAttributeValue(null, "n")); final int mode = Integer.parseInt(parser.getAttributeValue(null, "m")); UidState uidState = getUidStateLocked(uid, true); if (uidState.opModes == null) { uidState.opModes = new SparseIntArray(); } uidState.opModes.put(code, mode); } else { Slog.w(TAG, "Unknown element under <uid-ops>: " + parser.getName()); XmlUtils.skipCurrentTag(parser); } } }
Example 7
Source File: DefaultPermissionGrantPolicy.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void parsePermission(XmlPullParser parser, List<DefaultPermissionGrant> outPackageExceptions) throws IOException, XmlPullParserException { final 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 (TAG_PERMISSION.contains(parser.getName())) { String name = parser.getAttributeValue(null, ATTR_NAME); if (name == null) { Log.w(TAG, "Mandatory name attribute missing for permission tag"); XmlUtils.skipCurrentTag(parser); continue; } final boolean fixed = XmlUtils.readBooleanAttribute(parser, ATTR_FIXED); DefaultPermissionGrant exception = new DefaultPermissionGrant(name, fixed); outPackageExceptions.add(exception); } else { Log.e(TAG, "Unknown tag " + parser.getName() + "under <exception>"); } } }
Example 8
Source File: PackageParser.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
private boolean parseAllMetaData(Resources res, XmlPullParser parser, AttributeSet attrs, String tag, Component outInfo, String[] outError) throws XmlPullParserException, IOException { 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("meta-data")) { if ((outInfo.metaData=parseMetaData(res, parser, attrs, outInfo.metaData, outError)) == null) { return false; } } else { if (!RIGID_PARSER) { Slog.w(TAG, "Unknown element under " + tag + ": " + parser.getName() + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } else { outError[0] = "Bad element under " + tag + ": " + parser.getName(); return false; } } } return true; }
Example 9
Source File: XmlConfigSource.java From cwac-netsecurity with Apache License 2.0 | 5 votes |
private Collection<CertificatesEntryRef> parseTrustAnchors(XmlResourceParser parser, boolean defaultOverridePins) throws IOException, XmlPullParserException, ParserException { int outerDepth = parser.getDepth(); List<CertificatesEntryRef> anchors = new ArrayList<>(); while (XmlUtils.nextElementWithin(parser, outerDepth)) { String tagName = parser.getName(); if (tagName.equals("certificates")) { anchors.add(parseCertificatesEntry(parser, defaultOverridePins)); } else { XmlUtils.skipCurrentTag(parser); } } return anchors; }
Example 10
Source File: DisplaySettings.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void readDisplay(XmlPullParser parser) throws NumberFormatException, XmlPullParserException, IOException { String name = parser.getAttributeValue(null, "name"); if (name != null) { Entry entry = new Entry(name); entry.overscanLeft = getIntAttribute(parser, "overscanLeft"); entry.overscanTop = getIntAttribute(parser, "overscanTop"); entry.overscanRight = getIntAttribute(parser, "overscanRight"); entry.overscanBottom = getIntAttribute(parser, "overscanBottom"); mEntries.put(name, entry); } XmlUtils.skipCurrentTag(parser); }
Example 11
Source File: IntentFilterVerificationInfo.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** @hide */ public void readFromXml(XmlPullParser parser) throws XmlPullParserException, IOException { mPackageName = getStringFromXml(parser, ATTR_PACKAGE_NAME, null); if (mPackageName == null) { Log.e(TAG, "Package name cannot be null!"); } int status = getIntFromXml(parser, ATTR_STATUS, -1); if (status == -1) { Log.e(TAG, "Unknown status value: " + status); } mMainStatus = status; 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 tagName = parser.getName(); if (tagName.equals(TAG_DOMAIN)) { String name = getStringFromXml(parser, ATTR_DOMAIN_NAME, null); if (!TextUtils.isEmpty(name)) { mDomains.add(name); } } else { Log.w(TAG, "Unknown tag parsing IntentFilter: " + tagName); } XmlUtils.skipCurrentTag(parser); } }
Example 12
Source File: PackageParser.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
private boolean parseAllMetaData(Resources res, XmlPullParser parser, AttributeSet attrs, String tag, Component outInfo, String[] outError) throws XmlPullParserException, IOException { 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("meta-data")) { if ((outInfo.metaData=parseMetaData(res, parser, attrs, outInfo.metaData, outError)) == null) { return false; } } else { if (!RIGID_PARSER) { Slog.w(TAG, "Unknown element under " + tag + ": " + parser.getName() + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } else { outError[0] = "Bad element under " + tag + ": " + parser.getName(); return false; } } } return true; }
Example 13
Source File: PackageParser.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
private boolean parseUsesPermission(Package pkg, Resources res, XmlResourceParser parser, AttributeSet attrs, String[] outError) throws XmlPullParserException, IOException { TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestUsesPermission); // Note: don't allow this value to be a reference to a resource // that may change. String name = sa.getNonResourceString( com.android.internal.R.styleable.AndroidManifestUsesPermission_name); /* boolean required = sa.getBoolean( com.android.internal.R.styleable.AndroidManifestUsesPermission_required, true); */ boolean required = true; // Optional <uses-permission> not supported sa.recycle(); if (name != null) { int index = pkg.requestedPermissions.indexOf(name); if (index == -1) { pkg.requestedPermissions.add(name.intern()); pkg.requestedPermissionsRequired.add(required ? Boolean.TRUE : Boolean.FALSE); } else { if (pkg.requestedPermissionsRequired.get(index) != required) { outError[0] = "conflicting <uses-permission> entries"; mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } } } XmlUtils.skipCurrentTag(parser); return true; }
Example 14
Source File: PackageParser.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
private boolean parseAllMetaData(Resources res, XmlPullParser parser, AttributeSet attrs, String tag, Component outInfo, String[] outError) throws XmlPullParserException, IOException { 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("meta-data")) { if ((outInfo.metaData=parseMetaData(res, parser, attrs, outInfo.metaData, outError)) == null) { return false; } } else { if (!RIGID_PARSER) { Slog.w(TAG, "Unknown element under " + tag + ": " + parser.getName() + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } else { outError[0] = "Bad element under " + tag + ": " + parser.getName(); return false; } } } return true; }
Example 15
Source File: AccountManagerBackupHelper.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public void restoreAccountAccessPermissions(byte[] data, int userId) { try { ByteArrayInputStream dataStream = new ByteArrayInputStream(data); XmlPullParser parser = Xml.newPullParser(); parser.setInput(dataStream, StandardCharsets.UTF_8.name()); PackageManager packageManager = mAccountManagerService.mContext.getPackageManager(); final int permissionsOuterDepth = parser.getDepth(); while (XmlUtils.nextElementWithin(parser, permissionsOuterDepth)) { if (!TAG_PERMISSIONS.equals(parser.getName())) { continue; } final int permissionOuterDepth = parser.getDepth(); while (XmlUtils.nextElementWithin(parser, permissionOuterDepth)) { if (!TAG_PERMISSION.equals(parser.getName())) { continue; } String accountDigest = parser.getAttributeValue(null, ATTR_ACCOUNT_SHA_256); if (TextUtils.isEmpty(accountDigest)) { XmlUtils.skipCurrentTag(parser); } String packageName = parser.getAttributeValue(null, ATTR_PACKAGE); if (TextUtils.isEmpty(packageName)) { XmlUtils.skipCurrentTag(parser); } String digest = parser.getAttributeValue(null, ATTR_DIGEST); if (TextUtils.isEmpty(digest)) { XmlUtils.skipCurrentTag(parser); } PendingAppPermission pendingAppPermission = new PendingAppPermission( accountDigest, packageName, digest, userId); if (!pendingAppPermission.apply(packageManager)) { synchronized (mLock) { // Start watching before add pending to avoid a missed signal if (mRestorePackageMonitor == null) { mRestorePackageMonitor = new RestorePackageMonitor(); mRestorePackageMonitor.register(mAccountManagerService.mContext, mAccountManagerService.mHandler.getLooper(), true); } if (mRestorePendingAppPermissions == null) { mRestorePendingAppPermissions = new ArrayList<>(); } mRestorePendingAppPermissions.add(pendingAppPermission); } } } } // Make sure we eventually prune the in-memory pending restores mRestoreCancelCommand = new CancelRestoreCommand(); mAccountManagerService.mHandler.postDelayed(mRestoreCancelCommand, PENDING_RESTORE_TIMEOUT_MILLIS); } catch (XmlPullParserException | IOException e) { Log.e(TAG, "Error restoring app permissions", e); } }
Example 16
Source File: XmlConfigSource.java From cwac-netsecurity with Apache License 2.0 | 4 votes |
private NetworkSecurityConfig.Builder parseDebugOverridesResource() throws IOException, XmlPullParserException, ParserException { Resources resources = mContext.getResources(); String packageName = resources.getResourcePackageName(mResourceId); String entryName = resources.getResourceEntryName(mResourceId); int resId = resources.getIdentifier(entryName + "_debug", "xml", packageName); // No debug-overrides resource was found, nothing to parse. if (resId == 0) { return null; } NetworkSecurityConfig.Builder debugConfigBuilder = null; // Parse debug-overrides out of the _debug resource. XmlResourceParser parser=null; try { parser = resources.getXml(resId); XmlUtils.beginDocument(parser, "network-security-config"); int outerDepth = parser.getDepth(); boolean seenDebugOverrides = false; while (XmlUtils.nextElementWithin(parser, outerDepth)) { if ("debug-overrides".equals(parser.getName())) { if (seenDebugOverrides) { throw new ParserException(parser, "Only one debug-overrides allowed"); } if (mDebugBuild) { debugConfigBuilder = parseConfigEntry(parser, null, null, CONFIG_DEBUG).get(0).first; } else { XmlUtils.skipCurrentTag(parser); } seenDebugOverrides = true; } else { XmlUtils.skipCurrentTag(parser); } } } finally { if (parser!=null) parser.close(); } return debugConfigBuilder; }
Example 17
Source File: PreferredComponent.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public PreferredComponent(Callbacks callbacks, XmlPullParser parser) throws XmlPullParserException, IOException { mCallbacks = callbacks; mShortComponent = parser.getAttributeValue(null, ATTR_NAME); mComponent = ComponentName.unflattenFromString(mShortComponent); if (mComponent == null) { mParseError = "Bad activity name " + mShortComponent; } String matchStr = parser.getAttributeValue(null, ATTR_MATCH); mMatch = matchStr != null ? Integer.parseInt(matchStr, 16) : 0; String setCountStr = parser.getAttributeValue(null, ATTR_SET); int setCount = setCountStr != null ? Integer.parseInt(setCountStr) : 0; String alwaysStr = parser.getAttributeValue(null, ATTR_ALWAYS); mAlways = alwaysStr != null ? Boolean.parseBoolean(alwaysStr) : true; String[] myPackages = setCount > 0 ? new String[setCount] : null; String[] myClasses = setCount > 0 ? new String[setCount] : null; String[] myComponents = setCount > 0 ? new String[setCount] : null; int setPos = 0; 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 tagName = parser.getName(); //Log.i(TAG, "Parse outerDepth=" + outerDepth + " depth=" // + parser.getDepth() + " tag=" + tagName); if (tagName.equals(TAG_SET)) { String name = parser.getAttributeValue(null, ATTR_NAME); if (name == null) { if (mParseError == null) { mParseError = "No name in set tag in preferred activity " + mShortComponent; } } else if (setPos >= setCount) { if (mParseError == null) { mParseError = "Too many set tags in preferred activity " + mShortComponent; } } else { ComponentName cn = ComponentName.unflattenFromString(name); if (cn == null) { if (mParseError == null) { mParseError = "Bad set name " + name + " in preferred activity " + mShortComponent; } } else { myPackages[setPos] = cn.getPackageName(); myClasses[setPos] = cn.getClassName(); myComponents[setPos] = name; setPos++; } } XmlUtils.skipCurrentTag(parser); } else if (!mCallbacks.onReadTag(tagName, parser)) { Slog.w("PreferredComponent", "Unknown element: " + parser.getName()); XmlUtils.skipCurrentTag(parser); } } if (setPos != setCount) { if (mParseError == null) { mParseError = "Not enough set tags (expected " + setCount + " but found " + setPos + ") in " + mShortComponent; } } mSetPackages = myPackages; mSetClasses = myClasses; mSetComponents = myComponents; }
Example 18
Source File: PackageParser.java From AndroidComponentPlugin with Apache License 2.0 | 4 votes |
private boolean parseUsesPermission(Package pkg, Resources res, XmlResourceParser parser, AttributeSet attrs, String[] outError) throws XmlPullParserException, IOException { TypedArray sa = res.obtainAttributes(attrs, com.android.internal.R.styleable.AndroidManifestUsesPermission); // Note: don't allow this value to be a reference to a resource // that may change. String name = sa.getNonResourceString( com.android.internal.R.styleable.AndroidManifestUsesPermission_name); /* boolean required = sa.getBoolean( com.android.internal.R.styleable.AndroidManifestUsesPermission_required, true); */ boolean required = true; // Optional <uses-permission> not supported int maxSdkVersion = 0; TypedValue val = sa.peekValue( com.android.internal.R.styleable.AndroidManifestUsesPermission_maxSdkVersion); if (val != null) { if (val.type >= TypedValue.TYPE_FIRST_INT && val.type <= TypedValue.TYPE_LAST_INT) { maxSdkVersion = val.data; } } sa.recycle(); if ((maxSdkVersion == 0) || (maxSdkVersion >= Build.VERSION.RESOURCES_SDK_INT)) { if (name != null) { int index = pkg.requestedPermissions.indexOf(name); if (index == -1) { pkg.requestedPermissions.add(name.intern()); pkg.requestedPermissionsRequired.add(required ? Boolean.TRUE : Boolean.FALSE); } else { if (pkg.requestedPermissionsRequired.get(index) != required) { outError[0] = "conflicting <uses-permission> entries"; mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED; return false; } } } } XmlUtils.skipCurrentTag(parser); return true; }
Example 19
Source File: XmlConfigSource.java From cwac-netsecurity with Apache License 2.0 | 4 votes |
private void parseNetworkSecurityConfig(XmlResourceParser parser) throws IOException, XmlPullParserException, ParserException { Set<String> seenDomains = new HashSet<>(); List<Pair<NetworkSecurityConfig.Builder, Set<Domain>>> builders = new ArrayList<>(); NetworkSecurityConfig.Builder baseConfigBuilder = null; NetworkSecurityConfig.Builder debugConfigBuilder = null; boolean seenDebugOverrides = false; boolean seenBaseConfig = false; XmlUtils.beginDocument(parser, "network-security-config"); int outerDepth = parser.getDepth(); while (XmlUtils.nextElementWithin(parser, outerDepth)) { if ("base-config".equals(parser.getName())) { if (seenBaseConfig) { throw new ParserException(parser, "Only one base-config allowed"); } seenBaseConfig = true; baseConfigBuilder = parseConfigEntry(parser, seenDomains, null, CONFIG_BASE).get(0).first; } else if ("domain-config".equals(parser.getName())) { builders.addAll( parseConfigEntry(parser, seenDomains, baseConfigBuilder, CONFIG_DOMAIN)); } else if ("debug-overrides".equals(parser.getName())) { if (seenDebugOverrides) { throw new ParserException(parser, "Only one debug-overrides allowed"); } if (mDebugBuild) { debugConfigBuilder = parseConfigEntry(parser, null, null, CONFIG_DEBUG).get(0).first; } else { XmlUtils.skipCurrentTag(parser); } seenDebugOverrides = true; } else { XmlUtils.skipCurrentTag(parser); } } // If debug is true and there was no debug-overrides in the file check for an extra // _debug resource. if (mDebugBuild && debugConfigBuilder == null) { debugConfigBuilder = parseDebugOverridesResource(); } // Use the platform default as the parent of the base config for any values not provided // there. If there is no base config use the platform default. NetworkSecurityConfig.Builder platformDefaultBuilder = NetworkSecurityConfig.getDefaultBuilder(mTargetSdkVersion); addDebugAnchorsIfNeeded(debugConfigBuilder, platformDefaultBuilder); if (baseConfigBuilder != null) { baseConfigBuilder.setParent(platformDefaultBuilder); addDebugAnchorsIfNeeded(debugConfigBuilder, baseConfigBuilder); } else { baseConfigBuilder = platformDefaultBuilder; } // Build the per-domain config mapping. Set<Pair<Domain, NetworkSecurityConfig>> configs = new HashSet<>(); for (Pair<NetworkSecurityConfig.Builder, Set<Domain>> entry : builders) { NetworkSecurityConfig.Builder builder = entry.first; Set<Domain> domains = entry.second; // Set the parent of configs that do not have a parent to the base-config. This can // happen if the base-config comes after a domain-config in the file. // Note that this is safe with regards to children because of the order that // parseConfigEntry returns builders, the parent is always before the children. The // children builders will not have build called until _after_ their parents have their // parent set so everything is consistent. if (builder.getParent() == null) { builder.setParent(baseConfigBuilder); } addDebugAnchorsIfNeeded(debugConfigBuilder, builder); NetworkSecurityConfig config = builder.build(); for (Domain domain : domains) { configs.add(new Pair<>(domain, config)); } } mDefaultConfig = baseConfigBuilder.build(); mDomainMap = configs; }
Example 20
Source File: ActivityRecord.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
static ActivityRecord restoreFromXml(XmlPullParser in, ActivityStackSupervisor stackSupervisor) throws IOException, XmlPullParserException { Intent intent = null; PersistableBundle persistentState = null; int launchedFromUid = 0; String launchedFromPackage = null; String resolvedType = null; boolean componentSpecified = false; int userId = 0; long createTime = -1; final int outerDepth = in.getDepth(); TaskDescription taskDescription = new TaskDescription(); for (int attrNdx = in.getAttributeCount() - 1; attrNdx >= 0; --attrNdx) { final String attrName = in.getAttributeName(attrNdx); final String attrValue = in.getAttributeValue(attrNdx); if (DEBUG) Slog.d(TaskPersister.TAG, "ActivityRecord: attribute name=" + attrName + " value=" + attrValue); if (ATTR_ID.equals(attrName)) { createTime = Long.parseLong(attrValue); } else if (ATTR_LAUNCHEDFROMUID.equals(attrName)) { launchedFromUid = Integer.parseInt(attrValue); } else if (ATTR_LAUNCHEDFROMPACKAGE.equals(attrName)) { launchedFromPackage = attrValue; } else if (ATTR_RESOLVEDTYPE.equals(attrName)) { resolvedType = attrValue; } else if (ATTR_COMPONENTSPECIFIED.equals(attrName)) { componentSpecified = Boolean.parseBoolean(attrValue); } else if (ATTR_USERID.equals(attrName)) { userId = Integer.parseInt(attrValue); } else if (attrName.startsWith(ATTR_TASKDESCRIPTION_PREFIX)) { taskDescription.restoreFromXml(attrName, attrValue); } else { Log.d(TAG, "Unknown ActivityRecord attribute=" + attrName); } } int event; while (((event = in.next()) != END_DOCUMENT) && (event != END_TAG || in.getDepth() >= outerDepth)) { if (event == START_TAG) { final String name = in.getName(); if (DEBUG) Slog.d(TaskPersister.TAG, "ActivityRecord: START_TAG name=" + name); if (TAG_INTENT.equals(name)) { intent = Intent.restoreFromXml(in); if (DEBUG) Slog.d(TaskPersister.TAG, "ActivityRecord: intent=" + intent); } else if (TAG_PERSISTABLEBUNDLE.equals(name)) { persistentState = PersistableBundle.restoreFromXml(in); if (DEBUG) Slog.d(TaskPersister.TAG, "ActivityRecord: persistentState=" + persistentState); } else { Slog.w(TAG, "restoreActivity: unexpected name=" + name); XmlUtils.skipCurrentTag(in); } } } if (intent == null) { throw new XmlPullParserException("restoreActivity error intent=" + intent); } final ActivityManagerService service = stackSupervisor.mService; final ActivityInfo aInfo = stackSupervisor.resolveActivity(intent, resolvedType, 0, null, userId, Binder.getCallingUid()); if (aInfo == null) { throw new XmlPullParserException("restoreActivity resolver error. Intent=" + intent + " resolvedType=" + resolvedType); } final ActivityRecord r = new ActivityRecord(service, null /* caller */, 0 /* launchedFromPid */, launchedFromUid, launchedFromPackage, intent, resolvedType, aInfo, service.getConfiguration(), null /* resultTo */, null /* resultWho */, 0 /* reqCode */, componentSpecified, false /* rootVoiceInteraction */, stackSupervisor, null /* options */, null /* sourceRecord */); r.persistentState = persistentState; r.taskDescription = taskDescription; r.createTime = createTime; return r; }