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

Commit 94056d1c authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

Do not create oat directory for an app in ASEC container

Currently installation fails, if an app is located on SD card (inside ASEC).
If an app is located inside ASEC, dexopt output should go to
/data/dalvik-cache. dexopt also needs to be performed at a later stage,
because the name of the oat file contains the absolute path to the dex file.

Bug: 20452651
Change-Id: I4432ca7a0b0e88b705705acf42e5cae78cadf729
parent 0d703f74
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -199,7 +199,8 @@ final class PackageDexOptimizer {
    @Nullable
    private String createOatDirIfSupported(PackageParser.Package pkg, String dexInstructionSet)
            throws IOException {
        if (pkg.isSystemApp() && !pkg.isUpdatedSystemApp()) {
        if ((pkg.isSystemApp() && !pkg.isUpdatedSystemApp()) || pkg.isForwardLocked()
                || pkg.applicationInfo.isExternalAsec()) {
            return null;
        }
        File codePath = new File(pkg.codePath);
+16 −12
Original line number Diff line number Diff line
@@ -11067,7 +11067,7 @@ public class PackageManagerService extends IPackageManager.Stub {
        final boolean onExternal = (((installFlags & PackageManager.INSTALL_EXTERNAL) != 0)
                || (args.volumeUuid != null));
        boolean replace = false;
        final int scanFlags = SCAN_NEW_INSTALL | SCAN_FORCE_DEX | SCAN_UPDATE_SIGNATURE;
        int scanFlags = SCAN_NEW_INSTALL | SCAN_FORCE_DEX | SCAN_UPDATE_SIGNATURE;
        // Result object to be returned
        res.returnCode = PackageManager.INSTALL_SUCCEEDED;
@@ -11234,7 +11234,11 @@ public class PackageManagerService extends IPackageManager.Stub {
            return;
        }
        // Run dexopt before old package gets removed, to minimize time when app is not available
        // If app directory is not writable, dexopt will be called after the rename
        if (!forwardLocked && !pkg.applicationInfo.isExternalAsec()) {
            // Enable SCAN_NO_DEX flag to skip dexopt at a later stage
            scanFlags |= SCAN_NO_DEX;
            // Run dexopt before old package gets removed, to minimize time when app is unavailable
            int result = mPackageDexOptimizer
                    .performDexOpt(pkg, null /* instruction sets */, true /* forceDex */,
                            false /* defer */, false /* inclDependencies */);
@@ -11242,6 +11246,7 @@ public class PackageManagerService extends IPackageManager.Stub {
                res.setError(INSTALL_FAILED_DEXOPT, "Dexopt failed for " + pkg.codePath);
                return;
            }
        }
        if (!args.doRename(res.returnCode, pkg, oldCodePath)) {
            res.setError(INSTALL_FAILED_INSUFFICIENT_STORAGE, "Failed rename");
@@ -11250,13 +11255,12 @@ public class PackageManagerService extends IPackageManager.Stub {
        startIntentFilterVerifications(args.user.getIdentifier(), pkg);
        // Call with SCAN_NO_DEX, since dexopt has already been made
        if (replace) {
            replacePackageLI(pkg, parseFlags, scanFlags | SCAN_REPLACING | SCAN_NO_DEX, args.user,
            replacePackageLI(pkg, parseFlags, scanFlags | SCAN_REPLACING, args.user,
                    installerPackageName, volumeUuid, res);
        } else {
            installNewPackageLI(pkg, parseFlags, scanFlags | SCAN_DELETE_DATA_ON_FAILURES
                    | SCAN_NO_DEX, args.user, installerPackageName, volumeUuid, res);
            installNewPackageLI(pkg, parseFlags, scanFlags | SCAN_DELETE_DATA_ON_FAILURES,
                    args.user, installerPackageName, volumeUuid, res);
        }
        synchronized (mPackages) {
            final PackageSetting ps = mSettings.mPackages.get(pkgName);