Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server.wm; |
| 18 | |
Wale Ogunwale | 6827856 | 2017-09-23 17:13:55 -0700 | [diff] [blame] | 19 | import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; |
Wale Ogunwale | b62139d | 2017-09-20 15:37:35 -0700 | [diff] [blame] | 20 | import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 21 | import static android.util.TypedValue.COMPLEX_UNIT_DIP; |
| 22 | |
Yi Jin | 6c6e9ca | 2018-03-20 16:53:35 -0700 | [diff] [blame] | 23 | import static com.android.server.wm.PinnedStackControllerProto.DEFAULT_BOUNDS; |
| 24 | import static com.android.server.wm.PinnedStackControllerProto.MOVEMENT_BOUNDS; |
Evan Rosky | 35630df | 2018-10-31 10:22:08 -0700 | [diff] [blame] | 25 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
| 26 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 27 | |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 28 | import android.app.RemoteAction; |
| 29 | import android.content.pm.ParceledListSlice; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 30 | import android.content.res.Resources; |
| 31 | import android.graphics.Point; |
| 32 | import android.graphics.Rect; |
| 33 | import android.os.Handler; |
| 34 | import android.os.IBinder; |
| 35 | import android.os.RemoteException; |
| 36 | import android.util.DisplayMetrics; |
| 37 | import android.util.Log; |
| 38 | import android.util.Size; |
| 39 | import android.util.Slog; |
| 40 | import android.util.TypedValue; |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 41 | import android.util.proto.ProtoOutputStream; |
Winson Chung | 14fefc2 | 2016-11-02 10:02:29 -0700 | [diff] [blame] | 42 | import android.view.DisplayInfo; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 43 | import android.view.Gravity; |
| 44 | import android.view.IPinnedStackController; |
| 45 | import android.view.IPinnedStackListener; |
| 46 | |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 47 | import com.android.internal.policy.PipSnapAlgorithm; |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 48 | import com.android.server.UiThread; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 49 | |
| 50 | import java.io.PrintWriter; |
Winson Chung | e55c019 | 2017-08-24 14:50:48 -0700 | [diff] [blame] | 51 | import java.lang.ref.WeakReference; |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 52 | import java.util.ArrayList; |
| 53 | import java.util.List; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 54 | |
| 55 | /** |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 56 | * Holds the common state of the pinned stack between the system and SystemUI. If SystemUI ever |
| 57 | * needs to be restarted, it will be notified with the last known state. |
| 58 | * |
| 59 | * Changes to the pinned stack also flow through this controller, and generally, the system only |
| 60 | * changes the pinned stack bounds through this controller in two ways: |
| 61 | * |
| 62 | * 1) When first entering PiP: the controller returns the valid bounds given, taking aspect ratio |
| 63 | * and IME state into account. |
| 64 | * 2) When rotating the device: the controller calculates the new bounds in the new orientation, |
| 65 | * taking the minimized and IME state into account. In this case, we currently ignore the |
| 66 | * SystemUI adjustments (ie. expanded for menu, interaction, etc). |
| 67 | * |
| 68 | * Other changes in the system, including adjustment of IME, configuration change, and more are |
| 69 | * handled by SystemUI (similar to the docked stack divider). |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 70 | */ |
| 71 | class PinnedStackController { |
| 72 | |
| 73 | private static final String TAG = TAG_WITH_CLASS_NAME ? "PinnedStackController" : TAG_WM; |
| 74 | |
Winson Chung | e55c019 | 2017-08-24 14:50:48 -0700 | [diff] [blame] | 75 | public static final float INVALID_SNAP_FRACTION = -1f; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 76 | private final WindowManagerService mService; |
| 77 | private final DisplayContent mDisplayContent; |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 78 | private final Handler mHandler = UiThread.getHandler(); |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 79 | |
| 80 | private IPinnedStackListener mPinnedStackListener; |
| 81 | private final PinnedStackListenerDeathHandler mPinnedStackListenerDeathHandler = |
| 82 | new PinnedStackListenerDeathHandler(); |
| 83 | |
| 84 | private final PinnedStackControllerCallback mCallbacks = new PinnedStackControllerCallback(); |
| 85 | private final PipSnapAlgorithm mSnapAlgorithm; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 86 | |
| 87 | // States that affect how the PIP can be manipulated |
Winson Chung | fa705378 | 2016-11-08 15:45:10 -0800 | [diff] [blame] | 88 | private boolean mIsMinimized; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 89 | private boolean mIsImeShowing; |
| 90 | private int mImeHeight; |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 91 | private boolean mIsShelfShowing; |
| 92 | private int mShelfHeight; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 93 | |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 94 | // The set of actions and aspect-ratio for the that are currently allowed on the PiP activity |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 95 | private ArrayList<RemoteAction> mActions = new ArrayList<>(); |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 96 | private float mAspectRatio = -1f; |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 97 | |
Winson Chung | 14fefc2 | 2016-11-02 10:02:29 -0700 | [diff] [blame] | 98 | // Used to calculate stack bounds across rotations |
| 99 | private final DisplayInfo mDisplayInfo = new DisplayInfo(); |
Winson Chung | 114aeea | 2017-01-09 16:08:07 -0800 | [diff] [blame] | 100 | private final Rect mStableInsets = new Rect(); |
Winson Chung | 14fefc2 | 2016-11-02 10:02:29 -0700 | [diff] [blame] | 101 | |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 102 | // The size and position information that describes where the pinned stack will go by default. |
Winson Chung | a71febe | 2017-05-22 11:14:22 -0700 | [diff] [blame] | 103 | private int mDefaultMinSize; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 104 | private int mDefaultStackGravity; |
Mady Mellor | a7f6974 | 2017-02-03 11:00:20 -0800 | [diff] [blame] | 105 | private float mDefaultAspectRatio; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 106 | private Point mScreenEdgeInsets; |
Winson Chung | a71febe | 2017-05-22 11:14:22 -0700 | [diff] [blame] | 107 | private int mCurrentMinSize; |
Winson Chung | e55c019 | 2017-08-24 14:50:48 -0700 | [diff] [blame] | 108 | private float mReentrySnapFraction = INVALID_SNAP_FRACTION; |
| 109 | private WeakReference<AppWindowToken> mLastPipActivity = null; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 110 | |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 111 | // The aspect ratio bounds of the PIP. |
| 112 | private float mMinAspectRatio; |
| 113 | private float mMaxAspectRatio; |
| 114 | |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 115 | // Temp vars for calculation |
| 116 | private final DisplayMetrics mTmpMetrics = new DisplayMetrics(); |
| 117 | private final Rect mTmpInsets = new Rect(); |
Jorim Jaggi | ad5d284 | 2016-11-01 18:22:53 -0700 | [diff] [blame] | 118 | private final Rect mTmpRect = new Rect(); |
Winson Chung | 34a07f4 | 2017-03-10 18:06:25 -0800 | [diff] [blame] | 119 | private final Rect mTmpAnimatingBoundsRect = new Rect(); |
Winson Chung | f1f72f6 | 2017-02-14 17:15:48 -0800 | [diff] [blame] | 120 | private final Point mTmpDisplaySize = new Point(); |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 121 | |
Winson Chung | e55c019 | 2017-08-24 14:50:48 -0700 | [diff] [blame] | 122 | |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 123 | /** |
| 124 | * The callback object passed to listeners for them to notify the controller of state changes. |
| 125 | */ |
| 126 | private class PinnedStackControllerCallback extends IPinnedStackController.Stub { |
| 127 | |
| 128 | @Override |
Winson Chung | fa705378 | 2016-11-08 15:45:10 -0800 | [diff] [blame] | 129 | public void setIsMinimized(final boolean isMinimized) { |
| 130 | mHandler.post(() -> { |
| 131 | mIsMinimized = isMinimized; |
Mady Mellor | 3b10dcd | 2017-01-23 10:08:35 -0800 | [diff] [blame] | 132 | mSnapAlgorithm.setMinimized(isMinimized); |
Winson Chung | fa705378 | 2016-11-08 15:45:10 -0800 | [diff] [blame] | 133 | }); |
| 134 | } |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 135 | |
| 136 | @Override |
Winson Chung | a71febe | 2017-05-22 11:14:22 -0700 | [diff] [blame] | 137 | public void setMinEdgeSize(int minEdgeSize) { |
| 138 | mHandler.post(() -> { |
| 139 | mCurrentMinSize = Math.max(mDefaultMinSize, minEdgeSize); |
| 140 | }); |
| 141 | } |
| 142 | |
| 143 | @Override |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 144 | public int getDisplayRotation() { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 145 | synchronized (mService.mGlobalLock) { |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 146 | return mDisplayInfo.rotation; |
| 147 | } |
| 148 | } |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | /** |
| 152 | * Handler for the case where the listener dies. |
| 153 | */ |
| 154 | private class PinnedStackListenerDeathHandler implements IBinder.DeathRecipient { |
| 155 | |
| 156 | @Override |
| 157 | public void binderDied() { |
| 158 | // Clean up the state if the listener dies |
Winson Chung | 397967f | 2017-11-01 16:21:35 -0700 | [diff] [blame] | 159 | if (mPinnedStackListener != null) { |
| 160 | mPinnedStackListener.asBinder().unlinkToDeath(mPinnedStackListenerDeathHandler, 0); |
| 161 | } |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 162 | mPinnedStackListener = null; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | PinnedStackController(WindowManagerService service, DisplayContent displayContent) { |
| 167 | mService = service; |
| 168 | mDisplayContent = displayContent; |
| 169 | mSnapAlgorithm = new PipSnapAlgorithm(service.mContext); |
Winson Chung | 14fefc2 | 2016-11-02 10:02:29 -0700 | [diff] [blame] | 170 | mDisplayInfo.copyFrom(mDisplayContent.getDisplayInfo()); |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 171 | reloadResources(); |
Winson Chung | 401f78e | 2017-06-16 10:52:40 -0700 | [diff] [blame] | 172 | // Initialize the aspect ratio to the default aspect ratio. Don't do this in reload |
| 173 | // resources as it would clobber mAspectRatio when entering PiP from fullscreen which |
| 174 | // triggers a configuration change and the resources to be reloaded. |
| 175 | mAspectRatio = mDefaultAspectRatio; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | void onConfigurationChanged() { |
| 179 | reloadResources(); |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Reloads all the resources for the current configuration. |
| 184 | */ |
Wale Ogunwale | 027f475 | 2017-05-12 10:37:16 -0700 | [diff] [blame] | 185 | private void reloadResources() { |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 186 | final Resources res = mService.mContext.getResources(); |
Winson Chung | a71febe | 2017-05-22 11:14:22 -0700 | [diff] [blame] | 187 | mDefaultMinSize = res.getDimensionPixelSize( |
Mady Mellor | a7f6974 | 2017-02-03 11:00:20 -0800 | [diff] [blame] | 188 | com.android.internal.R.dimen.default_minimal_size_pip_resizable_task); |
Winson Chung | a71febe | 2017-05-22 11:14:22 -0700 | [diff] [blame] | 189 | mCurrentMinSize = mDefaultMinSize; |
Mady Mellor | a7f6974 | 2017-02-03 11:00:20 -0800 | [diff] [blame] | 190 | mDefaultAspectRatio = res.getFloat( |
| 191 | com.android.internal.R.dimen.config_pictureInPictureDefaultAspectRatio); |
Wale Ogunwale | 027f475 | 2017-05-12 10:37:16 -0700 | [diff] [blame] | 192 | final String screenEdgeInsetsDpString = res.getString( |
| 193 | com.android.internal.R.string.config_defaultPictureInPictureScreenEdgeInsets); |
| 194 | final Size screenEdgeInsetsDp = !screenEdgeInsetsDpString.isEmpty() |
| 195 | ? Size.parseSize(screenEdgeInsetsDpString) |
| 196 | : null; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 197 | mDefaultStackGravity = res.getInteger( |
| 198 | com.android.internal.R.integer.config_defaultPictureInPictureGravity); |
| 199 | mDisplayContent.getDisplay().getRealMetrics(mTmpMetrics); |
Wale Ogunwale | 027f475 | 2017-05-12 10:37:16 -0700 | [diff] [blame] | 200 | mScreenEdgeInsets = screenEdgeInsetsDp == null ? new Point() |
| 201 | : new Point(dpToPx(screenEdgeInsetsDp.getWidth(), mTmpMetrics), |
| 202 | dpToPx(screenEdgeInsetsDp.getHeight(), mTmpMetrics)); |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 203 | mMinAspectRatio = res.getFloat( |
| 204 | com.android.internal.R.dimen.config_pictureInPictureMinAspectRatio); |
| 205 | mMaxAspectRatio = res.getFloat( |
| 206 | com.android.internal.R.dimen.config_pictureInPictureMaxAspectRatio); |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | /** |
| 210 | * Registers a pinned stack listener. |
| 211 | */ |
| 212 | void registerPinnedStackListener(IPinnedStackListener listener) { |
| 213 | try { |
| 214 | listener.asBinder().linkToDeath(mPinnedStackListenerDeathHandler, 0); |
| 215 | listener.onListenerRegistered(mCallbacks); |
| 216 | mPinnedStackListener = listener; |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 217 | notifyImeVisibilityChanged(mIsImeShowing, mImeHeight); |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 218 | notifyShelfVisibilityChanged(mIsShelfShowing, mShelfHeight); |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 219 | // The movement bounds notification needs to be sent before the minimized state, since |
| 220 | // SystemUI may use the bounds to retore the minimized position |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 221 | notifyMovementBoundsChanged(false /* fromImeAdjustment */, |
| 222 | false /* fromShelfAdjustment */); |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 223 | notifyActionsChanged(mActions); |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 224 | notifyMinimizeChanged(mIsMinimized); |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 225 | } catch (RemoteException e) { |
| 226 | Log.e(TAG, "Failed to register pinned stack listener", e); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | /** |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 231 | * @return whether the given {@param aspectRatio} is valid. |
| 232 | */ |
| 233 | public boolean isValidPictureInPictureAspectRatio(float aspectRatio) { |
Winson Chung | bd04196 | 2017-03-06 15:07:25 -0800 | [diff] [blame] | 234 | return Float.compare(mMinAspectRatio, aspectRatio) <= 0 && |
| 235 | Float.compare(aspectRatio, mMaxAspectRatio) <= 0; |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | /** |
Winson Chung | 84a3834 | 2016-11-08 16:15:10 -0800 | [diff] [blame] | 239 | * Returns the current bounds (or the default bounds if there are no current bounds) with the |
| 240 | * specified aspect ratio. |
| 241 | */ |
Winson Chung | a71febe | 2017-05-22 11:14:22 -0700 | [diff] [blame] | 242 | Rect transformBoundsToAspectRatio(Rect stackBounds, float aspectRatio, |
| 243 | boolean useCurrentMinEdgeSize) { |
Mady Mellor | a7f6974 | 2017-02-03 11:00:20 -0800 | [diff] [blame] | 244 | // Save the snap fraction, calculate the aspect ratio based on screen size |
Winson Chung | 84a3834 | 2016-11-08 16:15:10 -0800 | [diff] [blame] | 245 | final float snapFraction = mSnapAlgorithm.getSnapFraction(stackBounds, |
| 246 | getMovementBounds(stackBounds)); |
Winson Chung | a71febe | 2017-05-22 11:14:22 -0700 | [diff] [blame] | 247 | |
| 248 | final int minEdgeSize = useCurrentMinEdgeSize ? mCurrentMinSize : mDefaultMinSize; |
| 249 | final Size size = mSnapAlgorithm.getSizeForAspectRatio(aspectRatio, minEdgeSize, |
| 250 | mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight); |
Mady Mellor | a7f6974 | 2017-02-03 11:00:20 -0800 | [diff] [blame] | 251 | final int left = (int) (stackBounds.centerX() - size.getWidth() / 2f); |
| 252 | final int top = (int) (stackBounds.centerY() - size.getHeight() / 2f); |
| 253 | stackBounds.set(left, top, left + size.getWidth(), top + size.getHeight()); |
Winson Chung | 84a3834 | 2016-11-08 16:15:10 -0800 | [diff] [blame] | 254 | mSnapAlgorithm.applySnapFraction(stackBounds, getMovementBounds(stackBounds), snapFraction); |
Winson Chung | f1f72f6 | 2017-02-14 17:15:48 -0800 | [diff] [blame] | 255 | if (mIsMinimized) { |
| 256 | applyMinimizedOffset(stackBounds, getMovementBounds(stackBounds)); |
| 257 | } |
Winson Chung | 84a3834 | 2016-11-08 16:15:10 -0800 | [diff] [blame] | 258 | return stackBounds; |
| 259 | } |
| 260 | |
| 261 | /** |
Winson Chung | e55c019 | 2017-08-24 14:50:48 -0700 | [diff] [blame] | 262 | * Saves the current snap fraction for re-entry of the current activity into PiP. |
| 263 | */ |
| 264 | void saveReentrySnapFraction(final AppWindowToken token, final Rect stackBounds) { |
| 265 | mReentrySnapFraction = getSnapFraction(stackBounds); |
| 266 | mLastPipActivity = new WeakReference<>(token); |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * Resets the last saved snap fraction so that the default bounds will be returned. |
| 271 | */ |
| 272 | void resetReentrySnapFraction(AppWindowToken token) { |
| 273 | if (mLastPipActivity != null && mLastPipActivity.get() == token) { |
| 274 | mReentrySnapFraction = INVALID_SNAP_FRACTION; |
| 275 | mLastPipActivity = null; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | /** |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 280 | * @return the default bounds to show the PIP when there is no active PIP. |
| 281 | */ |
Winson Chung | e55c019 | 2017-08-24 14:50:48 -0700 | [diff] [blame] | 282 | Rect getDefaultOrLastSavedBounds() { |
| 283 | return getDefaultBounds(mReentrySnapFraction); |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * @return the default bounds to show the PIP, if a {@param snapFraction} is provided, then it |
| 288 | * will apply the default bounds to the provided snap fraction. |
| 289 | */ |
| 290 | Rect getDefaultBounds(float snapFraction) { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 291 | synchronized (mService.mGlobalLock) { |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 292 | final Rect insetBounds = new Rect(); |
| 293 | getInsetBounds(insetBounds); |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 294 | |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 295 | final Rect defaultBounds = new Rect(); |
Winson Chung | a71febe | 2017-05-22 11:14:22 -0700 | [diff] [blame] | 296 | final Size size = mSnapAlgorithm.getSizeForAspectRatio(mDefaultAspectRatio, |
| 297 | mDefaultMinSize, mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight); |
Winson Chung | e55c019 | 2017-08-24 14:50:48 -0700 | [diff] [blame] | 298 | if (snapFraction != INVALID_SNAP_FRACTION) { |
| 299 | defaultBounds.set(0, 0, size.getWidth(), size.getHeight()); |
| 300 | final Rect movementBounds = getMovementBounds(defaultBounds); |
| 301 | mSnapAlgorithm.applySnapFraction(defaultBounds, movementBounds, snapFraction); |
| 302 | } else { |
| 303 | Gravity.apply(mDefaultStackGravity, size.getWidth(), size.getHeight(), insetBounds, |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 304 | 0, Math.max(mIsImeShowing ? mImeHeight : 0, |
| 305 | mIsShelfShowing ? mShelfHeight : 0), |
| 306 | defaultBounds); |
Winson Chung | e55c019 | 2017-08-24 14:50:48 -0700 | [diff] [blame] | 307 | } |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 308 | return defaultBounds; |
| 309 | } |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | /** |
Winson Chung | 32c566f | 2017-04-11 18:31:21 -0700 | [diff] [blame] | 313 | * In the case where the display rotation is changed but there is no stack, we can't depend on |
| 314 | * onTaskStackBoundsChanged() to be called. But we still should update our known display info |
| 315 | * with the new state so that we can update SystemUI. |
| 316 | */ |
Evan Rosky | 39b6f23 | 2018-10-30 18:35:41 -0700 | [diff] [blame] | 317 | synchronized void onDisplayInfoChanged(DisplayInfo displayInfo) { |
| 318 | mDisplayInfo.copyFrom(displayInfo); |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 319 | notifyMovementBoundsChanged(false /* fromImeAdjustment */, false /* fromShelfAdjustment */); |
Winson Chung | 32c566f | 2017-04-11 18:31:21 -0700 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | /** |
Winson Chung | 47f2bf6 | 2017-02-16 18:58:12 -0800 | [diff] [blame] | 323 | * Updates the display info, calculating and returning the new stack and movement bounds in the |
| 324 | * new orientation of the device if necessary. |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 325 | */ |
Winson Chung | 19953ca | 2017-04-11 11:19:23 -0700 | [diff] [blame] | 326 | boolean onTaskStackBoundsChanged(Rect targetBounds, Rect outBounds) { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 327 | synchronized (mService.mGlobalLock) { |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 328 | final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo(); |
| 329 | if (mDisplayInfo.equals(displayInfo)) { |
| 330 | // We are already in the right orientation, ignore |
| 331 | outBounds.setEmpty(); |
| 332 | return false; |
| 333 | } else if (targetBounds.isEmpty()) { |
| 334 | // The stack is null, we are just initializing the stack, so just store the display |
| 335 | // info and ignore |
| 336 | mDisplayInfo.copyFrom(displayInfo); |
| 337 | outBounds.setEmpty(); |
| 338 | return false; |
| 339 | } |
| 340 | |
| 341 | mTmpRect.set(targetBounds); |
| 342 | final Rect postChangeStackBounds = mTmpRect; |
| 343 | |
| 344 | // Calculate the snap fraction of the current stack along the old movement bounds |
Winson Chung | e55c019 | 2017-08-24 14:50:48 -0700 | [diff] [blame] | 345 | final float snapFraction = getSnapFraction(postChangeStackBounds); |
Winson Chung | 19953ca | 2017-04-11 11:19:23 -0700 | [diff] [blame] | 346 | mDisplayInfo.copyFrom(displayInfo); |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 347 | |
| 348 | // Calculate the stack bounds in the new orientation to the same same fraction along the |
| 349 | // rotated movement bounds. |
| 350 | final Rect postChangeMovementBounds = getMovementBounds(postChangeStackBounds, |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 351 | false /* adjustForIme */, false /* adjustForShelf */); |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 352 | mSnapAlgorithm.applySnapFraction(postChangeStackBounds, postChangeMovementBounds, |
| 353 | snapFraction); |
| 354 | if (mIsMinimized) { |
| 355 | applyMinimizedOffset(postChangeStackBounds, postChangeMovementBounds); |
| 356 | } |
| 357 | |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 358 | notifyMovementBoundsChanged(false /* fromImeAdjustment */, |
| 359 | false /* fromShelfAdjustment */); |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 360 | |
| 361 | outBounds.set(postChangeStackBounds); |
| 362 | return true; |
Winson Chung | 14fefc2 | 2016-11-02 10:02:29 -0700 | [diff] [blame] | 363 | } |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | /** |
| 367 | * Sets the Ime state and height. |
| 368 | */ |
| 369 | void setAdjustedForIme(boolean adjustedForIme, int imeHeight) { |
Winson Chung | 2a35e6d | 2018-01-13 14:27:50 -0800 | [diff] [blame] | 370 | // Due to the order of callbacks from the system, we may receive an ime height even when |
| 371 | // {@param adjustedForIme} is false, and also a zero height when {@param adjustedForIme} |
| 372 | // is true. Instead, ensure that the ime state changes with the height and if the ime is |
| 373 | // showing, then the height is non-zero. |
| 374 | final boolean imeShowing = adjustedForIme && imeHeight > 0; |
| 375 | imeHeight = imeShowing ? imeHeight : 0; |
| 376 | if (imeShowing == mIsImeShowing && imeHeight == mImeHeight) { |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 377 | return; |
| 378 | } |
| 379 | |
Winson Chung | 2a35e6d | 2018-01-13 14:27:50 -0800 | [diff] [blame] | 380 | mIsImeShowing = imeShowing; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 381 | mImeHeight = imeHeight; |
Winson Chung | 2a35e6d | 2018-01-13 14:27:50 -0800 | [diff] [blame] | 382 | notifyImeVisibilityChanged(imeShowing, imeHeight); |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 383 | notifyMovementBoundsChanged(true /* fromImeAdjustment */, false /* fromShelfAdjustment */); |
| 384 | } |
| 385 | |
| 386 | /** |
| 387 | * Sets the shelf state and height. |
| 388 | */ |
| 389 | void setAdjustedForShelf(boolean adjustedForShelf, int shelfHeight) { |
| 390 | final boolean shelfShowing = adjustedForShelf && shelfHeight > 0; |
| 391 | if (shelfShowing == mIsShelfShowing && shelfHeight == mShelfHeight) { |
| 392 | return; |
| 393 | } |
| 394 | |
| 395 | mIsShelfShowing = shelfShowing; |
| 396 | mShelfHeight = shelfHeight; |
| 397 | notifyShelfVisibilityChanged(shelfShowing, shelfHeight); |
| 398 | notifyMovementBoundsChanged(false /* fromImeAdjustment */, true /* fromShelfAdjustment */); |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | /** |
| 402 | * Sets the current aspect ratio. |
| 403 | */ |
| 404 | void setAspectRatio(float aspectRatio) { |
| 405 | if (Float.compare(mAspectRatio, aspectRatio) != 0) { |
| 406 | mAspectRatio = aspectRatio; |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 407 | notifyMovementBoundsChanged(false /* fromImeAdjustment */, |
| 408 | false /* fromShelfAdjustment */); |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 409 | } |
| 410 | } |
| 411 | |
| 412 | /** |
Winson Chung | c95ff84 | 2017-03-21 10:20:20 -0700 | [diff] [blame] | 413 | * @return the current aspect ratio. |
| 414 | */ |
| 415 | float getAspectRatio() { |
| 416 | return mAspectRatio; |
| 417 | } |
| 418 | |
| 419 | /** |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 420 | * Sets the current set of actions. |
| 421 | */ |
| 422 | void setActions(List<RemoteAction> actions) { |
| 423 | mActions.clear(); |
Winson Chung | c2baac0 | 2017-01-11 13:34:47 -0800 | [diff] [blame] | 424 | if (actions != null) { |
| 425 | mActions.addAll(actions); |
| 426 | } |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 427 | notifyActionsChanged(mActions); |
| 428 | } |
| 429 | |
| 430 | /** |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 431 | * Notifies listeners that the PIP needs to be adjusted for the IME. |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 432 | */ |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 433 | private void notifyImeVisibilityChanged(boolean imeVisible, int imeHeight) { |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 434 | if (mPinnedStackListener != null) { |
| 435 | try { |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 436 | mPinnedStackListener.onImeVisibilityChanged(imeVisible, imeHeight); |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 437 | } catch (RemoteException e) { |
| 438 | Slog.e(TAG_WM, "Error delivering bounds changed event.", e); |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 443 | private void notifyShelfVisibilityChanged(boolean shelfVisible, int shelfHeight) { |
| 444 | if (mPinnedStackListener != null) { |
| 445 | try { |
| 446 | mPinnedStackListener.onShelfVisibilityChanged(shelfVisible, shelfHeight); |
| 447 | } catch (RemoteException e) { |
| 448 | Slog.e(TAG_WM, "Error delivering bounds changed event.", e); |
| 449 | } |
| 450 | } |
| 451 | } |
| 452 | |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 453 | /** |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 454 | * Notifies listeners that the PIP minimized state has changed. |
| 455 | */ |
| 456 | private void notifyMinimizeChanged(boolean isMinimized) { |
| 457 | if (mPinnedStackListener != null) { |
| 458 | try { |
| 459 | mPinnedStackListener.onMinimizedStateChanged(isMinimized); |
| 460 | } catch (RemoteException e) { |
| 461 | Slog.e(TAG_WM, "Error delivering minimize changed event.", e); |
| 462 | } |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | /** |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 467 | * Notifies listeners that the PIP actions have changed. |
| 468 | */ |
| 469 | private void notifyActionsChanged(List<RemoteAction> actions) { |
| 470 | if (mPinnedStackListener != null) { |
| 471 | try { |
| 472 | mPinnedStackListener.onActionsChanged(new ParceledListSlice(actions)); |
| 473 | } catch (RemoteException e) { |
| 474 | Slog.e(TAG_WM, "Error delivering actions changed event.", e); |
| 475 | } |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | /** |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 480 | * Notifies listeners that the PIP movement bounds have changed. |
| 481 | */ |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 482 | private void notifyMovementBoundsChanged(boolean fromImeAdjustment, |
| 483 | boolean fromShelfAdjustment) { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 484 | synchronized (mService.mGlobalLock) { |
Wale Ogunwale | b62139d | 2017-09-20 15:37:35 -0700 | [diff] [blame] | 485 | if (mPinnedStackListener == null) { |
| 486 | return; |
| 487 | } |
| 488 | try { |
| 489 | final Rect insetBounds = new Rect(); |
| 490 | getInsetBounds(insetBounds); |
Winson Chung | e55c019 | 2017-08-24 14:50:48 -0700 | [diff] [blame] | 491 | final Rect normalBounds = getDefaultBounds(INVALID_SNAP_FRACTION); |
Wale Ogunwale | b62139d | 2017-09-20 15:37:35 -0700 | [diff] [blame] | 492 | if (isValidPictureInPictureAspectRatio(mAspectRatio)) { |
| 493 | transformBoundsToAspectRatio(normalBounds, mAspectRatio, |
| 494 | false /* useCurrentMinEdgeSize */); |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 495 | } |
Wale Ogunwale | b62139d | 2017-09-20 15:37:35 -0700 | [diff] [blame] | 496 | final Rect animatingBounds = mTmpAnimatingBoundsRect; |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 497 | final TaskStack pinnedStack = mDisplayContent.getPinnedStack(); |
Wale Ogunwale | b62139d | 2017-09-20 15:37:35 -0700 | [diff] [blame] | 498 | if (pinnedStack != null) { |
| 499 | pinnedStack.getAnimationOrCurrentBounds(animatingBounds); |
| 500 | } else { |
| 501 | animatingBounds.set(normalBounds); |
| 502 | } |
| 503 | mPinnedStackListener.onMovementBoundsChanged(insetBounds, normalBounds, |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 504 | animatingBounds, fromImeAdjustment, fromShelfAdjustment, |
| 505 | mDisplayInfo.rotation); |
Wale Ogunwale | b62139d | 2017-09-20 15:37:35 -0700 | [diff] [blame] | 506 | } catch (RemoteException e) { |
| 507 | Slog.e(TAG_WM, "Error delivering actions changed event.", e); |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 508 | } |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | /** |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 513 | * @return the bounds on the screen that the PIP can be visible in. |
| 514 | */ |
Winson Chung | 14fefc2 | 2016-11-02 10:02:29 -0700 | [diff] [blame] | 515 | private void getInsetBounds(Rect outRect) { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 516 | synchronized (mService.mGlobalLock) { |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 517 | mDisplayContent.getDisplayPolicy().getStableInsetsLw(mDisplayInfo.rotation, |
| 518 | mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight, |
| 519 | mDisplayInfo.displayCutout, mTmpInsets); |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 520 | outRect.set(mTmpInsets.left + mScreenEdgeInsets.x, mTmpInsets.top + mScreenEdgeInsets.y, |
| 521 | mDisplayInfo.logicalWidth - mTmpInsets.right - mScreenEdgeInsets.x, |
| 522 | mDisplayInfo.logicalHeight - mTmpInsets.bottom - mScreenEdgeInsets.y); |
| 523 | } |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | /** |
Winson Chung | 5589333 | 2017-02-17 17:13:10 -0800 | [diff] [blame] | 527 | * @return the movement bounds for the given {@param stackBounds} and the current state of the |
| 528 | * controller. |
| 529 | */ |
| 530 | private Rect getMovementBounds(Rect stackBounds) { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 531 | synchronized (mService.mGlobalLock) { |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 532 | return getMovementBounds(stackBounds, true /* adjustForIme */, |
| 533 | true /* adjustForShelf */); |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 534 | } |
Winson Chung | 5589333 | 2017-02-17 17:13:10 -0800 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | /** |
| 538 | * @return the movement bounds for the given {@param stackBounds} and the current state of the |
| 539 | * controller. |
| 540 | */ |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 541 | private Rect getMovementBounds(Rect stackBounds, boolean adjustForIme, boolean adjustForShelf) { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 542 | synchronized (mService.mGlobalLock) { |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 543 | final Rect movementBounds = new Rect(); |
| 544 | getInsetBounds(movementBounds); |
Winson Chung | 5589333 | 2017-02-17 17:13:10 -0800 | [diff] [blame] | 545 | |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 546 | // Apply the movement bounds adjustments based on the current state |
| 547 | mSnapAlgorithm.getMovementBounds(stackBounds, movementBounds, movementBounds, |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 548 | Math.max((adjustForIme && mIsImeShowing) ? mImeHeight : 0, |
| 549 | (adjustForShelf && mIsShelfShowing) ? mShelfHeight : 0)); |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 550 | return movementBounds; |
| 551 | } |
Winson Chung | 5589333 | 2017-02-17 17:13:10 -0800 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | /** |
Winson Chung | f1f72f6 | 2017-02-14 17:15:48 -0800 | [diff] [blame] | 555 | * Applies the minimized offsets to the given stack bounds. |
| 556 | */ |
| 557 | private void applyMinimizedOffset(Rect stackBounds, Rect movementBounds) { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 558 | synchronized (mService.mGlobalLock) { |
Winson Chung | ef4dc81 | 2017-04-11 13:31:44 -0700 | [diff] [blame] | 559 | mTmpDisplaySize.set(mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight); |
| 560 | mService.getStableInsetsLocked(mDisplayContent.getDisplayId(), mStableInsets); |
| 561 | mSnapAlgorithm.applyMinimizedOffset(stackBounds, movementBounds, mTmpDisplaySize, |
| 562 | mStableInsets); |
| 563 | } |
Winson Chung | f1f72f6 | 2017-02-14 17:15:48 -0800 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | /** |
Winson Chung | e55c019 | 2017-08-24 14:50:48 -0700 | [diff] [blame] | 567 | * @return the default snap fraction to apply instead of the default gravity when calculating |
| 568 | * the default stack bounds when first entering PiP. |
| 569 | */ |
| 570 | private float getSnapFraction(Rect stackBounds) { |
| 571 | return mSnapAlgorithm.getSnapFraction(stackBounds, getMovementBounds(stackBounds)); |
| 572 | } |
| 573 | |
| 574 | /** |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 575 | * @return the pixels for a given dp value. |
| 576 | */ |
| 577 | private int dpToPx(float dpValue, DisplayMetrics dm) { |
| 578 | return (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, dpValue, dm); |
| 579 | } |
| 580 | |
| 581 | void dump(String prefix, PrintWriter pw) { |
| 582 | pw.println(prefix + "PinnedStackController"); |
Winson Chung | e55c019 | 2017-08-24 14:50:48 -0700 | [diff] [blame] | 583 | pw.print(prefix + " defaultBounds="); |
| 584 | getDefaultBounds(INVALID_SNAP_FRACTION).printShortString(pw); |
Jorim Jaggi | ad5d284 | 2016-11-01 18:22:53 -0700 | [diff] [blame] | 585 | pw.println(); |
Winson Chung | 95b7b62 | 2018-10-05 15:00:01 -0700 | [diff] [blame] | 586 | pw.println(prefix + " mDefaultMinSize=" + mDefaultMinSize); |
| 587 | pw.println(prefix + " mDefaultStackGravity=" + mDefaultStackGravity); |
| 588 | pw.println(prefix + " mDefaultAspectRatio=" + mDefaultAspectRatio); |
Wale Ogunwale | 6827856 | 2017-09-23 17:13:55 -0700 | [diff] [blame] | 589 | mService.getStackBounds(WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD, mTmpRect); |
Jorim Jaggi | ad5d284 | 2016-11-01 18:22:53 -0700 | [diff] [blame] | 590 | pw.print(prefix + " movementBounds="); getMovementBounds(mTmpRect).printShortString(pw); |
| 591 | pw.println(); |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 592 | pw.println(prefix + " mIsImeShowing=" + mIsImeShowing); |
Tracy Zhou | 4351308 | 2018-03-08 21:58:36 -0800 | [diff] [blame] | 593 | pw.println(prefix + " mImeHeight=" + mImeHeight); |
| 594 | pw.println(prefix + " mIsShelfShowing=" + mIsShelfShowing); |
| 595 | pw.println(prefix + " mShelfHeight=" + mShelfHeight); |
Winson Chung | 8efa165 | 2018-06-06 09:34:23 -0700 | [diff] [blame] | 596 | pw.println(prefix + " mReentrySnapFraction=" + mReentrySnapFraction); |
Winson Chung | fa705378 | 2016-11-08 15:45:10 -0800 | [diff] [blame] | 597 | pw.println(prefix + " mIsMinimized=" + mIsMinimized); |
Winson Chung | 95b7b62 | 2018-10-05 15:00:01 -0700 | [diff] [blame] | 598 | pw.println(prefix + " mAspectRatio=" + mAspectRatio); |
| 599 | pw.println(prefix + " mMinAspectRatio=" + mMinAspectRatio); |
| 600 | pw.println(prefix + " mMaxAspectRatio=" + mMaxAspectRatio); |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 601 | if (mActions.isEmpty()) { |
| 602 | pw.println(prefix + " mActions=[]"); |
| 603 | } else { |
| 604 | pw.println(prefix + " mActions=["); |
| 605 | for (int i = 0; i < mActions.size(); i++) { |
| 606 | RemoteAction action = mActions.get(i); |
| 607 | pw.print(prefix + " Action[" + i + "]: "); |
| 608 | action.dump("", pw); |
| 609 | } |
| 610 | pw.println(prefix + " ]"); |
| 611 | } |
Winson Chung | 95b7b62 | 2018-10-05 15:00:01 -0700 | [diff] [blame] | 612 | pw.println(prefix + " mDisplayInfo=" + mDisplayInfo); |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 613 | } |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 614 | |
| 615 | void writeToProto(ProtoOutputStream proto, long fieldId) { |
| 616 | final long token = proto.start(fieldId); |
Winson Chung | e55c019 | 2017-08-24 14:50:48 -0700 | [diff] [blame] | 617 | getDefaultBounds(INVALID_SNAP_FRACTION).writeToProto(proto, DEFAULT_BOUNDS); |
Wale Ogunwale | 6827856 | 2017-09-23 17:13:55 -0700 | [diff] [blame] | 618 | mService.getStackBounds(WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD, mTmpRect); |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 619 | getMovementBounds(mTmpRect).writeToProto(proto, MOVEMENT_BOUNDS); |
| 620 | proto.end(token); |
| 621 | } |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 622 | } |