From 5a4e8283e926e5844a8d9283e9af2a8048aa5d1a Mon Sep 17 00:00:00 2001 From: Songchun Fan Date: Wed, 28 Jul 2021 12:08:39 -0700 Subject: [PATCH] [pm] ignore partial progress update after off-incfs migration When we migrate a partially loaded app off incremental, the incomplete progress could still be reported by incfs, right before the incfs instance is deleted. This partial progress could override the full progress reported by the update installation. And after the incfs instance is deleted, there will be no more progress update. As a result, the launcher gets the last progress update as a partial progress, and the progress loading icon remain partially loaded until reboot. This CL fixes the problem by rejecting partial progress reported from incfs after the progress has already been changed to 100%. In reality it could only happen during off-incfs migration. It also applies in general as the progress number should never go from 100% to below 100%. BUG: 187762951 Test: manual Change-Id: I3b87226a4e75d71f0d8e4886917e4456b355e1fa --- .../java/com/android/server/pm/IncrementalStates.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/pm/IncrementalStates.java b/services/core/java/com/android/server/pm/IncrementalStates.java index 7627281d21887..3101ca7f9f6bc 100644 --- a/services/core/java/com/android/server/pm/IncrementalStates.java +++ b/services/core/java/com/android/server/pm/IncrementalStates.java @@ -118,12 +118,19 @@ public final class IncrementalStates { * @param progress Value between [0, 1]. */ public void setProgress(float progress) { + final boolean oldLoadingState; final boolean newLoadingState; synchronized (mLock) { - updateProgressLocked(progress); + oldLoadingState = mLoadingState.isLoading(); + if (oldLoadingState) { + // Due to asynchronous progress reporting, incomplete progress might be received + // after the app is migrated off incremental. Ignore such progress updates. + updateProgressLocked(progress); + } newLoadingState = mLoadingState.isLoading(); } - if (!newLoadingState) { + if (oldLoadingState && !newLoadingState) { + // Only report the state change when loading state changes from true to false onLoadingStateChanged(); } }