Merge "PackageParser: Parse android:classLoader during the full parse." into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
af706b40de
@@ -414,7 +414,7 @@ public final class Pm {
|
||||
try {
|
||||
ApkLite baseApk = PackageParser.parseApkLite(file, 0);
|
||||
PackageLite pkgLite = new PackageLite(null, baseApk, null, null, null, null,
|
||||
null, null, null);
|
||||
null, null);
|
||||
params.sessionParams.setSize(
|
||||
PackageHelper.calculateInstalledSize(pkgLite, false,
|
||||
params.sessionParams.abiOverride));
|
||||
|
||||
@@ -428,12 +428,9 @@ public class PackageParser {
|
||||
public final boolean extractNativeLibs;
|
||||
public final boolean isolatedSplits;
|
||||
|
||||
public final String classLoaderName;
|
||||
public final String[] splitClassLoaderNames;
|
||||
|
||||
public PackageLite(String codePath, ApkLite baseApk, String[] splitNames,
|
||||
boolean[] isFeatureSplits, String[] usesSplitNames, String[] configForSplit,
|
||||
String[] splitCodePaths, int[] splitRevisionCodes, String[] splitClassLoaderNames) {
|
||||
String[] splitCodePaths, int[] splitRevisionCodes) {
|
||||
this.packageName = baseApk.packageName;
|
||||
this.versionCode = baseApk.versionCode;
|
||||
this.installLocation = baseApk.installLocation;
|
||||
@@ -453,9 +450,6 @@ public class PackageParser {
|
||||
this.use32bitAbi = baseApk.use32bitAbi;
|
||||
this.extractNativeLibs = baseApk.extractNativeLibs;
|
||||
this.isolatedSplits = baseApk.isolatedSplits;
|
||||
|
||||
this.classLoaderName = baseApk.classLoaderName;
|
||||
this.splitClassLoaderNames = splitClassLoaderNames;
|
||||
}
|
||||
|
||||
public List<String> getAllCodePaths() {
|
||||
@@ -490,14 +484,13 @@ public class PackageParser {
|
||||
public final boolean use32bitAbi;
|
||||
public final boolean extractNativeLibs;
|
||||
public final boolean isolatedSplits;
|
||||
public final String classLoaderName;
|
||||
|
||||
public ApkLite(String codePath, String packageName, String splitName, boolean isFeatureSplit,
|
||||
String configForSplit, String usesSplitName, int versionCode, int revisionCode,
|
||||
int installLocation, List<VerifierInfo> verifiers, Signature[] signatures,
|
||||
Certificate[][] certificates, boolean coreApp, boolean debuggable,
|
||||
boolean multiArch, boolean use32bitAbi, boolean extractNativeLibs,
|
||||
boolean isolatedSplits, String classLoaderName) {
|
||||
boolean isolatedSplits) {
|
||||
this.codePath = codePath;
|
||||
this.packageName = packageName;
|
||||
this.splitName = splitName;
|
||||
@@ -516,7 +509,6 @@ public class PackageParser {
|
||||
this.use32bitAbi = use32bitAbi;
|
||||
this.extractNativeLibs = extractNativeLibs;
|
||||
this.isolatedSplits = isolatedSplits;
|
||||
this.classLoaderName = classLoaderName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -885,7 +877,7 @@ public class PackageParser {
|
||||
final ApkLite baseApk = parseApkLite(packageFile, flags);
|
||||
final String packagePath = packageFile.getAbsolutePath();
|
||||
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
|
||||
return new PackageLite(packagePath, baseApk, null, null, null, null, null, null, null);
|
||||
return new PackageLite(packagePath, baseApk, null, null, null, null, null, null);
|
||||
}
|
||||
|
||||
static PackageLite parseClusterPackageLite(File packageDir, int flags)
|
||||
@@ -956,7 +948,6 @@ public class PackageParser {
|
||||
configForSplits = new String[size];
|
||||
splitCodePaths = new String[size];
|
||||
splitRevisionCodes = new int[size];
|
||||
splitClassLoaderNames = new String[size];
|
||||
|
||||
splitNames = apks.keySet().toArray(splitNames);
|
||||
Arrays.sort(splitNames, sSplitNameComparator);
|
||||
@@ -968,13 +959,12 @@ public class PackageParser {
|
||||
configForSplits[i] = apk.configForSplit;
|
||||
splitCodePaths[i] = apk.codePath;
|
||||
splitRevisionCodes[i] = apk.revisionCode;
|
||||
splitClassLoaderNames[i] = apk.classLoaderName;
|
||||
}
|
||||
}
|
||||
|
||||
final String codePath = packageDir.getAbsolutePath();
|
||||
return new PackageLite(codePath, baseApk, splitNames, isFeatureSplits, usesSplitNames,
|
||||
configForSplits, splitCodePaths, splitRevisionCodes, splitClassLoaderNames);
|
||||
configForSplits, splitCodePaths, splitRevisionCodes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1239,8 +1229,7 @@ public class PackageParser {
|
||||
pkg.splitPrivateFlags = new int[num];
|
||||
pkg.applicationInfo.splitNames = pkg.splitNames;
|
||||
pkg.applicationInfo.splitDependencies = splitDependencies;
|
||||
pkg.applicationInfo.classLoaderName = lite.classLoaderName;
|
||||
pkg.applicationInfo.splitClassLoaderNames = lite.splitClassLoaderNames;
|
||||
pkg.applicationInfo.splitClassLoaderNames = new String[num];
|
||||
|
||||
for (int i = 0; i < num; i++) {
|
||||
final AssetManager splitAssets = assetLoader.getSplitAssetManager(i);
|
||||
@@ -1854,7 +1843,6 @@ public class PackageParser {
|
||||
boolean isFeatureSplit = false;
|
||||
String configForSplit = null;
|
||||
String usesSplitName = null;
|
||||
String classLoaderName = null;
|
||||
|
||||
for (int i = 0; i < attrs.getAttributeCount(); i++) {
|
||||
final String attr = attrs.getAttributeName(i);
|
||||
@@ -1911,14 +1899,6 @@ public class PackageParser {
|
||||
if ("extractNativeLibs".equals(attr)) {
|
||||
extractNativeLibs = attrs.getAttributeBooleanValue(i, true);
|
||||
}
|
||||
if ("classLoader".equals(attr)) {
|
||||
classLoaderName = attrs.getAttributeValue(i);
|
||||
if (!ClassLoaderFactory.isValidClassLoaderName(classLoaderName)) {
|
||||
throw new PackageParserException(
|
||||
PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED,
|
||||
"Invalid class loader name: " + classLoaderName);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (TAG_USES_SPLIT.equals(parser.getName())) {
|
||||
if (usesSplitName != null) {
|
||||
@@ -1938,7 +1918,7 @@ public class PackageParser {
|
||||
return new ApkLite(codePath, packageSplit.first, packageSplit.second, isFeatureSplit,
|
||||
configForSplit, usesSplitName, versionCode, revisionCode, installLocation,
|
||||
verifiers, signatures, certificates, coreApp, debuggable, multiArch, use32bitAbi,
|
||||
extractNativeLibs, isolatedSplits, classLoaderName);
|
||||
extractNativeLibs, isolatedSplits);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3690,6 +3670,13 @@ public class PackageParser {
|
||||
ai.uiOptions = sa.getInt(
|
||||
com.android.internal.R.styleable.AndroidManifestApplication_uiOptions, 0);
|
||||
|
||||
ai.classLoaderName = sa.getString(
|
||||
com.android.internal.R.styleable.AndroidManifestApplication_classLoader);
|
||||
if (ai.classLoaderName != null
|
||||
&& !ClassLoaderFactory.isValidClassLoaderName(ai.classLoaderName)) {
|
||||
outError[0] = "Invalid class loader name: " + ai.classLoaderName;
|
||||
}
|
||||
|
||||
sa.recycle();
|
||||
|
||||
if (outError[0] != null) {
|
||||
@@ -3939,6 +3926,16 @@ public class PackageParser {
|
||||
owner.splitFlags[splitIndex] |= ApplicationInfo.FLAG_HAS_CODE;
|
||||
}
|
||||
|
||||
final String classLoaderName = sa.getString(
|
||||
com.android.internal.R.styleable.AndroidManifestApplication_classLoader);
|
||||
if (classLoaderName == null || ClassLoaderFactory.isValidClassLoaderName(classLoaderName)) {
|
||||
owner.applicationInfo.splitClassLoaderNames[splitIndex] = classLoaderName;
|
||||
} else {
|
||||
outError[0] = "Invalid class loader name: " + classLoaderName;
|
||||
mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
|
||||
return false;
|
||||
}
|
||||
|
||||
final int innerDepth = parser.getDepth();
|
||||
int type;
|
||||
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
|
||||
|
||||
@@ -1153,7 +1153,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
// This is kind of hacky; we're creating a half-parsed package that is
|
||||
// straddled between the inherited and staged APKs.
|
||||
final PackageLite pkg = new PackageLite(null, baseApk, null, null, null, null,
|
||||
splitPaths.toArray(new String[splitPaths.size()]), null, null);
|
||||
splitPaths.toArray(new String[splitPaths.size()]), null);
|
||||
final boolean isForwardLocked =
|
||||
(params.installFlags & PackageManager.INSTALL_FORWARD_LOCK) != 0;
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ class PackageManagerShellCommand extends ShellCommand {
|
||||
try {
|
||||
ApkLite baseApk = PackageParser.parseApkLite(file, 0);
|
||||
PackageLite pkgLite = new PackageLite(null, baseApk, null, null, null, null,
|
||||
null, null, null);
|
||||
null, null);
|
||||
params.sessionParams.setSize(PackageHelper.calculateInstalledSize(
|
||||
pkgLite, false, params.sessionParams.abiOverride));
|
||||
} catch (PackageParserException | IOException e) {
|
||||
|
||||
Reference in New Issue
Block a user