Merge "Reparent PiP menu under the PiP task" into udc-dev am: 05ff134729
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23605149 Change-Id: I55eea59349e136f8dbbe1159dc02ea72e87738d5 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -31,6 +31,8 @@ import android.os.RemoteException;
|
|||||||
import android.util.Size;
|
import android.util.Size;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewRootImpl;
|
||||||
import android.view.WindowManagerGlobal;
|
import android.view.WindowManagerGlobal;
|
||||||
|
|
||||||
import com.android.internal.protolog.common.ProtoLog;
|
import com.android.internal.protolog.common.ProtoLog;
|
||||||
@@ -131,6 +133,8 @@ public class PhonePipMenuController implements PipMenuController {
|
|||||||
|
|
||||||
private PipMenuView mPipMenuView;
|
private PipMenuView mPipMenuView;
|
||||||
|
|
||||||
|
private SurfaceControl mLeash;
|
||||||
|
|
||||||
private ActionListener mMediaActionListener = new ActionListener() {
|
private ActionListener mMediaActionListener = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onMediaActionsChanged(List<RemoteAction> mediaActions) {
|
public void onMediaActionsChanged(List<RemoteAction> mediaActions) {
|
||||||
@@ -166,6 +170,7 @@ public class PhonePipMenuController implements PipMenuController {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void attach(SurfaceControl leash) {
|
public void attach(SurfaceControl leash) {
|
||||||
|
mLeash = leash;
|
||||||
attachPipMenuView();
|
attachPipMenuView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,6 +181,7 @@ public class PhonePipMenuController implements PipMenuController {
|
|||||||
public void detach() {
|
public void detach() {
|
||||||
hideMenu();
|
hideMenu();
|
||||||
detachPipMenuView();
|
detachPipMenuView();
|
||||||
|
mLeash = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void attachPipMenuView() {
|
void attachPipMenuView() {
|
||||||
@@ -185,6 +191,36 @@ public class PhonePipMenuController implements PipMenuController {
|
|||||||
}
|
}
|
||||||
mPipMenuView = new PipMenuView(mContext, this, mMainExecutor, mMainHandler,
|
mPipMenuView = new PipMenuView(mContext, this, mMainExecutor, mMainHandler,
|
||||||
mSplitScreenController, mPipUiEventLogger);
|
mSplitScreenController, mPipUiEventLogger);
|
||||||
|
mPipMenuView.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onViewAttachedToWindow(View v) {
|
||||||
|
v.getViewRootImpl().addSurfaceChangedCallback(
|
||||||
|
new ViewRootImpl.SurfaceChangedCallback() {
|
||||||
|
@Override
|
||||||
|
public void surfaceCreated(SurfaceControl.Transaction t) {
|
||||||
|
final SurfaceControl sc = getSurfaceControl();
|
||||||
|
if (sc != null) {
|
||||||
|
t.reparent(sc, mLeash);
|
||||||
|
// make menu on top of the surface
|
||||||
|
t.setLayer(sc, Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void surfaceReplaced(SurfaceControl.Transaction t) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void surfaceDestroyed() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewDetachedFromWindow(View v) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mSystemWindows.addView(mPipMenuView,
|
mSystemWindows.addView(mPipMenuView,
|
||||||
getPipMenuLayoutParams(mContext, MENU_WINDOW_TITLE, 0 /* width */, 0 /* height */),
|
getPipMenuLayoutParams(mContext, MENU_WINDOW_TITLE, 0 /* width */, 0 /* height */),
|
||||||
0, SHELL_ROOT_LAYER_PIP);
|
0, SHELL_ROOT_LAYER_PIP);
|
||||||
@@ -321,30 +357,10 @@ public class PhonePipMenuController implements PipMenuController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is no pip leash supplied, that means the PiP leash is already finalized
|
// TODO(b/286307861) transaction should be applied outside of PiP menu controller
|
||||||
// resizing and the PiP menu is also resized. We then want to do a scale from the current
|
|
||||||
// new menu bounds.
|
|
||||||
if (pipLeash != null && t != null) {
|
if (pipLeash != null && t != null) {
|
||||||
mPipMenuView.getBoundsOnScreen(mTmpSourceBounds);
|
t.apply();
|
||||||
} else {
|
|
||||||
mTmpSourceBounds.set(0, 0, destinationBounds.width(), destinationBounds.height());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mTmpSourceRectF.set(mTmpSourceBounds);
|
|
||||||
mTmpDestinationRectF.set(destinationBounds);
|
|
||||||
mMoveTransform.setRectToRect(mTmpSourceRectF, mTmpDestinationRectF, Matrix.ScaleToFit.FILL);
|
|
||||||
final SurfaceControl surfaceControl = getSurfaceControl();
|
|
||||||
if (surfaceControl == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final SurfaceControl.Transaction menuTx =
|
|
||||||
mSurfaceControlTransactionFactory.getTransaction();
|
|
||||||
menuTx.setMatrix(surfaceControl, mMoveTransform, mTmpTransform);
|
|
||||||
if (pipLeash != null && t != null) {
|
|
||||||
// Merge the two transactions, vsyncId has been set on menuTx.
|
|
||||||
menuTx.merge(t);
|
|
||||||
}
|
|
||||||
menuTx.apply();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -362,18 +378,10 @@ public class PhonePipMenuController implements PipMenuController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final SurfaceControl surfaceControl = getSurfaceControl();
|
// TODO(b/286307861) transaction should be applied outside of PiP menu controller
|
||||||
if (surfaceControl == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final SurfaceControl.Transaction menuTx =
|
|
||||||
mSurfaceControlTransactionFactory.getTransaction();
|
|
||||||
menuTx.setCrop(surfaceControl, destinationBounds);
|
|
||||||
if (pipLeash != null && t != null) {
|
if (pipLeash != null && t != null) {
|
||||||
// Merge the two transactions, vsyncId has been set on menuTx.
|
t.apply();
|
||||||
menuTx.merge(t);
|
|
||||||
}
|
}
|
||||||
menuTx.apply();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkPipMenuState() {
|
private boolean checkPipMenuState() {
|
||||||
|
|||||||
Reference in New Issue
Block a user