Merge "Adding additional logs to debug synchronous modification of update listeners" into ub-launcher3-master
diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java
index c4b2f68..a6ef10a 100644
--- a/src/com/android/launcher3/allapps/AllAppsStore.java
+++ b/src/com/android/launcher3/allapps/AllAppsStore.java
@@ -18,6 +18,7 @@
 import static com.android.launcher3.AppInfo.COMPONENT_KEY_COMPARATOR;
 import static com.android.launcher3.AppInfo.EMPTY_ARRAY;
 
+import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
 
@@ -55,6 +56,8 @@
     private int mDeferUpdatesFlags = 0;
     private boolean mUpdatePending = false;
 
+    private boolean mListenerUpdateInProgress = false;
+
     public AppInfo[] getApps() {
         return mApps;
     }
@@ -99,10 +102,12 @@
             mUpdatePending = true;
             return;
         }
+        mListenerUpdateInProgress = true;
         int count = mUpdateListeners.size();
         for (int i = 0; i < count; i++) {
             mUpdateListeners.get(i).onAppsUpdated();
         }
+        mListenerUpdateInProgress = false;
     }
 
     public void addUpdateListener(OnUpdateListener listener) {
@@ -110,6 +115,9 @@
     }
 
     public void removeUpdateListener(OnUpdateListener listener) {
+        if (mListenerUpdateInProgress) {
+            Log.e("AllAppsStore", "Trying to remove listener during update", new Exception());
+        }
         mUpdateListeners.remove(listener);
     }