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

Commit 589f2b53 authored by Fyodor Kupolov's avatar Fyodor Kupolov Committed by Narayan Kamath
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
Bug: 21360107

(cherry picked from commit 94056d1c)

Change-Id: Id1ced7159e5af9c05be0b637437b3b260e859c1d
parent 3385b616
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -916,6 +916,11 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
    }

    /** @hide */
    public boolean isInternal() {
        return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
    }

    /**
     * @hide
     */
+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.isInternal())) {
            return null;
        }
        File codePath = new File(pkg.codePath);
+16 −12
Original line number Diff line number Diff line
@@ -10254,7 +10254,7 @@ public class PackageManagerService extends IPackageManager.Stub {
        boolean forwardLocked = ((installFlags & PackageManager.INSTALL_FORWARD_LOCK) != 0);
        boolean onSd = ((installFlags & PackageManager.INSTALL_EXTERNAL) != 0);
        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;
@@ -10421,7 +10421,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.isInternal()) {
            // 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 */);
@@ -10429,19 +10433,19 @@ 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");
            return;
        }
        // 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, res);
        } else {
            installNewPackageLI(pkg, parseFlags, scanFlags | SCAN_DELETE_DATA_ON_FAILURES
                            | SCAN_NO_DEX, args.user, installerPackageName, res);
            installNewPackageLI(pkg, parseFlags, scanFlags | SCAN_DELETE_DATA_ON_FAILURES,
                    args.user, installerPackageName, res);
        }
        synchronized (mPackages) {
            final PackageSetting ps = mSettings.mPackages.get(pkgName);