Call bindDeepShortcuts() from runBindSynchronousPage().

Otherwise Launcher's copy of the deep shortcut map is cleared when Launcher
is re-created, such as on rotation, so the UI won't show shortcuts.

Change-Id: I3bb6a904762dc4661cc2b5da28485e4bf778c9e7
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 3e66654..3e98c13 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -236,7 +236,7 @@
 
     /** Runs the specified runnable immediately if called from the main thread, otherwise it is
      * posted on the main thread handler. */
-    @Thunk void runOnMainThread(Runnable r) {
+    private void runOnMainThread(Runnable r) {
         if (sWorkerThread.getThreadId() == Process.myTid()) {
             // If we are on the worker thread, post onto the main handler
             mHandler.post(r);
@@ -247,7 +247,7 @@
 
     /** Runs the specified runnable immediately if called from the worker thread, otherwise it is
      * posted on the worker thread handler. */
-    @Thunk static void runOnWorkerThread(Runnable r) {
+    private static void runOnWorkerThread(Runnable r) {
         if (sWorkerThread.getThreadId() == Process.myTid()) {
             r.run();
         } else {
@@ -1298,8 +1298,8 @@
                 // If there is already one running, tell it to stop.
                 stopLoaderLocked();
                 mLoaderTask = new LoaderTask(mApp.getContext(), synchronousBindPage);
-                if (synchronousBindPage != PagedView.INVALID_RESTORE_PAGE
-                        && mAllAppsLoaded && mWorkspaceLoaded && !mIsLoaderTaskRunning) {
+                if (synchronousBindPage != PagedView.INVALID_RESTORE_PAGE && mAllAppsLoaded
+                        && mWorkspaceLoaded && mDeepShortcutsLoaded && !mIsLoaderTaskRunning) {
                     mLoaderTask.runBindSynchronousPage(synchronousBindPage);
                 } else {
                     sWorkerThread.setPriority(Thread.NORM_PRIORITY);
@@ -1441,6 +1441,8 @@
             // XXX: For now, continue posting the binding of AllApps as there are other issues that
             //      arise from that.
             onlyBindAllApps();
+
+            bindDeepShortcuts();
         }
 
         public void run() {
@@ -2660,12 +2662,7 @@
                     }
                 }
             };
-            boolean isRunningOnMainThread = !(sWorkerThread.getThreadId() == Process.myTid());
-            if (isRunningOnMainThread) {
-                r.run();
-            } else {
-                mHandler.post(r);
-            }
+            runOnMainThread(r);
         }
 
         private void loadAllApps() {
@@ -2777,7 +2774,7 @@
                     mDeepShortcutsLoaded = true;
                 }
             }
-            bindDeepShortcutMapOnMainThread();
+            bindDeepShortcuts();
         }
 
         public void dumpState() {
@@ -2810,10 +2807,10 @@
         }
     }
 
-    private void bindDeepShortcutMapOnMainThread() {
+    public void bindDeepShortcuts() {
         final MultiHashMap<ComponentKey, String> shortcutMapCopy = new MultiHashMap<>();
         shortcutMapCopy.putAll(mBgDeepShortcutMap);
-        mHandler.post(new Runnable() {
+        Runnable r = new Runnable() {
             @Override
             public void run() {
                 Callbacks callbacks = getCallback();
@@ -2821,7 +2818,8 @@
                     callbacks.bindDeepShortcutMap(shortcutMapCopy);
                 }
             }
-        });
+        };
+        runOnMainThread(r);
     }
 
     /**
@@ -3322,7 +3320,7 @@
 
             // Update the deep shortcut map, in case the list of ids has changed for an activity.
             updateDeepShortcutMap(mPackageName, mShortcuts);
-            bindDeepShortcutMapOnMainThread();
+            bindDeepShortcuts();
         }
     }