Listen for cases where touch controllers change, and update them

Otherwise we'd be stuck using the old touch controllers until DragLayer
is setup again (e.g. launcher is killed).

Bug: 77921826
Change-Id: I8aac6fc453839902cb2d99279a6bd1549ee17d79
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 90c55c9..8840860 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -18,7 +18,6 @@
 
 import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION;
 import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE;
-
 import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
 import static com.android.launcher3.LauncherState.ALL_APPS;
 import static com.android.launcher3.LauncherState.NORMAL;
@@ -81,7 +80,6 @@
 import com.android.launcher3.dragndrop.DragController;
 import com.android.launcher3.dragndrop.DragLayer;
 import com.android.launcher3.dragndrop.DragView;
-import com.android.launcher3.dynamicui.WallpaperColorInfo;
 import com.android.launcher3.folder.FolderIcon;
 import com.android.launcher3.folder.FolderIconPreviewVerifier;
 import com.android.launcher3.keyboard.CustomActionsPopup;
@@ -923,7 +921,9 @@
                 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
 
         // Setup the drag layer
-        mDragLayer.setup(mDragController);
+        Runnable setupDragLayer = () -> mDragLayer.setup(mDragController);
+        UiFactory.setOnTouchControllersChangedListener(this, setupDragLayer);
+        setupDragLayer.run();
 
         mWorkspace.setup(mDragController);
         // Until the workspace is bound, ensure that we keep the wallpaper offset locked to the
@@ -1327,6 +1327,8 @@
         unregisterReceiver(mReceiver);
         mWorkspace.removeFolderListeners();
 
+        UiFactory.setOnTouchControllersChangedListener(this, null);
+
         // Stop callbacks from LauncherModel
         // It's possible to receive onDestroy after a new Launcher activity has
         // been created. In this case, don't interfere with the new Launcher.