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

Commit 219b5356 authored by Calin Juravle's avatar Calin Juravle
Browse files

Fix the instruction set for dex file during (re)moving ops.

This complements https://android-review.googlesource.com/#/c/103231/
where the instruction set was mapped just for comptilation. The same
should have been done for move,remove and getSize.

The list of dex code ISAs is alo de-duped.

Bug: 16185267
Change-Id: I8fe453a800812e382e8f41b5f7922997aa9c18a9
parent 2f4cf2cf
Loading
Loading
Loading
Loading
+23 −13
Original line number Diff line number Diff line
@@ -1350,7 +1350,9 @@ public class PackageManagerService extends IPackageManager.Stub {
            boolean didDexOptLibraryOrTool = false;
            final List<String> dexCodeInstructionSets = getAllDexCodeInstructionSets();
            final List<String> allInstructionSets = getAllInstructionSets();
            final String[] dexCodeInstructionSets =
                getDexCodeInstructionSets(allInstructionSets.toArray(new String[allInstructionSets.size()]));
            /**
             * Ensure all external libraries have had dexopt run on them.
@@ -4399,18 +4401,21 @@ public class PackageManagerService extends IPackageManager.Stub {
        return allInstructionSets;
    }
    /**
     * Returns the instruction set that should be used to compile dex code. In the presence of
     * a native bridge this might be different than the one shared libraries use.
     */
    public static String getDexCodeInstructionSet(String sharedLibraryIsa) {
        String dexCodeIsa = SystemProperties.get("ro.dalvik.vm.isa." + sharedLibraryIsa);
        return (dexCodeIsa.isEmpty() ? sharedLibraryIsa : dexCodeIsa);
    }
    private static List<String> getAllDexCodeInstructionSets() {
        List<String> instructionSets = getAllInstructionSets();
        List<String> dexCodeInstructionSets = new ArrayList<String>(instructionSets.size());
    private static String[] getDexCodeInstructionSets(String[] instructionSets) {
        HashSet<String> dexCodeInstructionSets = new HashSet<String>(instructionSets.length);
        for (String instructionSet : instructionSets) {
            dexCodeInstructionSets.add(getDexCodeInstructionSet(instructionSet));
        }
        return dexCodeInstructionSets;
        return dexCodeInstructionSets.toArray(new String[dexCodeInstructionSets.size()]);
    }
    private int performDexOptLI(PackageParser.Package pkg, boolean forceDex, boolean defer,
@@ -5750,7 +5755,8 @@ public class PackageManagerService extends IPackageManager.Stub {
                            ps.pkg.applicationInfo.cpuAbi = null;
                            return false;
                        } else {
                            mInstaller.rmdex(ps.codePathString, getPreferredInstructionSet());
                            mInstaller.rmdex(ps.codePathString,
                                             getDexCodeInstructionSet(getPreferredInstructionSet()));
                        }
                    }
                }
@@ -8981,7 +8987,8 @@ public class PackageManagerService extends IPackageManager.Stub {
                if (instructionSet == null) {
                    throw new IllegalStateException("instructionSet == null");
                }
                int retCode = mInstaller.rmdex(sourceDir, instructionSet);
                final String dexCodeInstructionSet = getDexCodeInstructionSet(instructionSet);
                int retCode = mInstaller.rmdex(sourceDir, dexCodeInstructionSet);
                if (retCode < 0) {
                    Slog.w(TAG, "Couldn't remove dex file for package: "
                            +  " at location "
@@ -9259,7 +9266,8 @@ public class PackageManagerService extends IPackageManager.Stub {
            if (instructionSet == null) {
                throw new IllegalStateException("instructionSet == null");
            }
            int retCode = mInstaller.rmdex(sourceFile, instructionSet);
            final String dexCodeInstructionSet = getDexCodeInstructionSet(instructionSet);
            int retCode = mInstaller.rmdex(sourceFile, dexCodeInstructionSet);
            if (retCode < 0) {
                Slog.w(TAG, "Couldn't remove dex file for package: "
                        + " at location "
@@ -9692,8 +9700,9 @@ public class PackageManagerService extends IPackageManager.Stub {
    private int moveDexFilesLI(PackageParser.Package newPackage) {
        if ((newPackage.applicationInfo.flags&ApplicationInfo.FLAG_HAS_CODE) != 0) {
            final String instructionSet = getAppInstructionSet(newPackage.applicationInfo);
            final String dexCodeInstructionSet = getDexCodeInstructionSet(instructionSet);
            int retCode = mInstaller.movedex(newPackage.mScanPath, newPackage.mPath,
                                             instructionSet);
                                             dexCodeInstructionSet);
            if (retCode != 0) {
                /*
                 * Programs may be lazily run through dexopt, so the
@@ -9704,8 +9713,8 @@ public class PackageManagerService extends IPackageManager.Stub {
                 * file from a previous version of the package.
                 */
                newPackage.mDexOptNeeded = true;
                mInstaller.rmdex(newPackage.mScanPath, instructionSet);
                mInstaller.rmdex(newPackage.mPath, instructionSet);
                mInstaller.rmdex(newPackage.mScanPath, dexCodeInstructionSet);
                mInstaller.rmdex(newPackage.mPath, dexCodeInstructionSet);
            }
        }
        return PackageManager.INSTALL_SUCCEEDED;
@@ -10761,9 +10770,10 @@ public class PackageManagerService extends IPackageManager.Stub {
                publicSrcDir = applicationInfo.publicSourceDir;
            }
        }
        String dexCodeInstructionSet = getDexCodeInstructionSet(getAppInstructionSetFromSettings(ps));
        int res = mInstaller.getSizeInfo(packageName, userHandle, p.mPath, libDirPath,
                publicSrcDir, asecPath, getAppInstructionSetFromSettings(ps),
                pStats);
                publicSrcDir, asecPath, dexCodeInstructionSet, pStats);
        if (res < 0) {
            return false;
        }