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

Commit 29c772cb authored by Calin Juravle's avatar Calin Juravle Committed by Andreas Gampe
Browse files

[framework] Pass .dm files to dexopt at install time

(cherry picked from commit cc65194e)

Test: DexoptOptionsTest
      adb install foo.apk foo.dm
Bug: 30934496

Merged-In: If7e705a0efc0954a385ec3bfe7a93921c0d83351
Change-Id: If7e705a0efc0954a385ec3bfe7a93921c0d83351
parent e4ad74e8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -576,7 +576,7 @@ public class ZygoteInit {
                    installd.dexopt(classPathElement, Process.SYSTEM_UID, packageName,
                            instructionSet, dexoptNeeded, outputPath, dexFlags, compilerFilter,
                            uuid, classLoaderContext, seInfo, false /* downgrade */,
                            targetSdkVersion, /*profileName*/ null);
                            targetSdkVersion, /*profileName*/ null, /*dexMetadataPath*/ null);
                } catch (RemoteException | ServiceSpecificException e) {
                    // Ignore (but log), we need this on the classpath for fallback mode.
                    Log.w(TAG, "Failed compiling classpath element for system server: "
+3 −2
Original line number Diff line number Diff line
@@ -286,13 +286,14 @@ public class Installer extends SystemService {
            int dexoptNeeded, @Nullable String outputPath, int dexFlags,
            String compilerFilter, @Nullable String volumeUuid, @Nullable String sharedLibraries,
            @Nullable String seInfo, boolean downgrade, int targetSdkVersion,
            @Nullable String profileName) throws InstallerException {
            @Nullable String profileName, @Nullable String dexMetadataPath)
            throws InstallerException {
        assertValidInstructionSet(instructionSet);
        if (!checkBeforeRemote()) return;
        try {
            mInstalld.dexopt(apkPath, uid, pkgName, instructionSet, dexoptNeeded, outputPath,
                    dexFlags, compilerFilter, volumeUuid, sharedLibraries, seInfo, downgrade,
                    targetSdkVersion, profileName);
                    targetSdkVersion, profileName, dexMetadataPath);
        } catch (Exception e) {
            throw InstallerException.from(e);
        }
+5 −4
Original line number Diff line number Diff line
@@ -261,12 +261,12 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
                    String instructionSet, int dexoptNeeded, @Nullable String outputPath,
                    int dexFlags, String compilerFilter, @Nullable String volumeUuid,
                    @Nullable String sharedLibraries, @Nullable String seInfo, boolean downgrade,
                    int targetSdkVersion, @Nullable String profileName)
                    throws InstallerException {
                    int targetSdkVersion, @Nullable String profileName,
                    @Nullable String dexMetadataPath) throws InstallerException {
                final StringBuilder builder = new StringBuilder();

                // The version. Right now it's 5.
                builder.append("5 ");
                // The version. Right now it's 6.
                builder.append("6 ");

                builder.append("dexopt");

@@ -284,6 +284,7 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
                encodeParameter(builder, downgrade);
                encodeParameter(builder, targetSdkVersion);
                encodeParameter(builder, profileName);
                encodeParameter(builder, dexMetadataPath);

                commands.add(builder.toString());
            }
+13 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageParser;
import android.content.pm.dex.ArtManager;
import android.content.pm.dex.DexMetadataHelper;
import android.os.FileUtils;
import android.os.PowerManager;
import android.os.SystemClock;
@@ -214,6 +215,13 @@ public class PackageDexOptimizer {

            String profileName = ArtManager.getProfileName(i == 0 ? null : pkg.splitNames[i - 1]);

            String dexMetadataPath = null;
            if (options.isDexoptInstallWithDexMetadata()) {
                File dexMetadataFile = DexMetadataHelper.findDexMetadataForFile(new File(path));
                dexMetadataPath = dexMetadataFile == null
                        ? null : dexMetadataFile.getAbsolutePath();
            }

            final boolean isUsedByOtherApps = options.isDexoptAsSharedLibrary()
                    || packageUseInfo.isUsedByOtherApps(path);
            final String compilerFilter = getRealCompilerFilter(pkg.applicationInfo,
@@ -228,7 +236,7 @@ public class PackageDexOptimizer {
            for (String dexCodeIsa : dexCodeInstructionSets) {
                int newResult = dexOptPath(pkg, path, dexCodeIsa, compilerFilter,
                        profileUpdated, classLoaderContexts[i], dexoptFlags, sharedGid,
                        packageStats, options.isDowngrade(), profileName);
                        packageStats, options.isDowngrade(), profileName, dexMetadataPath);
                // The end result is:
                //  - FAILED if any path failed,
                //  - PERFORMED if at least one path needed compilation,
@@ -253,7 +261,7 @@ public class PackageDexOptimizer {
    private int dexOptPath(PackageParser.Package pkg, String path, String isa,
            String compilerFilter, boolean profileUpdated, String classLoaderContext,
            int dexoptFlags, int uid, CompilerStats.PackageStats packageStats, boolean downgrade,
            String profileName) {
            String profileName, String dexMetadataPath) {
        int dexoptNeeded = getDexoptNeeded(path, isa, compilerFilter, classLoaderContext,
                profileUpdated, downgrade);
        if (Math.abs(dexoptNeeded) == DexFile.NO_DEXOPT_NEEDED) {
@@ -280,7 +288,7 @@ public class PackageDexOptimizer {
            mInstaller.dexopt(path, uid, pkg.packageName, isa, dexoptNeeded, oatDir, dexoptFlags,
                    compilerFilter, pkg.volumeUuid, classLoaderContext, pkg.applicationInfo.seInfo,
                    false /* downgrade*/, pkg.applicationInfo.targetSdkVersion,
                    profileName);
                    profileName, dexMetadataPath);

            if (packageStats != null) {
                long endTime = System.currentTimeMillis();
@@ -401,7 +409,8 @@ public class PackageDexOptimizer {
                mInstaller.dexopt(path, info.uid, info.packageName, isa, /*dexoptNeeded*/ 0,
                        /*oatDir*/ null, dexoptFlags,
                        compilerFilter, info.volumeUuid, classLoaderContext, info.seInfoUser,
                        options.isDowngrade(), info.targetSdkVersion, /*profileName*/ null);
                        options.isDowngrade(), info.targetSdkVersion, /*profileName*/ null,
                        /*dexMetadataPath*/ null);
            }

            return DEX_OPT_PERFORMED;
+2 −1
Original line number Diff line number Diff line
@@ -18872,7 +18872,8 @@ public class PackageManagerService extends IPackageManager.Stub
            // Also, don't fail application installs if the dexopt step fails.
            DexoptOptions dexoptOptions = new DexoptOptions(pkg.packageName,
                    REASON_INSTALL,
                    DexoptOptions.DEXOPT_BOOT_COMPLETE);
                    DexoptOptions.DEXOPT_BOOT_COMPLETE |
                    DexoptOptions.DEXOPT_INSTALL_WITH_DEX_METADATA_FILE);
            mPackageDexOptimizer.performDexOpt(pkg, pkg.usesLibraryFiles,
                    null /* instructionSets */,
                    getOrCreateCompilerPackageStats(pkg),
Loading