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

Commit 0f02aeb6 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow "cmd package bg-dexopt-job" to take a list of package names"

parents 4573e9b8 09dd1ec4
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -543,9 +543,10 @@ interface IPackageManager {
    void forceDexOpt(String packageName);

    /**
     * Execute the background dexopt job immediately.
     * Execute the background dexopt job immediately on packages in packageNames.
     * If null, then execute on all packages.
     */
    boolean runBackgroundDexoptJob();
    boolean runBackgroundDexoptJob(in List<String> packageNames);

    /**
     * Reconcile the information we have about the secondary dex files belonging to
+13 −3
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.pm;

import static com.android.server.pm.PackageManagerService.DEBUG_DEXOPT;

import android.annotation.Nullable;
import android.app.job.JobInfo;
import android.app.job.JobParameters;
import android.app.job.JobScheduler;
@@ -40,6 +41,7 @@ import com.android.server.PinnerService;
import com.android.server.pm.dex.DexoptOptions;

import java.io.File;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.TimeUnit;
@@ -402,14 +404,22 @@ public class BackgroundDexOptService extends JobService {
    }

    /**
     * Execute the idle optimizations immediately.
     * Execute idle optimizations immediately on packages in packageNames. If packageNames is null,
     * then execute on all packages.
     */
    public static boolean runIdleOptimizationsNow(PackageManagerService pm, Context context) {
    public static boolean runIdleOptimizationsNow(PackageManagerService pm, Context context,
            @Nullable List<String> packageNames) {
        // Create a new object to make sure we don't interfere with the scheduled jobs.
        // Note that this may still run at the same time with the job scheduled by the
        // JobScheduler but the scheduler will not be able to cancel it.
        BackgroundDexOptService bdos = new BackgroundDexOptService();
        int result = bdos.idleOptimization(pm, pm.getOptimizablePackages(), context);
        ArraySet<String> packagesToOptimize;
        if (packageNames == null) {
            packagesToOptimize = pm.getOptimizablePackages();
        } else {
            packagesToOptimize = new ArraySet<>(packageNames);
        }
        int result = bdos.idleOptimization(pm, packagesToOptimize, context);
        return result == OPTIMIZE_PROCESSED;
    }

+2 −2
Original line number Diff line number Diff line
@@ -8985,11 +8985,11 @@ public class PackageManagerService extends IPackageManager.Stub
     * Execute the background dexopt job immediately.
     */
    @Override
    public boolean runBackgroundDexoptJob() {
    public boolean runBackgroundDexoptJob(@Nullable List<String> packageNames) {
        if (getInstantAppPackageName(Binder.getCallingUid()) != null) {
            return false;
        }
        return BackgroundDexOptService.runIdleOptimizationsNow(this, mContext);
        return BackgroundDexOptService.runIdleOptimizationsNow(this, mContext, packageNames);
    }
    List<PackageParser.Package> findSharedNonSystemLibraries(PackageParser.Package p) {
+7 −1
Original line number Diff line number Diff line
@@ -1219,7 +1219,13 @@ class PackageManagerShellCommand extends ShellCommand {
    }

    private int runDexoptJob() throws RemoteException {
        boolean result = mInterface.runBackgroundDexoptJob();
        String arg;
        List<String> packageNames = new ArrayList<>();
        while ((arg = getNextArg()) != null) {
            packageNames.add(arg);
        }
        boolean result = mInterface.runBackgroundDexoptJob(packageNames.isEmpty() ? null :
                packageNames);
        return result ? 0 : -1;
    }