OSDN Git Service

Avoid stripping empty screens if the workspace is still loading (issue 12523285)
authorAdam Cohen <adamcohen@google.com>
Sat, 1 Mar 2014 20:12:59 +0000 (12:12 -0800)
committerAdam Cohen <adamcohen@google.com>
Sat, 1 Mar 2014 20:17:44 +0000 (12:17 -0800)
-> This appears to be what may be causing data loss in some users during update.
   A certain (seemingly) rare combination of life-cycle events and package events
   seems to be the culprit (potentially why it's seen at update time).

Change-Id: Iea4f8aef012ba80b7ba568e0df264edb9284efbe

src/com/android/launcher3/Launcher.java
src/com/android/launcher3/Workspace.java

index c87f9e2..7944173 100644 (file)
@@ -2078,6 +2078,10 @@ public class Launcher extends Activity
         return mWorkspaceLoading || mWaitingForResult;
     }
 
+    public boolean isWorkspaceLoading() {
+        return mWorkspaceLoading;
+    }
+
     private void resetAddInfo() {
         mPendingAddInfo.container = ItemInfo.NO_ID;
         mPendingAddInfo.screenId = -1;
@@ -3771,6 +3775,8 @@ public class Launcher extends Activity
      * Implementation of the method from LauncherModel.Callbacks.
      */
     public void startBinding() {
+        mWorkspaceLoading = true;
+
         // If we're starting binding all over again, clear any bind calls we'd postponed in
         // the past (see waitUntilResume) -- we don't need them since we're starting binding
         // from scratch again
index 50d29ed..7e01232 100644 (file)
@@ -863,6 +863,12 @@ public class Workspace extends SmoothPagedView
         // Log to disk
         Launcher.addDumpLog(TAG, "11683562 - stripEmptyScreens()", true);
 
+        if (isWorkspaceLoading()) {
+            // Don't strip empty screens if the workspace is still loading
+            Launcher.addDumpLog(TAG, "    - workspace loading, skip", true);
+            return;
+        }
+
         if (isPageMoving()) {
             mStripScreensOnPageStopMoving = true;
             return;