[pm/incremental] restore package loading progress on reboot

Also add loading progress in package dumpsys. Example:

$ adb shell dumpsys package
Package [com.supercell.clashroyale] (69009ab):
...
timeStamp=2021-01-27 13:16:01
firstInstallTime=2021-01-27 13:14:00
lastUpdateTime=2021-01-27 13:14:00
installerPackageName=com.android.vending
loadingProgress=57% <--- new
...

BUG: 178532628
BUG: 178528867
Test: manual with Clash Royale nugget installs
Change-Id: Ieedc92eee30de4c47d74a32018b8c92990c05328
This commit is contained in:
Songchun Fan
2021-01-27 13:29:23 -08:00
parent e7ce67f421
commit fbb21698e3
2 changed files with 17 additions and 6 deletions

View File

@@ -61,12 +61,12 @@ public final class IncrementalStates {
public IncrementalStates() {
// By default the package is not startable and not fully loaded (i.e., is loading)
this(false, true);
this(false, true, 0);
}
public IncrementalStates(boolean isStartable, boolean isLoading) {
public IncrementalStates(boolean isStartable, boolean isLoading, float loadingProgress) {
mStartableState = new StartableState(isStartable);
mLoadingState = new LoadingState(isLoading);
mLoadingState = new LoadingState(isLoading, loadingProgress);
mStatusConsumer = new StatusConsumer();
}
@@ -405,9 +405,10 @@ public final class IncrementalStates {
private boolean mIsLoading;
private float mProgress;
LoadingState(boolean isLoading) {
LoadingState(boolean isLoading, float loadingProgress) {
mIsLoading = isLoading;
mProgress = isLoading ? 0 : 1;
// loading progress is reset to 1 if loading has finished
mProgress = isLoading ? loadingProgress : 1;
}
public boolean isLoading() {

View File

@@ -73,6 +73,7 @@ import android.os.SystemClock;
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.incremental.IncrementalManager;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
import android.service.pm.PackageServiceDumpProto;
@@ -2957,6 +2958,8 @@ public final class Settings implements Watchable, Snappable {
if (pkg.isPackageLoading()) {
serializer.attributeBoolean(null, "isLoading", true);
}
serializer.attributeFloat(null, "loadingProgress",
pkg.getIncrementalStates().getProgress());
writeUsesStaticLibLPw(serializer, pkg.usesStaticLibraries, pkg.usesStaticLibrariesVersions);
@@ -3699,6 +3702,7 @@ public final class Settings implements Watchable, Snappable {
boolean installedForceQueryable = false;
boolean isStartable = false;
boolean isLoading = false;
float loadingProgress = 0;
try {
name = parser.getAttributeValue(null, ATTR_NAME);
realName = parser.getAttributeValue(null, "realName");
@@ -3717,6 +3721,7 @@ public final class Settings implements Watchable, Snappable {
installedForceQueryable = parser.getAttributeBoolean(null, "forceQueryable", false);
isStartable = parser.getAttributeBoolean(null, "isStartable", false);
isLoading = parser.getAttributeBoolean(null, "isLoading", false);
loadingProgress = parser.getAttributeFloat(null, "loadingProgress", 0);
if (primaryCpuAbiString == null && legacyCpuAbiString != null) {
primaryCpuAbiString = legacyCpuAbiString;
@@ -3864,7 +3869,8 @@ public final class Settings implements Watchable, Snappable {
packageSetting.secondaryCpuAbiString = secondaryCpuAbiString;
packageSetting.updateAvailable = updateAvailable;
packageSetting.forceQueryableOverride = installedForceQueryable;
packageSetting.incrementalStates = new IncrementalStates(isStartable, isLoading);
packageSetting.incrementalStates = new IncrementalStates(isStartable, isLoading,
loadingProgress);
// Handle legacy string here for single-user mode
final String enabledStr = parser.getAttributeValue(null, ATTR_ENABLED);
if (enabledStr != null) {
@@ -4814,6 +4820,10 @@ public final class Settings implements Watchable, Snappable {
pw.print(prefix); pw.print(" installerAttributionTag=");
pw.println(ps.installSource.installerAttributionTag);
}
if (IncrementalManager.isIncrementalPath(ps.getPathString())) {
pw.print(prefix); pw.println(" loadingProgress="
+ (int) (ps.getIncrementalStates().getProgress() * 100) + "%");
}
if (ps.volumeUuid != null) {
pw.print(prefix); pw.print(" volumeUuid=");
pw.println(ps.volumeUuid);