Loading core/java/android/view/IPinnedStackController.aidl +8 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,14 @@ interface IPinnedStackController { */ oneway void setIsMinimized(boolean isMinimized); /** * Notifies the controller of the current min edge size, this is needed to allow the system to * properly calculate the aspect ratio of the expanded PIP. The given {@param minEdgeSize} is * always bounded to be larger than the default minEdgeSize, so the caller can call this method * with 0 to reset to the default size. */ oneway void setMinEdgeSize(int minEdgeSize); /** * @return what WM considers to be the current device rotation. */ Loading packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java +7 −1 Original line number Diff line number Diff line Loading @@ -716,9 +716,15 @@ public class PipTouchHandler { * Updates the current movement bounds based on whether the menu is currently visible. */ private void updateMovementBounds(int menuState) { mMovementBounds = menuState == MENU_STATE_FULL boolean isMenuExpanded = menuState == MENU_STATE_FULL; mMovementBounds = isMenuExpanded ? mExpandedMovementBounds : mNormalMovementBounds; try { mPinnedStackController.setMinEdgeSize(isMenuExpanded ? mExpandedShortestEdgeSize : 0); } catch (RemoteException e) { Log.e(TAG, "Could not set minimized state", e); } } /** Loading services/core/java/com/android/server/am/ActivityStackSupervisor.java +2 −2 Original line number Diff line number Diff line Loading @@ -2989,8 +2989,8 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // Calculate the default bounds (don't use existing stack bounds as we may have just created // the stack, and schedule the start of the animation into PiP (the bounds animator that // is triggered by this is posted on another thread) final Rect destBounds = stack.getPictureInPictureBounds(aspectRatio, false /* useExistingStackBounds */); final Rect destBounds = stack.getDefaultPictureInPictureBounds(aspectRatio); stack.animateResizePinnedStack(sourceHintBounds, destBounds, -1 /* animationDuration */, true /* fromFullscreen */); Loading services/core/java/com/android/server/am/PinnedActivityStack.java +2 −2 Original line number Diff line number Diff line Loading @@ -44,9 +44,9 @@ class PinnedActivityStack extends ActivityStack<PinnedStackWindowController> return new PinnedStackWindowController(mStackId, this, displayId, onTop, outBounds); } Rect getPictureInPictureBounds(float aspectRatio, boolean useExistingStackBounds) { Rect getDefaultPictureInPictureBounds(float aspectRatio) { return getWindowContainerController().getPictureInPictureBounds(aspectRatio, useExistingStackBounds); null /* currentStackBounds */); } void animateResizePinnedStack(Rect sourceHintBounds, Rect toBounds, int animationDuration, Loading services/core/java/com/android/server/wm/PinnedStackController.java +22 −18 Original line number Diff line number Diff line Loading @@ -92,17 +92,16 @@ class PinnedStackController { private final Rect mStableInsets = new Rect(); // The size and position information that describes where the pinned stack will go by default. private int mDefaultMinSize; private int mDefaultStackGravity; private float mDefaultAspectRatio; private Point mScreenEdgeInsets; private int mCurrentMinSize; // The aspect ratio bounds of the PIP. private float mMinAspectRatio; private float mMaxAspectRatio; // The minimum edge size of the normal PiP bounds. private int mMinSize; // Temp vars for calculation private final DisplayMetrics mTmpMetrics = new DisplayMetrics(); private final Rect mTmpInsets = new Rect(); Loading @@ -123,6 +122,13 @@ class PinnedStackController { }); } @Override public void setMinEdgeSize(int minEdgeSize) { mHandler.post(() -> { mCurrentMinSize = Math.max(mDefaultMinSize, minEdgeSize); }); } @Override public int getDisplayRotation() { synchronized (mService.mWindowMap) { Loading Loading @@ -160,10 +166,12 @@ class PinnedStackController { */ private void reloadResources() { final Resources res = mService.mContext.getResources(); mMinSize = res.getDimensionPixelSize( mDefaultMinSize = res.getDimensionPixelSize( com.android.internal.R.dimen.default_minimal_size_pip_resizable_task); mCurrentMinSize = mDefaultMinSize; mDefaultAspectRatio = res.getFloat( com.android.internal.R.dimen.config_pictureInPictureDefaultAspectRatio); mAspectRatio = mDefaultAspectRatio; final String screenEdgeInsetsDpString = res.getString( com.android.internal.R.string.config_defaultPictureInPictureScreenEdgeInsets); final Size screenEdgeInsetsDp = !screenEdgeInsetsDpString.isEmpty() Loading Loading @@ -212,11 +220,15 @@ class PinnedStackController { * Returns the current bounds (or the default bounds if there are no current bounds) with the * specified aspect ratio. */ Rect transformBoundsToAspectRatio(Rect stackBounds, float aspectRatio) { Rect transformBoundsToAspectRatio(Rect stackBounds, float aspectRatio, boolean useCurrentMinEdgeSize) { // Save the snap fraction, calculate the aspect ratio based on screen size final float snapFraction = mSnapAlgorithm.getSnapFraction(stackBounds, getMovementBounds(stackBounds)); final Size size = getSize(aspectRatio); final int minEdgeSize = useCurrentMinEdgeSize ? mCurrentMinSize : mDefaultMinSize; final Size size = mSnapAlgorithm.getSizeForAspectRatio(aspectRatio, minEdgeSize, mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight); final int left = (int) (stackBounds.centerX() - size.getWidth() / 2f); final int top = (int) (stackBounds.centerY() - size.getHeight() / 2f); stackBounds.set(left, top, left + size.getWidth(), top + size.getHeight()); Loading @@ -227,16 +239,6 @@ class PinnedStackController { return stackBounds; } /** * @return the size of the PIP based on the given {@param aspectRatio}. */ Size getSize(float aspectRatio) { synchronized (mService.mWindowMap) { return mSnapAlgorithm.getSizeForAspectRatio(aspectRatio, mMinSize, mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight); } } /** * @return the default bounds to show the PIP when there is no active PIP. */ Loading @@ -246,7 +248,8 @@ class PinnedStackController { getInsetBounds(insetBounds); final Rect defaultBounds = new Rect(); final Size size = getSize(mDefaultAspectRatio); final Size size = mSnapAlgorithm.getSizeForAspectRatio(mDefaultAspectRatio, mDefaultMinSize, mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight); Gravity.apply(mDefaultStackGravity, size.getWidth(), size.getHeight(), insetBounds, 0, mIsImeShowing ? mImeHeight : 0, defaultBounds); return defaultBounds; Loading Loading @@ -401,7 +404,8 @@ class PinnedStackController { getInsetBounds(insetBounds); final Rect normalBounds = getDefaultBounds(); if (isValidPictureInPictureAspectRatio(mAspectRatio)) { transformBoundsToAspectRatio(normalBounds, mAspectRatio); transformBoundsToAspectRatio(normalBounds, mAspectRatio, false /* useCurrentMinEdgeSize */); } final Rect animatingBounds = mTmpAnimatingBoundsRect; final TaskStack pinnedStack = mDisplayContent.getStackById(PINNED_STACK_ID); Loading Loading
core/java/android/view/IPinnedStackController.aidl +8 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,14 @@ interface IPinnedStackController { */ oneway void setIsMinimized(boolean isMinimized); /** * Notifies the controller of the current min edge size, this is needed to allow the system to * properly calculate the aspect ratio of the expanded PIP. The given {@param minEdgeSize} is * always bounded to be larger than the default minEdgeSize, so the caller can call this method * with 0 to reset to the default size. */ oneway void setMinEdgeSize(int minEdgeSize); /** * @return what WM considers to be the current device rotation. */ Loading
packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java +7 −1 Original line number Diff line number Diff line Loading @@ -716,9 +716,15 @@ public class PipTouchHandler { * Updates the current movement bounds based on whether the menu is currently visible. */ private void updateMovementBounds(int menuState) { mMovementBounds = menuState == MENU_STATE_FULL boolean isMenuExpanded = menuState == MENU_STATE_FULL; mMovementBounds = isMenuExpanded ? mExpandedMovementBounds : mNormalMovementBounds; try { mPinnedStackController.setMinEdgeSize(isMenuExpanded ? mExpandedShortestEdgeSize : 0); } catch (RemoteException e) { Log.e(TAG, "Could not set minimized state", e); } } /** Loading
services/core/java/com/android/server/am/ActivityStackSupervisor.java +2 −2 Original line number Diff line number Diff line Loading @@ -2989,8 +2989,8 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // Calculate the default bounds (don't use existing stack bounds as we may have just created // the stack, and schedule the start of the animation into PiP (the bounds animator that // is triggered by this is posted on another thread) final Rect destBounds = stack.getPictureInPictureBounds(aspectRatio, false /* useExistingStackBounds */); final Rect destBounds = stack.getDefaultPictureInPictureBounds(aspectRatio); stack.animateResizePinnedStack(sourceHintBounds, destBounds, -1 /* animationDuration */, true /* fromFullscreen */); Loading
services/core/java/com/android/server/am/PinnedActivityStack.java +2 −2 Original line number Diff line number Diff line Loading @@ -44,9 +44,9 @@ class PinnedActivityStack extends ActivityStack<PinnedStackWindowController> return new PinnedStackWindowController(mStackId, this, displayId, onTop, outBounds); } Rect getPictureInPictureBounds(float aspectRatio, boolean useExistingStackBounds) { Rect getDefaultPictureInPictureBounds(float aspectRatio) { return getWindowContainerController().getPictureInPictureBounds(aspectRatio, useExistingStackBounds); null /* currentStackBounds */); } void animateResizePinnedStack(Rect sourceHintBounds, Rect toBounds, int animationDuration, Loading
services/core/java/com/android/server/wm/PinnedStackController.java +22 −18 Original line number Diff line number Diff line Loading @@ -92,17 +92,16 @@ class PinnedStackController { private final Rect mStableInsets = new Rect(); // The size and position information that describes where the pinned stack will go by default. private int mDefaultMinSize; private int mDefaultStackGravity; private float mDefaultAspectRatio; private Point mScreenEdgeInsets; private int mCurrentMinSize; // The aspect ratio bounds of the PIP. private float mMinAspectRatio; private float mMaxAspectRatio; // The minimum edge size of the normal PiP bounds. private int mMinSize; // Temp vars for calculation private final DisplayMetrics mTmpMetrics = new DisplayMetrics(); private final Rect mTmpInsets = new Rect(); Loading @@ -123,6 +122,13 @@ class PinnedStackController { }); } @Override public void setMinEdgeSize(int minEdgeSize) { mHandler.post(() -> { mCurrentMinSize = Math.max(mDefaultMinSize, minEdgeSize); }); } @Override public int getDisplayRotation() { synchronized (mService.mWindowMap) { Loading Loading @@ -160,10 +166,12 @@ class PinnedStackController { */ private void reloadResources() { final Resources res = mService.mContext.getResources(); mMinSize = res.getDimensionPixelSize( mDefaultMinSize = res.getDimensionPixelSize( com.android.internal.R.dimen.default_minimal_size_pip_resizable_task); mCurrentMinSize = mDefaultMinSize; mDefaultAspectRatio = res.getFloat( com.android.internal.R.dimen.config_pictureInPictureDefaultAspectRatio); mAspectRatio = mDefaultAspectRatio; final String screenEdgeInsetsDpString = res.getString( com.android.internal.R.string.config_defaultPictureInPictureScreenEdgeInsets); final Size screenEdgeInsetsDp = !screenEdgeInsetsDpString.isEmpty() Loading Loading @@ -212,11 +220,15 @@ class PinnedStackController { * Returns the current bounds (or the default bounds if there are no current bounds) with the * specified aspect ratio. */ Rect transformBoundsToAspectRatio(Rect stackBounds, float aspectRatio) { Rect transformBoundsToAspectRatio(Rect stackBounds, float aspectRatio, boolean useCurrentMinEdgeSize) { // Save the snap fraction, calculate the aspect ratio based on screen size final float snapFraction = mSnapAlgorithm.getSnapFraction(stackBounds, getMovementBounds(stackBounds)); final Size size = getSize(aspectRatio); final int minEdgeSize = useCurrentMinEdgeSize ? mCurrentMinSize : mDefaultMinSize; final Size size = mSnapAlgorithm.getSizeForAspectRatio(aspectRatio, minEdgeSize, mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight); final int left = (int) (stackBounds.centerX() - size.getWidth() / 2f); final int top = (int) (stackBounds.centerY() - size.getHeight() / 2f); stackBounds.set(left, top, left + size.getWidth(), top + size.getHeight()); Loading @@ -227,16 +239,6 @@ class PinnedStackController { return stackBounds; } /** * @return the size of the PIP based on the given {@param aspectRatio}. */ Size getSize(float aspectRatio) { synchronized (mService.mWindowMap) { return mSnapAlgorithm.getSizeForAspectRatio(aspectRatio, mMinSize, mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight); } } /** * @return the default bounds to show the PIP when there is no active PIP. */ Loading @@ -246,7 +248,8 @@ class PinnedStackController { getInsetBounds(insetBounds); final Rect defaultBounds = new Rect(); final Size size = getSize(mDefaultAspectRatio); final Size size = mSnapAlgorithm.getSizeForAspectRatio(mDefaultAspectRatio, mDefaultMinSize, mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight); Gravity.apply(mDefaultStackGravity, size.getWidth(), size.getHeight(), insetBounds, 0, mIsImeShowing ? mImeHeight : 0, defaultBounds); return defaultBounds; Loading Loading @@ -401,7 +404,8 @@ class PinnedStackController { getInsetBounds(insetBounds); final Rect normalBounds = getDefaultBounds(); if (isValidPictureInPictureAspectRatio(mAspectRatio)) { transformBoundsToAspectRatio(normalBounds, mAspectRatio); transformBoundsToAspectRatio(normalBounds, mAspectRatio, false /* useCurrentMinEdgeSize */); } final Rect animatingBounds = mTmpAnimatingBoundsRect; final TaskStack pinnedStack = mDisplayContent.getStackById(PINNED_STACK_ID); Loading