Winson | 73bc159 | 2016-10-18 18:47:43 -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.systemui.pip.phone; |
| 18 | |
Arthur Hung | d52d119 | 2019-08-30 16:06:59 +0800 | [diff] [blame] | 19 | import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; |
| 20 | import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; |
| 21 | |
Sudheer Shanka | dc589ac | 2016-11-10 15:30:17 -0800 | [diff] [blame] | 22 | import android.app.ActivityManager; |
Wale Ogunwale | 65ebd95 | 2018-04-25 15:41:44 -0700 | [diff] [blame] | 23 | import android.app.ActivityTaskManager; |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 24 | import android.app.IActivityManager; |
Wale Ogunwale | 65ebd95 | 2018-04-25 15:41:44 -0700 | [diff] [blame] | 25 | import android.app.IActivityTaskManager; |
Winson Chung | 3535df2 | 2017-01-17 18:43:39 -0800 | [diff] [blame] | 26 | import android.content.ComponentName; |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 27 | import android.content.Context; |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 28 | import android.content.pm.ParceledListSlice; |
Winson Chung | 0c5a592 | 2017-05-22 17:41:06 -0700 | [diff] [blame] | 29 | import android.content.res.Configuration; |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 30 | import android.graphics.Rect; |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 31 | import android.os.Handler; |
| 32 | import android.os.RemoteException; |
| 33 | import android.util.Log; |
Winson Chung | 85d3c8a | 2017-09-15 15:41:00 -0700 | [diff] [blame] | 34 | import android.util.Pair; |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 35 | import android.view.DisplayInfo; |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 36 | import android.view.IPinnedStackController; |
Gus Prevas | ab33679 | 2018-11-14 13:52:20 -0500 | [diff] [blame] | 37 | |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 38 | import com.android.systemui.Dependency; |
| 39 | import com.android.systemui.UiOffloadThread; |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame^] | 40 | import com.android.systemui.broadcast.BroadcastDispatcher; |
Winson Chung | 29a7865 | 2017-02-09 18:35:26 -0800 | [diff] [blame] | 41 | import com.android.systemui.pip.BasePipManager; |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 42 | import com.android.systemui.pip.PipBoundsHandler; |
Winson Chung | aa35745 | 2017-10-31 11:35:30 -0700 | [diff] [blame] | 43 | import com.android.systemui.shared.system.ActivityManagerWrapper; |
Winson Chung | cbb15a9 | 2018-01-25 17:46:16 +0000 | [diff] [blame] | 44 | import com.android.systemui.shared.system.InputConsumerController; |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 45 | import com.android.systemui.shared.system.PinnedStackListenerForwarder.PinnedStackListener; |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 46 | import com.android.systemui.shared.system.TaskStackChangeListener; |
| 47 | import com.android.systemui.shared.system.WindowManagerWrapper; |
Gus Prevas | ab33679 | 2018-11-14 13:52:20 -0500 | [diff] [blame] | 48 | |
Winson Chung | 29a7865 | 2017-02-09 18:35:26 -0800 | [diff] [blame] | 49 | import java.io.PrintWriter; |
| 50 | |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 51 | /** |
| 52 | * Manages the picture-in-picture (PIP) UI and states for Phones. |
| 53 | */ |
Winson Chung | 29a7865 | 2017-02-09 18:35:26 -0800 | [diff] [blame] | 54 | public class PipManager implements BasePipManager { |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 55 | private static final String TAG = "PipManager"; |
| 56 | |
| 57 | private static PipManager sPipController; |
| 58 | |
| 59 | private Context mContext; |
| 60 | private IActivityManager mActivityManager; |
Wale Ogunwale | 65ebd95 | 2018-04-25 15:41:44 -0700 | [diff] [blame] | 61 | private IActivityTaskManager mActivityTaskManager; |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 62 | private Handler mHandler = new Handler(); |
| 63 | |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 64 | private final PinnedStackListener mPinnedStackListener = new PipManagerPinnedStackListener(); |
| 65 | private final DisplayInfo mTmpDisplayInfo = new DisplayInfo(); |
| 66 | private final Rect mTmpInsetBounds = new Rect(); |
| 67 | private final Rect mTmpNormalBounds = new Rect(); |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 68 | |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 69 | private PipBoundsHandler mPipBoundsHandler; |
Winson Chung | d2d9097 | 2017-02-28 11:40:41 -0800 | [diff] [blame] | 70 | private InputConsumerController mInputConsumerController; |
Winson Chung | 15504af | 2016-11-02 18:11:36 -0700 | [diff] [blame] | 71 | private PipMenuActivityController mMenuController; |
Winson Chung | 97a60d9 | 2017-01-18 16:01:53 -0800 | [diff] [blame] | 72 | private PipMediaController mMediaController; |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 73 | private PipTouchHandler mTouchHandler; |
Winson Chung | 95bccdc | 2018-01-03 11:45:47 -0800 | [diff] [blame] | 74 | private PipAppOpsListener mAppOpsListener; |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 75 | |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 76 | /** |
Winson Chung | 929d4f7 | 2017-01-13 10:21:33 -0800 | [diff] [blame] | 77 | * Handler for system task stack changes. |
| 78 | */ |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 79 | TaskStackChangeListener mTaskStackListener = new TaskStackChangeListener() { |
Winson Chung | 929d4f7 | 2017-01-13 10:21:33 -0800 | [diff] [blame] | 80 | @Override |
Wale Ogunwale | 89be576 | 2017-10-04 13:27:49 -0700 | [diff] [blame] | 81 | public void onActivityPinned(String packageName, int userId, int taskId, int stackId) { |
Winson Chung | 929d4f7 | 2017-01-13 10:21:33 -0800 | [diff] [blame] | 82 | mTouchHandler.onActivityPinned(); |
Winson Chung | 97a60d9 | 2017-01-18 16:01:53 -0800 | [diff] [blame] | 83 | mMediaController.onActivityPinned(); |
Winson Chung | d2d9097 | 2017-02-28 11:40:41 -0800 | [diff] [blame] | 84 | mMenuController.onActivityPinned(); |
Winson Chung | 95bccdc | 2018-01-03 11:45:47 -0800 | [diff] [blame] | 85 | mAppOpsListener.onActivityPinned(packageName); |
Winson Chung | ac52f28 | 2017-03-30 14:44:52 -0700 | [diff] [blame] | 86 | |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 87 | Dependency.get(UiOffloadThread.class).submit(() -> { |
| 88 | WindowManagerWrapper.getInstance().setPipVisibility(true); |
| 89 | }); |
Winson Chung | c81c0ce | 2017-03-17 12:27:30 -0700 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public void onActivityUnpinned() { |
Winson Chung | 85d3c8a | 2017-09-15 15:41:00 -0700 | [diff] [blame] | 94 | final Pair<ComponentName, Integer> topPipActivityInfo = PipUtils.getTopPinnedActivity( |
| 95 | mContext, mActivityManager); |
| 96 | final ComponentName topActivity = topPipActivityInfo.first; |
Winson Chung | 85d3c8a | 2017-09-15 15:41:00 -0700 | [diff] [blame] | 97 | mMenuController.onActivityUnpinned(); |
| 98 | mTouchHandler.onActivityUnpinned(topActivity); |
Winson Chung | 95bccdc | 2018-01-03 11:45:47 -0800 | [diff] [blame] | 99 | mAppOpsListener.onActivityUnpinned(); |
Winson Chung | ac52f28 | 2017-03-30 14:44:52 -0700 | [diff] [blame] | 100 | |
Winson Chung | 67f5c8b | 2018-09-24 12:09:19 -0700 | [diff] [blame] | 101 | Dependency.get(UiOffloadThread.class).submit(() -> { |
| 102 | WindowManagerWrapper.getInstance().setPipVisibility(topActivity != null); |
| 103 | }); |
Winson Chung | 929d4f7 | 2017-01-13 10:21:33 -0800 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | @Override |
Winson Chung | 85d3998 | 2017-02-24 15:21:25 -0800 | [diff] [blame] | 107 | public void onPinnedStackAnimationStarted() { |
| 108 | // Disable touches while the animation is running |
| 109 | mTouchHandler.setTouchEnabled(false); |
| 110 | } |
| 111 | |
| 112 | @Override |
Winson Chung | 929d4f7 | 2017-01-13 10:21:33 -0800 | [diff] [blame] | 113 | public void onPinnedStackAnimationEnded() { |
Winson Chung | 85d3998 | 2017-02-24 15:21:25 -0800 | [diff] [blame] | 114 | // Re-enable touches after the animation completes |
| 115 | mTouchHandler.setTouchEnabled(true); |
Winson Chung | ac52f28 | 2017-03-30 14:44:52 -0700 | [diff] [blame] | 116 | mTouchHandler.onPinnedStackAnimationEnded(); |
Winson Chung | 3448824 | 2017-04-26 15:53:51 -0700 | [diff] [blame] | 117 | mMenuController.onPinnedStackAnimationEnded(); |
Winson Chung | 929d4f7 | 2017-01-13 10:21:33 -0800 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | @Override |
Winson Chung | e6385a2 | 2017-05-02 18:15:16 -0700 | [diff] [blame] | 121 | public void onPinnedActivityRestartAttempt(boolean clearedTask) { |
Winson Chung | e6385a2 | 2017-05-02 18:15:16 -0700 | [diff] [blame] | 122 | mTouchHandler.getMotionHelper().expandPip(clearedTask /* skipAnimation */); |
Winson Chung | 929d4f7 | 2017-01-13 10:21:33 -0800 | [diff] [blame] | 123 | } |
| 124 | }; |
| 125 | |
| 126 | /** |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 127 | * Handler for messages from the PIP controller. |
| 128 | */ |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 129 | private class PipManagerPinnedStackListener extends PinnedStackListener { |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 130 | @Override |
| 131 | public void onListenerRegistered(IPinnedStackController controller) { |
| 132 | mHandler.post(() -> { |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 133 | mPipBoundsHandler.setPinnedStackController(controller); |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 134 | mTouchHandler.setPinnedStackController(controller); |
| 135 | }); |
| 136 | } |
| 137 | |
| 138 | @Override |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 139 | public void onImeVisibilityChanged(boolean imeVisible, int imeHeight) { |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 140 | mHandler.post(() -> { |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 141 | mPipBoundsHandler.onImeVisibilityChanged(imeVisible, imeHeight); |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 142 | mTouchHandler.onImeVisibilityChanged(imeVisible, imeHeight); |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 143 | }); |
| 144 | } |
| 145 | |
| 146 | @Override |
| 147 | public void onMinimizedStateChanged(boolean isMinimized) { |
| 148 | mHandler.post(() -> { |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 149 | mPipBoundsHandler.onMinimizedStateChanged(isMinimized); |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 150 | mTouchHandler.setMinimizedState(isMinimized, true /* fromController */); |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 151 | }); |
| 152 | } |
| 153 | |
| 154 | @Override |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 155 | public void onMovementBoundsChanged(Rect animatingBounds, boolean fromImeAdjustment, |
| 156 | boolean fromShelfAdjustment) { |
Hongwei Wang | 9b75180 | 2019-09-11 12:13:21 -0700 | [diff] [blame] | 157 | mHandler.post(() -> updateMovementBounds(animatingBounds, fromImeAdjustment, |
| 158 | fromShelfAdjustment)); |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | @Override |
| 162 | public void onActionsChanged(ParceledListSlice actions) { |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 163 | mHandler.post(() -> mMenuController.setAppActions(actions)); |
| 164 | } |
| 165 | |
| 166 | @Override |
| 167 | public void onSaveReentrySnapFraction(ComponentName componentName, Rect bounds) { |
| 168 | mHandler.post(() -> mPipBoundsHandler.onSaveReentrySnapFraction(componentName, bounds)); |
| 169 | } |
| 170 | |
| 171 | @Override |
| 172 | public void onResetReentrySnapFraction(ComponentName componentName) { |
| 173 | mHandler.post(() -> mPipBoundsHandler.onResetReentrySnapFraction(componentName)); |
| 174 | } |
| 175 | |
| 176 | @Override |
| 177 | public void onDisplayInfoChanged(DisplayInfo displayInfo) { |
| 178 | mHandler.post(() -> mPipBoundsHandler.onDisplayInfoChanged(displayInfo)); |
| 179 | } |
| 180 | |
| 181 | @Override |
| 182 | public void onConfigurationChanged() { |
| 183 | mHandler.post(() -> mPipBoundsHandler.onConfigurationChanged()); |
| 184 | } |
| 185 | |
| 186 | @Override |
| 187 | public void onAspectRatioChanged(float aspectRatio) { |
| 188 | mHandler.post(() -> mPipBoundsHandler.onAspectRatioChanged(aspectRatio)); |
| 189 | } |
| 190 | |
| 191 | @Override |
| 192 | public void onPrepareAnimation(Rect sourceRectHint, float aspectRatio, Rect bounds) { |
Winson Chung | 2a82fe5 | 2017-02-02 14:43:34 -0800 | [diff] [blame] | 193 | mHandler.post(() -> { |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 194 | mPipBoundsHandler.onPrepareAnimation(sourceRectHint, aspectRatio, bounds); |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 195 | }); |
| 196 | } |
| 197 | } |
| 198 | |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 199 | private PipManager() {} |
| 200 | |
| 201 | /** |
| 202 | * Initializes {@link PipManager}. |
| 203 | */ |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame^] | 204 | public void initialize(Context context, BroadcastDispatcher broadcastDispatcher) { |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 205 | mContext = context; |
Sudheer Shanka | dc589ac | 2016-11-10 15:30:17 -0800 | [diff] [blame] | 206 | mActivityManager = ActivityManager.getService(); |
Wale Ogunwale | 65ebd95 | 2018-04-25 15:41:44 -0700 | [diff] [blame] | 207 | mActivityTaskManager = ActivityTaskManager.getService(); |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 208 | |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 209 | try { |
Joshua Tsuji | a19515f | 2019-02-13 18:02:29 -0500 | [diff] [blame] | 210 | WindowManagerWrapper.getInstance().addPinnedStackListener(mPinnedStackListener); |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 211 | } catch (RemoteException e) { |
| 212 | Log.e(TAG, "Failed to register pinned stack listener", e); |
| 213 | } |
Winson Chung | 2cf6ad8 | 2017-11-09 17:36:59 -0800 | [diff] [blame] | 214 | ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener); |
Winson Chung | a29eb98 | 2016-12-14 12:01:27 -0800 | [diff] [blame] | 215 | |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 216 | mPipBoundsHandler = new PipBoundsHandler(context); |
Winson Chung | cbb15a9 | 2018-01-25 17:46:16 +0000 | [diff] [blame] | 217 | mInputConsumerController = InputConsumerController.getPipInputConsumer(); |
Fabian Kozynski | 5ca7a51 | 2019-10-16 19:56:11 +0000 | [diff] [blame^] | 218 | mMediaController = new PipMediaController(context, mActivityManager, broadcastDispatcher); |
Winson Chung | d2d9097 | 2017-02-28 11:40:41 -0800 | [diff] [blame] | 219 | mMenuController = new PipMenuActivityController(context, mActivityManager, mMediaController, |
| 220 | mInputConsumerController); |
Wale Ogunwale | 65ebd95 | 2018-04-25 15:41:44 -0700 | [diff] [blame] | 221 | mTouchHandler = new PipTouchHandler(context, mActivityManager, mActivityTaskManager, |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 222 | mMenuController, mInputConsumerController, mPipBoundsHandler); |
Winson Chung | 95bccdc | 2018-01-03 11:45:47 -0800 | [diff] [blame] | 223 | mAppOpsListener = new PipAppOpsListener(context, mActivityManager, |
| 224 | mTouchHandler.getMotionHelper()); |
Arthur Hung | d52d119 | 2019-08-30 16:06:59 +0800 | [diff] [blame] | 225 | |
| 226 | // If SystemUI restart, and it already existed a pinned stack, |
| 227 | // register the pip input consumer to ensure touch can send to it. |
| 228 | try { |
| 229 | ActivityManager.StackInfo stackInfo = mActivityTaskManager.getStackInfo( |
| 230 | WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED); |
| 231 | if (stackInfo != null) { |
| 232 | mInputConsumerController.registerInputConsumer(); |
| 233 | } |
| 234 | } catch (RemoteException e) { |
| 235 | e.printStackTrace(); |
| 236 | } |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | /** |
| 240 | * Updates the PIP per configuration changed. |
| 241 | */ |
Winson Chung | 0c5a592 | 2017-05-22 17:41:06 -0700 | [diff] [blame] | 242 | public void onConfigurationChanged(Configuration newConfig) { |
Winson Chung | 303c6b7 | 2016-10-24 17:12:49 -0700 | [diff] [blame] | 243 | mTouchHandler.onConfigurationChanged(); |
| 244 | } |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 245 | |
| 246 | /** |
Winson Chung | b502690 | 2017-05-03 12:45:13 -0700 | [diff] [blame] | 247 | * Expands the PIP. |
| 248 | */ |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 249 | @Override |
| 250 | public void expandPip() { |
Winson Chung | b502690 | 2017-05-03 12:45:13 -0700 | [diff] [blame] | 251 | mTouchHandler.getMotionHelper().expandPip(false /* skipAnimation */); |
| 252 | } |
| 253 | |
| 254 | /** |
Winson Chung | 2dbcf09 | 2018-10-24 13:00:41 -0700 | [diff] [blame] | 255 | * Hides the PIP menu. |
| 256 | */ |
| 257 | @Override |
| 258 | public void hidePipMenu(Runnable onStartCallback, Runnable onEndCallback) { |
| 259 | mMenuController.hideMenu(onStartCallback, onEndCallback); |
| 260 | } |
| 261 | |
| 262 | /** |
Winson Chung | ac52f28 | 2017-03-30 14:44:52 -0700 | [diff] [blame] | 263 | * Sent from KEYCODE_WINDOW handler in PhoneWindowManager, to request the menu to be shown. |
| 264 | */ |
| 265 | public void showPictureInPictureMenu() { |
| 266 | mTouchHandler.showPictureInPictureMenu(); |
| 267 | } |
| 268 | |
| 269 | /** |
Hongwei Wang | 9b75180 | 2019-09-11 12:13:21 -0700 | [diff] [blame] | 270 | * Sets both shelf visibility and its height. |
| 271 | */ |
| 272 | @Override |
| 273 | public void setShelfHeight(boolean visible, int height) { |
| 274 | mHandler.post(() -> { |
| 275 | final boolean changed = mPipBoundsHandler.setShelfHeight(visible, height); |
| 276 | if (changed) { |
| 277 | mTouchHandler.onShelfVisibilityChanged(visible, height); |
| 278 | updateMovementBounds(mPipBoundsHandler.getLastDestinationBounds(), |
| 279 | false /* fromImeAdjustment */, true /* fromShelfAdjustment */); |
| 280 | } |
| 281 | }); |
| 282 | } |
| 283 | |
| 284 | private void updateMovementBounds(Rect animatingBounds, boolean fromImeAdjustment, |
| 285 | boolean fromShelfAdjustment) { |
| 286 | // Populate inset / normal bounds and DisplayInfo from mPipBoundsHandler first. |
| 287 | mPipBoundsHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds, |
| 288 | animatingBounds, mTmpDisplayInfo); |
| 289 | mTouchHandler.onMovementBoundsChanged(mTmpInsetBounds, mTmpNormalBounds, |
| 290 | animatingBounds, fromImeAdjustment, fromShelfAdjustment, |
| 291 | mTmpDisplayInfo.rotation); |
| 292 | } |
| 293 | |
| 294 | /** |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 295 | * Gets an instance of {@link PipManager}. |
| 296 | */ |
| 297 | public static PipManager getInstance() { |
| 298 | if (sPipController == null) { |
| 299 | sPipController = new PipManager(); |
| 300 | } |
| 301 | return sPipController; |
| 302 | } |
Winson Chung | 29a7865 | 2017-02-09 18:35:26 -0800 | [diff] [blame] | 303 | |
| 304 | public void dump(PrintWriter pw) { |
| 305 | final String innerPrefix = " "; |
| 306 | pw.println(TAG); |
Winson Chung | d2d9097 | 2017-02-28 11:40:41 -0800 | [diff] [blame] | 307 | mInputConsumerController.dump(pw, innerPrefix); |
Winson Chung | 29a7865 | 2017-02-09 18:35:26 -0800 | [diff] [blame] | 308 | mMenuController.dump(pw, innerPrefix); |
| 309 | mTouchHandler.dump(pw, innerPrefix); |
Hongwei Wang | 43a752b | 2019-09-17 20:20:30 +0000 | [diff] [blame] | 310 | mPipBoundsHandler.dump(pw, innerPrefix); |
Winson Chung | 29a7865 | 2017-02-09 18:35:26 -0800 | [diff] [blame] | 311 | } |
Winson | 73bc159 | 2016-10-18 18:47:43 -0700 | [diff] [blame] | 312 | } |