Don't specify 1P Launcher3 type if 3P Launcher is active

Instead of referencing Launcher directly (which may not be
present when there's a 3P launcher), reference the lowest
common ancestor of Launcher and RecentActivity to avoid
ClassCastExceptions.

Test: Visually inspected that Pixel Launcher crash dialog
no longer pops up.
* Install 3P launcher
* In developer options enable "enable freeform windows"
* Restart phone for settings to take effect
* Try to use it on any app you have in recent tasks

Fixes: 135419782
Change-Id: Ie1f54880ab46956b23e253850ca7f79b161da9bd
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index 1cdb18c..8de0069 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -120,6 +120,10 @@
 
     public abstract View getRootView();
 
+    public void returnToHomescreen() {
+        // no-op
+    }
+
     public Rect getViewBounds(View v) {
         int[] pos = new int[2];
         v.getLocationOnScreen(pos);
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index b864111..40d7668 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2568,6 +2568,12 @@
         return (Launcher) fromContext(context);
     }
 
+    @Override
+    public void returnToHomescreen() {
+        super.returnToHomescreen();
+        getStateManager().goToState(LauncherState.NORMAL);
+    }
+
     /**
      * Just a wrapper around the type cast to allow easier tracking of calls.
      */