Move Pip codes from SysUI to WMShell lib (9/N)

Bug: 161118569

Test: make SystemUI
Test: make ArcSystemUI
Test: make WMShellUnitTests
Test: lunch cf_x86_tv-userdebug & make
Test: atest CtsSystemUiTestCases:BasicPipTests
Test: atest CtsSystemUiTestCases:CustomPipActionsTests
Test: atest CtsSystemUiTestCases:FlickerPipTests
Test: atest CtsSystemUiTestCases:PipNotificationTests
Test: atest SystemUITests
Test: atest WMShellUnitTests
Test: manual test PIP demo AP
Test: manual test TV PIP function
Test: manual test disabled PIP
Test: adb shell input keyevent 171(KEYCODE_WINDOW)
Test: adb shell am start -n android.systemui.cts.tv.pip/.PipTestActivity
    -a android.systemui.cts.tv.pip.PipTestActivity.enter_pip
Test: adb root;adb shell am start \
    -n com.android.systemui/com.android.wm.shell.pip.tv.PipMenuActivity
Test: adb shell dumpsys activity service com.android.systemui
Change-Id: I0ec0e9b9bfc4795a10483acd225f14bde9c72407
diff --git a/libs/WindowManager/Shell/Android.bp b/libs/WindowManager/Shell/Android.bp
index 1591b06..0defbd6 100644
--- a/libs/WindowManager/Shell/Android.bp
+++ b/libs/WindowManager/Shell/Android.bp
@@ -23,7 +23,18 @@
 
 filegroup {
     name: "wm_shell-sources",
-    srcs: ["src/**/*.java"],
+    srcs: [
+        "src/**/*.java",
+    ],
+    path: "src",
+}
+
+// TODO(b/168581922) protologtool do not support kotlin(*.kt)
+filegroup {
+    name: "wm_shell-sources-kt",
+    srcs: [
+        "src/**/*.kt",
+    ],
     path: "src",
 }
 
@@ -97,15 +108,23 @@
     name: "WindowManager-Shell",
     srcs: [
         ":wm_shell_protolog_src",
+        // TODO(b/168581922) protologtool do not support kotlin(*.kt)
+        ":wm_shell-sources-kt",
         "src/**/I*.aidl",
     ],
     resource_dirs: [
         "res",
     ],
     static_libs: [
+        "androidx.dynamicanimation_dynamicanimation",
+        "kotlinx-coroutines-android",
+        "kotlinx-coroutines-core",
         "protolog-lib",
         "WindowManager-Shell-proto",
         "androidx.appcompat_appcompat",
     ],
+    kotlincflags: ["-Xjvm-default=enable"],
     manifest: "AndroidManifest.xml",
+
+    min_sdk_version: "26",
 }
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/dismiss_circle_background.xml b/libs/WindowManager/Shell/res/drawable/dismiss_circle_background.xml
similarity index 100%
rename from packages/SystemUI/res/drawable/dismiss_circle_background.xml
rename to libs/WindowManager/Shell/res/drawable/dismiss_circle_background.xml
diff --git a/packages/SystemUI/res/drawable/ic_skip_next_white.xml b/libs/WindowManager/Shell/res/drawable/pip_ic_skip_next_white.xml
similarity index 100%
rename from packages/SystemUI/res/drawable/ic_skip_next_white.xml
rename to libs/WindowManager/Shell/res/drawable/pip_ic_skip_next_white.xml
diff --git a/packages/SystemUI/res/drawable/ic_skip_previous_white.xml b/libs/WindowManager/Shell/res/drawable/pip_ic_skip_previous_white.xml
similarity index 100%
rename from packages/SystemUI/res/drawable/ic_skip_previous_white.xml
rename to libs/WindowManager/Shell/res/drawable/pip_ic_skip_previous_white.xml
diff --git a/libs/WindowManager/Shell/res/layout/tv_pip_control_button.xml b/libs/WindowManager/Shell/res/layout/tv_pip_control_button.xml
index 72287c1..727ac34 100644
--- a/libs/WindowManager/Shell/res/layout/tv_pip_control_button.xml
+++ b/libs/WindowManager/Shell/res/layout/tv_pip_control_button.xml
@@ -14,7 +14,7 @@
     See the License for the specific language governing permissions and
     limitations under the License.
 -->
-<!-- Layout for {@link com.android.systemui.pip.tv.PipControlButtonView}. -->
+<!-- Layout for {@link com.android.wm.shell.pip.tv.PipControlButtonView}. -->
 <merge xmlns:android="http://schemas.android.com/apk/res/android">
 
     <ImageView android:id="@+id/button"
diff --git a/libs/WindowManager/Shell/res/layout/tv_pip_controls.xml b/libs/WindowManager/Shell/res/layout/tv_pip_controls.xml
index 22e0452..d2f235e 100644
--- a/libs/WindowManager/Shell/res/layout/tv_pip_controls.xml
+++ b/libs/WindowManager/Shell/res/layout/tv_pip_controls.xml
@@ -14,17 +14,17 @@
     See the License for the specific language governing permissions and
     limitations under the License.
 -->
-<!-- Layout for {@link com.android.systemui.pip.tv.PipControlsView}. -->
+<!-- Layout for {@link com.android.wm.shell.pip.tv.PipControlsView}. -->
 <merge xmlns:android="http://schemas.android.com/apk/res/android">
 
-    <com.android.systemui.pip.tv.PipControlButtonView
+    <com.android.wm.shell.pip.tv.PipControlButtonView
         android:id="@+id/full_button"
         android:layout_width="@dimen/picture_in_picture_button_width"
         android:layout_height="wrap_content"
         android:src="@drawable/pip_ic_fullscreen_white"
         android:text="@string/pip_fullscreen" />
 
-    <com.android.systemui.pip.tv.PipControlButtonView
+    <com.android.wm.shell.pip.tv.PipControlButtonView
         android:id="@+id/close_button"
         android:layout_width="@dimen/picture_in_picture_button_width"
         android:layout_height="wrap_content"
@@ -32,7 +32,7 @@
         android:src="@drawable/pip_ic_close_white"
         android:text="@string/pip_close" />
 
-    <com.android.systemui.pip.tv.PipControlButtonView
+    <com.android.wm.shell.pip.tv.PipControlButtonView
         android:id="@+id/play_pause_button"
         android:layout_width="@dimen/picture_in_picture_button_width"
         android:layout_height="wrap_content"
diff --git a/libs/WindowManager/Shell/res/layout/tv_pip_custom_control.xml b/libs/WindowManager/Shell/res/layout/tv_pip_custom_control.xml
index e6cd112..452f2cd 100644
--- a/libs/WindowManager/Shell/res/layout/tv_pip_custom_control.xml
+++ b/libs/WindowManager/Shell/res/layout/tv_pip_custom_control.xml
@@ -14,7 +14,7 @@
     See the License for the specific language governing permissions and
     limitations under the License.
 -->
-<com.android.systemui.pip.tv.PipControlButtonView
+<com.android.wm.shell.pip.tv.PipControlButtonView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="@dimen/picture_in_picture_button_width"
     android:layout_height="wrap_content"
diff --git a/libs/WindowManager/Shell/res/layout/tv_pip_menu.xml b/libs/WindowManager/Shell/res/layout/tv_pip_menu.xml
index a049787..d8474b8 100644
--- a/libs/WindowManager/Shell/res/layout/tv_pip_menu.xml
+++ b/libs/WindowManager/Shell/res/layout/tv_pip_menu.xml
@@ -15,15 +15,15 @@
     limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:orientation="horizontal"
-    android:paddingTop="350dp"
-    android:background="#CC000000"
-    android:gravity="top|center_horizontal"
-    android:clipChildren="false">
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:orientation="horizontal"
+              android:paddingTop="350dp"
+              android:background="#CC000000"
+              android:gravity="top|center_horizontal"
+              android:clipChildren="false">
 
-    <com.android.systemui.pip.tv.PipControlsView
+    <com.android.wm.shell.pip.tv.PipControlsView
         android:id="@+id/pip_controls"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
diff --git a/libs/WindowManager/Shell/res/values/config.xml b/libs/WindowManager/Shell/res/values/config.xml
index 63b0f6f..e99350b 100644
--- a/libs/WindowManager/Shell/res/values/config.xml
+++ b/libs/WindowManager/Shell/res/values/config.xml
@@ -32,4 +32,8 @@
 
     <!-- Allow one handed to enable round corner -->
     <bool name="config_one_handed_enable_round_corner">true</bool>
+
+    <!-- Bounds [left top right bottom] on screen for picture-in-picture (PIP) windows,
+     when the PIP menu is shown in center. -->
+    <string translatable="false" name="pip_menu_bounds">"596 280 1324 690"</string>
 </resources>
diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml
index 7fb641a..a9917a6 100644
--- a/libs/WindowManager/Shell/res/values/dimen.xml
+++ b/libs/WindowManager/Shell/res/values/dimen.xml
@@ -57,6 +57,9 @@
     <dimen name="pip_resize_handle_margin">4dp</dimen>
     <dimen name="pip_resize_handle_padding">0dp</dimen>
 
+    <dimen name="dismiss_target_x_size">24dp</dimen>
+    <dimen name="floating_dismiss_bottom_margin">50dp</dimen>
+
     <!-- How high we lift the divider when touching -->
     <dimen name="docked_stack_divider_lift_elevation">4dp</dimen>
 
diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/WindowManagerShellWrapper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/WindowManagerShellWrapper.java
similarity index 94%
rename from packages/SystemUI/src/com/android/systemui/wmshell/WindowManagerShellWrapper.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/WindowManagerShellWrapper.java
index 178d472..acb9a5da 100644
--- a/packages/SystemUI/src/com/android/systemui/wmshell/WindowManagerShellWrapper.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/WindowManagerShellWrapper.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.wmshell;
+package com.android.wm.shell;
 
 import static android.view.Display.DEFAULT_DISPLAY;
 
@@ -22,7 +22,7 @@
 import android.os.RemoteException;
 import android.view.WindowManagerGlobal;
 
-import com.android.systemui.shared.system.PinnedStackListenerForwarder;
+import com.android.wm.shell.pip.PinnedStackListenerForwarder;
 
 /**
  * The singleton wrapper to communicate between WindowManagerService and WMShell features
diff --git a/packages/SystemUI/src/com/android/systemui/util/animation/FloatProperties.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/animation/FloatProperties.kt
similarity index 98%
rename from packages/SystemUI/src/com/android/systemui/util/animation/FloatProperties.kt
rename to libs/WindowManager/Shell/src/com/android/wm/shell/animation/FloatProperties.kt
index a284a74..d4f8282 100644
--- a/packages/SystemUI/src/com/android/systemui/util/animation/FloatProperties.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/animation/FloatProperties.kt
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.util.animation
+package com.android.wm.shell.animation
 
 import android.graphics.Rect
 import android.graphics.RectF
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/animation/Interpolators.java b/libs/WindowManager/Shell/src/com/android/wm/shell/animation/Interpolators.java
index b794b91..416ada7 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/animation/Interpolators.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/animation/Interpolators.java
@@ -24,6 +24,16 @@
  */
 public class Interpolators {
     /**
+     * Interpolator for alpha in animation.
+     */
+    public static final Interpolator ALPHA_IN = new PathInterpolator(0.4f, 0f, 1f, 1f);
+
+    /**
+     * Interpolator for alpha out animation.
+     */
+    public static final Interpolator ALPHA_OUT = new PathInterpolator(0f, 0f, 0.8f, 1f);
+
+    /**
      * Interpolator for fast out linear in animation.
      */
     public static final Interpolator FAST_OUT_LINEAR_IN = new PathInterpolator(0.4f, 0f, 1f, 1f);
diff --git a/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimator.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/animation/PhysicsAnimator.kt
similarity index 99%
rename from packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimator.kt
rename to libs/WindowManager/Shell/src/com/android/wm/shell/animation/PhysicsAnimator.kt
index 2a5424c..5cd660a 100644
--- a/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimator.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/animation/PhysicsAnimator.kt
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.util.animation
+package com.android.wm.shell.animation
 
 import android.os.Looper
 import android.util.ArrayMap
@@ -26,7 +26,7 @@
 import androidx.dynamicanimation.animation.FloatPropertyCompat
 import androidx.dynamicanimation.animation.SpringAnimation
 import androidx.dynamicanimation.animation.SpringForce
-import com.android.systemui.util.animation.PhysicsAnimator.Companion.getInstance
+import com.android.wm.shell.animation.PhysicsAnimator.Companion.getInstance
 import java.lang.ref.WeakReference
 import java.util.WeakHashMap
 import kotlin.math.abs
diff --git a/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimatorTestUtils.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/animation/PhysicsAnimatorTestUtils.kt
similarity index 96%
rename from packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimatorTestUtils.kt
rename to libs/WindowManager/Shell/src/com/android/wm/shell/animation/PhysicsAnimatorTestUtils.kt
index c50eeac..86eb8da 100644
--- a/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimatorTestUtils.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/animation/PhysicsAnimatorTestUtils.kt
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,16 +13,28 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.systemui.util.animation
+package com.android.wm.shell.animation
 
 import android.os.Handler
 import android.os.Looper
 import android.util.ArrayMap
 import androidx.dynamicanimation.animation.FloatPropertyCompat
-import com.android.systemui.util.animation.PhysicsAnimatorTestUtils.prepareForTest
-import java.util.ArrayDeque
+import com.android.wm.shell.animation.PhysicsAnimatorTestUtils.prepareForTest
+import java.util.*
 import java.util.concurrent.CountDownLatch
 import java.util.concurrent.TimeUnit
+import kotlin.collections.ArrayList
+import kotlin.collections.HashMap
+import kotlin.collections.HashSet
+import kotlin.collections.Set
+import kotlin.collections.component1
+import kotlin.collections.component2
+import kotlin.collections.drop
+import kotlin.collections.forEach
+import kotlin.collections.getOrPut
+import kotlin.collections.set
+import kotlin.collections.toList
+import kotlin.collections.toTypedArray
 
 typealias UpdateMatcher = (PhysicsAnimator.AnimationUpdate) -> Boolean
 typealias UpdateFramesPerProperty<T> =
@@ -84,7 +96,7 @@
      */
     @JvmStatic
     fun setBlockTimeout(timeoutMs: Long) {
-        this.timeoutMs = timeoutMs
+        PhysicsAnimatorTestUtils.timeoutMs = timeoutMs
     }
 
     /**
diff --git a/packages/SystemUI/src/com/android/systemui/util/DismissCircleView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DismissCircleView.java
similarity index 96%
rename from packages/SystemUI/src/com/android/systemui/util/DismissCircleView.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/common/DismissCircleView.java
index 8946c97a..976fba5 100644
--- a/packages/SystemUI/src/com/android/systemui/util/DismissCircleView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DismissCircleView.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.util;
+package com.android.wm.shell.common;
 
 import android.content.Context;
 import android.content.res.Configuration;
@@ -23,7 +23,7 @@
 import android.widget.FrameLayout;
 import android.widget.ImageView;
 
-import com.android.systemui.R;
+import com.android.wm.shell.R;
 
 /**
  * Circular view with a semitransparent, circular background with an 'X' inside it.
diff --git a/packages/SystemUI/src/com/android/systemui/util/FloatingContentCoordinator.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/common/FloatingContentCoordinator.kt
similarity index 92%
rename from packages/SystemUI/src/com/android/systemui/util/FloatingContentCoordinator.kt
rename to libs/WindowManager/Shell/src/com/android/wm/shell/common/FloatingContentCoordinator.kt
index bcfb2af..d5d072a 100644
--- a/packages/SystemUI/src/com/android/systemui/util/FloatingContentCoordinator.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/FloatingContentCoordinator.kt
@@ -1,9 +1,24 @@
-package com.android.systemui.util
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.wm.shell.common
 
 import android.graphics.Rect
 import android.util.Log
-import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.util.FloatingContentCoordinator.FloatingContent
+import com.android.wm.shell.common.FloatingContentCoordinator.FloatingContent
 import java.util.HashMap
 
 /** Tag for debug logging. */
@@ -20,7 +35,6 @@
  * no longer visible.
  */
 
-@SysUISingleton
 class FloatingContentCoordinator constructor() {
     /**
      * Represents a piece of floating content, such as PIP or the Bubbles stack. Provides methods
@@ -260,14 +274,18 @@
 
             // Lazily calculate the closest possible new tops for the content, above and below its
             // current location.
-            val newContentBoundsAbove by lazy { findAreaForContentAboveOrBelow(
-                    contentRect,
-                    exclusionRects = rectsToAvoidAbove.plus(newlyOverlappingRect),
-                    findAbove = true) }
-            val newContentBoundsBelow by lazy { findAreaForContentAboveOrBelow(
-                    contentRect,
-                    exclusionRects = rectsToAvoidBelow.plus(newlyOverlappingRect),
-                    findAbove = false) }
+            val newContentBoundsAbove by lazy {
+                findAreaForContentAboveOrBelow(
+                        contentRect,
+                        exclusionRects = rectsToAvoidAbove.plus(newlyOverlappingRect),
+                        findAbove = true)
+            }
+            val newContentBoundsBelow by lazy {
+                findAreaForContentAboveOrBelow(
+                        contentRect,
+                        exclusionRects = rectsToAvoidBelow.plus(newlyOverlappingRect),
+                        findAbove = false)
+            }
 
             val positionAboveInBounds by lazy { allowedBounds.contains(newContentBoundsAbove) }
             val positionBelowInBounds by lazy { allowedBounds.contains(newContentBoundsBelow) }
@@ -347,4 +365,4 @@
                     (r1.right <= r2.right && r1.right >= r2.left)
         }
     }
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/src/com/android/systemui/util/magnetictarget/MagnetizedObject.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/common/magnetictarget/MagnetizedObject.kt
similarity index 99%
rename from packages/SystemUI/src/com/android/systemui/util/magnetictarget/MagnetizedObject.kt
rename to libs/WindowManager/Shell/src/com/android/wm/shell/common/magnetictarget/MagnetizedObject.kt
index f441049..b4d7387 100644
--- a/packages/SystemUI/src/com/android/systemui/util/magnetictarget/MagnetizedObject.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/magnetictarget/MagnetizedObject.kt
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.systemui.util.magnetictarget
+package com.android.wm.shell.common.magnetictarget
 
 import android.annotation.SuppressLint
 import android.content.Context
@@ -31,7 +31,7 @@
 import androidx.dynamicanimation.animation.DynamicAnimation
 import androidx.dynamicanimation.animation.FloatPropertyCompat
 import androidx.dynamicanimation.animation.SpringForce
-import com.android.systemui.util.animation.PhysicsAnimator
+import com.android.wm.shell.animation.PhysicsAnimator
 import kotlin.math.abs
 import kotlin.math.hypot
 
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/PinnedStackListenerForwarder.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PinnedStackListenerForwarder.java
similarity index 98%
rename from packages/SystemUI/shared/src/com/android/systemui/shared/system/PinnedStackListenerForwarder.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/PinnedStackListenerForwarder.java
index 2091baa..993e0e7 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/PinnedStackListenerForwarder.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PinnedStackListenerForwarder.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.shared.system;
+package com.android.wm.shell.pip;
 
 import android.app.RemoteAction;
 import android.content.ComponentName;
diff --git a/packages/SystemUI/src/com/android/systemui/pip/Pip.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/Pip.java
similarity index 88%
rename from packages/SystemUI/src/com/android/systemui/pip/Pip.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/Pip.java
index 2b11550..7c26251 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/Pip.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/Pip.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,14 +14,15 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip;
+package com.android.wm.shell.pip;
 
+import android.annotation.Nullable;
 import android.app.ActivityManager;
 import android.content.ComponentName;
 import android.media.session.MediaController;
 
-import com.android.systemui.pip.phone.PipTouchHandler;
-import com.android.systemui.pip.tv.PipController;
+import com.android.wm.shell.pip.phone.PipTouchHandler;
+import com.android.wm.shell.pip.tv.PipController;
 
 import java.io.PrintWriter;
 import java.util.function.Consumer;
@@ -31,14 +32,14 @@
  */
 public interface Pip {
     /**
-     * Registers {@link com.android.systemui.pip.tv.PipController.Listener} that gets called.
+     * Registers {@link com.android.wm.shell.pip.tv.PipController.Listener} that gets called.
      * whenever receiving notification on changes in PIP.
      */
     default void addListener(PipController.Listener listener) {
     }
 
     /**
-     * Registers a {@link com.android.systemui.pip.tv.PipController.MediaListener} to PipController.
+     * Registers a {@link PipController.MediaListener} to PipController.
      */
     default void addMediaListener(PipController.MediaListener listener) {
     }
@@ -72,7 +73,13 @@
         return -1;
     }
 
-    default PipTouchHandler getPipTouchHandler() {
+    /**
+     * Get the touch handler which manages all the touch handling for PIP on the Phone,
+     * including moving, dismissing and expanding the PIP. (Do not used in TV)
+     *
+     * @return
+     */
+    default @Nullable PipTouchHandler getPipTouchHandler() {
         return null;
     }
 
@@ -167,7 +174,7 @@
     }
 
     /**
-     * Removes a {@link com.android.systemui.pip.tv.PipController.MediaListener} from PipController.
+     * Removes a {@link PipController.MediaListener} from PipController.
      */
     default void removeMediaListener(PipController.MediaListener listener) {
     }
diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java
similarity index 93%
rename from packages/SystemUI/src/com/android/systemui/pip/PipAnimationController.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java
index 52ce7fe..d829462 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/PipAnimationController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip;
+package com.android.wm.shell.pip;
 
 import android.animation.AnimationHandler;
 import android.animation.Animator;
@@ -26,7 +26,7 @@
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.graphics.SfVsyncFrameCallbackProvider;
-import com.android.systemui.Interpolators;
+import com.android.wm.shell.animation.Interpolators;
 
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
@@ -86,12 +86,13 @@
                 return handler;
             });
 
-    PipAnimationController(PipSurfaceTransactionHelper helper) {
+    public PipAnimationController(PipSurfaceTransactionHelper helper) {
         mSurfaceTransactionHelper = helper;
     }
 
     @SuppressWarnings("unchecked")
-    PipTransitionAnimator getAnimator(SurfaceControl leash,
+    @VisibleForTesting
+    public PipTransitionAnimator getAnimator(SurfaceControl leash,
             Rect destinationBounds, float alphaStart, float alphaEnd) {
         if (mCurrentAnimator == null) {
             mCurrentAnimator = setupPipTransitionAnimator(
@@ -108,7 +109,8 @@
     }
 
     @SuppressWarnings("unchecked")
-    PipTransitionAnimator getAnimator(SurfaceControl leash, Rect startBounds, Rect endBounds,
+    @VisibleForTesting
+    public PipTransitionAnimator getAnimator(SurfaceControl leash, Rect startBounds, Rect endBounds,
             Rect sourceHintRect, @PipAnimationController.TransitionDirection int direction) {
         if (mCurrentAnimator == null) {
             mCurrentAnimator = setupPipTransitionAnimator(
@@ -234,20 +236,23 @@
 
         @Override public void onAnimationRepeat(Animator animation) {}
 
-        @AnimationType int getAnimationType() {
+        @VisibleForTesting
+        @AnimationType public int getAnimationType() {
             return mAnimationType;
         }
 
-        PipTransitionAnimator<T> setPipAnimationCallback(PipAnimationCallback callback) {
+        @VisibleForTesting
+        public PipTransitionAnimator<T> setPipAnimationCallback(PipAnimationCallback callback) {
             mPipAnimationCallback = callback;
             return this;
         }
-
-        @TransitionDirection int getTransitionDirection() {
+        @VisibleForTesting
+        @TransitionDirection public int getTransitionDirection() {
             return mTransitionDirection;
         }
 
-        PipTransitionAnimator<T> setTransitionDirection(@TransitionDirection int direction) {
+        @VisibleForTesting
+        public PipTransitionAnimator<T> setTransitionDirection(@TransitionDirection int direction) {
             if (direction != TRANSITION_DIRECTION_SAME) {
                 mTransitionDirection = direction;
             }
@@ -258,7 +263,8 @@
             return mStartValue;
         }
 
-        T getEndValue() {
+        @VisibleForTesting
+        public T getEndValue() {
             return mEndValue;
         }
 
@@ -295,7 +301,7 @@
          * animation. In which case we can update the end bounds and keep the existing animation
          * running instead of cancelling it.
          */
-        void updateEndValue(T endValue) {
+        public void updateEndValue(T endValue) {
             mEndValue = endValue;
         }
 
@@ -304,7 +310,7 @@
         }
 
         @VisibleForTesting
-        void setSurfaceControlTransactionFactory(
+        public void setSurfaceControlTransactionFactory(
                 PipSurfaceTransactionHelper.SurfaceControlTransactionFactory factory) {
             mSurfaceControlTransactionFactory = factory;
         }
@@ -353,7 +359,7 @@
                 }
 
                 @Override
-                void updateEndValue(Float endValue) {
+                public void updateEndValue(Float endValue) {
                     super.updateEndValue(endValue);
                     mStartValue = mCurrentValue;
                 }
@@ -444,7 +450,7 @@
                 }
 
                 @Override
-                void updateEndValue(Rect endValue) {
+                public void updateEndValue(Rect endValue) {
                     super.updateEndValue(endValue);
                     if (mStartValue != null && mCurrentValue != null) {
                         mStartValue.set(mCurrentValue);
diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipBoundsHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipBoundsHandler.java
similarity index 97%
rename from packages/SystemUI/src/com/android/systemui/pip/PipBoundsHandler.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipBoundsHandler.java
index 89b5c38..de3261b 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/PipBoundsHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipBoundsHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip;
+package com.android.wm.shell.pip;
 
 import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
 import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
@@ -39,7 +39,6 @@
 import android.view.Gravity;
 import android.window.WindowContainerTransaction;
 
-import com.android.systemui.dagger.SysUISingleton;
 import com.android.wm.shell.common.DisplayLayout;
 
 import java.io.PrintWriter;
@@ -48,7 +47,6 @@
  * Handles bounds calculation for PIP on Phone and other form factors, it keeps tracking variant
  * state changes originated from Window Manager and is the source of truth for PiP window bounds.
  */
-@SysUISingleton
 public class PipBoundsHandler {
 
     private static final String TAG = PipBoundsHandler.class.getSimpleName();
@@ -254,7 +252,7 @@
     /**
      * See {@link #getDestinationBounds(ComponentName, float, Rect, Size, boolean)}
      */
-    Rect getDestinationBounds(ComponentName componentName, float aspectRatio, Rect bounds,
+    public Rect getDestinationBounds(ComponentName componentName, float aspectRatio, Rect bounds,
             Size minimalSize) {
         return getDestinationBounds(componentName, aspectRatio, bounds, minimalSize,
                 false /* useCurrentMinEdgeSize */);
@@ -263,7 +261,7 @@
     /**
      * @return {@link Rect} of the destination PiP window bounds.
      */
-    Rect getDestinationBounds(ComponentName componentName, float aspectRatio, Rect bounds,
+    public Rect getDestinationBounds(ComponentName componentName, float aspectRatio, Rect bounds,
             Size minimalSize, boolean useCurrentMinEdgeSize) {
         if (!componentName.equals(mLastPipComponentName)) {
             onResetReentryBoundsUnchecked();
@@ -288,7 +286,7 @@
         return destinationBounds;
     }
 
-    float getDefaultAspectRatio() {
+    public float getDefaultAspectRatio() {
         return mDefaultAspectRatio;
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipSnapAlgorithm.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSnapAlgorithm.java
similarity index 98%
rename from packages/SystemUI/src/com/android/systemui/pip/PipSnapAlgorithm.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSnapAlgorithm.java
index 5d23e42..820930c 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/PipSnapAlgorithm.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSnapAlgorithm.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip;
+package com.android.wm.shell.pip;
 
 import android.content.Context;
 import android.content.res.Resources;
diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipSurfaceTransactionHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java
similarity index 88%
rename from packages/SystemUI/src/com/android/systemui/pip/PipSurfaceTransactionHelper.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java
index fc724cb..b9a5536 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/PipSurfaceTransactionHelper.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipSurfaceTransactionHelper.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip;
+package com.android.wm.shell.pip;
 
 import android.content.Context;
 import android.content.res.Resources;
@@ -23,13 +23,11 @@
 import android.graphics.RectF;
 import android.view.SurfaceControl;
 
-import com.android.systemui.dagger.SysUISingleton;
 import com.android.wm.shell.R;
 
 /**
  * Abstracts the common operations on {@link SurfaceControl.Transaction} for PiP transition.
  */
-@SysUISingleton
 public class PipSurfaceTransactionHelper {
 
     private final boolean mEnableCornerRadius;
@@ -63,7 +61,7 @@
      * Operates the alpha on a given transaction and leash
      * @return same {@link PipSurfaceTransactionHelper} instance for method chaining
      */
-    PipSurfaceTransactionHelper alpha(SurfaceControl.Transaction tx, SurfaceControl leash,
+    public PipSurfaceTransactionHelper alpha(SurfaceControl.Transaction tx, SurfaceControl leash,
             float alpha) {
         tx.setAlpha(leash, alpha);
         return this;
@@ -73,7 +71,7 @@
      * Operates the crop (and position) on a given transaction and leash
      * @return same {@link PipSurfaceTransactionHelper} instance for method chaining
      */
-    PipSurfaceTransactionHelper crop(SurfaceControl.Transaction tx, SurfaceControl leash,
+    public PipSurfaceTransactionHelper crop(SurfaceControl.Transaction tx, SurfaceControl leash,
             Rect destinationBounds) {
         tx.setWindowCrop(leash, destinationBounds.width(), destinationBounds.height())
                 .setPosition(leash, destinationBounds.left, destinationBounds.top);
@@ -84,7 +82,7 @@
      * Operates the scale (setMatrix) on a given transaction and leash
      * @return same {@link PipSurfaceTransactionHelper} instance for method chaining
      */
-    PipSurfaceTransactionHelper scale(SurfaceControl.Transaction tx, SurfaceControl leash,
+    public PipSurfaceTransactionHelper scale(SurfaceControl.Transaction tx, SurfaceControl leash,
             Rect sourceBounds, Rect destinationBounds) {
         mTmpSourceRectF.set(sourceBounds);
         mTmpDestinationRectF.set(destinationBounds);
@@ -98,7 +96,8 @@
      * Operates the scale (setMatrix) on a given transaction and leash
      * @return same {@link PipSurfaceTransactionHelper} instance for method chaining
      */
-    PipSurfaceTransactionHelper scaleAndCrop(SurfaceControl.Transaction tx, SurfaceControl leash,
+    public PipSurfaceTransactionHelper scaleAndCrop(SurfaceControl.Transaction tx,
+            SurfaceControl leash,
             Rect sourceBounds, Rect destinationBounds, Rect insets) {
         mTmpSourceRectF.set(sourceBounds);
         mTmpDestinationRect.set(sourceBounds);
@@ -119,9 +118,11 @@
 
     /**
      * Resets the scale (setMatrix) on a given transaction and leash if there's any
+     *
      * @return same {@link PipSurfaceTransactionHelper} instance for method chaining
      */
-    PipSurfaceTransactionHelper resetScale(SurfaceControl.Transaction tx, SurfaceControl leash,
+    public PipSurfaceTransactionHelper resetScale(SurfaceControl.Transaction tx,
+            SurfaceControl leash,
             Rect destinationBounds) {
         tx.setMatrix(leash, Matrix.IDENTITY_MATRIX, mTmpFloat9)
                 .setPosition(leash, destinationBounds.left, destinationBounds.top);
@@ -132,7 +133,7 @@
      * Operates the round corner radius on a given transaction and leash
      * @return same {@link PipSurfaceTransactionHelper} instance for method chaining
      */
-    PipSurfaceTransactionHelper round(SurfaceControl.Transaction tx, SurfaceControl leash,
+    public PipSurfaceTransactionHelper round(SurfaceControl.Transaction tx, SurfaceControl leash,
             boolean applyCornerRadius) {
         if (mEnableCornerRadius) {
             tx.setCornerRadius(leash, applyCornerRadius ? mCornerRadius : 0);
@@ -140,7 +141,7 @@
         return this;
     }
 
-    interface SurfaceControlTransactionFactory {
+    public interface SurfaceControlTransactionFactory {
         SurfaceControl.Transaction getTransaction();
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java
similarity index 97%
rename from packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java
index 98e5794..bb501fb 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java
@@ -14,23 +14,23 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip;
+package com.android.wm.shell.pip;
 
 import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
 import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
 import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
 import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
 
-import static com.android.systemui.pip.PipAnimationController.ANIM_TYPE_ALPHA;
-import static com.android.systemui.pip.PipAnimationController.ANIM_TYPE_BOUNDS;
-import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_LEAVE_PIP;
-import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN;
-import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_NONE;
-import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_REMOVE_STACK;
-import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_SAME;
-import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
-import static com.android.systemui.pip.PipAnimationController.isInPipDirection;
-import static com.android.systemui.pip.PipAnimationController.isOutPipDirection;
+import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_ALPHA;
+import static com.android.wm.shell.pip.PipAnimationController.ANIM_TYPE_BOUNDS;
+import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_LEAVE_PIP;
+import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_LEAVE_PIP_TO_SPLIT_SCREEN;
+import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_NONE;
+import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_REMOVE_STACK;
+import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_SAME;
+import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
+import static com.android.wm.shell.pip.PipAnimationController.isInPipDirection;
+import static com.android.wm.shell.pip.PipAnimationController.isOutPipDirection;
 
 import android.annotation.NonNull;
 import android.annotation.Nullable;
@@ -59,13 +59,13 @@
 import android.window.WindowContainerTransactionCallback;
 
 import com.android.internal.os.SomeArgs;
-import com.android.systemui.dagger.SysUISingleton;
-import com.android.systemui.pip.phone.PipMenuActivityController;
-import com.android.systemui.pip.phone.PipUpdateThread;
-import com.android.systemui.pip.phone.PipUtils;
 import com.android.wm.shell.R;
 import com.android.wm.shell.ShellTaskOrganizer;
 import com.android.wm.shell.common.DisplayController;
+import com.android.wm.shell.pip.phone.PipMenuActivityController;
+import com.android.wm.shell.pip.phone.PipMotionHelper;
+import com.android.wm.shell.pip.phone.PipUpdateThread;
+import com.android.wm.shell.pip.phone.PipUtils;
 import com.android.wm.shell.splitscreen.SplitScreen;
 
 import java.io.PrintWriter;
@@ -86,9 +86,8 @@
  * and files a final {@link WindowContainerTransaction} at the end of the transition.
  *
  * This class is also responsible for general resize/offset PiP operations within SysUI component,
- * see also {@link com.android.systemui.pip.phone.PipMotionHelper}.
+ * see also {@link PipMotionHelper}.
  */
-@SysUISingleton
 public class PipTaskOrganizer extends TaskOrganizer implements ShellTaskOrganizer.TaskListener,
         DisplayController.OnDisplaysChangedListener {
     private static final String TAG = PipTaskOrganizer.class.getSimpleName();
diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipUiEventLogger.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipUiEventLogger.java
similarity index 96%
rename from packages/SystemUI/src/com/android/systemui/pip/PipUiEventLogger.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipUiEventLogger.java
index 22adbb7..de3bb29 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/PipUiEventLogger.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipUiEventLogger.java
@@ -14,19 +14,17 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip;
+package com.android.wm.shell.pip;
 
 import android.app.TaskInfo;
 import android.content.pm.PackageManager;
 
 import com.android.internal.logging.UiEvent;
 import com.android.internal.logging.UiEventLogger;
-import com.android.systemui.dagger.SysUISingleton;
 
 /**
  * Helper class that ends PiP log to UiEvent, see also go/uievent
  */
-@SysUISingleton
 public class PipUiEventLogger {
 
     private static final int INVALID_PACKAGE_UID = -1;
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipAccessibilityInteractionConnection.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipAccessibilityInteractionConnection.java
similarity index 97%
rename from packages/SystemUI/src/com/android/systemui/pip/phone/PipAccessibilityInteractionConnection.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipAccessibilityInteractionConnection.java
index a133189..fddd547 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipAccessibilityInteractionConnection.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipAccessibilityInteractionConnection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.systemui.pip.phone;
+package com.android.wm.shell.pip.phone;
 
 import android.content.Context;
 import android.graphics.Rect;
@@ -27,9 +27,9 @@
 import android.view.accessibility.IAccessibilityInteractionConnection;
 import android.view.accessibility.IAccessibilityInteractionConnectionCallback;
 
-import com.android.systemui.pip.PipSnapAlgorithm;
-import com.android.systemui.pip.PipTaskOrganizer;
 import com.android.wm.shell.R;
+import com.android.wm.shell.pip.PipSnapAlgorithm;
+import com.android.wm.shell.pip.PipTaskOrganizer;
 
 import java.util.ArrayList;
 import java.util.List;
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipAppOpsListener.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipAppOpsListener.java
similarity index 97%
rename from packages/SystemUI/src/com/android/systemui/pip/phone/PipAppOpsListener.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipAppOpsListener.java
index 7dfd99c..6b6b521 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipAppOpsListener.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipAppOpsListener.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.phone;
+package com.android.wm.shell.pip.phone;
 
 import static android.app.AppOpsManager.MODE_ALLOWED;
 import static android.app.AppOpsManager.OP_PICTURE_IN_PICTURE;
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java
similarity index 96%
rename from packages/SystemUI/src/com/android/systemui/pip/phone/PipController.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java
index 6253043..5193656 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,11 +14,11 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.phone;
+package com.android.wm.shell.pip.phone;
 
 import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
 
-import static com.android.systemui.pip.PipAnimationController.isOutPipDirection;
+import static com.android.wm.shell.pip.PipAnimationController.isOutPipDirection;
 
 import android.annotation.Nullable;
 import android.app.ActivityManager;
@@ -36,14 +36,13 @@
 import android.view.IPinnedStackController;
 import android.window.WindowContainerTransaction;
 
-import com.android.systemui.dagger.SysUISingleton;
-import com.android.systemui.pip.Pip;
-import com.android.systemui.pip.PipBoundsHandler;
-import com.android.systemui.pip.PipTaskOrganizer;
-import com.android.systemui.shared.system.PinnedStackListenerForwarder;
-import com.android.systemui.wmshell.WindowManagerShellWrapper;
+import com.android.wm.shell.WindowManagerShellWrapper;
 import com.android.wm.shell.common.DisplayChangeController;
 import com.android.wm.shell.common.DisplayController;
+import com.android.wm.shell.pip.PinnedStackListenerForwarder;
+import com.android.wm.shell.pip.Pip;
+import com.android.wm.shell.pip.PipBoundsHandler;
+import com.android.wm.shell.pip.PipTaskOrganizer;
 
 import java.io.PrintWriter;
 import java.util.function.Consumer;
@@ -51,7 +50,6 @@
 /**
  * Manages the picture-in-picture (PIP) UI and states for Phones.
  */
-@SysUISingleton
 public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallback {
     private static final String TAG = "PipController";
 
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMediaController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMediaController.java
similarity index 86%
rename from packages/SystemUI/src/com/android/systemui/pip/phone/PipMediaController.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMediaController.java
index a5b5092..4a8db6b 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMediaController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMediaController.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.phone;
+package com.android.wm.shell.pip.phone;
 
 import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
 
@@ -33,7 +33,7 @@
 import android.media.session.PlaybackState;
 import android.os.UserHandle;
 
-import com.android.systemui.R;
+import com.android.wm.shell.R;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -46,10 +46,10 @@
  */
 public class PipMediaController {
 
-    private static final String ACTION_PLAY = "com.android.systemui.pip.phone.PLAY";
-    private static final String ACTION_PAUSE = "com.android.systemui.pip.phone.PAUSE";
-    private static final String ACTION_NEXT = "com.android.systemui.pip.phone.NEXT";
-    private static final String ACTION_PREV = "com.android.systemui.pip.phone.PREV";
+    private static final String ACTION_PLAY = "com.android.wm.shell.pip.phone.PLAY";
+    private static final String ACTION_PAUSE = "com.android.wm.shell.pip.phone.PAUSE";
+    private static final String ACTION_NEXT = "com.android.wm.shell.pip.phone.NEXT";
+    private static final String ACTION_PREV = "com.android.wm.shell.pip.phone.PREV";
 
     /**
      * A listener interface to receive notification on changes to the media actions.
@@ -88,12 +88,13 @@
         }
     };
 
-    private final MediaController.Callback mPlaybackChangedListener = new MediaController.Callback() {
-        @Override
-        public void onPlaybackStateChanged(PlaybackState state) {
-            notifyActionsChanged();
-        }
-    };
+    private final MediaController.Callback mPlaybackChangedListener =
+            new MediaController.Callback() {
+                @Override
+                public void onPlaybackStateChanged(PlaybackState state) {
+                    notifyActionsChanged();
+                }
+            };
 
     private final MediaSessionManager.OnActiveSessionsChangedListener mSessionsChangedListener =
             controllers -> resolveActiveMediaController(controllers);
@@ -180,26 +181,26 @@
         String pauseDescription = mContext.getString(R.string.pip_pause);
         mPauseAction = new RemoteAction(Icon.createWithResource(mContext,
                 R.drawable.pip_ic_pause_white), pauseDescription, pauseDescription,
-                        PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_PAUSE),
-                                FLAG_UPDATE_CURRENT));
+                PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_PAUSE),
+                        FLAG_UPDATE_CURRENT));
 
         String playDescription = mContext.getString(R.string.pip_play);
         mPlayAction = new RemoteAction(Icon.createWithResource(mContext,
                 R.drawable.pip_ic_play_arrow_white), playDescription, playDescription,
-                        PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_PLAY),
-                                FLAG_UPDATE_CURRENT));
+                PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_PLAY),
+                        FLAG_UPDATE_CURRENT));
 
         String nextDescription = mContext.getString(R.string.pip_skip_to_next);
         mNextAction = new RemoteAction(Icon.createWithResource(mContext,
-                R.drawable.ic_skip_next_white), nextDescription, nextDescription,
-                        PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_NEXT),
-                                FLAG_UPDATE_CURRENT));
+                R.drawable.pip_ic_skip_next_white), nextDescription, nextDescription,
+                PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_NEXT),
+                        FLAG_UPDATE_CURRENT));
 
         String prevDescription = mContext.getString(R.string.pip_skip_to_prev);
         mPrevAction = new RemoteAction(Icon.createWithResource(mContext,
-                R.drawable.ic_skip_previous_white), prevDescription, prevDescription,
-                        PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_PREV),
-                                FLAG_UPDATE_CURRENT));
+                R.drawable.pip_ic_skip_previous_white), prevDescription, prevDescription,
+                PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_PREV),
+                        FLAG_UPDATE_CURRENT));
     }
 
     /**
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuActivityController.java
similarity index 98%
rename from packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuActivityController.java
index 6c23225..c53803a7 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuActivityController.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.phone;
+package com.android.wm.shell.pip.phone;
 
 import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
 import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
@@ -34,8 +34,8 @@
 import android.view.WindowManager;
 import android.view.WindowManagerGlobal;
 
-import com.android.systemui.pip.PipTaskOrganizer;
-import com.android.systemui.pip.phone.PipMediaController.ActionListener;
+import com.android.wm.shell.pip.PipTaskOrganizer;
+import com.android.wm.shell.pip.phone.PipMediaController.ActionListener;
 
 import java.io.PrintWriter;
 import java.util.ArrayList;
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuIconsAlgorithm.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuIconsAlgorithm.java
similarity index 98%
rename from packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuIconsAlgorithm.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuIconsAlgorithm.java
index 6cfed07..985cd0f 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuIconsAlgorithm.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuIconsAlgorithm.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.phone;
+package com.android.wm.shell.pip.phone;
 
 import android.content.Context;
 import android.graphics.Rect;
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java
similarity index 98%
rename from packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuView.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java
index 48ddbff..24e49f8 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMenuView.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.phone;
+package com.android.wm.shell.pip.phone;
 
 import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK;
 import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
@@ -23,9 +23,9 @@
 import static android.view.accessibility.AccessibilityManager.FLAG_CONTENT_ICONS;
 import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK;
 
-import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_CLOSE;
-import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_FULL;
-import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_NONE;
+import static com.android.wm.shell.pip.phone.PipMenuActivityController.MENU_STATE_CLOSE;
+import static com.android.wm.shell.pip.phone.PipMenuActivityController.MENU_STATE_FULL;
+import static com.android.wm.shell.pip.phone.PipMenuActivityController.MENU_STATE_NONE;
 
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
@@ -59,8 +59,8 @@
 import android.widget.ImageButton;
 import android.widget.LinearLayout;
 
-import com.android.systemui.Interpolators;
-import com.android.systemui.R;
+import com.android.wm.shell.R;
+import com.android.wm.shell.animation.Interpolators;
 
 import java.util.ArrayList;
 import java.util.List;
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java
similarity index 97%
rename from packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java
index e241219..cc86cf9 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.phone;
+package com.android.wm.shell.pip.phone;
 
 import android.annotation.NonNull;
 import android.annotation.Nullable;
@@ -28,16 +28,17 @@
 import android.util.Log;
 import android.view.Choreographer;
 
+import androidx.annotation.VisibleForTesting;
 import androidx.dynamicanimation.animation.AnimationHandler;
 import androidx.dynamicanimation.animation.AnimationHandler.FrameCallbackScheduler;
 import androidx.dynamicanimation.animation.SpringForce;
 
-import com.android.systemui.pip.PipSnapAlgorithm;
-import com.android.systemui.pip.PipTaskOrganizer;
-import com.android.systemui.util.FloatingContentCoordinator;
-import com.android.systemui.util.animation.FloatProperties;
-import com.android.systemui.util.animation.PhysicsAnimator;
-import com.android.systemui.util.magnetictarget.MagnetizedObject;
+import com.android.wm.shell.animation.FloatProperties;
+import com.android.wm.shell.animation.PhysicsAnimator;
+import com.android.wm.shell.common.FloatingContentCoordinator;
+import com.android.wm.shell.common.magnetictarget.MagnetizedObject;
+import com.android.wm.shell.pip.PipSnapAlgorithm;
+import com.android.wm.shell.pip.PipTaskOrganizer;
 
 import java.io.PrintWriter;
 import java.util.function.Consumer;
@@ -503,7 +504,8 @@
     /**
      * Animates the PiP to offset it from the IME or shelf.
      */
-    void animateToOffset(Rect originalBounds, int offset) {
+    @VisibleForTesting
+    public void animateToOffset(Rect originalBounds, int offset) {
         if (DEBUG) {
             Log.d(TAG, "animateToOffset: originalBounds=" + originalBounds + " offset=" + offset
                     + " callers=\n" + Debug.getCallers(5, "    "));
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java
similarity index 97%
rename from packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java
index 1e3d871..ef38755 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipResizeGestureHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipResizeGestureHandler.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.systemui.pip.phone;
+package com.android.wm.shell.pip.phone;
 
 import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.PIP_PINCH_RESIZE;
 import static com.android.internal.policy.TaskResizingAlgorithm.CTRL_BOTTOM;
@@ -42,11 +42,13 @@
 import android.view.ScaleGestureDetector;
 import android.view.ViewConfiguration;
 
+import androidx.annotation.VisibleForTesting;
+
 import com.android.internal.policy.TaskResizingAlgorithm;
-import com.android.systemui.pip.PipBoundsHandler;
-import com.android.systemui.pip.PipTaskOrganizer;
-import com.android.systemui.pip.PipUiEventLogger;
 import com.android.wm.shell.R;
+import com.android.wm.shell.pip.PipBoundsHandler;
+import com.android.wm.shell.pip.PipTaskOrganizer;
+import com.android.wm.shell.pip.PipUiEventLogger;
 
 import java.io.PrintWriter;
 import java.util.concurrent.Executor;
@@ -490,11 +492,11 @@
         return mUserResizeBounds;
     }
 
-    void updateMaxSize(int maxX, int maxY) {
+    @VisibleForTesting public void updateMaxSize(int maxX, int maxY) {
         mMaxSize.set(maxX, maxY);
     }
 
-    void updateMinSize(int minX, int minY) {
+    @VisibleForTesting public void updateMinSize(int minX, int minY) {
         mMinSize.set(minX, minY);
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchGesture.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchGesture.java
similarity index 91%
rename from packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchGesture.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchGesture.java
index 72335db..1a3cc8b 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchGesture.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchGesture.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.phone;
+package com.android.wm.shell.pip.phone;
 
 /**
  * A generic interface for a touch gesture.
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java
similarity index 97%
rename from packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java
index 1f9125da..6b31772 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,13 +14,13 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.phone;
+package com.android.wm.shell.pip.phone;
 
 import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.PIP_STASHING;
-import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
-import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_CLOSE;
-import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_FULL;
-import static com.android.systemui.pip.phone.PipMenuActivityController.MENU_STATE_NONE;
+import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
+import static com.android.wm.shell.pip.phone.PipMenuActivityController.MENU_STATE_CLOSE;
+import static com.android.wm.shell.pip.phone.PipMenuActivityController.MENU_STATE_FULL;
+import static com.android.wm.shell.pip.phone.PipMenuActivityController.MENU_STATE_NONE;
 
 import android.annotation.SuppressLint;
 import android.content.ComponentName;
@@ -55,15 +55,15 @@
 import androidx.dynamicanimation.animation.SpringForce;
 
 import com.android.internal.annotations.VisibleForTesting;
-import com.android.systemui.R;
-import com.android.systemui.pip.PipAnimationController;
-import com.android.systemui.pip.PipBoundsHandler;
-import com.android.systemui.pip.PipTaskOrganizer;
-import com.android.systemui.pip.PipUiEventLogger;
-import com.android.systemui.util.DismissCircleView;
-import com.android.systemui.util.FloatingContentCoordinator;
-import com.android.systemui.util.animation.PhysicsAnimator;
-import com.android.systemui.util.magnetictarget.MagnetizedObject;
+import com.android.wm.shell.R;
+import com.android.wm.shell.animation.PhysicsAnimator;
+import com.android.wm.shell.common.DismissCircleView;
+import com.android.wm.shell.common.FloatingContentCoordinator;
+import com.android.wm.shell.common.magnetictarget.MagnetizedObject;
+import com.android.wm.shell.pip.PipAnimationController;
+import com.android.wm.shell.pip.PipBoundsHandler;
+import com.android.wm.shell.pip.PipTaskOrganizer;
+import com.android.wm.shell.pip.PipUiEventLogger;
 
 import java.io.PrintWriter;
 
@@ -140,9 +140,9 @@
     private Rect mInsetBounds = new Rect();
     // The reference bounds used to calculate the normal/expanded target bounds
     private Rect mNormalBounds = new Rect();
-    @VisibleForTesting Rect mNormalMovementBounds = new Rect();
+    @VisibleForTesting public Rect mNormalMovementBounds = new Rect();
     private Rect mExpandedBounds = new Rect();
-    @VisibleForTesting Rect mExpandedMovementBounds = new Rect();
+    @VisibleForTesting public Rect mExpandedMovementBounds = new Rect();
     private int mExpandedShortestEdgeSize;
 
     // Used to workaround an issue where the WM rotation happens before we are notified, allowing
@@ -898,17 +898,17 @@
     }
 
     @VisibleForTesting
-    PipResizeGestureHandler getPipResizeGestureHandler() {
+    public PipResizeGestureHandler getPipResizeGestureHandler() {
         return mPipResizeGestureHandler;
     }
 
     @VisibleForTesting
-    void setPipResizeGestureHandler(PipResizeGestureHandler pipResizeGestureHandler) {
+    public void setPipResizeGestureHandler(PipResizeGestureHandler pipResizeGestureHandler) {
         mPipResizeGestureHandler = pipResizeGestureHandler;
     }
 
     @VisibleForTesting
-    void setPipMotionHelper(PipMotionHelper pipMotionHelper) {
+    public void setPipMotionHelper(PipMotionHelper pipMotionHelper) {
         mMotionHelper = pipMotionHelper;
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchState.java
similarity index 94%
rename from packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchState.java
index ecd1128a..21715077 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchState.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipTouchState.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.phone;
+package com.android.wm.shell.pip.phone;
 
 import android.graphics.PointF;
 import android.os.Handler;
@@ -35,7 +35,7 @@
     private static final boolean DEBUG = false;
 
     @VisibleForTesting
-    static final long DOUBLE_TAP_TIMEOUT = 200;
+    public static final long DOUBLE_TAP_TIMEOUT = 200;
     static final long HOVER_EXIT_TIMEOUT = 50;
 
     private final Handler mHandler;
@@ -106,8 +106,8 @@
                 mAllowDraggingOffscreen = true;
                 mIsUserInteracting = true;
                 mDownTouchTime = ev.getEventTime();
-                mIsDoubleTap = !mPreviouslyDragging &&
-                        (mDownTouchTime - mLastDownTouchTime) < DOUBLE_TAP_TIMEOUT;
+                mIsDoubleTap = !mPreviouslyDragging
+                        && (mDownTouchTime - mLastDownTouchTime) < DOUBLE_TAP_TIMEOUT;
                 mIsWaitingForDoubleTap = false;
                 mIsDragging = false;
                 mLastDownTouchTime = mDownTouchTime;
@@ -163,8 +163,8 @@
                     final int newPointerIndex = (pointerIndex == 0) ? 1 : 0;
                     mActivePointerId = ev.getPointerId(newPointerIndex);
                     if (DEBUG) {
-                        Log.e(TAG, "Relinquish active pointer id on POINTER_UP: " +
-                                mActivePointerId);
+                        Log.e(TAG,
+                                "Relinquish active pointer id on POINTER_UP: " + mActivePointerId);
                     }
                     mLastTouch.set(ev.getRawX(newPointerIndex), ev.getRawY(newPointerIndex));
                 }
@@ -191,8 +191,8 @@
                 mUpTouchTime = ev.getEventTime();
                 mLastTouch.set(ev.getRawX(pointerIndex), ev.getRawY(pointerIndex));
                 mPreviouslyDragging = mIsDragging;
-                mIsWaitingForDoubleTap = !mIsDoubleTap && !mIsDragging &&
-                        (mUpTouchTime - mDownTouchTime) < DOUBLE_TAP_TIMEOUT;
+                mIsWaitingForDoubleTap = !mIsDoubleTap && !mIsDragging
+                        && (mUpTouchTime - mDownTouchTime) < DOUBLE_TAP_TIMEOUT;
 
                 // Fall through to clean up
             }
@@ -223,7 +223,7 @@
 
     /**
      * @return the movement delta between the last handled touch event and the previous touch
-     *         position.
+     * position.
      */
     public PointF getLastTouchDelta() {
         return mLastDelta;
@@ -238,7 +238,7 @@
 
     /**
      * @return the movement delta between the last handled touch event and the down touch
-     *         position.
+     * position.
      */
     public PointF getDownTouchDelta() {
         return mDownDelta;
@@ -318,7 +318,8 @@
         }
     }
 
-    @VisibleForTesting long getDoubleTapTimeoutCallbackDelay() {
+    @VisibleForTesting
+    public long getDoubleTapTimeoutCallbackDelay() {
         if (mIsWaitingForDoubleTap) {
             return Math.max(0, DOUBLE_TAP_TIMEOUT - (mUpTouchTime - mDownTouchTime));
         }
@@ -333,7 +334,8 @@
         mHandler.removeCallbacks(mDoubleTapTimeoutCallback);
     }
 
-    void scheduleHoverExitTimeoutCallback() {
+    @VisibleForTesting
+    public void scheduleHoverExitTimeoutCallback() {
         mHandler.removeCallbacks(mHoverExitTimeoutCallback);
         mHandler.postDelayed(mHoverExitTimeoutCallback, HOVER_EXIT_TIMEOUT);
     }
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipUpdateThread.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipUpdateThread.java
similarity index 94%
rename from packages/SystemUI/src/com/android/systemui/pip/phone/PipUpdateThread.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipUpdateThread.java
index 6c5d846..d686cac 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipUpdateThread.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipUpdateThread.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.phone;
+package com.android.wm.shell.pip.phone;
 
 import android.os.Handler;
 import android.os.HandlerThread;
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipUtils.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipUtils.java
similarity index 93%
rename from packages/SystemUI/src/com/android/systemui/pip/phone/PipUtils.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipUtils.java
index 1bf6dd7..6a58ce0 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipUtils.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipUtils.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.phone;
+package com.android.wm.shell.pip.phone;
 
 import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
 import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
@@ -35,7 +35,7 @@
 
     /**
      * @return the ComponentName and user id of the top non-SystemUI activity in the pinned stack.
-     *         The component name may be null if no such activity exists.
+     * The component name may be null if no such activity exists.
      */
     public static Pair<ComponentName, Integer> getTopPipActivity(Context context,
             IActivityManager activityManager) {
diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/PipControlButtonView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipControlButtonView.java
similarity index 95%
rename from packages/SystemUI/src/com/android/systemui/pip/tv/PipControlButtonView.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipControlButtonView.java
index db9bedd..4e82bb5 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/tv/PipControlButtonView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipControlButtonView.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.tv;
+package com.android.wm.shell.pip.tv;
 
 import android.animation.Animator;
 import android.animation.AnimatorInflater;
@@ -83,9 +83,9 @@
         mButtonImageView = findViewById(R.id.button);
         mDescriptionTextView = findViewById(R.id.desc);
 
-        int[] values = new int[] {android.R.attr.src, android.R.attr.text};
-        TypedArray typedArray =
-            context.obtainStyledAttributes(attrs, values, defStyleAttr, defStyleRes);
+        int[] values = new int[]{android.R.attr.src, android.R.attr.text};
+        TypedArray typedArray = context.obtainStyledAttributes(attrs, values, defStyleAttr,
+                defStyleRes);
 
         setImageResource(typedArray.getResourceId(0, 0));
         setText(typedArray.getResourceId(1, 0));
diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/PipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipController.java
similarity index 97%
rename from packages/SystemUI/src/com/android/systemui/pip/tv/PipController.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipController.java
index d27f257..3eec20f 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/tv/PipController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipController.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.tv;
+package com.android.wm.shell.pip.tv;
 
 import static android.app.ActivityTaskManager.INVALID_STACK_ID;
 import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
@@ -45,13 +45,12 @@
 import android.util.Log;
 import android.view.DisplayInfo;
 
-import com.android.systemui.R;
-import com.android.systemui.dagger.SysUISingleton;
-import com.android.systemui.pip.Pip;
-import com.android.systemui.pip.PipBoundsHandler;
-import com.android.systemui.pip.PipTaskOrganizer;
-import com.android.systemui.shared.system.PinnedStackListenerForwarder;
-import com.android.systemui.wmshell.WindowManagerShellWrapper;
+import com.android.wm.shell.R;
+import com.android.wm.shell.WindowManagerShellWrapper;
+import com.android.wm.shell.pip.PinnedStackListenerForwarder;
+import com.android.wm.shell.pip.Pip;
+import com.android.wm.shell.pip.PipBoundsHandler;
+import com.android.wm.shell.pip.PipTaskOrganizer;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -59,7 +58,6 @@
 /**
  * Manages the picture-in-picture (PIP) UI and states.
  */
-@SysUISingleton
 public class PipController implements Pip, PipTaskOrganizer.PipTransitionCallback {
     private static final String TAG = "PipController";
     static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -252,6 +250,9 @@
                 Log.e(TAG, "Failed to register pinned stack listener", e);
             }
         }
+
+        // TODO(b/169395392) Refactor PipMenuActivity to PipMenuView
+        PipMenuActivity.setPipController(this);
     }
 
     private void loadConfigurationsAndApply(Configuration newConfig) {
diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/PipControlsView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipControlsView.java
similarity index 91%
rename from packages/SystemUI/src/com/android/systemui/pip/tv/PipControlsView.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipControlsView.java
index 125444d..14960c3 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/tv/PipControlsView.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipControlsView.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.tv;
+package com.android.wm.shell.pip.tv;
 
 import android.content.Context;
 import android.util.AttributeSet;
@@ -30,6 +30,10 @@
  */
 public class PipControlsView extends LinearLayout {
 
+    public PipControlsView(Context context) {
+        this(context, null);
+    }
+
     public PipControlsView(Context context, AttributeSet attrs) {
         this(context, attrs, 0);
     }
diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/PipControlsViewController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipControlsViewController.java
similarity index 84%
rename from packages/SystemUI/src/com/android/systemui/pip/tv/PipControlsViewController.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipControlsViewController.java
index 8c04a52..f66e902 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/tv/PipControlsViewController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipControlsViewController.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2019 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.tv;
+package com.android.wm.shell.pip.tv;
 
 import android.app.PendingIntent;
 import android.app.RemoteAction;
@@ -26,17 +26,13 @@
 import android.view.LayoutInflater;
 import android.view.View;
 
-import com.android.systemui.dagger.qualifiers.Main;
-import com.android.systemui.pip.Pip;
 import com.android.wm.shell.R;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Optional;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 
-import javax.inject.Inject;
 
 /**
  * Controller for {@link PipControlsView}.
@@ -49,7 +45,7 @@
     private final PipControlsView mView;
     private final LayoutInflater mLayoutInflater;
     private final Handler mHandler;
-    private final Optional<Pip> mPipOptional;
+    private final PipController mPipController;
     private final PipControlButtonView mPlayPauseButtonView;
     private MediaController mMediaController;
     private PipControlButtonView mFocusedChild;
@@ -77,14 +73,12 @@
                 @Override
                 public void onViewAttachedToWindow(View v) {
                     updateMediaController();
-                    mPipOptional.ifPresent(
-                            pip -> pip.addMediaListener(mPipMediaListener));
+                    mPipController.addMediaListener(mPipMediaListener);
                 }
 
                 @Override
                 public void onViewDetachedFromWindow(View v) {
-                    mPipOptional.ifPresent(
-                            pip -> pip.removeMediaListener(mPipMediaListener));
+                    mPipController.removeMediaListener(mPipMediaListener);
                 }
             };
 
@@ -110,12 +104,11 @@
                 }
             };
 
-    @Inject
-    public PipControlsViewController(PipControlsView view, Optional<Pip> pipOptional,
-            LayoutInflater layoutInflater, @Main Handler handler) {
+    public PipControlsViewController(PipControlsView view, PipController pipController,
+            LayoutInflater layoutInflater, Handler handler) {
         super();
         mView = view;
-        mPipOptional = pipOptional;
+        mPipController = pipController;
         mLayoutInflater = layoutInflater;
         mHandler = handler;
 
@@ -126,34 +119,29 @@
 
         View fullButtonView = mView.getFullButtonView();
         fullButtonView.setOnFocusChangeListener(mFocusChangeListener);
-        fullButtonView.setOnClickListener(
-                v -> mPipOptional.ifPresent(pip -> pip.movePipToFullscreen())
-        );
+        fullButtonView.setOnClickListener(mView -> mPipController.movePipToFullscreen());
 
         View closeButtonView = mView.getCloseButtonView();
         closeButtonView.setOnFocusChangeListener(mFocusChangeListener);
         closeButtonView.setOnClickListener(v -> {
-            mPipOptional.ifPresent(pip -> pip.closePip());
+            mPipController.closePip();
             if (mListener != null) {
                 mListener.onClosed();
             }
         });
 
-
         mPlayPauseButtonView = mView.getPlayPauseButtonView();
         mPlayPauseButtonView.setOnFocusChangeListener(mFocusChangeListener);
         mPlayPauseButtonView.setOnClickListener(v -> {
             if (mMediaController == null || mMediaController.getPlaybackState() == null) {
                 return;
             }
-            mPipOptional.ifPresent(pip -> {
-                final int playbackState = pip.getPlaybackState();
-                if (playbackState == PipController.PLAYBACK_STATE_PAUSED) {
-                    mMediaController.getTransportControls().play();
-                } else if (playbackState == PipController.PLAYBACK_STATE_PLAYING) {
-                    mMediaController.getTransportControls().pause();
-                }
-            });
+            final int playbackState = mPipController.getPlaybackState();
+            if (playbackState == PipController.PLAYBACK_STATE_PAUSED) {
+                mMediaController.getTransportControls().play();
+            } else if (playbackState == PipController.PLAYBACK_STATE_PLAYING) {
+                mMediaController.getTransportControls().pause();
+            }
 
             // View will be updated later in {@link mMediaControllerCallback}
         });
@@ -161,7 +149,7 @@
 
     private void updateMediaController() {
         AtomicReference<MediaController> newController = new AtomicReference<>();
-        mPipOptional.ifPresent(pip -> newController.set(pip.getMediaController()));
+        newController.set(mPipController.getMediaController());
 
         if (newController.get() == null || mMediaController == newController.get()) {
             return;
@@ -224,7 +212,7 @@
             mPlayPauseButtonView.setVisibility(View.GONE);
         } else {
             AtomicInteger state = new AtomicInteger(PipController.STATE_UNKNOWN);
-            mPipOptional.ifPresent(pip -> state.set(pip.getPlaybackState()));
+            state.set(mPipController.getPlaybackState());
             if (state.get() == PipController.STATE_UNKNOWN
                     || state.get() == PipController.PLAYBACK_STATE_UNAVAILABLE) {
                 mPlayPauseButtonView.setVisibility(View.GONE);
diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/PipMenuActivity.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipMenuActivity.java
similarity index 77%
rename from packages/SystemUI/src/com/android/systemui/pip/tv/PipMenuActivity.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipMenuActivity.java
index 7e812d9..06d2408 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/tv/PipMenuActivity.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipMenuActivity.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.tv;
+package com.android.wm.shell.pip.tv;
 
 import android.animation.Animator;
 import android.animation.AnimatorInflater;
@@ -25,59 +25,40 @@
 import android.os.Bundle;
 import android.util.Log;
 
-import com.android.systemui.pip.Pip;
-import com.android.systemui.pip.tv.dagger.TvPipComponent;
 import com.android.wm.shell.R;
 
 import java.util.Collections;
-import java.util.Optional;
-
-import javax.inject.Inject;
 
 /**
  * Activity to show the PIP menu to control PIP.
+ * TODO(b/169395392) Refactor PipMenuActivity to PipMenuView
  */
-
 public class PipMenuActivity extends Activity implements PipController.Listener {
     private static final String TAG = "PipMenuActivity";
     private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
 
     static final String EXTRA_CUSTOM_ACTIONS = "custom_actions";
 
-    private final TvPipComponent.Builder mPipComponentBuilder;
-    private TvPipComponent mTvPipComponent;
-    private final Optional<Pip> mPipOptional;
+    private static PipController sPipController;
 
     private Animator mFadeInAnimation;
     private Animator mFadeOutAnimation;
     private boolean mRestorePipSizeWhenClose;
     private PipControlsViewController mPipControlsViewController;
 
-    @Inject
-    public PipMenuActivity(TvPipComponent.Builder pipComponentBuilder,
-            Optional<Pip> pipOptional) {
-        super();
-        mPipComponentBuilder = pipComponentBuilder;
-        mPipOptional = pipOptional;
-    }
-
     @Override
     protected void onCreate(Bundle bundle) {
         if (DEBUG) Log.d(TAG, "onCreate()");
 
         super.onCreate(bundle);
-        mPipOptional.ifPresent(pip -> {
-            if (!pip.isPipShown()) {
-                finish();
-            }
-        });
+        if (sPipController == null || sPipController.isPipShown()) {
+            finish();
+        }
         setContentView(R.layout.tv_pip_menu);
-        mTvPipComponent = mPipComponentBuilder.pipControlsView(
-                findViewById(R.id.pip_controls)).build();
-        mPipControlsViewController = mTvPipComponent.getPipControlsViewController();
-
-        mPipOptional.ifPresent(pip -> pip.addListener(this));
-
+        mPipControlsViewController = new PipControlsViewController(
+                findViewById(R.id.pip_controls), sPipController,
+                getLayoutInflater(), getApplicationContext().getMainThreadHandler());
+        sPipController.addListener(this);
         mRestorePipSizeWhenClose = true;
         mFadeInAnimation = AnimatorInflater.loadAnimator(
                 this, R.anim.tv_pip_menu_fade_in_animation);
@@ -104,7 +85,7 @@
             if (DEBUG) Log.d(TAG, "   > restoring to the default position");
 
             // When PIP menu activity is closed, restore to the default position.
-            mPipOptional.ifPresent(pip -> pip.resizePinnedStack(PipController.STATE_PIP));
+            sPipController.resizePinnedStack(PipController.STATE_PIP);
         }
         finish();
     }
@@ -131,9 +112,9 @@
         if (DEBUG) Log.d(TAG, "onDestroy()");
 
         super.onDestroy();
-        mPipOptional.ifPresent(pip -> pip.removeListener(this));
-        mPipOptional.ifPresent(pip -> pip.resumePipResizing(
-                PipController.SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_MENU_ACTIVITY_FINISH));
+        sPipController.removeListener(this);
+        sPipController.resumePipResizing(
+                PipController.SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_MENU_ACTIVITY_FINISH);
     }
 
     @Override
@@ -184,8 +165,8 @@
         if (DEBUG) Log.d(TAG, "onPipResizeAboutToStart()");
 
         finish();
-        mPipOptional.ifPresent(pip -> pip.suspendPipResizing(
-                PipController.SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_MENU_ACTIVITY_FINISH));
+        sPipController.suspendPipResizing(
+                PipController.SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_MENU_ACTIVITY_FINISH);
     }
 
     @Override
@@ -194,4 +175,16 @@
 
         super.finish();
     }
+
+    /**
+     * TODO(b/169395392) Refactor PipMenuActivity to PipMenuView
+     *
+     * @param pipController The singleton pipController instance for TV
+     */
+    public static void setPipController(PipController pipController) {
+        if (sPipController != null) {
+            return;
+        }
+        sPipController = pipController;
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/PipNotification.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipNotification.java
similarity index 97%
rename from packages/SystemUI/src/com/android/systemui/pip/tv/PipNotification.java
rename to libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipNotification.java
index 0666811..7433085 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/tv/PipNotification.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/tv/PipNotification.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 The Android Open Source Project
+ * Copyright (C) 2020 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.tv;
+package com.android.wm.shell.pip.tv;
 
 import android.app.Notification;
 import android.app.NotificationManager;
@@ -37,7 +37,6 @@
 import android.util.Log;
 
 import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
-import com.android.systemui.util.NotificationChannels;
 import com.android.wm.shell.R;
 
 /**
@@ -53,6 +52,8 @@
     private static final String ACTION_MENU = "PipNotification.menu";
     private static final String ACTION_CLOSE = "PipNotification.close";
 
+    public static final String NOTIFICATION_CHANNEL_TVPIP = "TPP";
+
     private final PackageManager mPackageManager;
 
     private final PipController mPipController;
@@ -169,7 +170,7 @@
         mNotificationManager = (NotificationManager) context.getSystemService(
                 Context.NOTIFICATION_SERVICE);
 
-        mNotificationBuilder = new Notification.Builder(context, NotificationChannels.TVPIP)
+        mNotificationBuilder = new Notification.Builder(context, NOTIFICATION_CHANNEL_TVPIP)
                 .setLocalOnly(true)
                 .setOngoing(false)
                 .setCategory(Notification.CATEGORY_SYSTEM)
diff --git a/libs/WindowManager/Shell/tests/unittest/Android.bp b/libs/WindowManager/Shell/tests/unittest/Android.bp
index 937b00b..9940ea5 100644
--- a/libs/WindowManager/Shell/tests/unittest/Android.bp
+++ b/libs/WindowManager/Shell/tests/unittest/Android.bp
@@ -23,20 +23,30 @@
         "androidx.test.runner",
         "androidx.test.rules",
         "androidx.test.ext.junit",
+        "androidx.dynamicanimation_dynamicanimation",
+        "dagger2",
+        "kotlinx-coroutines-android",
+        "kotlinx-coroutines-core",
         "mockito-target-extended-minus-junit4",
         "truth-prebuilt",
         "testables",
     ],
+
     libs: [
         "android.test.mock",
         "android.test.base",
         "android.test.runner",
     ],
+
     jni_libs: [
         "libdexmakerjvmtiagent",
         "libstaticjvmtiagent",
     ],
 
+    kotlincflags: ["-Xjvm-default=enable"],
+
+    plugins: ["dagger2-compiler"],
+
     optimize: {
         enabled: false,
     },
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/animation/PhysicsAnimatorTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/animation/PhysicsAnimatorTest.kt
similarity index 95%
rename from packages/SystemUI/tests/src/com/android/systemui/util/animation/PhysicsAnimatorTest.kt
rename to libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/animation/PhysicsAnimatorTest.kt
index bd59680..4bd9bed 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/animation/PhysicsAnimatorTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/animation/PhysicsAnimatorTest.kt
@@ -1,4 +1,20 @@
-package com.android.systemui.util.animation
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.wm.shell.animation
 
 import android.testing.AndroidTestingRunner
 import android.testing.TestableLooper
@@ -11,11 +27,11 @@
 import androidx.dynamicanimation.animation.SpringForce
 import androidx.test.filters.SmallTest
 import com.android.systemui.SysuiTestCase
-import com.android.systemui.util.animation.PhysicsAnimator.EndListener
-import com.android.systemui.util.animation.PhysicsAnimator.UpdateListener
-import com.android.systemui.util.animation.PhysicsAnimatorTestUtils.clearAnimationUpdateFrames
-import com.android.systemui.util.animation.PhysicsAnimatorTestUtils.getAnimationUpdateFrames
-import com.android.systemui.util.animation.PhysicsAnimatorTestUtils.verifyAnimationUpdateFrames
+import com.android.wm.shell.animation.PhysicsAnimator.EndListener
+import com.android.wm.shell.animation.PhysicsAnimator.UpdateListener
+import com.android.wm.shell.animation.PhysicsAnimatorTestUtils.clearAnimationUpdateFrames
+import com.android.wm.shell.animation.PhysicsAnimatorTestUtils.getAnimationUpdateFrames
+import com.android.wm.shell.animation.PhysicsAnimatorTestUtils.verifyAnimationUpdateFrames
 import org.junit.After
 import org.junit.Assert
 import org.junit.Assert.assertEquals
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/magnetictarget/MagnetizedObjectTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/magnetictarget/MagnetizedObjectTest.kt
similarity index 99%
rename from packages/SystemUI/tests/src/com/android/systemui/util/magnetictarget/MagnetizedObjectTest.kt
rename to libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/magnetictarget/MagnetizedObjectTest.kt
index 251ca9c..fe53641 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/magnetictarget/MagnetizedObjectTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/magnetictarget/MagnetizedObjectTest.kt
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package com.android.systemui.util.magnetictarget
+package com.android.wm.shell.common.magnetictarget
 
 import android.testing.AndroidTestingRunner
 import android.testing.TestableLooper
diff --git a/packages/SystemUI/tests/src/com/android/systemui/pip/PipAnimationControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipAnimationControllerTest.java
similarity index 93%
rename from packages/SystemUI/tests/src/com/android/systemui/pip/PipAnimationControllerTest.java
rename to libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipAnimationControllerTest.java
index 89ca32c..7d51886 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/pip/PipAnimationControllerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipAnimationControllerTest.java
@@ -16,8 +16,8 @@
 
 package com.android.systemui.pip;
 
-import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_LEAVE_PIP;
-import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
+import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_LEAVE_PIP;
+import static com.android.wm.shell.pip.PipAnimationController.TRANSITION_DIRECTION_TO_PIP;
 
 import static org.junit.Assert.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
@@ -32,7 +32,9 @@
 
 import androidx.test.filters.SmallTest;
 
-import com.android.systemui.SysuiTestCase;
+import com.android.wm.shell.pip.PipAnimationController;
+import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
+import com.android.wm.shell.pip.PipTestCase;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -47,7 +49,7 @@
 @RunWith(AndroidTestingRunner.class)
 @SmallTest
 @TestableLooper.RunWithLooper(setAsMainLooper = true)
-public class PipAnimationControllerTest extends SysuiTestCase {
+public class PipAnimationControllerTest extends PipTestCase {
 
     private PipAnimationController mPipAnimationController;
 
@@ -161,7 +163,7 @@
      * A dummy {@link SurfaceControl.Transaction} class.
      * This is created as {@link Mock} does not support method chaining.
      */
-    private static class DummySurfaceControlTx extends SurfaceControl.Transaction {
+    public static class DummySurfaceControlTx extends SurfaceControl.Transaction {
         @Override
         public SurfaceControl.Transaction setAlpha(SurfaceControl leash, float alpha) {
             return this;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/pip/PipBoundsHandlerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipBoundsHandlerTest.java
similarity index 98%
rename from packages/SystemUI/tests/src/com/android/systemui/pip/PipBoundsHandlerTest.java
rename to libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipBoundsHandlerTest.java
index cdb1770..f514b0b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/pip/PipBoundsHandlerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipBoundsHandlerTest.java
@@ -31,7 +31,8 @@
 
 import androidx.test.filters.SmallTest;
 
-import com.android.systemui.SysuiTestCase;
+import com.android.wm.shell.pip.PipBoundsHandler;
+import com.android.wm.shell.pip.PipTestCase;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -46,7 +47,7 @@
 @RunWith(AndroidTestingRunner.class)
 @SmallTest
 @TestableLooper.RunWithLooper(setAsMainLooper = true)
-public class PipBoundsHandlerTest extends SysuiTestCase {
+public class PipBoundsHandlerTest extends PipTestCase {
     private static final int ROUNDING_ERROR_MARGIN = 16;
     private static final float ASPECT_RATIO_ERROR_MARGIN = 0.01f;
     private static final float DEFAULT_ASPECT_RATIO = 1f;
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipTestCase.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipTestCase.java
new file mode 100644
index 0000000..fdebe4e
--- /dev/null
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/PipTestCase.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.wm.shell.pip;
+
+import static android.view.Display.DEFAULT_DISPLAY;
+
+import android.content.Context;
+import android.hardware.display.DisplayManager;
+import android.testing.TestableContext;
+
+import androidx.test.InstrumentationRegistry;
+
+import org.junit.Before;
+
+/**
+ * Base class that does One Handed specific setup.
+ */
+public abstract class PipTestCase {
+
+    protected TestableContext mContext;
+
+    @Before
+    public void setup() {
+        final Context context =
+                InstrumentationRegistry.getInstrumentation().getTargetContext();
+        final DisplayManager dm = context.getSystemService(DisplayManager.class);
+        mContext = new TestableContext(
+                context.createDisplayContext(dm.getDisplay(DEFAULT_DISPLAY)));
+
+        InstrumentationRegistry
+                .getInstrumentation()
+                .getUiAutomation()
+                .adoptShellPermissionIdentity();
+    }
+
+    protected Context getContext() {
+        return mContext;
+    }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipControllerTest.java
similarity index 71%
rename from packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipControllerTest.java
rename to libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipControllerTest.java
index 1274621..d305c64 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipControllerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipControllerTest.java
@@ -31,13 +31,15 @@
 import android.testing.TestableContext;
 import android.testing.TestableLooper;
 
-import com.android.systemui.SysuiTestCase;
-import com.android.systemui.pip.PipBoundsHandler;
-import com.android.systemui.pip.PipTaskOrganizer;
-import com.android.systemui.shared.system.ActivityManagerWrapper;
-import com.android.systemui.statusbar.policy.ConfigurationController;
-import com.android.systemui.wmshell.WindowManagerShellWrapper;
+import com.android.wm.shell.WindowManagerShellWrapper;
 import com.android.wm.shell.common.DisplayController;
+import com.android.wm.shell.pip.PipBoundsHandler;
+import com.android.wm.shell.pip.PipTaskOrganizer;
+import com.android.wm.shell.pip.PipTestCase;
+import com.android.wm.shell.pip.phone.PipAppOpsListener;
+import com.android.wm.shell.pip.phone.PipController;
+import com.android.wm.shell.pip.phone.PipMediaController;
+import com.android.wm.shell.pip.phone.PipTouchHandler;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -51,15 +53,14 @@
 @SmallTest
 @RunWith(AndroidTestingRunner.class)
 @TestableLooper.RunWithLooper
-public class PipControllerTest extends SysuiTestCase {
-    private PipController mPipController;
+public class PipControllerTest extends PipTestCase {
+    private com.android.wm.shell.pip.phone.PipController mPipController;
     private TestableContext mSpiedContext;
 
-    @Mock private ActivityManagerWrapper mMockActivityManagerWrapper;
-    @Mock private ConfigurationController mMockConfigurationController;
     @Mock private DisplayController mMockdDisplayController;
     @Mock private PackageManager mPackageManager;
-    @Mock private PipMenuActivityController mMockPipMenuActivityController;
+    @Mock private com.android.wm.shell.pip.phone.PipMenuActivityController
+            mMockPipMenuActivityController;
     @Mock private PipAppOpsListener mMockPipAppOpsListener;
     @Mock private PipBoundsHandler mMockPipBoundsHandler;
     @Mock private PipMediaController mMockPipMediaController;
@@ -77,14 +78,9 @@
         when(mSpiedContext.getPackageManager()).thenReturn(mPackageManager);
 
         mPipController = new PipController(mSpiedContext, mMockdDisplayController,
-                mMockPipAppOpsListener,
-                mMockPipBoundsHandler, mMockPipMediaController, mMockPipMenuActivityController,
-                mMockPipTaskOrganizer, mMockPipTouchHandler, mMockWindowManagerShellWrapper);
-    }
-
-    @Test
-    public void testNonPipDevice_shouldNotRegisterTaskStackListener() {
-        verify(mMockActivityManagerWrapper, never()).registerTaskStackListener(any());
+                mMockPipAppOpsListener, mMockPipBoundsHandler, mMockPipMediaController,
+                mMockPipMenuActivityController, mMockPipTaskOrganizer, mMockPipTouchHandler,
+                mMockWindowManagerShellWrapper);
     }
 
     @Test
@@ -101,9 +97,4 @@
     public void testNonPipDevice_shouldNotAddDisplayWindowListener() {
         verify(mMockdDisplayController, never()).addDisplayWindowListener(any());
     }
-
-    @Test
-    public void testNonPipDevice_shouldNotAddCallback() {
-        verify(mMockConfigurationController, never()).addCallback(any());
-    }
 }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTaskOrganizerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTaskOrganizerTest.java
similarity index 90%
rename from packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTaskOrganizerTest.java
rename to libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTaskOrganizerTest.java
index b1a7df8..663169f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTaskOrganizerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTaskOrganizerTest.java
@@ -32,13 +32,13 @@
 import android.testing.TestableContext;
 import android.testing.TestableLooper;
 
-import com.android.systemui.SysuiTestCase;
-import com.android.systemui.pip.PipBoundsHandler;
-import com.android.systemui.pip.PipSurfaceTransactionHelper;
-import com.android.systemui.pip.PipTaskOrganizer;
-import com.android.systemui.pip.PipUiEventLogger;
 import com.android.wm.shell.ShellTaskOrganizer;
 import com.android.wm.shell.common.DisplayController;
+import com.android.wm.shell.pip.PipBoundsHandler;
+import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
+import com.android.wm.shell.pip.PipTaskOrganizer;
+import com.android.wm.shell.pip.PipTestCase;
+import com.android.wm.shell.pip.PipUiEventLogger;
 import com.android.wm.shell.splitscreen.SplitScreen;
 
 import org.junit.Before;
@@ -55,7 +55,7 @@
 @SmallTest
 @RunWith(AndroidTestingRunner.class)
 @TestableLooper.RunWithLooper
-public class PipTaskOrganizerTest extends SysuiTestCase {
+public class PipTaskOrganizerTest extends PipTestCase {
     private PipTaskOrganizer mSpiedPipTaskOrganizer;
     private TestableContext mSpiedContext;
 
diff --git a/packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTouchHandlerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTouchHandlerTest.java
similarity index 89%
rename from packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTouchHandlerTest.java
rename to libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTouchHandlerTest.java
index ad83ebb..c96cb20 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTouchHandlerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTouchHandlerTest.java
@@ -30,13 +30,17 @@
 
 import androidx.test.filters.SmallTest;
 
-import com.android.systemui.R;
-import com.android.systemui.SysuiTestCase;
-import com.android.systemui.pip.PipBoundsHandler;
-import com.android.systemui.pip.PipSnapAlgorithm;
-import com.android.systemui.pip.PipTaskOrganizer;
-import com.android.systemui.pip.PipUiEventLogger;
-import com.android.systemui.util.FloatingContentCoordinator;
+import com.android.wm.shell.R;
+import com.android.wm.shell.common.FloatingContentCoordinator;
+import com.android.wm.shell.pip.PipBoundsHandler;
+import com.android.wm.shell.pip.PipSnapAlgorithm;
+import com.android.wm.shell.pip.PipTaskOrganizer;
+import com.android.wm.shell.pip.PipTestCase;
+import com.android.wm.shell.pip.PipUiEventLogger;
+import com.android.wm.shell.pip.phone.PipMenuActivityController;
+import com.android.wm.shell.pip.phone.PipMotionHelper;
+import com.android.wm.shell.pip.phone.PipResizeGestureHandler;
+import com.android.wm.shell.pip.phone.PipTouchHandler;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -54,7 +58,7 @@
 @RunWith(AndroidTestingRunner.class)
 @SmallTest
 @TestableLooper.RunWithLooper(setAsMainLooper = true)
-public class PipTouchHandlerTest extends SysuiTestCase {
+public class PipTouchHandlerTest extends PipTestCase {
 
     private PipTouchHandler mPipTouchHandler;
 
diff --git a/packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTouchStateTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTouchStateTest.java
similarity index 96%
rename from packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTouchStateTest.java
rename to libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTouchStateTest.java
index 17b2e32..2702130 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/pip/phone/PipTouchStateTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PipTouchStateTest.java
@@ -11,7 +11,7 @@
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License
+ * limitations under the License.
  */
 
 package com.android.systemui.pip.phone;
@@ -35,7 +35,8 @@
 
 import androidx.test.filters.SmallTest;
 
-import com.android.systemui.SysuiTestCase;
+import com.android.wm.shell.pip.PipTestCase;
+import com.android.wm.shell.pip.phone.PipTouchState;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -46,7 +47,7 @@
 @RunWith(AndroidTestingRunner.class)
 @SmallTest
 @RunWithLooper
-public class PipTouchStateTest extends SysuiTestCase {
+public class PipTouchStateTest extends PipTestCase {
 
     private PipTouchState mTouchState;
     private CountDownLatch mDoubleTapCallbackTriggeredLatch;
@@ -157,4 +158,4 @@
     private MotionEvent createMotionEvent(int action, long eventTime, float x, float y) {
         return MotionEvent.obtain(0, eventTime, action, x, y, 0);
     }
-}
\ No newline at end of file
+}
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index cf78a13..505ef7a 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -518,7 +518,7 @@
 
         <!-- started from PipController -->
         <activity
-            android:name=".pip.tv.PipMenuActivity"
+            android:name="com.android.wm.shell.pip.tv.PipMenuActivity"
             android:permission="com.android.systemui.permission.SELF"
             android:exported="false"
             android:theme="@style/PipTheme"
diff --git a/packages/SystemUI/res/values/config_tv.xml b/packages/SystemUI/res/values/config_tv.xml
index 7451ba8..2e77674 100644
--- a/packages/SystemUI/res/values/config_tv.xml
+++ b/packages/SystemUI/res/values/config_tv.xml
@@ -15,10 +15,6 @@
 -->
 
 <resources>
-    <!-- Bounds [left top right bottom] on screen for picture-in-picture (PIP) windows,
-         when the PIP menu is shown in center. -->
-    <string translatable="false" name="pip_menu_bounds">"596 280 1324 690"</string>
-
     <!-- Whether to enable microphone disclosure indicator
          (com.android.systemui.statusbar.tv.micdisclosure.AudioRecordingDisclosureBar). -->
     <bool name="audio_recording_disclosure_enabled">true</bool>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 8777d50..7cbbaf9 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -974,8 +974,6 @@
     <!-- The start margin of quick scrub onboarding toast. -->
     <dimen name="recents_quick_scrub_onboarding_margin_start">8dp</dimen>
 
-    <dimen name="floating_dismiss_bottom_margin">50dp</dimen>
-
     <dimen name="default_gear_space">18dp</dimen>
     <dimen name="cell_overlay_padding">18dp</dimen>
 
@@ -1232,8 +1230,6 @@
     <dimen name="bubble_dismiss_target_padding_y">20dp</dimen>
     <dimen name="bubble_manage_menu_elevation">4dp</dimen>
 
-    <dimen name="dismiss_target_x_size">24dp</dimen>
-
     <!-- Bubbles user education views -->
     <dimen name="bubbles_manage_education_width">160dp</dimen>
     <!-- The inset from the top bound of the manage button to place the user education. -->
diff --git a/packages/SystemUI/shared/Android.bp b/packages/SystemUI/shared/Android.bp
index 68f4b746..606fd2c 100644
--- a/packages/SystemUI/shared/Android.bp
+++ b/packages/SystemUI/shared/Android.bp
@@ -37,8 +37,6 @@
     static_libs: [
         "PluginCoreLib",
     ],
-
-
     java_version: "1.8",
     min_sdk_version: "26",
 }
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
index dff405c..90b64ea 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java
@@ -88,7 +88,6 @@
 import com.android.systemui.model.SysUiState;
 import com.android.systemui.plugins.statusbar.StatusBarStateController;
 import com.android.systemui.shared.system.ActivityManagerWrapper;
-import com.android.systemui.shared.system.PinnedStackListenerForwarder;
 import com.android.systemui.shared.system.TaskStackChangeListener;
 import com.android.systemui.statusbar.FeatureFlags;
 import com.android.systemui.statusbar.NotificationLockscreenUserManager;
@@ -112,8 +111,9 @@
 import com.android.systemui.statusbar.phone.StatusBar;
 import com.android.systemui.statusbar.policy.ConfigurationController;
 import com.android.systemui.statusbar.policy.ZenModeController;
-import com.android.systemui.util.FloatingContentCoordinator;
-import com.android.systemui.wmshell.WindowManagerShellWrapper;
+import com.android.wm.shell.WindowManagerShellWrapper;
+import com.android.wm.shell.common.FloatingContentCoordinator;
+import com.android.wm.shell.pip.PinnedStackListenerForwarder;
 
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
index f2fba23..0dcd1d2 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java
@@ -16,6 +16,13 @@
 
 package com.android.systemui.bubbles;
 
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
+
+import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_STACK_VIEW;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES;
+import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
+
 import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
 import android.animation.ValueAnimator;
@@ -78,10 +85,10 @@
 import com.android.systemui.shared.system.QuickStepContract;
 import com.android.systemui.shared.system.SysUiStatsLog;
 import com.android.systemui.statusbar.phone.CollapsedStatusBarFragment;
-import com.android.systemui.util.FloatingContentCoordinator;
 import com.android.systemui.util.RelativeTouchListener;
-import com.android.systemui.util.animation.PhysicsAnimator;
-import com.android.systemui.util.magnetictarget.MagnetizedObject;
+import com.android.wm.shell.animation.PhysicsAnimator;
+import com.android.wm.shell.common.FloatingContentCoordinator;
+import com.android.wm.shell.common.magnetictarget.MagnetizedObject;
 
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
@@ -92,12 +99,6 @@
 import java.util.List;
 import java.util.function.Consumer;
 
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
-import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
-import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_STACK_VIEW;
-import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES;
-import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_WITH_CLASS_NAME;
-
 /**
  * Renders bubbles in a stack and handles animating expanded and collapsed states.
  */
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/DismissView.kt b/packages/SystemUI/src/com/android/systemui/bubbles/DismissView.kt
index 71faf4a..b3c552d 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/DismissView.kt
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/DismissView.kt
@@ -10,8 +10,8 @@
 import androidx.dynamicanimation.animation.SpringForce.DAMPING_RATIO_LOW_BOUNCY
 import androidx.dynamicanimation.animation.SpringForce.STIFFNESS_LOW
 import com.android.systemui.R
-import com.android.systemui.util.DismissCircleView
-import com.android.systemui.util.animation.PhysicsAnimator
+import com.android.wm.shell.common.DismissCircleView
+import com.android.wm.shell.animation.PhysicsAnimator
 
 /*
  * View that handles interactions between DismissCircleView and BubbleStackView.
@@ -29,7 +29,7 @@
 
     var isShowing = false
     private val animator = PhysicsAnimator.getInstance(circle)
-    private val spring = PhysicsAnimator.SpringConfig(STIFFNESS_LOW, DAMPING_RATIO_LOW_BOUNCY);
+    private val spring = PhysicsAnimator.SpringConfig(STIFFNESS_LOW, DAMPING_RATIO_LOW_BOUNCY)
     private val DISMISS_SCRIM_FADE_MS = 200
     init {
         setLayoutParams(LayoutParams(
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
index f2a4f15..9f88ee5 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/ExpandedAnimationController.java
@@ -32,8 +32,8 @@
 
 import com.android.systemui.Interpolators;
 import com.android.systemui.R;
-import com.android.systemui.util.animation.PhysicsAnimator;
-import com.android.systemui.util.magnetictarget.MagnetizedObject;
+import com.android.wm.shell.animation.PhysicsAnimator;
+import com.android.wm.shell.common.magnetictarget.MagnetizedObject;
 
 import com.google.android.collect.Sets;
 
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java b/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
index 46ef9bc..b7490a5 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/animation/StackAnimationController.java
@@ -36,9 +36,9 @@
 
 import com.android.systemui.R;
 import com.android.systemui.bubbles.BubbleStackView;
-import com.android.systemui.util.FloatingContentCoordinator;
-import com.android.systemui.util.animation.PhysicsAnimator;
-import com.android.systemui.util.magnetictarget.MagnetizedObject;
+import com.android.wm.shell.animation.PhysicsAnimator;
+import com.android.wm.shell.common.FloatingContentCoordinator;
+import com.android.wm.shell.common.magnetictarget.MagnetizedObject;
 
 import com.google.android.collect.Sets;
 
diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/dagger/BubbleModule.java b/packages/SystemUI/src/com/android/systemui/bubbles/dagger/BubbleModule.java
index 08902f8..d2eaf0d 100644
--- a/packages/SystemUI/src/com/android/systemui/bubbles/dagger/BubbleModule.java
+++ b/packages/SystemUI/src/com/android/systemui/bubbles/dagger/BubbleModule.java
@@ -40,8 +40,8 @@
 import com.android.systemui.statusbar.phone.ShadeController;
 import com.android.systemui.statusbar.policy.ConfigurationController;
 import com.android.systemui.statusbar.policy.ZenModeController;
-import com.android.systemui.util.FloatingContentCoordinator;
-import com.android.systemui.wmshell.WindowManagerShellWrapper;
+import com.android.wm.shell.WindowManagerShellWrapper;
+import com.android.wm.shell.common.FloatingContentCoordinator;
 
 import dagger.Module;
 import dagger.Provides;
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaCarouselScrollHandler.kt b/packages/SystemUI/src/com/android/systemui/media/MediaCarouselScrollHandler.kt
index 4863999..d80aafb 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaCarouselScrollHandler.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaCarouselScrollHandler.kt
@@ -32,7 +32,7 @@
 import com.android.systemui.R
 import com.android.systemui.classifier.Classifier.NOTIFICATION_DISMISS
 import com.android.systemui.plugins.FalsingManager
-import com.android.systemui.util.animation.PhysicsAnimator
+import com.android.wm.shell.animation.PhysicsAnimator
 import com.android.systemui.util.concurrency.DelayableExecutor
 
 private const val FLING_SLOP = 1000000
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaScrollView.kt b/packages/SystemUI/src/com/android/systemui/media/MediaScrollView.kt
index b887225..00273bc 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaScrollView.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaScrollView.kt
@@ -8,7 +8,7 @@
 import android.view.ViewGroup
 import android.widget.HorizontalScrollView
 import com.android.systemui.Gefingerpoken
-import com.android.systemui.util.animation.physicsAnimator
+import com.android.wm.shell.animation.physicsAnimator
 
 /**
  * A ScrollView used in Media that doesn't limit itself to the childs bounds. This is useful
diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/dagger/TvPipComponent.java b/packages/SystemUI/src/com/android/systemui/pip/tv/dagger/TvPipComponent.java
deleted file mode 100644
index 8e8b7f3..0000000
--- a/packages/SystemUI/src/com/android/systemui/pip/tv/dagger/TvPipComponent.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.pip.tv.dagger;
-
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import com.android.systemui.pip.tv.PipControlsView;
-import com.android.systemui.pip.tv.PipControlsViewController;
-import com.android.systemui.statusbar.phone.dagger.StatusBarComponent;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-
-import javax.inject.Scope;
-
-import dagger.BindsInstance;
-import dagger.Subcomponent;
-
-/**
- * Component for injecting into Pip related classes.
- */
-@Subcomponent
-public interface TvPipComponent {
-    /**
-     * Builder for {@link StatusBarComponent}.
-     */
-    @Subcomponent.Builder
-    interface Builder {
-        @BindsInstance
-        TvPipComponent.Builder pipControlsView(PipControlsView pipControlsView);
-        TvPipComponent build();
-    }
-
-    /**
-     * Scope annotation for singleton items within the PipComponent.
-     */
-    @Documented
-    @Retention(RUNTIME)
-    @Scope
-    @interface PipScope {}
-
-    /**
-     * Creates a StatusBarWindowViewController.
-     */
-    @TvPipComponent.PipScope
-    PipControlsViewController getPipControlsViewController();
-}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java b/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
index eba4465..ac55fa0 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
@@ -31,7 +31,7 @@
 
 import com.android.systemui.R;
 import com.android.systemui.qs.customize.QSCustomizer;
-import com.android.systemui.util.animation.PhysicsAnimator;
+import com.android.wm.shell.animation.PhysicsAnimator;
 
 /**
  * Wrapper view with background which contains {@link QSPanel} and {@link BaseStatusBarHeader}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
index f11683d..0ae1170 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
@@ -75,9 +75,6 @@
 import com.android.systemui.navigationbar.NavigationBarController;
 import com.android.systemui.navigationbar.NavigationBarView;
 import com.android.systemui.navigationbar.NavigationModeController;
-import com.android.systemui.pip.Pip;
-import com.android.systemui.pip.PipAnimationController;
-import com.android.systemui.pip.phone.PipUtils;
 import com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
 import com.android.systemui.settings.CurrentUserTracker;
 import com.android.systemui.shared.recents.IOverviewProxy;
@@ -94,6 +91,9 @@
 import com.android.systemui.statusbar.policy.CallbackController;
 import com.android.wm.shell.onehanded.OneHanded;
 import com.android.wm.shell.onehanded.OneHandedEvents;
+import com.android.wm.shell.pip.Pip;
+import com.android.wm.shell.pip.PipAnimationController;
+import com.android.wm.shell.pip.phone.PipUtils;
 import com.android.wm.shell.splitscreen.SplitScreen;
 
 import java.io.FileDescriptor;
@@ -108,6 +108,7 @@
 
 import dagger.Lazy;
 
+
 /**
  * Class to send information from overview to launcher with a binder.
  */
diff --git a/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIBinder.java b/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIBinder.java
index f277b30..bde88b1 100644
--- a/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIBinder.java
+++ b/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIBinder.java
@@ -17,7 +17,7 @@
 package com.android.systemui.tv;
 
 import com.android.systemui.dagger.GlobalRootComponent;
-import com.android.systemui.pip.tv.dagger.TvPipModule;
+import com.android.systemui.wmshell.TvPipModule;
 
 import dagger.Binds;
 import dagger.Module;
diff --git a/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java b/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java
index 90b95ea..0d63324 100644
--- a/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java
+++ b/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java
@@ -25,6 +25,7 @@
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.systemui.R;
 import com.android.systemui.SystemUI;
+import com.android.wm.shell.pip.tv.PipNotification;
 
 import java.util.Arrays;
 
@@ -34,8 +35,8 @@
     public static String SCREENSHOTS_HEADSUP = "SCN_HEADSUP";
     public static String GENERAL     = "GEN";
     public static String STORAGE     = "DSK";
-    public static String TVPIP       = "TPP";
     public static String BATTERY     = "BAT";
+    public static String TVPIP       = PipNotification.NOTIFICATION_CHANNEL_TVPIP;
     public static String HINTS       = "HNT";
 
     public NotificationChannels(Context context) {
diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/dagger/TvPipModule.java b/packages/SystemUI/src/com/android/systemui/wmshell/TvPipModule.java
similarity index 63%
rename from packages/SystemUI/src/com/android/systemui/pip/tv/dagger/TvPipModule.java
rename to packages/SystemUI/src/com/android/systemui/wmshell/TvPipModule.java
index f094854..247baf8 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/tv/dagger/TvPipModule.java
+++ b/packages/SystemUI/src/com/android/systemui/wmshell/TvPipModule.java
@@ -14,45 +14,38 @@
  * limitations under the License.
  */
 
-package com.android.systemui.pip.tv.dagger;
+package com.android.systemui.wmshell;
 
-import android.app.Activity;
 import android.content.Context;
+import android.os.Handler;
+import android.view.LayoutInflater;
 
 import com.android.systemui.dagger.SysUISingleton;
-import com.android.systemui.pip.Pip;
-import com.android.systemui.pip.PipBoundsHandler;
-import com.android.systemui.pip.PipSurfaceTransactionHelper;
-import com.android.systemui.pip.PipTaskOrganizer;
-import com.android.systemui.pip.PipUiEventLogger;
-import com.android.systemui.pip.tv.PipController;
-import com.android.systemui.pip.tv.PipMenuActivity;
-import com.android.systemui.pip.tv.PipNotification;
-import com.android.systemui.wmshell.WindowManagerShellWrapper;
 import com.android.wm.shell.ShellTaskOrganizer;
+import com.android.wm.shell.WindowManagerShellWrapper;
 import com.android.wm.shell.common.DisplayController;
+import com.android.wm.shell.pip.Pip;
+import com.android.wm.shell.pip.PipBoundsHandler;
+import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
+import com.android.wm.shell.pip.PipTaskOrganizer;
+import com.android.wm.shell.pip.PipUiEventLogger;
+import com.android.wm.shell.pip.tv.PipController;
+import com.android.wm.shell.pip.tv.PipControlsView;
+import com.android.wm.shell.pip.tv.PipControlsViewController;
+import com.android.wm.shell.pip.tv.PipNotification;
 import com.android.wm.shell.splitscreen.SplitScreen;
 
 import java.util.Optional;
 
-import dagger.Binds;
 import dagger.Module;
 import dagger.Provides;
-import dagger.multibindings.ClassKey;
-import dagger.multibindings.IntoMap;
 
 /**
  * Dagger module for TV Pip.
  */
-@Module(subcomponents = {TvPipComponent.class})
+@Module
 public abstract class TvPipModule {
 
-    /** Inject into PipMenuActivity. */
-    @Binds
-    @IntoMap
-    @ClassKey(PipMenuActivity.class)
-    public abstract Activity providePipMenuActivity(PipMenuActivity activity);
-
     @SysUISingleton
     @Provides
     static Pip providePipController(Context context,
@@ -65,6 +58,21 @@
 
     @SysUISingleton
     @Provides
+    static PipControlsViewController providePipControlsViewContrller(
+            PipControlsView pipControlsView, PipController pipController,
+            LayoutInflater layoutInflater, Handler handler) {
+        return new PipControlsViewController(pipControlsView, pipController, layoutInflater,
+                handler);
+    }
+
+    @SysUISingleton
+    @Provides
+    static PipControlsView providePipControlsView(Context context) {
+        return new PipControlsView(context, null);
+    }
+
+    @SysUISingleton
+    @Provides
     static PipNotification providePipNotification(Context context,
             PipController pipController) {
         return new PipNotification(context, pipController);
@@ -72,13 +80,13 @@
 
     @SysUISingleton
     @Provides
-    static PipBoundsHandler providesPipBoundsHandler(Context context) {
+    static PipBoundsHandler providePipBoundsHandler(Context context) {
         return new PipBoundsHandler(context);
     }
 
     @SysUISingleton
     @Provides
-    static PipTaskOrganizer providesPipTaskOrganizer(Context context,
+    static PipTaskOrganizer providePipTaskOrganizer(Context context,
             PipBoundsHandler pipBoundsHandler,
             PipSurfaceTransactionHelper pipSurfaceTransactionHelper,
             Optional<SplitScreen> splitScreenOptional, DisplayController displayController,
diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/TvWMShellModule.java b/packages/SystemUI/src/com/android/systemui/wmshell/TvWMShellModule.java
index 1e6a9e8..56efffc 100644
--- a/packages/SystemUI/src/com/android/systemui/wmshell/TvWMShellModule.java
+++ b/packages/SystemUI/src/com/android/systemui/wmshell/TvWMShellModule.java
@@ -22,7 +22,6 @@
 
 import com.android.systemui.dagger.SysUISingleton;
 import com.android.systemui.dagger.qualifiers.Main;
-import com.android.systemui.pip.tv.dagger.TvPipModule;
 import com.android.wm.shell.ShellTaskOrganizer;
 import com.android.wm.shell.common.DisplayController;
 import com.android.wm.shell.common.DisplayImeController;
diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java b/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java
index 250c592..b828535 100644
--- a/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java
+++ b/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java
@@ -55,8 +55,6 @@
 import com.android.systemui.keyguard.ScreenLifecycle;
 import com.android.systemui.model.SysUiState;
 import com.android.systemui.navigationbar.NavigationModeController;
-import com.android.systemui.pip.Pip;
-import com.android.systemui.pip.phone.PipUtils;
 import com.android.systemui.shared.system.ActivityManagerWrapper;
 import com.android.systemui.shared.system.InputConsumerController;
 import com.android.systemui.shared.system.TaskStackChangeListener;
@@ -73,6 +71,8 @@
 import com.android.wm.shell.onehanded.OneHandedEvents;
 import com.android.wm.shell.onehanded.OneHandedGestureHandler.OneHandedGestureEventCallback;
 import com.android.wm.shell.onehanded.OneHandedTransitionCallback;
+import com.android.wm.shell.pip.Pip;
+import com.android.wm.shell.pip.phone.PipUtils;
 import com.android.wm.shell.protolog.ShellProtoLogImpl;
 import com.android.wm.shell.splitscreen.SplitScreen;
 
diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/WMShellBaseModule.java b/packages/SystemUI/src/com/android/systemui/wmshell/WMShellBaseModule.java
index dfb30b4..bb3b1b4 100644
--- a/packages/SystemUI/src/com/android/systemui/wmshell/WMShellBaseModule.java
+++ b/packages/SystemUI/src/com/android/systemui/wmshell/WMShellBaseModule.java
@@ -27,22 +27,23 @@
 import com.android.systemui.bubbles.Bubbles;
 import com.android.systemui.dagger.SysUISingleton;
 import com.android.systemui.dagger.qualifiers.Main;
-import com.android.systemui.pip.Pip;
-import com.android.systemui.pip.PipSurfaceTransactionHelper;
-import com.android.systemui.pip.PipUiEventLogger;
-import com.android.systemui.pip.phone.PipAppOpsListener;
-import com.android.systemui.pip.phone.PipMediaController;
-import com.android.systemui.pip.phone.PipTouchHandler;
 import com.android.systemui.shared.system.InputConsumerController;
 import com.android.systemui.util.DeviceConfigProxy;
-import com.android.systemui.util.FloatingContentCoordinator;
 import com.android.wm.shell.ShellTaskOrganizer;
+import com.android.wm.shell.WindowManagerShellWrapper;
 import com.android.wm.shell.animation.FlingAnimationUtils;
 import com.android.wm.shell.common.DisplayController;
+import com.android.wm.shell.common.FloatingContentCoordinator;
 import com.android.wm.shell.common.SyncTransactionQueue;
 import com.android.wm.shell.common.SystemWindows;
 import com.android.wm.shell.common.TransactionPool;
 import com.android.wm.shell.onehanded.OneHanded;
+import com.android.wm.shell.pip.Pip;
+import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
+import com.android.wm.shell.pip.PipUiEventLogger;
+import com.android.wm.shell.pip.phone.PipAppOpsListener;
+import com.android.wm.shell.pip.phone.PipMediaController;
+import com.android.wm.shell.pip.phone.PipTouchHandler;
 import com.android.wm.shell.splitscreen.SplitScreen;
 
 import dagger.BindsOptionalOf;
@@ -89,7 +90,7 @@
 
     @SysUISingleton
     @Provides
-    static PipAppOpsListener providesPipAppOpsListener(Context context,
+    static PipAppOpsListener providePipAppOpsListener(Context context,
             IActivityManager activityManager,
             PipTouchHandler pipTouchHandler) {
         return new PipAppOpsListener(context, activityManager, pipTouchHandler.getMotionHelper());
@@ -97,7 +98,7 @@
 
     @SysUISingleton
     @Provides
-    static PipMediaController providesPipMediaController(Context context,
+    static PipMediaController providePipMediaController(Context context,
             IActivityManager activityManager) {
         return new PipMediaController(context, activityManager);
     }
diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/WMShellModule.java b/packages/SystemUI/src/com/android/systemui/wmshell/WMShellModule.java
index b4852b2..61c3f9c 100644
--- a/packages/SystemUI/src/com/android/systemui/wmshell/WMShellModule.java
+++ b/packages/SystemUI/src/com/android/systemui/wmshell/WMShellModule.java
@@ -22,25 +22,26 @@
 
 import com.android.systemui.dagger.SysUISingleton;
 import com.android.systemui.dagger.qualifiers.Main;
-import com.android.systemui.pip.Pip;
-import com.android.systemui.pip.PipBoundsHandler;
-import com.android.systemui.pip.PipSurfaceTransactionHelper;
-import com.android.systemui.pip.PipTaskOrganizer;
-import com.android.systemui.pip.PipUiEventLogger;
-import com.android.systemui.pip.phone.PipAppOpsListener;
-import com.android.systemui.pip.phone.PipController;
-import com.android.systemui.pip.phone.PipMediaController;
-import com.android.systemui.pip.phone.PipMenuActivityController;
-import com.android.systemui.pip.phone.PipTouchHandler;
-import com.android.systemui.util.FloatingContentCoordinator;
 import com.android.wm.shell.ShellTaskOrganizer;
+import com.android.wm.shell.WindowManagerShellWrapper;
 import com.android.wm.shell.common.DisplayController;
 import com.android.wm.shell.common.DisplayImeController;
+import com.android.wm.shell.common.FloatingContentCoordinator;
 import com.android.wm.shell.common.SyncTransactionQueue;
 import com.android.wm.shell.common.SystemWindows;
 import com.android.wm.shell.common.TransactionPool;
 import com.android.wm.shell.onehanded.OneHanded;
 import com.android.wm.shell.onehanded.OneHandedController;
+import com.android.wm.shell.pip.Pip;
+import com.android.wm.shell.pip.PipBoundsHandler;
+import com.android.wm.shell.pip.PipSurfaceTransactionHelper;
+import com.android.wm.shell.pip.PipTaskOrganizer;
+import com.android.wm.shell.pip.PipUiEventLogger;
+import com.android.wm.shell.pip.phone.PipAppOpsListener;
+import com.android.wm.shell.pip.phone.PipController;
+import com.android.wm.shell.pip.phone.PipMediaController;
+import com.android.wm.shell.pip.phone.PipMenuActivityController;
+import com.android.wm.shell.pip.phone.PipTouchHandler;
 import com.android.wm.shell.splitscreen.SplitScreen;
 import com.android.wm.shell.splitscreen.SplitScreenController;
 
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
index 2f8d3f6..08ccd854 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java
@@ -91,8 +91,8 @@
 import com.android.systemui.statusbar.policy.ConfigurationController;
 import com.android.systemui.statusbar.policy.HeadsUpManager;
 import com.android.systemui.statusbar.policy.ZenModeController;
-import com.android.systemui.util.FloatingContentCoordinator;
-import com.android.systemui.wmshell.WindowManagerShellWrapper;
+import com.android.wm.shell.WindowManagerShellWrapper;
+import com.android.wm.shell.common.FloatingContentCoordinator;
 
 import com.google.common.collect.ImmutableList;
 
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java
index cfbd398..1eaa6a4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/NewNotifPipelineBubbleControllerTest.java
@@ -90,9 +90,9 @@
 import com.android.systemui.statusbar.policy.ConfigurationController;
 import com.android.systemui.statusbar.policy.HeadsUpManager;
 import com.android.systemui.statusbar.policy.ZenModeController;
-import com.android.systemui.util.FloatingContentCoordinator;
 import com.android.systemui.util.InjectionInflationController;
-import com.android.systemui.wmshell.WindowManagerShellWrapper;
+import com.android.wm.shell.WindowManagerShellWrapper;
+import com.android.wm.shell.common.FloatingContentCoordinator;
 
 import org.junit.Before;
 import org.junit.Ignore;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/TestableBubbleController.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/TestableBubbleController.java
index ec9571a..87ea22a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/TestableBubbleController.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/TestableBubbleController.java
@@ -35,8 +35,9 @@
 import com.android.systemui.statusbar.phone.ShadeController;
 import com.android.systemui.statusbar.policy.ConfigurationController;
 import com.android.systemui.statusbar.policy.ZenModeController;
-import com.android.systemui.util.FloatingContentCoordinator;
-import com.android.systemui.wmshell.WindowManagerShellWrapper;
+import com.android.wm.shell.WindowManagerShellWrapper;
+import com.android.wm.shell.common.FloatingContentCoordinator;
+
 
 /**
  * Testable BubbleController subclass that immediately synchronizes surfaces.
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/StackAnimationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/StackAnimationControllerTest.java
index cc62a2f..9242ce9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/StackAnimationControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/bubbles/animation/StackAnimationControllerTest.java
@@ -33,7 +33,7 @@
 import androidx.test.filters.SmallTest;
 
 import com.android.systemui.R;
-import com.android.systemui.util.FloatingContentCoordinator;
+import com.android.wm.shell.common.FloatingContentCoordinator;
 
 import org.junit.Before;
 import org.junit.Ignore;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/recents/OverviewProxyServiceTest.java b/packages/SystemUI/tests/src/com/android/systemui/recents/OverviewProxyServiceTest.java
index 727f91c..0c3db57 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/recents/OverviewProxyServiceTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/recents/OverviewProxyServiceTest.java
@@ -36,11 +36,11 @@
 import com.android.systemui.model.SysUiState;
 import com.android.systemui.navigationbar.NavigationBarController;
 import com.android.systemui.navigationbar.NavigationModeController;
-import com.android.systemui.pip.Pip;
 import com.android.systemui.shared.recents.IPinnedStackAnimationListener;
 import com.android.systemui.statusbar.CommandQueue;
 import com.android.systemui.statusbar.NotificationShadeWindowController;
 import com.android.systemui.statusbar.phone.StatusBar;
+import com.android.wm.shell.pip.Pip;
 import com.android.wm.shell.splitscreen.SplitScreen;
 
 import org.junit.Before;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/util/FloatingContentCoordinatorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/util/FloatingContentCoordinatorTest.kt
index 8eecde1..31848a6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/util/FloatingContentCoordinatorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/util/FloatingContentCoordinatorTest.kt
@@ -5,6 +5,7 @@
 import android.testing.TestableLooper
 import androidx.test.filters.SmallTest
 import com.android.systemui.SysuiTestCase
+import com.android.wm.shell.common.FloatingContentCoordinator
 import org.junit.After
 import org.junit.Assert.assertEquals
 import org.junit.Assert.assertFalse
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/WMShellTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/WMShellTest.java
index 0b75950..a5fbf19 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/WMShellTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/WMShellTest.java
@@ -36,8 +36,6 @@
 import com.android.systemui.keyguard.ScreenLifecycle;
 import com.android.systemui.model.SysUiState;
 import com.android.systemui.navigationbar.NavigationModeController;
-import com.android.systemui.pip.Pip;
-import com.android.systemui.pip.phone.PipTouchHandler;
 import com.android.systemui.shared.system.ActivityManagerWrapper;
 import com.android.systemui.shared.system.InputConsumerController;
 import com.android.systemui.shared.system.TaskStackChangeListener;
@@ -49,6 +47,8 @@
 import com.android.wm.shell.onehanded.OneHanded;
 import com.android.wm.shell.onehanded.OneHandedGestureHandler;
 import com.android.wm.shell.onehanded.OneHandedTransitionCallback;
+import com.android.wm.shell.pip.Pip;
+import com.android.wm.shell.pip.phone.PipTouchHandler;
 import com.android.wm.shell.splitscreen.SplitScreen;
 
 import org.junit.Before;
@@ -70,6 +70,7 @@
     @Mock KeyguardUpdateMonitor mKeyguardUpdateMonitor;
     @Mock ActivityManagerWrapper mActivityManagerWrapper;
     @Mock DisplayImeController mDisplayImeController;
+    @Mock InputConsumerController mMockInputConsumerController;
     @Mock NavigationModeController mNavigationModeController;
     @Mock ScreenLifecycle mScreenLifecycle;
     @Mock SysUiState mSysUiState;
@@ -112,17 +113,22 @@
 
     @Test
     public void nonPipDevice_shouldNotInitPip() {
-        TestableContext spiedContext = spy(mContext);
-        when(mMockPackageManager.hasSystemFeature(FEATURE_PICTURE_IN_PICTURE)).thenReturn(false);
-        when(spiedContext.getPackageManager()).thenReturn(mMockPackageManager);
-        final WMShell nonPipWMShell = new WMShell(spiedContext, mCommandQueue,
-                mConfigurationController, mInputConsumerController, mKeyguardUpdateMonitor,
+        final TestableContext nonPipContext = getNonPipFeatureContext();
+        final WMShell nonPipWMShell = new WMShell(nonPipContext, mCommandQueue,
+                mConfigurationController, mMockInputConsumerController, mKeyguardUpdateMonitor,
                 mActivityManagerWrapper, mDisplayImeController, mNavigationModeController,
                 mScreenLifecycle, mSysUiState, Optional.of(mPip), Optional.of(mSplitScreen),
                 Optional.of(mOneHanded), mTaskOrganizer, mProtoTracer);
         nonPipWMShell.initPip(mPip);
 
         verify(mCommandQueue, never()).addCallback(any());
+        verify(mKeyguardUpdateMonitor, never()).registerCallback(any());
+        verify(mConfigurationController, never()).addCallback(any());
+        verify(mSysUiState, never()).addCallback(any());
+        verify(mActivityManagerWrapper, never()).registerTaskStackListener(any());
+        verify(mMockInputConsumerController, never()).setInputListener(any());
+        verify(mMockInputConsumerController, never()).setRegistrationListener(any());
+        verify(mPip, never()).registerSessionListenerForCurrentUser();
     }
 
     @Test
@@ -151,4 +157,11 @@
                 OneHandedGestureHandler.OneHandedGestureEventCallback.class));
         verify(mOneHanded).registerTransitionCallback(any(OneHandedTransitionCallback.class));
     }
+
+    TestableContext getNonPipFeatureContext() {
+        TestableContext spiedContext = spy(mContext);
+        when(mMockPackageManager.hasSystemFeature(FEATURE_PICTURE_IN_PICTURE)).thenReturn(false);
+        when(spiedContext.getPackageManager()).thenReturn(mMockPackageManager);
+        return spiedContext;
+    }
 }