Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 561e13d6 authored by Narayan Kamath's avatar Narayan Kamath
Browse files

Fix application moves.

We don't dex2oat during application moves, so we must scan
the package again scanPackageDirtyLI to deduce its ABI.

This is unnecessary (since a move cannot change ABIs), but we
need some additional refactoring to avoid a second scan.

bug: 21337469

(cherry picked from commit cd251fa3)

Change-Id: Id1ed3bdfabb41e05e6a2f7efbd05d2103a67c663
parent 8f9339d0
Loading
Loading
Loading
Loading
+9 −18
Original line number Diff line number Diff line
@@ -5522,25 +5522,16 @@ public class PackageManagerService extends IPackageManager.Stub {
            if ((scanFlags & SCAN_NEW_INSTALL) == 0) {
                deriveNonSystemPackageAbi(pkg, scanFile, cpuAbiOverride, true /* extract libs */);
            } else {
                // Verify the ABIs haven't changed since we last deduced them.
                String oldPrimaryCpuAbi = pkg.applicationInfo.primaryCpuAbi;
                String oldSecondaryCpuAbi = pkg.applicationInfo.secondaryCpuAbi;
                // TODO: The only purpose of this code is to update the native library paths
                // based on the final install location. We can simplify this and avoid having
                // to scan the package again.
                // TODO: We need this second call to derive in two cases :
                //
                // - To update the native library paths based on the final install location.
                // - We don't call dexopt when moving packages, and so we have to scan again.
                //
                // We can simplify this and avoid having to scan the package again by letting
                // scanPackageLI know if the current install was a move (and deriving things only
                // in that case) and by "reparenting" the native lib directory in the case of
                // a normal (non-move) install.
                deriveNonSystemPackageAbi(pkg, scanFile, cpuAbiOverride, false /* extract libs */);
                if (!TextUtils.equals(oldPrimaryCpuAbi, pkg.applicationInfo.primaryCpuAbi)) {
                    throw new PackageManagerException(INSTALL_FAILED_INTERNAL_ERROR,
                            "unexpected abi change for " + pkg.packageName + " ("
                            + oldPrimaryCpuAbi + "-> " + pkg.applicationInfo.primaryCpuAbi);
                }
                if (!TextUtils.equals(oldSecondaryCpuAbi, pkg.applicationInfo.secondaryCpuAbi)) {
                    throw new PackageManagerException(INSTALL_FAILED_INTERNAL_ERROR,
                            "unexpected abi change for " + pkg.packageName + " ("
                            + oldSecondaryCpuAbi + "-> " + pkg.applicationInfo.secondaryCpuAbi);
                }
            }
            if (DEBUG_INSTALL) Slog.i(TAG, "Linking native library dir for " + path);