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

Commit 4bfc84a1 authored by Songchun Fan's avatar Songchun Fan
Browse files

[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
parent 9a2ae3ed
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -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,13 +19492,13 @@ public class PackageManagerService extends IPackageManager.Stub
            final PackageSetting ps;
            synchronized (mLock) {
                ps = mSettings.getPackageLPr(mPackageName);
            }
                if (ps == null) {
                    return;
                }
                ps.setLoadingProgress(progress);
            }
        }
    }
    /**
     * Incremental storage health status callback, used to listen for monitoring changes and update