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

Commit ed8ce392 authored by Andreas Gampe's avatar Andreas Gampe Committed by Gerrit Code Review
Browse files

Merge "Framework: Be more verbose in A/B OTA"

parents d5af15ee 069a91ce
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import java.io.File;
import java.io.FileDescriptor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;

@@ -124,7 +125,8 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
        synchronized (mPackageManagerService.mPackages) {
            // Important: the packages we need to run with ab-ota compiler-reason.
            important = PackageManagerServiceUtils.getPackagesForDexopt(
                    mPackageManagerService.mPackages.values(), mPackageManagerService);
                    mPackageManagerService.mPackages.values(), mPackageManagerService,
                    DEBUG_DEXOPT);
            // Others: we should optimize this with the (first-)boot compiler-reason.
            others = new ArrayList<>(mPackageManagerService.mPackages.values());
            others.removeAll(important);
@@ -157,6 +159,24 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
        long spaceAvailableNow = getAvailableSpace();

        prepareMetricsLogging(important.size(), others.size(), spaceAvailable, spaceAvailableNow);

        if (DEBUG_DEXOPT) {
            try {
                // Output some data about the packages.
                PackageParser.Package lastUsed = Collections.max(important,
                        (pkg1, pkg2) -> Long.compare(
                                pkg1.getLatestForegroundPackageUseTimeInMills(),
                                pkg2.getLatestForegroundPackageUseTimeInMills()));
                Log.d(TAG, "A/B OTA: lastUsed time = "
                        + lastUsed.getLatestForegroundPackageUseTimeInMills());
                Log.d(TAG, "A/B OTA: deprioritized packages:");
                for (PackageParser.Package pkg : others) {
                    Log.d(TAG, "  " + pkg.packageName + " - "
                            + pkg.getLatestForegroundPackageUseTimeInMills());
                }
            } catch (Exception ignored) {
            }
        }
    }

    @Override
+10 −3
Original line number Diff line number Diff line
@@ -164,6 +164,13 @@ public class PackageManagerServiceUtils {
    public static List<PackageParser.Package> getPackagesForDexopt(
            Collection<PackageParser.Package> packages,
            PackageManagerService packageManagerService) {
        return getPackagesForDexopt(packages, packageManagerService, DEBUG_DEXOPT);
    }

    public static List<PackageParser.Package> getPackagesForDexopt(
            Collection<PackageParser.Package> packages,
            PackageManagerService packageManagerService,
            boolean debug) {
        ArrayList<PackageParser.Package> remainingPkgs = new ArrayList<>(packages);
        LinkedList<PackageParser.Package> result = new LinkedList<>();
        ArrayList<PackageParser.Package> sortTemp = new ArrayList<>(remainingPkgs.size());
@@ -189,14 +196,14 @@ public class PackageManagerServiceUtils {
        // TODO: add a property to control this?
        Predicate<PackageParser.Package> remainingPredicate;
        if (!remainingPkgs.isEmpty() && packageManagerService.isHistoricalPackageUsageAvailable()) {
            if (DEBUG_DEXOPT) {
            if (debug) {
                Log.i(TAG, "Looking at historical package use");
            }
            // Get the package that was used last.
            PackageParser.Package lastUsed = Collections.max(remainingPkgs, (pkg1, pkg2) ->
                    Long.compare(pkg1.getLatestForegroundPackageUseTimeInMills(),
                            pkg2.getLatestForegroundPackageUseTimeInMills()));
            if (DEBUG_DEXOPT) {
            if (debug) {
                Log.i(TAG, "Taking package " + lastUsed.packageName + " as reference in time use");
            }
            long estimatedPreviousSystemUseTime =
@@ -218,7 +225,7 @@ public class PackageManagerServiceUtils {
        applyPackageFilter(remainingPredicate, result, remainingPkgs, sortTemp,
                packageManagerService);

        if (DEBUG_DEXOPT) {
        if (debug) {
            Log.i(TAG, "Packages to be dexopted: " + packagesToString(result));
            Log.i(TAG, "Packages skipped from dexopt: " + packagesToString(remainingPkgs));
        }