Merge "[pm/incremental] restore package loading progress on reboot" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-01-28 01:28:04 +00:00
committed by Android (Google) Code Review
2 changed files with 17 additions and 6 deletions

View File

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

View File

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