Synchronizing loader preload to avoid launcher getting stuck in loading state,

which could be caused by the following sequence of events

  1) Starts preload => execution moved to background thread
     a) check if loader is running
     ... execution moved to ui thread

  2) Launcher starts
  3) Cancels any running loader and starts a new loader
     .... Execution on background thread
    b) Cancels any running loader and starts a new loader

Synchronizing (3), and [a, b] under same lock would avoid this case
Bug: 73399920

Change-Id: I6b01f797fd6f4a2e5b3c078bb374ad40fcc311c8
This commit is contained in:
Sunny Goyal
2018-02-15 10:27:42 -08:00
parent c36d6eefae
commit a1b4911e26
2 changed files with 11 additions and 5 deletions

View File

@@ -49,11 +49,8 @@ public class ModelPreload implements ModelUpdateTask {
@Override
public final void run() {
if (!mModel.isModelLoaded()) {
Log.d(TAG, "Workspace not loaded, loading now");
mModel.startLoaderForResults(
new LoaderResults(mApp, mBgDataModel, mAllAppsList, 0, null));
}
mModel.startLoaderForResultsIfNotLoaded(
new LoaderResults(mApp, mBgDataModel, mAllAppsList, 0, null));
Log.d(TAG, "Preload completed : " + mModel.isModelLoaded());
onComplete(mModel.isModelLoaded());
}