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

Commit 241bdded authored by Jiakai Zhang's avatar Jiakai Zhang Committed by Automerger Merge Worker
Browse files

Merge "Add the "--ignore-dexopt-profile" option." into main am: 66be198b

parents 3aeab9b6 66be198b
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -1449,6 +1449,7 @@ public abstract class PackageManager {
            INSTALL_ALLOW_DOWNGRADE,
            INSTALL_STAGED,
            INSTALL_REQUEST_UPDATE_OWNERSHIP,
            INSTALL_IGNORE_DEXOPT_PROFILE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface InstallFlags {}
@@ -1673,6 +1674,18 @@ public abstract class PackageManager {
     */
    public static final int INSTALL_FROM_MANAGED_USER_OR_PROFILE = 1 << 26;

    /**
     * If set, all dexopt profiles are ignored by dexopt during the installation, including the
     * profile in the DM file and the profile embedded in the APK file. If an invalid profile is
     * provided during installation, no warning will be reported by {@code adb install}.
     *
     * This option does not affect later dexopt operations (e.g., background dexopt and manual `pm
     * compile` invocations).
     *
     * @hide
     */
    public static final int INSTALL_IGNORE_DEXOPT_PROFILE = 1 << 28;

    /**
     * Flag parameter for {@link #installPackage} to force a non-staged update of an APEX. This is
     * a development-only feature and should not be used on end user devices.
+11 −2
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.pm.ApplicationInfo;
import android.content.pm.DataLoaderType;
import android.content.pm.Flags;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInfoLite;
import android.content.pm.PackageInstaller;
@@ -167,6 +168,7 @@ import com.android.internal.util.FrameworkStatsLog;
import com.android.server.EventLogTags;
import com.android.server.LocalManagerRegistry;
import com.android.server.SystemConfig;
import com.android.server.art.model.ArtFlags;
import com.android.server.art.model.DexoptParams;
import com.android.server.art.model.DexoptResult;
import com.android.server.pm.Installer.LegacyDexoptDisabledException;
@@ -2534,8 +2536,15 @@ final class InstallPackageHelper {
                            LocalManagerRegistry.getManager(PackageManagerLocal.class);
                    try (PackageManagerLocal.FilteredSnapshot snapshot =
                                    packageManagerLocal.withFilteredSnapshot()) {
                        DexoptParams params =
                                dexoptOptions.convertToDexoptParams(0 /* extraFlags */);
                        boolean ignoreDexoptProfile =
                                (installRequest.getInstallFlags()
                                        & PackageManager.INSTALL_IGNORE_DEXOPT_PROFILE)
                                != 0;
                        /*@DexoptFlags*/ int extraFlags =
                                ignoreDexoptProfile && Flags.useArtServiceV2()
                                ? ArtFlags.FLAG_IGNORE_PROFILE
                                : 0;
                        DexoptParams params = dexoptOptions.convertToDexoptParams(extraFlags);
                        DexoptResult dexOptResult = DexOptHelper.getArtManagerLocal().dexoptPackage(
                                snapshot, packageName, params);
                        installRequest.onDexoptFinished(dexOptResult);
+11 −1
Original line number Diff line number Diff line
@@ -3368,6 +3368,9 @@ class PackageManagerShellCommand extends ShellCommand {
                    sessionParams.installFlags |=
                            PackageManager.INSTALL_BYPASS_LOW_TARGET_SDK_BLOCK;
                    break;
                case "--ignore-dexopt-profile":
                    sessionParams.installFlags |= PackageManager.INSTALL_IGNORE_DEXOPT_PROFILE;
                    break;
                default:
                    throw new IllegalArgumentException("Unknown option " + opt);
            }
@@ -4263,7 +4266,7 @@ class PackageManagerShellCommand extends ShellCommand {
        pw.println("       [--enable-rollback]");
        pw.println("       [--force-uuid internal|UUID] [--pkg PACKAGE] [-S BYTES]");
        pw.println("       [--apex] [--non-staged] [--force-non-staged]");
        pw.println("       [--staged-ready-timeout TIMEOUT]");
        pw.println("       [--staged-ready-timeout TIMEOUT] [--ignore-dexopt-profile]");
        pw.println("       [PATH [SPLIT...]|-]");
        pw.println("    Install an application.  Must provide the apk data to install, either as");
        pw.println("    file path(s) or '-' to read from stdin.  Options are:");
@@ -4303,6 +4306,13 @@ class PackageManagerShellCommand extends ShellCommand {
        pw.println("          milliseconds for pre-reboot verification to complete when");
        pw.println("          performing staged install. This flag is used to alter the waiting");
        pw.println("          time. You can skip the waiting time by specifying a TIMEOUT of '0'");
        pw.println("      --ignore-dexopt-profile: If set, all profiles are ignored by dexopt");
        pw.println("          during the installation, including the profile in the DM file and");
        pw.println("          the profile embedded in the APK file. If an invalid profile is");
        pw.println("          provided during installation, no warning will be reported by `adb");
        pw.println("          install`.");
        pw.println("          This option does not affect later dexopt operations (e.g.,");
        pw.println("          background dexopt and manual `pm compile` invocations).");
        pw.println("");
        pw.println("  install-existing [--user USER_ID|all|current]");
        pw.println("       [--instant] [--full] [--wait] [--restrict-permissions] PACKAGE");