[pm/incremental] schedule write when loading progress is complete

We don't have an automatic write back in PackageSetting today.
Manually schedule a write when the loading of a package is complete.

Register the progress listener on reboot if a package has not finished
loading before reboot. This will reset the loading progress in the
package setting.

BUG: 181351007
Test: manual and cts test (coming up soon)
Change-Id: Ifea8e1866ce2211025efc20e1da51fff8f57b2aa
This commit is contained in:
Songchun Fan
2021-02-26 20:35:03 +00:00
parent 9a2ae3ed4c
commit 4bfc84a18b

View File

@@ -11634,9 +11634,17 @@ public class PackageManagerService extends IPackageManager.Stub
healthCheckParams.unhealthyTimeoutMs = INCREMENTAL_STORAGE_UNHEALTHY_TIMEOUT_MS;
healthCheckParams.unhealthyMonitoringMs =
INCREMENTAL_STORAGE_UNHEALTHY_MONITORING_MS;
// Continue monitoring health and loading progress of active incremental packages
mIncrementalManager.registerHealthListener(parsedPackage.getPath(),
healthCheckParams,
new IncrementalHealthListener(parsedPackage.getPackageName()));
final IncrementalStatesCallback incrementalStatesCallback =
new IncrementalStatesCallback(parsedPackage.getPackageName(),
UserHandle.getUid(UserHandle.ALL, pkgSetting.appId),
getInstalledUsers(pkgSetting, UserHandle.USER_ALL));
pkgSetting.setIncrementalStatesCallback(incrementalStatesCallback);
mIncrementalManager.registerLoadingProgressCallback(parsedPackage.getPath(),
new IncrementalProgressListener(parsedPackage.getPackageName()));
}
}
return scanResult.pkgSetting.pkg;
@@ -19420,6 +19428,8 @@ public class PackageManagerService extends IPackageManager.Stub
mIncrementalManager.unregisterLoadingProgressCallbacks(codePath);
// Unregister health listener as it will always be healthy from now
mIncrementalManager.unregisterHealthListener(codePath);
// Make sure the information is preserved
scheduleWriteSettingsLocked();
}
@Override
@@ -19482,11 +19492,11 @@ public class PackageManagerService extends IPackageManager.Stub
final PackageSetting ps;
synchronized (mLock) {
ps = mSettings.getPackageLPr(mPackageName);
if (ps == null) {
return;
}
ps.setLoadingProgress(progress);
}
if (ps == null) {
return;
}
ps.setLoadingProgress(progress);
}
}