Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java +40 −32 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ import android.os.RemoteException; import android.util.Size; import android.view.MotionEvent; import android.view.SurfaceControl; import android.view.View; import android.view.ViewRootImpl; import android.view.WindowManagerGlobal; import com.android.internal.protolog.common.ProtoLog; Loading Loading @@ -131,6 +133,8 @@ public class PhonePipMenuController implements PipMenuController { private PipMenuView mPipMenuView; private SurfaceControl mLeash; private ActionListener mMediaActionListener = new ActionListener() { @Override public void onMediaActionsChanged(List<RemoteAction> mediaActions) { Loading Loading @@ -166,6 +170,7 @@ public class PhonePipMenuController implements PipMenuController { */ @Override public void attach(SurfaceControl leash) { mLeash = leash; attachPipMenuView(); } Loading @@ -176,6 +181,7 @@ public class PhonePipMenuController implements PipMenuController { public void detach() { hideMenu(); detachPipMenuView(); mLeash = null; } void attachPipMenuView() { Loading @@ -185,6 +191,36 @@ public class PhonePipMenuController implements PipMenuController { } mPipMenuView = new PipMenuView(mContext, this, mMainExecutor, mMainHandler, 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, getPipMenuLayoutParams(mContext, MENU_WINDOW_TITLE, 0 /* width */, 0 /* height */), 0, SHELL_ROOT_LAYER_PIP); Loading Loading @@ -321,30 +357,10 @@ public class PhonePipMenuController implements PipMenuController { return; } // If there is no pip leash supplied, that means the PiP leash is already finalized // 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) { mPipMenuView.getBoundsOnScreen(mTmpSourceBounds); } 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); // TODO(b/286307861) transaction should be applied outside of PiP menu controller if (pipLeash != null && t != null) { // Merge the two transactions, vsyncId has been set on menuTx. menuTx.merge(t); t.apply(); } menuTx.apply(); } /** Loading @@ -362,18 +378,10 @@ public class PhonePipMenuController implements PipMenuController { return; } final SurfaceControl surfaceControl = getSurfaceControl(); if (surfaceControl == null) { return; } final SurfaceControl.Transaction menuTx = mSurfaceControlTransactionFactory.getTransaction(); menuTx.setCrop(surfaceControl, destinationBounds); // TODO(b/286307861) transaction should be applied outside of PiP menu controller if (pipLeash != null && t != null) { // Merge the two transactions, vsyncId has been set on menuTx. menuTx.merge(t); t.apply(); } menuTx.apply(); } private boolean checkPipMenuState() { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PhonePipMenuController.java +40 −32 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ import android.os.RemoteException; import android.util.Size; import android.view.MotionEvent; import android.view.SurfaceControl; import android.view.View; import android.view.ViewRootImpl; import android.view.WindowManagerGlobal; import com.android.internal.protolog.common.ProtoLog; Loading Loading @@ -131,6 +133,8 @@ public class PhonePipMenuController implements PipMenuController { private PipMenuView mPipMenuView; private SurfaceControl mLeash; private ActionListener mMediaActionListener = new ActionListener() { @Override public void onMediaActionsChanged(List<RemoteAction> mediaActions) { Loading Loading @@ -166,6 +170,7 @@ public class PhonePipMenuController implements PipMenuController { */ @Override public void attach(SurfaceControl leash) { mLeash = leash; attachPipMenuView(); } Loading @@ -176,6 +181,7 @@ public class PhonePipMenuController implements PipMenuController { public void detach() { hideMenu(); detachPipMenuView(); mLeash = null; } void attachPipMenuView() { Loading @@ -185,6 +191,36 @@ public class PhonePipMenuController implements PipMenuController { } mPipMenuView = new PipMenuView(mContext, this, mMainExecutor, mMainHandler, 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, getPipMenuLayoutParams(mContext, MENU_WINDOW_TITLE, 0 /* width */, 0 /* height */), 0, SHELL_ROOT_LAYER_PIP); Loading Loading @@ -321,30 +357,10 @@ public class PhonePipMenuController implements PipMenuController { return; } // If there is no pip leash supplied, that means the PiP leash is already finalized // 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) { mPipMenuView.getBoundsOnScreen(mTmpSourceBounds); } 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); // TODO(b/286307861) transaction should be applied outside of PiP menu controller if (pipLeash != null && t != null) { // Merge the two transactions, vsyncId has been set on menuTx. menuTx.merge(t); t.apply(); } menuTx.apply(); } /** Loading @@ -362,18 +378,10 @@ public class PhonePipMenuController implements PipMenuController { return; } final SurfaceControl surfaceControl = getSurfaceControl(); if (surfaceControl == null) { return; } final SurfaceControl.Transaction menuTx = mSurfaceControlTransactionFactory.getTransaction(); menuTx.setCrop(surfaceControl, destinationBounds); // TODO(b/286307861) transaction should be applied outside of PiP menu controller if (pipLeash != null && t != null) { // Merge the two transactions, vsyncId has been set on menuTx. menuTx.merge(t); t.apply(); } menuTx.apply(); } private boolean checkPipMenuState() { Loading