From 3e1b6ad1e3eda378738d03e5861b344992e80f86 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 10 Apr 2017 15:48:50 -0700 Subject: [PATCH] OtaDexOptService: Log post-reboot moves Disable artifact checks for non-upgrade booting. Log the number of successfully move artifacts. (cherry picked from commit 95349c0e9664ec6392a959893f96390310e3b8a4) Bug: 37158297 Test: m Test: manual Change-Id: Ic81531950582ce937e2e3b7815fb9132888d9a42 --- .../com/android/server/pm/OtaDexoptService.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/pm/OtaDexoptService.java b/services/core/java/com/android/server/pm/OtaDexoptService.java index 498181b5179ec..7b865429d0d76 100644 --- a/services/core/java/com/android/server/pm/OtaDexoptService.java +++ b/services/core/java/com/android/server/pm/OtaDexoptService.java @@ -95,9 +95,6 @@ public class OtaDexoptService extends IOtaDexopt.Stub { public OtaDexoptService(Context context, PackageManagerService packageManagerService) { this.mContext = context; this.mPackageManagerService = packageManagerService; - - // Now it's time to check whether we need to move any A/B artifacts. - moveAbArtifacts(packageManagerService.mInstaller); } public static OtaDexoptService main(Context context, @@ -105,6 +102,9 @@ public class OtaDexoptService extends IOtaDexopt.Stub { OtaDexoptService ota = new OtaDexoptService(context, packageManagerService); ServiceManager.addService("otadexopt", ota); + // Now it's time to check whether we need to move any A/B artifacts. + ota.moveAbArtifacts(packageManagerService.mInstaller); + return ota; } @@ -323,8 +323,15 @@ public class OtaDexoptService extends IOtaDexopt.Stub { throw new IllegalStateException("Should not be ota-dexopting when trying to move."); } + if (!mPackageManagerService.isUpgrade()) { + Slog.d(TAG, "No upgrade, skipping A/B artifacts check."); + return; + } + // Look into all packages. Collection pkgs = mPackageManagerService.getPackages(); + int packagePaths = 0; + int pathsSuccessful = 0; for (PackageParser.Package pkg : pkgs) { if (pkg == null) { continue; @@ -355,13 +362,16 @@ public class OtaDexoptService extends IOtaDexopt.Stub { // TODO: Check first whether there is an artifact, to save the roundtrip time. + packagePaths++; try { installer.moveAb(path, dexCodeInstructionSet, oatDir); + pathsSuccessful++; } catch (InstallerException e) { } } } } + Slog.i(TAG, "Moved " + pathsSuccessful + "/" + packagePaths); } /**