Refactor PiP logic in preparation for expanded state.
- #1: Move logic for handling IME size changes into SysUI, and only rely
on PinnedStackController to provide bounds when first entering
PiP and on rotation
- #2: Doing #1 allows us to move PipMotionHelper to SysUI completely, which
lets us aggregate the animation calls out of PipTouchHandler
- #3: Add proper callbacks to the listeners when the movement bounds
changed from config change, ime change, or aspect ratio change. This
allows SysUI to calculate the associated movement bounds for the
expanded state, and we can then remove the corresponding WM call.
It also means that SysUI is the only thing that needs to know about
the expanded state.
- #4: Fix issue where TV was getting the default bounds, not taking the
aspect ratio when the PiP was entered into account. Doing #3
allows us to report the right bounds.
- #5: Remove dead code related to edge snapping/minimizing now that they
are on by default and associated tuner setting, and controller
callbacks
Test: android.server.cts.ActivityManagerPinnedStackTests (all existing tests pass)
Change-Id: I3ef361bdf8d44094b4c0a11c70ba4db7d697fdec
Signed-off-by: Winson Chung <winsonc@google.com>
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
index 3df557d..f59b2a4 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
@@ -16,20 +16,16 @@
package com.android.systemui.pip.phone;
-import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.view.Display.DEFAULT_DISPLAY;
import android.app.ActivityManager;
-import android.app.ActivityManager.StackInfo;
-import android.app.ActivityOptions;
import android.app.IActivityManager;
import android.content.ComponentName;
import android.content.Context;
-import android.content.Intent;
import android.content.pm.ParceledListSlice;
+import android.graphics.Rect;
import android.os.Handler;
import android.os.RemoteException;
-import android.os.UserHandle;
import android.util.Log;
import android.view.IPinnedStackController;
import android.view.IPinnedStackListener;
@@ -94,7 +90,7 @@
}
}
if (expandPipToFullscreen) {
- mTouchHandler.expandPinnedStackToFullscreen();
+ mTouchHandler.getMotionHelper().expandPip();
} else {
Log.w(TAG, "Can not expand PiP to fullscreen via intent from the same package.");
}
@@ -114,28 +110,31 @@
}
@Override
- public void onBoundsChanged(boolean adjustedForIme) {
- // Do nothing
- }
-
- @Override
- public void onActionsChanged(ParceledListSlice actions) {
+ public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) {
mHandler.post(() -> {
- mMenuController.setAppActions(actions);
+ mTouchHandler.onImeVisibilityChanged(imeVisible, imeHeight);
});
}
@Override
public void onMinimizedStateChanged(boolean isMinimized) {
mHandler.post(() -> {
- mTouchHandler.onMinimizedStateChanged(isMinimized);
+ mTouchHandler.setMinimizedState(isMinimized, true /* fromController */);
});
}
@Override
- public void onSnapToEdgeStateChanged(boolean isSnapToEdge) {
+ public void onMovementBoundsChanged(Rect insetBounds, Rect normalBounds,
+ boolean fromImeAdjustement) {
mHandler.post(() -> {
- mTouchHandler.onSnapToEdgeStateChanged(isSnapToEdge);
+ mTouchHandler.onMovementBoundsChanged(insetBounds, normalBounds, fromImeAdjustement);
+ });
+ }
+
+ @Override
+ public void onActionsChanged(ParceledListSlice actions) {
+ mHandler.post(() -> {
+ mMenuController.setAppActions(actions);
});
}
}