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

Commit 7ee86d1d authored by Mathieu Chartier's avatar Mathieu Chartier Committed by Android (Google) Code Review
Browse files

Merge "Add dedicated flag to control app image generation" into pi-dev

parents 3a2d4143 a9c34338
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -67,6 +67,8 @@ public class Installer extends SystemService {
    public static final int DEXOPT_ENABLE_HIDDEN_API_CHECKS = 1 << 10;
    public static final int DEXOPT_ENABLE_HIDDEN_API_CHECKS = 1 << 10;
    /** Indicates that dexopt should convert to CompactDex. */
    /** Indicates that dexopt should convert to CompactDex. */
    public static final int DEXOPT_GENERATE_COMPACT_DEX = 1 << 11;
    public static final int DEXOPT_GENERATE_COMPACT_DEX = 1 << 11;
    /** Indicates that dexopt should generate an app image */
    public static final int DEXOPT_GENERATE_APP_IMAGE = 1 << 12;


    // NOTE: keep in sync with installd
    // NOTE: keep in sync with installd
    public static final int FLAG_CLEAR_CACHE_ONLY = 1 << 8;
    public static final int FLAG_CLEAR_CACHE_ONLY = 1 << 8;
+1 −1
Original line number Original line Diff line number Diff line
@@ -267,7 +267,7 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
                final StringBuilder builder = new StringBuilder();
                final StringBuilder builder = new StringBuilder();


                // The current version.
                // The current version.
                builder.append("8 ");
                builder.append("9 ");


                builder.append("dexopt");
                builder.append("dexopt");


+14 −0
Original line number Original line Diff line number Diff line
@@ -60,6 +60,7 @@ import static com.android.server.pm.Installer.DEXOPT_STORAGE_DE;
import static com.android.server.pm.Installer.DEXOPT_IDLE_BACKGROUND_JOB;
import static com.android.server.pm.Installer.DEXOPT_IDLE_BACKGROUND_JOB;
import static com.android.server.pm.Installer.DEXOPT_ENABLE_HIDDEN_API_CHECKS;
import static com.android.server.pm.Installer.DEXOPT_ENABLE_HIDDEN_API_CHECKS;
import static com.android.server.pm.Installer.DEXOPT_GENERATE_COMPACT_DEX;
import static com.android.server.pm.Installer.DEXOPT_GENERATE_COMPACT_DEX;
import static com.android.server.pm.Installer.DEXOPT_GENERATE_APP_IMAGE;
import static com.android.server.pm.InstructionSets.getAppDexInstructionSets;
import static com.android.server.pm.InstructionSets.getAppDexInstructionSets;
import static com.android.server.pm.InstructionSets.getDexCodeInstructionSets;
import static com.android.server.pm.InstructionSets.getDexCodeInstructionSets;


@@ -521,6 +522,10 @@ public class PackageDexOptimizer {
        return getDexFlags(pkg.applicationInfo, compilerFilter, options);
        return getDexFlags(pkg.applicationInfo, compilerFilter, options);
    }
    }


    private boolean isAppImageEnabled() {
        return SystemProperties.get("dalvik.vm.appimageformat", "").length() > 0;
    }

    private int getDexFlags(ApplicationInfo info, String compilerFilter, DexoptOptions options) {
    private int getDexFlags(ApplicationInfo info, String compilerFilter, DexoptOptions options) {
        int flags = info.flags;
        int flags = info.flags;
        boolean debuggable = (flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
        boolean debuggable = (flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
@@ -547,6 +552,14 @@ public class PackageDexOptimizer {
            case PackageManagerService.REASON_INSTALL:
            case PackageManagerService.REASON_INSTALL:
                 generateCompactDex = false;
                 generateCompactDex = false;
        }
        }
        // Use app images only if it is enabled and we are compiling
        // profile-guided (so the app image doesn't conservatively contain all classes).
        // If the app didn't request for the splits to be loaded in isolation or if it does not
        // declare inter-split dependencies, then all the splits will be loaded in the base
        // apk class loader (in the order of their definition, otherwise disable app images
        // because they are unsupported for multiple class loaders. b/7269679
        boolean generateAppImage = isProfileGuidedFilter && (info.splitDependencies == null ||
                !info.requestsIsolatedSplitLoading()) && isAppImageEnabled();
        int dexFlags =
        int dexFlags =
                (isPublic ? DEXOPT_PUBLIC : 0)
                (isPublic ? DEXOPT_PUBLIC : 0)
                | (debuggable ? DEXOPT_DEBUGGABLE : 0)
                | (debuggable ? DEXOPT_DEBUGGABLE : 0)
@@ -554,6 +567,7 @@ public class PackageDexOptimizer {
                | (options.isBootComplete() ? DEXOPT_BOOTCOMPLETE : 0)
                | (options.isBootComplete() ? DEXOPT_BOOTCOMPLETE : 0)
                | (options.isDexoptIdleBackgroundJob() ? DEXOPT_IDLE_BACKGROUND_JOB : 0)
                | (options.isDexoptIdleBackgroundJob() ? DEXOPT_IDLE_BACKGROUND_JOB : 0)
                | (generateCompactDex ? DEXOPT_GENERATE_COMPACT_DEX : 0)
                | (generateCompactDex ? DEXOPT_GENERATE_COMPACT_DEX : 0)
                | (generateAppImage ? DEXOPT_GENERATE_APP_IMAGE : 0)
                | hiddenApiFlag;
                | hiddenApiFlag;
        return adjustDexoptFlags(dexFlags);
        return adjustDexoptFlags(dexFlags);
    }
    }