Merge changes I80504f43,Ifc372eef

* changes:
  Fix package install flow w.r.t. dexopt
  Do not apply app-link autoVerify policy to instant app installs
This commit is contained in:
Treehugger Robot
2017-12-01 01:09:30 +00:00
committed by Gerrit Code Review
2 changed files with 62 additions and 44 deletions

View File

@@ -128,6 +128,10 @@ public class PackageDexOptimizer {
int performDexOpt(PackageParser.Package pkg, String[] sharedLibraries, int performDexOpt(PackageParser.Package pkg, String[] sharedLibraries,
String[] instructionSets, CompilerStats.PackageStats packageStats, String[] instructionSets, CompilerStats.PackageStats packageStats,
PackageDexUsage.PackageUseInfo packageUseInfo, DexoptOptions options) { PackageDexUsage.PackageUseInfo packageUseInfo, DexoptOptions options) {
if (pkg.applicationInfo.uid == -1) {
throw new IllegalArgumentException("Dexopt for " + pkg.packageName
+ " has invalid uid.");
}
if (!canOptimizePackage(pkg)) { if (!canOptimizePackage(pkg)) {
return DEX_OPT_SKIPPED; return DEX_OPT_SKIPPED;
} }
@@ -299,6 +303,9 @@ public class PackageDexOptimizer {
*/ */
public int dexOptSecondaryDexPath(ApplicationInfo info, String path, public int dexOptSecondaryDexPath(ApplicationInfo info, String path,
PackageDexUsage.DexUseInfo dexUseInfo, DexoptOptions options) { PackageDexUsage.DexUseInfo dexUseInfo, DexoptOptions options) {
if (info.uid == -1) {
throw new IllegalArgumentException("Dexopt for path " + path + " has invalid uid.");
}
synchronized (mInstallLock) { synchronized (mInstallLock) {
final long acquireTime = acquireWakeLockLI(info.uid); final long acquireTime = acquireWakeLockLI(info.uid);
try { try {

View File

@@ -18271,10 +18271,45 @@ public class PackageManagerService extends IPackageManager.Stub
return; return;
} }
// Verify if we need to dexopt the app. if (!instantApp) {
startIntentFilterVerifications(args.user.getIdentifier(), replace, pkg);
} else {
if (DEBUG_DOMAIN_VERIFICATION) {
Slog.d(TAG, "Not verifying instant app install for app links: " + pkgName);
}
}
try (PackageFreezer freezer = freezePackageForInstall(pkgName, installFlags,
"installPackageLI")) {
if (replace) {
if (pkg.applicationInfo.isStaticSharedLibrary()) {
// Static libs have a synthetic package name containing the version
// and cannot be updated as an update would get a new package name,
// unless this is the exact same version code which is useful for
// development.
PackageParser.Package existingPkg = mPackages.get(pkg.packageName);
if (existingPkg != null && existingPkg.mVersionCode != pkg.mVersionCode) {
res.setError(INSTALL_FAILED_DUPLICATE_PACKAGE, "Packages declaring "
+ "static-shared libs cannot be updated");
return;
}
}
replacePackageLIF(pkg, parseFlags, scanFlags | SCAN_REPLACING, args.user,
installerPackageName, res, args.installReason);
} else {
installNewPackageLIF(pkg, parseFlags, scanFlags | SCAN_DELETE_DATA_ON_FAILURES,
args.user, installerPackageName, volumeUuid, res, args.installReason);
}
}
// Check whether we need to dexopt the app.
// //
// NOTE: it is *important* to call dexopt after doRename which will sync the // NOTE: it is IMPORTANT to call dexopt:
// package data from PackageParser.Package and its corresponding ApplicationInfo. // - after doRename which will sync the package data from PackageParser.Package and its
// corresponding ApplicationInfo.
// - after installNewPackageLIF or replacePackageLIF which will update result with the
// uid of the application (pkg.applicationInfo.uid).
// This update happens in place!
// //
// We only need to dexopt if the package meets ALL of the following conditions: // We only need to dexopt if the package meets ALL of the following conditions:
// 1) it is not forward locked. // 1) it is not forward locked.
@@ -18287,7 +18322,8 @@ public class PackageManagerService extends IPackageManager.Stub
// continuous progress to the useur instead of mysteriously blocking somewhere in the // continuous progress to the useur instead of mysteriously blocking somewhere in the
// middle of running an instant app. The default behaviour can be overridden // middle of running an instant app. The default behaviour can be overridden
// via gservices. // via gservices.
final boolean performDexopt = !forwardLocked final boolean performDexopt = (res.returnCode == PackageManager.INSTALL_SUCCEEDED)
&& !forwardLocked
&& !pkg.applicationInfo.isExternalAsec() && !pkg.applicationInfo.isExternalAsec()
&& (!instantApp || Global.getInt(mContext.getContentResolver(), && (!instantApp || Global.getInt(mContext.getContentResolver(),
Global.INSTANT_APP_DEXOPT_ENABLED, 0) != 0); Global.INSTANT_APP_DEXOPT_ENABLED, 0) != 0);
@@ -18315,31 +18351,6 @@ public class PackageManagerService extends IPackageManager.Stub
// TODO: Layering violation // TODO: Layering violation
BackgroundDexOptService.notifyPackageChanged(pkg.packageName); BackgroundDexOptService.notifyPackageChanged(pkg.packageName);
startIntentFilterVerifications(args.user.getIdentifier(), replace, pkg);
try (PackageFreezer freezer = freezePackageForInstall(pkgName, installFlags,
"installPackageLI")) {
if (replace) {
if (pkg.applicationInfo.isStaticSharedLibrary()) {
// Static libs have a synthetic package name containing the version
// and cannot be updated as an update would get a new package name,
// unless this is the exact same version code which is useful for
// development.
PackageParser.Package existingPkg = mPackages.get(pkg.packageName);
if (existingPkg != null && existingPkg.mVersionCode != pkg.mVersionCode) {
res.setError(INSTALL_FAILED_DUPLICATE_PACKAGE, "Packages declaring "
+ "static-shared libs cannot be updated");
return;
}
}
replacePackageLIF(pkg, parseFlags, scanFlags | SCAN_REPLACING, args.user,
installerPackageName, res, args.installReason);
} else {
installNewPackageLIF(pkg, parseFlags, scanFlags | SCAN_DELETE_DATA_ON_FAILURES,
args.user, installerPackageName, volumeUuid, res, args.installReason);
}
}
synchronized (mPackages) { synchronized (mPackages) {
final PackageSetting ps = mSettings.mPackages.get(pkgName); final PackageSetting ps = mSettings.mPackages.get(pkgName);
if (ps != null) { if (ps != null) {