Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | 30e441d | 2017-11-09 08:28:45 -0800 | [diff] [blame] | 19 | import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT; |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 20 | import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; |
Wale Ogunwale | b62139d | 2017-09-20 15:37:35 -0700 | [diff] [blame] | 21 | import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; |
Wale Ogunwale | 44f036f | 2017-09-29 05:09:09 -0700 | [diff] [blame] | 22 | import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; |
Wale Ogunwale | 687b427 | 2017-07-27 02:56:23 -0700 | [diff] [blame] | 23 | import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; |
Wale Ogunwale | b62139d | 2017-09-20 15:37:35 -0700 | [diff] [blame] | 24 | import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; |
| 25 | import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; |
Wale Ogunwale | a77e146 | 2016-09-28 10:09:46 -0700 | [diff] [blame] | 26 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND; |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 27 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; |
| 28 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
Wale Ogunwale | 687b427 | 2017-07-27 02:56:23 -0700 | [diff] [blame] | 29 | import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; |
| 30 | import static android.content.res.Configuration.ORIENTATION_PORTRAIT; |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 31 | import static android.view.Display.DEFAULT_DISPLAY; |
| 32 | import static android.view.Display.FLAG_PRIVATE; |
Andrii Kulian | 4dfb9c4 | 2016-10-11 20:06:27 -0700 | [diff] [blame] | 33 | import static android.view.Surface.ROTATION_0; |
| 34 | import static android.view.Surface.ROTATION_180; |
| 35 | import static android.view.Surface.ROTATION_270; |
| 36 | import static android.view.Surface.ROTATION_90; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 37 | import static android.view.View.GONE; |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 38 | import static android.view.WindowManager.DOCKED_BOTTOM; |
| 39 | import static android.view.WindowManager.DOCKED_INVALID; |
| 40 | import static android.view.WindowManager.DOCKED_TOP; |
Vladislav Kaznacheev | 5d6bdeb | 2016-02-12 17:07:20 -0800 | [diff] [blame] | 41 | import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; |
| 42 | import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; |
| 43 | import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 44 | import static android.view.WindowManager.LayoutParams.FLAG_SECURE; |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 45 | import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 46 | import static android.view.WindowManager.LayoutParams.NEEDS_MENU_SET_TRUE; |
| 47 | import static android.view.WindowManager.LayoutParams.NEEDS_MENU_UNSET; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 48 | import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 49 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; |
Wale Ogunwale | 63d4ecc | 2016-09-08 18:48:26 -0700 | [diff] [blame] | 50 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 51 | import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 52 | import static android.view.WindowManager.LayoutParams.TYPE_DRAWN_APPLICATION; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 53 | import static android.view.WindowManager.LayoutParams.TYPE_DREAM; |
Wale Ogunwale | 3a93169 | 2016-11-02 16:49:48 -0700 | [diff] [blame] | 54 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; |
| 55 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 56 | import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 57 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG; |
| 58 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; |
Svetoslav Ganov | aa07653 | 2016-08-01 19:16:43 -0700 | [diff] [blame] | 59 | import static android.view.WindowManager.LayoutParams.TYPE_TOAST; |
Wale Ogunwale | ec73115 | 2016-09-08 20:18:57 -0700 | [diff] [blame] | 60 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 61 | import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM; |
| 62 | import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_CONFIG; |
| 63 | import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT; |
| 64 | import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; |
Jorim Jaggi | 75520d5 | 2017-08-24 17:23:19 +0200 | [diff] [blame] | 65 | import static com.android.server.wm.AppTransition.TRANSIT_KEYGUARD_UNOCCLUDE; |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 66 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 67 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_BOOT; |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 68 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DISPLAY; |
Wale Ogunwale | 63d4ecc | 2016-09-08 18:48:26 -0700 | [diff] [blame] | 69 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS; |
| 70 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT; |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 71 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_INPUT_METHOD; |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 72 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT; |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 73 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS; |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 74 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 75 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_SCREENSHOT; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 76 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_SCREEN_ON; |
Andrii Kulian | 839def9 | 2016-11-02 10:58:58 -0700 | [diff] [blame] | 77 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_STACK; |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 78 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TOKEN_MOVEMENT; |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 79 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WALLPAPER; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 80 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WALLPAPER_LIGHT; |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 81 | import static com.android.server.wm.WindowManagerDebugConfig.SHOW_LIGHT_TRANSACTIONS; |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 82 | import static com.android.server.wm.WindowManagerDebugConfig.SHOW_STACK_CRAWLS; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 83 | import static com.android.server.wm.WindowManagerDebugConfig.SHOW_TRANSACTIONS; |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 84 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 85 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 86 | import static com.android.server.wm.WindowManagerService.CUSTOM_SCREEN_ROTATION; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 87 | import static com.android.server.wm.WindowManagerService.H.SEND_NEW_CONFIGURATION; |
| 88 | import static com.android.server.wm.WindowManagerService.H.UPDATE_DOCKED_STACK_DIVIDER; |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 89 | import static com.android.server.wm.WindowManagerService.H.WINDOW_HIDE_TIMEOUT; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 90 | import static com.android.server.wm.WindowManagerService.LAYOUT_REPEAT_THRESHOLD; |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 91 | import static com.android.server.wm.WindowManagerService.MAX_ANIMATION_DURATION; |
| 92 | import static com.android.server.wm.WindowManagerService.SEAMLESS_ROTATION_TIMEOUT_DURATION; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 93 | import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_WILL_PLACE_SURFACES; |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 94 | import static com.android.server.wm.WindowManagerService.WINDOWS_FREEZING_SCREENS_ACTIVE; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 95 | import static com.android.server.wm.WindowManagerService.WINDOWS_FREEZING_SCREENS_TIMEOUT; |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 96 | import static com.android.server.wm.WindowManagerService.WINDOW_FREEZE_TIMEOUT_DURATION; |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 97 | import static com.android.server.wm.WindowManagerService.dipToPixel; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 98 | import static com.android.server.wm.WindowManagerService.logSurface; |
Wale Ogunwale | 231b06e | 2015-09-16 12:03:09 -0700 | [diff] [blame] | 99 | import static com.android.server.wm.WindowState.RESIZE_HANDLE_WIDTH_IN_DP; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 100 | import static com.android.server.wm.WindowStateAnimator.DRAW_PENDING; |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 101 | import static com.android.server.wm.WindowStateAnimator.READY_TO_SHOW; |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 102 | import static com.android.server.wm.WindowSurfacePlacer.SET_WALLPAPER_MAY_CHANGE; |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 103 | import static com.android.server.wm.proto.DisplayProto.ABOVE_APP_WINDOWS; |
| 104 | import static com.android.server.wm.proto.DisplayProto.BELOW_APP_WINDOWS; |
Wale Ogunwale | 828ff7e | 2017-11-14 01:01:29 +0000 | [diff] [blame] | 105 | import static com.android.server.wm.proto.DisplayProto.DISPLAY_FRAMES; |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 106 | import static com.android.server.wm.proto.DisplayProto.DISPLAY_INFO; |
| 107 | import static com.android.server.wm.proto.DisplayProto.DOCKED_STACK_DIVIDER_CONTROLLER; |
| 108 | import static com.android.server.wm.proto.DisplayProto.DPI; |
| 109 | import static com.android.server.wm.proto.DisplayProto.ID; |
| 110 | import static com.android.server.wm.proto.DisplayProto.IME_WINDOWS; |
| 111 | import static com.android.server.wm.proto.DisplayProto.PINNED_STACK_CONTROLLER; |
Steven Timotius | f2d6889 | 2017-08-28 17:00:01 -0700 | [diff] [blame] | 112 | import static com.android.server.wm.proto.DisplayProto.ROTATION; |
| 113 | import static com.android.server.wm.proto.DisplayProto.SCREEN_ROTATION_ANIMATION; |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 114 | import static com.android.server.wm.proto.DisplayProto.STACKS; |
Wale Ogunwale | 0d5609b | 2017-09-13 05:55:07 -0700 | [diff] [blame] | 115 | import static com.android.server.wm.proto.DisplayProto.WINDOW_CONTAINER; |
Craig Mautner | d5d5d0f | 2013-04-03 15:08:21 -0700 | [diff] [blame] | 116 | |
Wale Ogunwale | 0d5609b | 2017-09-13 05:55:07 -0700 | [diff] [blame] | 117 | import android.annotation.CallSuper; |
Andrii Kulian | 3a507b5 | 2016-09-19 18:14:12 -0700 | [diff] [blame] | 118 | import android.annotation.NonNull; |
Dean Harding | 3e5a152 | 2017-10-06 09:19:01 -0700 | [diff] [blame] | 119 | import android.content.pm.PackageManager; |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 120 | import android.content.res.CompatibilityInfo; |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 121 | import android.content.res.Configuration; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 122 | import android.graphics.Bitmap; |
Andrii Kulian | 4dfb9c4 | 2016-10-11 20:06:27 -0700 | [diff] [blame] | 123 | import android.graphics.Matrix; |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 124 | import android.graphics.Rect; |
Andrii Kulian | 4dfb9c4 | 2016-10-11 20:06:27 -0700 | [diff] [blame] | 125 | import android.graphics.RectF; |
Craig Mautner | 6601b7b | 2013-04-29 10:29:11 -0700 | [diff] [blame] | 126 | import android.graphics.Region; |
Jorim Jaggi | d47e7e1 | 2016-03-01 09:57:38 +0100 | [diff] [blame] | 127 | import android.graphics.Region.Op; |
Wale Ogunwale | b699ce0 | 2016-07-18 12:05:30 -0700 | [diff] [blame] | 128 | import android.hardware.display.DisplayManagerInternal; |
Wale Ogunwale | 9adfe57 | 2016-09-08 20:43:58 -0700 | [diff] [blame] | 129 | import android.os.Debug; |
Wale Ogunwale | b0f3b83 | 2016-10-17 10:13:07 -0700 | [diff] [blame] | 130 | import android.os.Handler; |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 131 | import android.os.IBinder; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 132 | import android.os.RemoteException; |
| 133 | import android.os.SystemClock; |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 134 | import android.os.Trace; |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 135 | import android.util.DisplayMetrics; |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 136 | import android.util.MutableBoolean; |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 137 | import android.util.Slog; |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 138 | import android.util.proto.ProtoOutputStream; |
Craig Mautner | b47bbc3 | 2012-08-22 17:41:48 -0700 | [diff] [blame] | 139 | import android.view.Display; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 140 | import android.view.DisplayInfo; |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 141 | import android.view.InputDevice; |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 142 | import android.view.MagnificationSpec; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 143 | import android.view.Surface; |
| 144 | import android.view.SurfaceControl; |
Jorim Jaggi | a5e1057 | 2017-11-15 14:36:26 +0100 | [diff] [blame] | 145 | import android.view.SurfaceControl.Transaction; |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 146 | import android.view.SurfaceSession; |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 147 | |
Bryce Lee | 48f4b57 | 2017-04-10 10:54:15 -0700 | [diff] [blame] | 148 | import com.android.internal.annotations.VisibleForTesting; |
Wale Ogunwale | f4ebe2e | 2016-11-09 13:24:43 -0800 | [diff] [blame] | 149 | import com.android.internal.util.ToBooleanFunction; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 150 | import com.android.internal.view.IInputMethodClient; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 151 | import com.android.server.policy.WindowManagerPolicy; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 152 | |
Robert Carr | 3b71624 | 2016-08-16 16:02:21 -0700 | [diff] [blame] | 153 | import java.io.FileDescriptor; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 154 | import java.io.PrintWriter; |
| 155 | import java.util.ArrayList; |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 156 | import java.util.Comparator; |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 157 | import java.util.HashMap; |
| 158 | import java.util.Iterator; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 159 | import java.util.LinkedList; |
Andrii Kulian | 3a507b5 | 2016-09-19 18:14:12 -0700 | [diff] [blame] | 160 | import java.util.List; |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 161 | import java.util.function.Consumer; |
| 162 | import java.util.function.Predicate; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 163 | |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 164 | /** |
| 165 | * Utility class for keeping track of the WindowStates and other pertinent contents of a |
| 166 | * particular Display. |
| 167 | * |
| 168 | * IMPORTANT: No method from this class should ever be used without holding |
| 169 | * WindowManagerService.mWindowMap. |
| 170 | */ |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 171 | class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowContainer> { |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 172 | private static final String TAG = TAG_WITH_CLASS_NAME ? "DisplayContent" : TAG_WM; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 173 | |
| 174 | /** Unique identifier of this stack. */ |
| 175 | private final int mDisplayId; |
| 176 | |
Wale Ogunwale | 3a93169 | 2016-11-02 16:49:48 -0700 | [diff] [blame] | 177 | /** The containers below are the only child containers the display can have. */ |
| 178 | // Contains all window containers that are related to apps (Activities) |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 179 | private final TaskStackContainers mTaskStackContainers = new TaskStackContainers(mService); |
Wale Ogunwale | 3a93169 | 2016-11-02 16:49:48 -0700 | [diff] [blame] | 180 | // Contains all non-app window containers that should be displayed above the app containers |
| 181 | // (e.g. Status bar) |
Robert Carr | ee4d4b9 | 2017-11-22 12:21:46 -0800 | [diff] [blame] | 182 | private final AboveAppWindowContainers mAboveAppWindowsContainers = |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 183 | new AboveAppWindowContainers("mAboveAppWindowsContainers", mService); |
Wale Ogunwale | 3a93169 | 2016-11-02 16:49:48 -0700 | [diff] [blame] | 184 | // Contains all non-app window containers that should be displayed below the app containers |
| 185 | // (e.g. Wallpaper). |
| 186 | private final NonAppWindowContainers mBelowAppWindowsContainers = |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 187 | new NonAppWindowContainers("mBelowAppWindowsContainers", mService); |
Wale Ogunwale | 3a93169 | 2016-11-02 16:49:48 -0700 | [diff] [blame] | 188 | // Contains all IME window containers. Note that the z-ordering of the IME windows will depend |
| 189 | // on the IME target. We mainly have this container grouping so we can keep track of all the IME |
Robert Carr | 9034d96 | 2018-01-04 18:27:42 -0800 | [diff] [blame] | 190 | // window containers together and move them in-sync if/when needed. We use a subclass of |
| 191 | // WindowContainer which is omitted from screen magnification, as the IME is never magnified. |
| 192 | private final NonMagnifiableWindowContainers mImeWindowsContainers = |
| 193 | new NonMagnifiableWindowContainers("mImeWindowsContainers", mService); |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 194 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 195 | private WindowState mTmpWindow; |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 196 | private WindowState mTmpWindow2; |
| 197 | private WindowAnimator mTmpWindowAnimator; |
| 198 | private boolean mTmpRecoveringMemory; |
| 199 | private boolean mUpdateImeTarget; |
| 200 | private boolean mTmpInitial; |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 201 | private int mMaxUiWidth; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 202 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 203 | // Mapping from a token IBinder to a WindowToken object on this display. |
| 204 | private final HashMap<IBinder, WindowToken> mTokenMap = new HashMap(); |
| 205 | |
Andrii Kulian | cd09799 | 2017-03-23 18:31:59 -0700 | [diff] [blame] | 206 | // Initial display metrics. |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 207 | int mInitialDisplayWidth = 0; |
| 208 | int mInitialDisplayHeight = 0; |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 209 | int mInitialDisplayDensity = 0; |
Andrii Kulian | cd09799 | 2017-03-23 18:31:59 -0700 | [diff] [blame] | 210 | |
| 211 | /** |
| 212 | * Overridden display size. Initialized with {@link #mInitialDisplayWidth} |
| 213 | * and {@link #mInitialDisplayHeight}, but can be set via shell command "adb shell wm size". |
| 214 | * @see WindowManagerService#setForcedDisplaySize(int, int, int) |
| 215 | */ |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 216 | int mBaseDisplayWidth = 0; |
| 217 | int mBaseDisplayHeight = 0; |
Andrii Kulian | cd09799 | 2017-03-23 18:31:59 -0700 | [diff] [blame] | 218 | /** |
| 219 | * Overridden display density for current user. Initialized with {@link #mInitialDisplayDensity} |
| 220 | * but can be set from Settings or via shell command "adb shell wm density". |
| 221 | * @see WindowManagerService#setForcedDisplayDensityForUser(int, int, int) |
| 222 | */ |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 223 | int mBaseDisplayDensity = 0; |
Jeff Brown | d46747a | 2015-04-15 19:02:36 -0700 | [diff] [blame] | 224 | boolean mDisplayScalingDisabled; |
Craig Mautner | 2d5618c | 2012-10-18 13:55:47 -0700 | [diff] [blame] | 225 | private final DisplayInfo mDisplayInfo = new DisplayInfo(); |
| 226 | private final Display mDisplay; |
Wale Ogunwale | 231b06e | 2015-09-16 12:03:09 -0700 | [diff] [blame] | 227 | private final DisplayMetrics mDisplayMetrics = new DisplayMetrics(); |
Wale Ogunwale | 828ff7e | 2017-11-14 01:01:29 +0000 | [diff] [blame] | 228 | DisplayFrames mDisplayFrames; |
| 229 | |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 230 | /** |
| 231 | * For default display it contains real metrics, empty for others. |
| 232 | * @see WindowManagerService#createWatermarkInTransaction() |
| 233 | */ |
| 234 | final DisplayMetrics mRealDisplayMetrics = new DisplayMetrics(); |
| 235 | /** @see #computeCompatSmallestWidth(boolean, int, int, int, int) */ |
| 236 | private final DisplayMetrics mTmpDisplayMetrics = new DisplayMetrics(); |
Lucas Dupin | 1ead7fc | 2017-05-24 14:14:44 -0700 | [diff] [blame] | 237 | |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 238 | /** |
| 239 | * Compat metrics computed based on {@link #mDisplayMetrics}. |
| 240 | * @see #updateDisplayAndOrientation(int) |
| 241 | */ |
| 242 | private final DisplayMetrics mCompatDisplayMetrics = new DisplayMetrics(); |
| 243 | |
| 244 | /** The desired scaling factor for compatible apps. */ |
| 245 | float mCompatibleScreenScale; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 246 | |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 247 | /** |
| 248 | * Current rotation of the display. |
| 249 | * Constants as per {@link android.view.Surface.Rotation}. |
| 250 | * |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 251 | * @see #updateRotationUnchecked(boolean) |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 252 | */ |
| 253 | private int mRotation = 0; |
Lucas Dupin | 1ead7fc | 2017-05-24 14:14:44 -0700 | [diff] [blame] | 254 | |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 255 | /** |
| 256 | * Last applied orientation of the display. |
| 257 | * Constants as per {@link android.content.pm.ActivityInfo.ScreenOrientation}. |
| 258 | * |
| 259 | * @see WindowManagerService#updateOrientationFromAppTokensLocked(boolean, int) |
| 260 | */ |
| 261 | private int mLastOrientation = SCREEN_ORIENTATION_UNSPECIFIED; |
Lucas Dupin | 1ead7fc | 2017-05-24 14:14:44 -0700 | [diff] [blame] | 262 | |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 263 | /** |
| 264 | * Flag indicating that the application is receiving an orientation that has different metrics |
| 265 | * than it expected. E.g. Portrait instead of Landscape. |
| 266 | * |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 267 | * @see #updateRotationUnchecked(boolean) |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 268 | */ |
| 269 | private boolean mAltOrientation = false; |
Lucas Dupin | 1ead7fc | 2017-05-24 14:14:44 -0700 | [diff] [blame] | 270 | |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 271 | /** |
| 272 | * Orientation forced by some window. If there is no visible window that specifies orientation |
| 273 | * it is set to {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}. |
| 274 | * |
| 275 | * @see NonAppWindowContainers#getOrientation() |
| 276 | */ |
| 277 | private int mLastWindowForcedOrientation = SCREEN_ORIENTATION_UNSPECIFIED; |
Lucas Dupin | 1ead7fc | 2017-05-24 14:14:44 -0700 | [diff] [blame] | 278 | |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 279 | /** |
| 280 | * Last orientation forced by the keyguard. It is applied when keyguard is shown and is not |
| 281 | * occluded. |
| 282 | * |
| 283 | * @see NonAppWindowContainers#getOrientation() |
| 284 | */ |
| 285 | private int mLastKeyguardForcedOrientation = SCREEN_ORIENTATION_UNSPECIFIED; |
| 286 | |
Lucas Dupin | 1ead7fc | 2017-05-24 14:14:44 -0700 | [diff] [blame] | 287 | /** |
| 288 | * Keep track of wallpaper visibility to notify changes. |
| 289 | */ |
| 290 | private boolean mLastWallpaperVisible = false; |
| 291 | |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 292 | private Rect mBaseDisplayRect = new Rect(); |
Craig Mautner | 6601b7b | 2013-04-29 10:29:11 -0700 | [diff] [blame] | 293 | |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 294 | // Accessed directly by all users. |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 295 | private boolean mLayoutNeeded; |
Craig Mautner | 76a7165 | 2012-09-03 23:23:58 -0700 | [diff] [blame] | 296 | int pendingLayoutChanges; |
Andrii Kulian | 839def9 | 2016-11-02 10:58:58 -0700 | [diff] [blame] | 297 | // TODO(multi-display): remove some of the usages. |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 298 | boolean isDefaultDisplay; |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 299 | |
Craig Mautner | dc54848 | 2014-02-05 13:35:24 -0800 | [diff] [blame] | 300 | /** Window tokens that are in the process of exiting, but still on screen for animations. */ |
Wale Ogunwale | 231b06e | 2015-09-16 12:03:09 -0700 | [diff] [blame] | 301 | final ArrayList<WindowToken> mExitingTokens = new ArrayList<>(); |
Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 302 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 303 | /** Detect user tapping outside of current focused task bounds .*/ |
| 304 | TaskTapPointerEventListener mTapDetector; |
Craig Mautner | cf910b0 | 2013-04-23 11:23:27 -0700 | [diff] [blame] | 305 | |
Craig Mautner | 6601b7b | 2013-04-29 10:29:11 -0700 | [diff] [blame] | 306 | /** Detect user tapping outside of current focused stack bounds .*/ |
Wale Ogunwale | 9adfe57 | 2016-09-08 20:43:58 -0700 | [diff] [blame] | 307 | private Region mTouchExcludeRegion = new Region(); |
Craig Mautner | 6601b7b | 2013-04-29 10:29:11 -0700 | [diff] [blame] | 308 | |
Craig Mautner | 6601b7b | 2013-04-29 10:29:11 -0700 | [diff] [blame] | 309 | /** Save allocating when calculating rects */ |
Filip Gruszczynski | 912d919 | 2015-12-01 16:14:04 -0800 | [diff] [blame] | 310 | private final Rect mTmpRect = new Rect(); |
| 311 | private final Rect mTmpRect2 = new Rect(); |
Andrii Kulian | 4dfb9c4 | 2016-10-11 20:06:27 -0700 | [diff] [blame] | 312 | private final RectF mTmpRectF = new RectF(); |
| 313 | private final Matrix mTmpMatrix = new Matrix(); |
Filip Gruszczynski | 912d919 | 2015-12-01 16:14:04 -0800 | [diff] [blame] | 314 | private final Region mTmpRegion = new Region(); |
Craig Mautner | 6601b7b | 2013-04-29 10:29:11 -0700 | [diff] [blame] | 315 | |
Bryce Lee | f3c6a47 | 2017-11-14 14:53:06 -0800 | [diff] [blame] | 316 | /** Used for handing back size of display */ |
| 317 | private final Rect mTmpBounds = new Rect(); |
| 318 | |
Craig Mautner | 95da108 | 2014-02-24 17:54:35 -0800 | [diff] [blame] | 319 | /** Remove this display when animation on it has completed. */ |
Wale Ogunwale | d4a00a0 | 2016-10-10 11:29:17 -0700 | [diff] [blame] | 320 | private boolean mDeferredRemoval; |
Craig Mautner | 1bf2b87 | 2014-02-05 15:37:40 -0800 | [diff] [blame] | 321 | |
Filip Gruszczynski | 466f321 | 2015-09-21 17:57:57 -0700 | [diff] [blame] | 322 | final DockedStackDividerController mDividerControllerLocked; |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 323 | final PinnedStackController mPinnedStackControllerLocked; |
Filip Gruszczynski | 466f321 | 2015-09-21 17:57:57 -0700 | [diff] [blame] | 324 | |
Filip Gruszczynski | ecf6722 | 2015-12-11 15:16:36 -0800 | [diff] [blame] | 325 | final ArrayList<WindowState> mTapExcludedWindows = new ArrayList<>(); |
| 326 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 327 | private boolean mHaveBootMsg = false; |
| 328 | private boolean mHaveApp = false; |
| 329 | private boolean mHaveWallpaper = false; |
| 330 | private boolean mHaveKeyguard = true; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 331 | |
| 332 | private final LinkedList<AppWindowToken> mTmpUpdateAllDrawn = new LinkedList(); |
| 333 | |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 334 | private final TaskForResizePointSearchResult mTmpTaskForResizePointSearchResult = |
| 335 | new TaskForResizePointSearchResult(); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 336 | private final ApplySurfaceChangesTransactionState mTmpApplySurfaceChangesTransactionState = |
| 337 | new ApplySurfaceChangesTransactionState(); |
| 338 | private final ScreenshotApplicationState mScreenshotApplicationState = |
| 339 | new ScreenshotApplicationState(); |
Jorim Jaggi | a5e1057 | 2017-11-15 14:36:26 +0100 | [diff] [blame] | 340 | private final Transaction mTmpTransaction = new Transaction(); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 341 | |
Wale Ogunwale | 601a3f0 | 2016-10-17 08:39:39 -0700 | [diff] [blame] | 342 | // True if this display is in the process of being removed. Used to determine if the removal of |
| 343 | // the display's direct children should be allowed. |
| 344 | private boolean mRemovingDisplay = false; |
| 345 | |
Bryce Lee | d187126 | 2017-06-12 14:12:29 -0700 | [diff] [blame] | 346 | // {@code false} if this display is in the processing of being created. |
| 347 | private boolean mDisplayReady = false; |
| 348 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 349 | WallpaperController mWallpaperController; |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 350 | |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 351 | private final SurfaceSession mSession = new SurfaceSession(); |
| 352 | |
| 353 | /** |
| 354 | * We organize all top-level Surfaces in to the following layers. |
| 355 | * mOverlayLayer contains a few Surfaces which are always on top of others |
Robert Carr | ee4d4b9 | 2017-11-22 12:21:46 -0800 | [diff] [blame] | 356 | * and omitted from Screen-Magnification, for example the strict mode flash or |
| 357 | * the magnification overlay itself. |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 358 | * {@link #mWindowingLayer} contains everything else. |
| 359 | */ |
| 360 | private SurfaceControl mOverlayLayer; |
| 361 | |
| 362 | /** |
| 363 | * See {@link #mOverlayLayer} |
| 364 | */ |
| 365 | private SurfaceControl mWindowingLayer; |
| 366 | |
| 367 | /** |
| 368 | * Specifies the size of the surfaces in {@link #mOverlayLayer} and {@link #mWindowingLayer}. |
| 369 | * <p> |
| 370 | * For these surfaces currently we use a surface based on the larger of width or height so we |
| 371 | * don't have to resize when rotating the display. |
| 372 | */ |
| 373 | private int mSurfaceSize; |
| 374 | |
| 375 | /** |
| 376 | * A list of surfaces to be destroyed after {@link #mPendingTransaction} is applied. |
| 377 | */ |
| 378 | private final ArrayList<SurfaceControl> mPendingDestroyingSurfaces = new ArrayList<>(); |
| 379 | |
Jorim Jaggi | 9af095b | 2017-12-12 17:18:57 +0100 | [diff] [blame] | 380 | /** Temporary float array to retrieve 3x3 matrix values. */ |
| 381 | private final float[] mTmpFloats = new float[9]; |
| 382 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 383 | private final Consumer<WindowState> mUpdateWindowsForAnimator = w -> { |
| 384 | WindowStateAnimator winAnimator = w.mWinAnimator; |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 385 | final AppWindowToken atoken = w.mAppToken; |
| 386 | if (winAnimator.mDrawState == READY_TO_SHOW) { |
| 387 | if (atoken == null || atoken.allDrawn) { |
| 388 | if (w.performShowLocked()) { |
| 389 | pendingLayoutChanges |= FINISH_LAYOUT_REDO_ANIM; |
| 390 | if (DEBUG_LAYOUT_REPEATS) { |
| 391 | mService.mWindowPlacerLocked.debugLayoutRepeats( |
| 392 | "updateWindowsAndWallpaperLocked 5", pendingLayoutChanges); |
| 393 | } |
| 394 | } |
| 395 | } |
| 396 | } |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 397 | }; |
| 398 | |
| 399 | private final Consumer<WindowState> mUpdateWallpaperForAnimator = w -> { |
| 400 | final WindowStateAnimator winAnimator = w.mWinAnimator; |
| 401 | if (winAnimator.mSurfaceController == null || !winAnimator.hasSurface()) { |
| 402 | return; |
| 403 | } |
| 404 | |
| 405 | final int flags = w.mAttrs.flags; |
| 406 | |
| 407 | // If this window is animating, make a note that we have an animating window and take |
| 408 | // care of a request to run a detached wallpaper animation. |
Jorim Jaggi | a5e1057 | 2017-11-15 14:36:26 +0100 | [diff] [blame] | 409 | if (winAnimator.isAnimationSet()) { |
| 410 | final AnimationAdapter anim = w.getAnimation(); |
| 411 | if (anim != null) { |
| 412 | if ((flags & FLAG_SHOW_WALLPAPER) != 0 && anim.getDetachWallpaper()) { |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 413 | mTmpWindow = w; |
| 414 | } |
Jorim Jaggi | a5e1057 | 2017-11-15 14:36:26 +0100 | [diff] [blame] | 415 | final int color = anim.getBackgroundColor(); |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 416 | if (color != 0) { |
| 417 | final TaskStack stack = w.getStack(); |
| 418 | if (stack != null) { |
| 419 | stack.setAnimationBackground(winAnimator, color); |
| 420 | } |
| 421 | } |
| 422 | } |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | // If this window's app token is running a detached wallpaper animation, make a note so |
| 426 | // we can ensure the wallpaper is displayed behind it. |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 427 | final AppWindowToken atoken = winAnimator.mWin.mAppToken; |
| 428 | final AnimationAdapter animation = atoken != null ? atoken.getAnimation() : null; |
| 429 | if (animation != null) { |
| 430 | if ((flags & FLAG_SHOW_WALLPAPER) != 0 && animation.getDetachWallpaper()) { |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 431 | mTmpWindow = w; |
| 432 | } |
| 433 | |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 434 | final int color = animation.getBackgroundColor(); |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 435 | if (color != 0) { |
| 436 | final TaskStack stack = w.getStack(); |
| 437 | if (stack != null) { |
| 438 | stack.setAnimationBackground(winAnimator, color); |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | }; |
| 443 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 444 | private final Consumer<WindowState> mScheduleToastTimeout = w -> { |
| 445 | final int lostFocusUid = mTmpWindow.mOwnerUid; |
| 446 | final Handler handler = mService.mH; |
| 447 | if (w.mAttrs.type == TYPE_TOAST && w.mOwnerUid == lostFocusUid) { |
| 448 | if (!handler.hasMessages(WINDOW_HIDE_TIMEOUT, w)) { |
| 449 | handler.sendMessageDelayed(handler.obtainMessage(WINDOW_HIDE_TIMEOUT, w), |
| 450 | w.mAttrs.hideTimeoutMilliseconds); |
| 451 | } |
| 452 | } |
| 453 | }; |
| 454 | |
| 455 | private final ToBooleanFunction<WindowState> mFindFocusedWindow = w -> { |
| 456 | final AppWindowToken focusedApp = mService.mFocusedApp; |
| 457 | if (DEBUG_FOCUS) Slog.v(TAG_WM, "Looking for focus: " + w |
| 458 | + ", flags=" + w.mAttrs.flags + ", canReceive=" + w.canReceiveKeys()); |
| 459 | |
| 460 | if (!w.canReceiveKeys()) { |
| 461 | return false; |
| 462 | } |
| 463 | |
| 464 | final AppWindowToken wtoken = w.mAppToken; |
| 465 | |
| 466 | // If this window's application has been removed, just skip it. |
| 467 | if (wtoken != null && (wtoken.removed || wtoken.sendingToBottom)) { |
| 468 | if (DEBUG_FOCUS) Slog.v(TAG_WM, "Skipping " + wtoken + " because " |
| 469 | + (wtoken.removed ? "removed" : "sendingToBottom")); |
| 470 | return false; |
| 471 | } |
| 472 | |
| 473 | if (focusedApp == null) { |
| 474 | if (DEBUG_FOCUS_LIGHT) Slog.v(TAG_WM, "findFocusedWindow: focusedApp=null" |
| 475 | + " using new focus @ " + w); |
| 476 | mTmpWindow = w; |
| 477 | return true; |
| 478 | } |
| 479 | |
| 480 | if (!focusedApp.windowsAreFocusable()) { |
| 481 | // Current focused app windows aren't focusable... |
| 482 | if (DEBUG_FOCUS_LIGHT) Slog.v(TAG_WM, "findFocusedWindow: focusedApp windows not" |
| 483 | + " focusable using new focus @ " + w); |
| 484 | mTmpWindow = w; |
| 485 | return true; |
| 486 | } |
| 487 | |
| 488 | // Descend through all of the app tokens and find the first that either matches |
| 489 | // win.mAppToken (return win) or mFocusedApp (return null). |
| 490 | if (wtoken != null && w.mAttrs.type != TYPE_APPLICATION_STARTING) { |
| 491 | if (focusedApp.compareTo(wtoken) > 0) { |
| 492 | // App stack below focused app stack. No focus for you!!! |
| 493 | if (DEBUG_FOCUS_LIGHT) Slog.v(TAG_WM, |
| 494 | "findFocusedWindow: Reached focused app=" + focusedApp); |
| 495 | mTmpWindow = null; |
| 496 | return true; |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | if (DEBUG_FOCUS_LIGHT) Slog.v(TAG_WM, "findFocusedWindow: Found new focus @ " + w); |
| 501 | mTmpWindow = w; |
| 502 | return true; |
| 503 | }; |
| 504 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 505 | private final Consumer<WindowState> mPerformLayout = w -> { |
| 506 | // Don't do layout of a window if it is not visible, or soon won't be visible, to avoid |
| 507 | // wasting time and funky changes while a window is animating away. |
| 508 | final boolean gone = (mTmpWindow != null && mService.mPolicy.canBeHiddenByKeyguardLw(w)) |
| 509 | || w.isGoneForLayoutLw(); |
| 510 | |
| 511 | if (DEBUG_LAYOUT && !w.mLayoutAttached) { |
| 512 | Slog.v(TAG, "1ST PASS " + w + ": gone=" + gone + " mHaveFrame=" + w.mHaveFrame |
| 513 | + " mLayoutAttached=" + w.mLayoutAttached |
| 514 | + " screen changed=" + w.isConfigChanged()); |
| 515 | final AppWindowToken atoken = w.mAppToken; |
| 516 | if (gone) Slog.v(TAG, " GONE: mViewVisibility=" + w.mViewVisibility |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 517 | + " mRelayoutCalled=" + w.mRelayoutCalled + " hidden=" + w.mToken.isHidden() |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 518 | + " hiddenRequested=" + (atoken != null && atoken.hiddenRequested) |
| 519 | + " parentHidden=" + w.isParentWindowHidden()); |
| 520 | else Slog.v(TAG, " VIS: mViewVisibility=" + w.mViewVisibility |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 521 | + " mRelayoutCalled=" + w.mRelayoutCalled + " hidden=" + w.mToken.isHidden() |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 522 | + " hiddenRequested=" + (atoken != null && atoken.hiddenRequested) |
| 523 | + " parentHidden=" + w.isParentWindowHidden()); |
| 524 | } |
| 525 | |
| 526 | // If this view is GONE, then skip it -- keep the current frame, and let the caller know |
| 527 | // so they can ignore it if they want. (We do the normal layout for INVISIBLE windows, |
| 528 | // since that means "perform layout as normal, just don't display"). |
| 529 | if (!gone || !w.mHaveFrame || w.mLayoutNeeded |
| 530 | || ((w.isConfigChanged() || w.setReportResizeHints()) |
| 531 | && !w.isGoneForLayoutLw() && |
| 532 | ((w.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 || |
| 533 | (w.mHasSurface && w.mAppToken != null && |
| 534 | w.mAppToken.layoutConfigChanges)))) { |
| 535 | if (!w.mLayoutAttached) { |
| 536 | if (mTmpInitial) { |
| 537 | //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial"); |
| 538 | w.mContentChanged = false; |
| 539 | } |
| 540 | if (w.mAttrs.type == TYPE_DREAM) { |
| 541 | // Don't layout windows behind a dream, so that if it does stuff like hide |
| 542 | // the status bar we won't get a bad transition when it goes away. |
| 543 | mTmpWindow = w; |
| 544 | } |
| 545 | w.mLayoutNeeded = false; |
| 546 | w.prelayout(); |
Jorim Jaggi | dc9385a | 2017-05-13 02:00:31 +0200 | [diff] [blame] | 547 | final boolean firstLayout = !w.isLaidOut(); |
Wale Ogunwale | 828ff7e | 2017-11-14 01:01:29 +0000 | [diff] [blame] | 548 | mService.mPolicy.layoutWindowLw(w, null, mDisplayFrames); |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 549 | w.mLayoutSeq = mService.mLayoutSeq; |
| 550 | |
Jorim Jaggi | dc9385a | 2017-05-13 02:00:31 +0200 | [diff] [blame] | 551 | // If this is the first layout, we need to initialize the last inset values as |
| 552 | // otherwise we'd immediately cause an unnecessary resize. |
| 553 | if (firstLayout) { |
| 554 | w.updateLastInsetValues(); |
| 555 | } |
| 556 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 557 | if (DEBUG_LAYOUT) Slog.v(TAG, " LAYOUT: mFrame=" + w.mFrame |
| 558 | + " mContainingFrame=" + w.mContainingFrame |
| 559 | + " mDisplayFrame=" + w.mDisplayFrame); |
| 560 | } |
| 561 | } |
| 562 | }; |
| 563 | |
| 564 | private final Consumer<WindowState> mPerformLayoutAttached = w -> { |
| 565 | if (w.mLayoutAttached) { |
| 566 | if (DEBUG_LAYOUT) Slog.v(TAG, "2ND PASS " + w + " mHaveFrame=" + w.mHaveFrame |
| 567 | + " mViewVisibility=" + w.mViewVisibility |
| 568 | + " mRelayoutCalled=" + w.mRelayoutCalled); |
| 569 | // If this view is GONE, then skip it -- keep the current frame, and let the caller |
| 570 | // know so they can ignore it if they want. (We do the normal layout for INVISIBLE |
| 571 | // windows, since that means "perform layout as normal, just don't display"). |
| 572 | if (mTmpWindow != null && mService.mPolicy.canBeHiddenByKeyguardLw(w)) { |
| 573 | return; |
| 574 | } |
| 575 | if ((w.mViewVisibility != GONE && w.mRelayoutCalled) || !w.mHaveFrame |
| 576 | || w.mLayoutNeeded) { |
| 577 | if (mTmpInitial) { |
| 578 | //Slog.i(TAG, "Window " + this + " clearing mContentChanged - initial"); |
| 579 | w.mContentChanged = false; |
| 580 | } |
| 581 | w.mLayoutNeeded = false; |
| 582 | w.prelayout(); |
Wale Ogunwale | 828ff7e | 2017-11-14 01:01:29 +0000 | [diff] [blame] | 583 | mService.mPolicy.layoutWindowLw(w, w.getParentWindow(), mDisplayFrames); |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 584 | w.mLayoutSeq = mService.mLayoutSeq; |
| 585 | if (DEBUG_LAYOUT) Slog.v(TAG, " LAYOUT: mFrame=" + w.mFrame |
| 586 | + " mContainingFrame=" + w.mContainingFrame |
| 587 | + " mDisplayFrame=" + w.mDisplayFrame); |
| 588 | } |
| 589 | } else if (w.mAttrs.type == TYPE_DREAM) { |
| 590 | // Don't layout windows behind a dream, so that if it does stuff like hide the |
| 591 | // status bar we won't get a bad transition when it goes away. |
| 592 | mTmpWindow = mTmpWindow2; |
| 593 | } |
| 594 | }; |
| 595 | |
| 596 | private final Predicate<WindowState> mComputeImeTargetPredicate = w -> { |
| 597 | if (DEBUG_INPUT_METHOD && mUpdateImeTarget) Slog.i(TAG_WM, "Checking window @" + w |
| 598 | + " fl=0x" + Integer.toHexString(w.mAttrs.flags)); |
| 599 | return w.canBeImeTarget(); |
| 600 | }; |
| 601 | |
| 602 | private final Consumer<WindowState> mApplyPostLayoutPolicy = |
| 603 | w -> mService.mPolicy.applyPostLayoutPolicyLw(w, w.mAttrs, w.getParentWindow(), |
| 604 | mService.mInputMethodTarget); |
| 605 | |
| 606 | private final Consumer<WindowState> mApplySurfaceChangesTransaction = w -> { |
| 607 | final WindowSurfacePlacer surfacePlacer = mService.mWindowPlacerLocked; |
| 608 | final boolean obscuredChanged = w.mObscured != |
| 609 | mTmpApplySurfaceChangesTransactionState.obscured; |
| 610 | final RootWindowContainer root = mService.mRoot; |
| 611 | // Only used if default window |
| 612 | final boolean someoneLosingFocus = !mService.mLosingFocus.isEmpty(); |
| 613 | |
| 614 | // Update effect. |
| 615 | w.mObscured = mTmpApplySurfaceChangesTransactionState.obscured; |
| 616 | if (!mTmpApplySurfaceChangesTransactionState.obscured) { |
| 617 | final boolean isDisplayed = w.isDisplayedLw(); |
| 618 | |
| 619 | if (isDisplayed && w.isObscuringDisplay()) { |
| 620 | // This window completely covers everything behind it, so we want to leave all |
| 621 | // of them as undimmed (for performance reasons). |
| 622 | root.mObscuringWindow = w; |
| 623 | mTmpApplySurfaceChangesTransactionState.obscured = true; |
| 624 | } |
| 625 | |
| 626 | mTmpApplySurfaceChangesTransactionState.displayHasContent |= |
| 627 | root.handleNotObscuredLocked(w, |
| 628 | mTmpApplySurfaceChangesTransactionState.obscured, |
| 629 | mTmpApplySurfaceChangesTransactionState.syswin); |
| 630 | |
| 631 | if (w.mHasSurface && isDisplayed) { |
| 632 | final int type = w.mAttrs.type; |
| 633 | if (type == TYPE_SYSTEM_DIALOG || type == TYPE_SYSTEM_ERROR |
| 634 | || (w.mAttrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
| 635 | mTmpApplySurfaceChangesTransactionState.syswin = true; |
| 636 | } |
| 637 | if (mTmpApplySurfaceChangesTransactionState.preferredRefreshRate == 0 |
| 638 | && w.mAttrs.preferredRefreshRate != 0) { |
| 639 | mTmpApplySurfaceChangesTransactionState.preferredRefreshRate |
| 640 | = w.mAttrs.preferredRefreshRate; |
| 641 | } |
| 642 | if (mTmpApplySurfaceChangesTransactionState.preferredModeId == 0 |
| 643 | && w.mAttrs.preferredDisplayModeId != 0) { |
| 644 | mTmpApplySurfaceChangesTransactionState.preferredModeId |
| 645 | = w.mAttrs.preferredDisplayModeId; |
| 646 | } |
| 647 | } |
| 648 | } |
| 649 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 650 | if (isDefaultDisplay && obscuredChanged && w.isVisibleLw() |
| 651 | && mWallpaperController.isWallpaperTarget(w)) { |
| 652 | // This is the wallpaper target and its obscured state changed... make sure the |
| 653 | // current wallpaper's visibility has been updated accordingly. |
| 654 | mWallpaperController.updateWallpaperVisibility(); |
| 655 | } |
| 656 | |
Jorim Jaggi | a5e1057 | 2017-11-15 14:36:26 +0100 | [diff] [blame] | 657 | // Use mTmpTransaction instead of mPendingTransaction because we don't want to commit |
| 658 | // other changes in mPendingTransaction at this point. |
| 659 | w.handleWindowMovedIfNeeded(mTmpTransaction); |
| 660 | SurfaceControl.mergeToGlobalTransaction(mTmpTransaction); |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 661 | |
| 662 | final WindowStateAnimator winAnimator = w.mWinAnimator; |
| 663 | |
| 664 | //Slog.i(TAG, "Window " + this + " clearing mContentChanged - done placing"); |
| 665 | w.mContentChanged = false; |
| 666 | |
| 667 | // Moved from updateWindowsAndWallpaperLocked(). |
| 668 | if (w.mHasSurface) { |
| 669 | // Take care of the window being ready to display. |
| 670 | final boolean committed = winAnimator.commitFinishDrawingLocked(); |
| 671 | if (isDefaultDisplay && committed) { |
| 672 | if (w.mAttrs.type == TYPE_DREAM) { |
| 673 | // HACK: When a dream is shown, it may at that point hide the lock screen. |
| 674 | // So we need to redo the layout to let the phone window manager make this |
| 675 | // happen. |
| 676 | pendingLayoutChanges |= FINISH_LAYOUT_REDO_LAYOUT; |
| 677 | if (DEBUG_LAYOUT_REPEATS) { |
| 678 | surfacePlacer.debugLayoutRepeats( |
| 679 | "dream and commitFinishDrawingLocked true", |
| 680 | pendingLayoutChanges); |
| 681 | } |
| 682 | } |
| 683 | if ((w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) { |
| 684 | if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, |
| 685 | "First draw done in potential wallpaper target " + w); |
| 686 | root.mWallpaperMayChange = true; |
| 687 | pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; |
| 688 | if (DEBUG_LAYOUT_REPEATS) { |
| 689 | surfacePlacer.debugLayoutRepeats( |
| 690 | "wallpaper and commitFinishDrawingLocked true", |
| 691 | pendingLayoutChanges); |
| 692 | } |
| 693 | } |
| 694 | } |
Robert Carr | 2117aaf | 2017-04-25 14:46:50 -0700 | [diff] [blame] | 695 | final TaskStack stack = w.getStack(); |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 696 | if (!winAnimator.isWaitingForOpening() |
Robert Carr | 2117aaf | 2017-04-25 14:46:50 -0700 | [diff] [blame] | 697 | || (stack != null && stack.isAnimatingBounds())) { |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 698 | // Updates the shown frame before we set up the surface. This is needed |
| 699 | // because the resizing could change the top-left position (in addition to |
| 700 | // size) of the window. setSurfaceBoundariesLocked uses mShownPosition to |
| 701 | // position the surface. |
| 702 | // |
| 703 | // If an animation is being started, we can't call this method because the |
| 704 | // animation hasn't processed its initial transformation yet, but in general |
Robert Carr | 2117aaf | 2017-04-25 14:46:50 -0700 | [diff] [blame] | 705 | // we do want to update the position if the window is animating. We make an exception |
| 706 | // for the bounds animating state, where an application may have been waiting |
| 707 | // for an exit animation to start, but instead enters PiP. We need to ensure |
| 708 | // we always recompute the top-left in this case. |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 709 | winAnimator.computeShownFrameLocked(); |
| 710 | } |
| 711 | winAnimator.setSurfaceBoundariesLocked(mTmpRecoveringMemory /* recoveringMemory */); |
Jorim Jaggi | a5e1057 | 2017-11-15 14:36:26 +0100 | [diff] [blame] | 712 | |
| 713 | // Since setSurfaceBoundariesLocked applies the clipping, we need to apply the position |
chaviw | e07246a | 2017-12-12 16:18:29 -0800 | [diff] [blame] | 714 | // to the surface of the window container and also the position of the stack window |
| 715 | // container as well. Use mTmpTransaction instead of mPendingTransaction to avoid |
| 716 | // committing any existing changes in there. |
Jorim Jaggi | a5e1057 | 2017-11-15 14:36:26 +0100 | [diff] [blame] | 717 | w.updateSurfacePosition(mTmpTransaction); |
chaviw | e07246a | 2017-12-12 16:18:29 -0800 | [diff] [blame] | 718 | if (stack != null) { |
| 719 | stack.updateSurfaceBounds(mTmpTransaction); |
| 720 | } |
Jorim Jaggi | a5e1057 | 2017-11-15 14:36:26 +0100 | [diff] [blame] | 721 | SurfaceControl.mergeToGlobalTransaction(mTmpTransaction); |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | final AppWindowToken atoken = w.mAppToken; |
| 725 | if (atoken != null) { |
| 726 | final boolean updateAllDrawn = atoken.updateDrawnWindowStates(w); |
| 727 | if (updateAllDrawn && !mTmpUpdateAllDrawn.contains(atoken)) { |
| 728 | mTmpUpdateAllDrawn.add(atoken); |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | if (isDefaultDisplay && someoneLosingFocus && w == mService.mCurrentFocus |
| 733 | && w.isDisplayedLw()) { |
| 734 | mTmpApplySurfaceChangesTransactionState.focusDisplayed = true; |
| 735 | } |
| 736 | |
| 737 | w.updateResizingWindowIfNeeded(); |
| 738 | }; |
| 739 | |
Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 740 | /** |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 741 | * Create new {@link DisplayContent} instance, add itself to the root window container and |
| 742 | * initialize direct children. |
Craig Mautner | 2d5618c | 2012-10-18 13:55:47 -0700 | [diff] [blame] | 743 | * @param display May not be null. |
Craig Mautner | df88d73 | 2014-01-27 09:21:32 -0800 | [diff] [blame] | 744 | * @param service You know. |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 745 | * @param wallpaperController wallpaper windows controller used to adjust the positioning of the |
| 746 | * wallpaper windows in the window list. |
Craig Mautner | 2d5618c | 2012-10-18 13:55:47 -0700 | [diff] [blame] | 747 | */ |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 748 | DisplayContent(Display display, WindowManagerService service, |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 749 | WallpaperController wallpaperController) { |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 750 | super(service); |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 751 | if (service.mRoot.getDisplayContent(display.getDisplayId()) != null) { |
| 752 | throw new IllegalArgumentException("Display with ID=" + display.getDisplayId() |
| 753 | + " already exists=" + service.mRoot.getDisplayContent(display.getDisplayId()) |
| 754 | + " new=" + display); |
| 755 | } |
| 756 | |
Craig Mautner | b47bbc3 | 2012-08-22 17:41:48 -0700 | [diff] [blame] | 757 | mDisplay = display; |
| 758 | mDisplayId = display.getDisplayId(); |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 759 | mWallpaperController = wallpaperController; |
Craig Mautner | b47bbc3 | 2012-08-22 17:41:48 -0700 | [diff] [blame] | 760 | display.getDisplayInfo(mDisplayInfo); |
Wale Ogunwale | 231b06e | 2015-09-16 12:03:09 -0700 | [diff] [blame] | 761 | display.getMetrics(mDisplayMetrics); |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 762 | isDefaultDisplay = mDisplayId == DEFAULT_DISPLAY; |
Wale Ogunwale | 828ff7e | 2017-11-14 01:01:29 +0000 | [diff] [blame] | 763 | mDisplayFrames = new DisplayFrames(mDisplayId, mDisplayInfo); |
Wale Ogunwale | fd04d8c | 2015-09-30 10:09:39 -0700 | [diff] [blame] | 764 | initializeDisplayBaseInfo(); |
Jorim Jaggi | 42625d1b | 2016-02-11 20:11:07 -0800 | [diff] [blame] | 765 | mDividerControllerLocked = new DockedStackDividerController(service, this); |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 766 | mPinnedStackControllerLocked = new PinnedStackController(service, this); |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 767 | |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 768 | mSurfaceSize = Math.max(mBaseDisplayHeight, mBaseDisplayWidth); |
| 769 | |
| 770 | final SurfaceControl.Builder b = mService.makeSurfaceBuilder(mSession) |
| 771 | .setSize(mSurfaceSize, mSurfaceSize) |
| 772 | .setOpaque(true); |
| 773 | mWindowingLayer = b.setName("Display Root").build(); |
| 774 | mOverlayLayer = b.setName("Display Overlays").build(); |
| 775 | |
Robert Carr | f59b8dd | 2017-10-02 18:58:36 -0700 | [diff] [blame] | 776 | getPendingTransaction().setLayer(mWindowingLayer, 0) |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 777 | .setLayerStack(mWindowingLayer, mDisplayId) |
| 778 | .show(mWindowingLayer) |
| 779 | .setLayer(mOverlayLayer, 1) |
| 780 | .setLayerStack(mOverlayLayer, mDisplayId) |
| 781 | .show(mOverlayLayer); |
Robert Carr | f59b8dd | 2017-10-02 18:58:36 -0700 | [diff] [blame] | 782 | getPendingTransaction().apply(); |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 783 | |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 784 | // These are the only direct children we should ever have and they are permanent. |
Wale Ogunwale | 3a93169 | 2016-11-02 16:49:48 -0700 | [diff] [blame] | 785 | super.addChild(mBelowAppWindowsContainers, null); |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 786 | super.addChild(mTaskStackContainers, null); |
Wale Ogunwale | 3a93169 | 2016-11-02 16:49:48 -0700 | [diff] [blame] | 787 | super.addChild(mAboveAppWindowsContainers, null); |
| 788 | super.addChild(mImeWindowsContainers, null); |
Andrii Kulian | 367ff7f | 2017-01-25 19:45:34 -0800 | [diff] [blame] | 789 | |
| 790 | // Add itself as a child to the root container. |
| 791 | mService.mRoot.addChild(this, null); |
Bryce Lee | d187126 | 2017-06-12 14:12:29 -0700 | [diff] [blame] | 792 | |
| 793 | // TODO(b/62541591): evaluate whether this is the best spot to declare the |
| 794 | // {@link DisplayContent} ready for use. |
| 795 | mDisplayReady = true; |
| 796 | } |
| 797 | |
| 798 | boolean isReady() { |
| 799 | // The display is ready when the system and the individual display are both ready. |
| 800 | return mService.mDisplayReady && mDisplayReady; |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 801 | } |
| 802 | |
| 803 | int getDisplayId() { |
| 804 | return mDisplayId; |
| 805 | } |
| 806 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 807 | WindowToken getWindowToken(IBinder binder) { |
| 808 | return mTokenMap.get(binder); |
| 809 | } |
| 810 | |
| 811 | AppWindowToken getAppWindowToken(IBinder binder) { |
| 812 | final WindowToken token = getWindowToken(binder); |
| 813 | if (token == null) { |
| 814 | return null; |
| 815 | } |
| 816 | return token.asAppWindowToken(); |
| 817 | } |
| 818 | |
Wale Ogunwale | 2f569ed | 2017-05-08 09:15:49 -0700 | [diff] [blame] | 819 | private void addWindowToken(IBinder binder, WindowToken token) { |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 820 | final DisplayContent dc = mService.mRoot.getWindowTokenDisplay(token); |
| 821 | if (dc != null) { |
| 822 | // We currently don't support adding a window token to the display if the display |
| 823 | // already has the binder mapped to another token. If there is a use case for supporting |
| 824 | // this moving forward we will either need to merge the WindowTokens some how or have |
| 825 | // the binder map to a list of window tokens. |
Wale Ogunwale | 2f569ed | 2017-05-08 09:15:49 -0700 | [diff] [blame] | 826 | throw new IllegalArgumentException("Can't map token=" + token + " to display=" |
| 827 | + getName() + " already mapped to display=" + dc + " tokens=" + dc.mTokenMap); |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 828 | } |
Wale Ogunwale | 2f569ed | 2017-05-08 09:15:49 -0700 | [diff] [blame] | 829 | if (binder == null) { |
| 830 | throw new IllegalArgumentException("Can't map token=" + token + " to display=" |
| 831 | + getName() + " binder is null"); |
| 832 | } |
| 833 | if (token == null) { |
| 834 | throw new IllegalArgumentException("Can't map null token to display=" |
| 835 | + getName() + " binder=" + binder); |
| 836 | } |
| 837 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 838 | mTokenMap.put(binder, token); |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 839 | |
| 840 | if (token.asAppWindowToken() == null) { |
| 841 | // Add non-app token to container hierarchy on the display. App tokens are added through |
| 842 | // the parent container managing them (e.g. Tasks). |
Wale Ogunwale | 3a93169 | 2016-11-02 16:49:48 -0700 | [diff] [blame] | 843 | switch (token.windowType) { |
| 844 | case TYPE_WALLPAPER: |
| 845 | mBelowAppWindowsContainers.addChild(token); |
| 846 | break; |
| 847 | case TYPE_INPUT_METHOD: |
| 848 | case TYPE_INPUT_METHOD_DIALOG: |
| 849 | mImeWindowsContainers.addChild(token); |
| 850 | break; |
| 851 | default: |
| 852 | mAboveAppWindowsContainers.addChild(token); |
| 853 | break; |
| 854 | } |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 855 | } |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | WindowToken removeWindowToken(IBinder binder) { |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 859 | final WindowToken token = mTokenMap.remove(binder); |
| 860 | if (token != null && token.asAppWindowToken() == null) { |
Wale Ogunwale | 3d0bfd9 | 2016-12-05 11:38:02 -0800 | [diff] [blame] | 861 | token.setExiting(); |
| 862 | } |
| 863 | return token; |
| 864 | } |
| 865 | |
| 866 | /** Changes the display the input window token is housed on to this one. */ |
| 867 | void reParentWindowToken(WindowToken token) { |
| 868 | final DisplayContent prevDc = token.getDisplayContent(); |
| 869 | if (prevDc == this) { |
| 870 | return; |
| 871 | } |
Andrii Kulian | 6cc1a1d | 2016-12-27 23:52:59 -0800 | [diff] [blame] | 872 | if (prevDc != null && prevDc.mTokenMap.remove(token.token) != null |
| 873 | && token.asAppWindowToken() == null) { |
| 874 | // Removed the token from the map, but made sure it's not an app token before removing |
| 875 | // from parent. |
| 876 | token.getParent().removeChild(token); |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 877 | } |
Wale Ogunwale | 3d0bfd9 | 2016-12-05 11:38:02 -0800 | [diff] [blame] | 878 | |
| 879 | addWindowToken(token.token, token); |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 880 | } |
| 881 | |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 882 | void removeAppToken(IBinder binder) { |
| 883 | final WindowToken token = removeWindowToken(binder); |
| 884 | if (token == null) { |
| 885 | Slog.w(TAG_WM, "removeAppToken: Attempted to remove non-existing token: " + binder); |
| 886 | return; |
| 887 | } |
| 888 | |
| 889 | final AppWindowToken appToken = token.asAppWindowToken(); |
| 890 | |
| 891 | if (appToken == null) { |
| 892 | Slog.w(TAG_WM, "Attempted to remove non-App token: " + binder + " token=" + token); |
| 893 | return; |
| 894 | } |
| 895 | |
| 896 | appToken.onRemovedFromDisplay(); |
| 897 | } |
| 898 | |
Craig Mautner | b47bbc3 | 2012-08-22 17:41:48 -0700 | [diff] [blame] | 899 | Display getDisplay() { |
| 900 | return mDisplay; |
| 901 | } |
| 902 | |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 903 | DisplayInfo getDisplayInfo() { |
| 904 | return mDisplayInfo; |
| 905 | } |
| 906 | |
Wale Ogunwale | 231b06e | 2015-09-16 12:03:09 -0700 | [diff] [blame] | 907 | DisplayMetrics getDisplayMetrics() { |
| 908 | return mDisplayMetrics; |
| 909 | } |
| 910 | |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 911 | int getRotation() { |
| 912 | return mRotation; |
| 913 | } |
| 914 | |
| 915 | void setRotation(int newRotation) { |
| 916 | mRotation = newRotation; |
| 917 | } |
| 918 | |
| 919 | int getLastOrientation() { |
| 920 | return mLastOrientation; |
| 921 | } |
| 922 | |
| 923 | void setLastOrientation(int orientation) { |
| 924 | mLastOrientation = orientation; |
| 925 | } |
| 926 | |
| 927 | boolean getAltOrientation() { |
| 928 | return mAltOrientation; |
| 929 | } |
| 930 | |
| 931 | void setAltOrientation(boolean altOrientation) { |
| 932 | mAltOrientation = altOrientation; |
| 933 | } |
| 934 | |
| 935 | int getLastWindowForcedOrientation() { |
| 936 | return mLastWindowForcedOrientation; |
| 937 | } |
| 938 | |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 939 | /** |
| 940 | * Update rotation of the display. |
| 941 | * |
| 942 | * Returns true if the rotation has been changed. In this case YOU MUST CALL |
| 943 | * {@link WindowManagerService#sendNewConfiguration(int)} TO UNFREEZE THE SCREEN. |
| 944 | */ |
| 945 | boolean updateRotationUnchecked(boolean inTransaction) { |
| 946 | if (mService.mDeferredRotationPauseCount > 0) { |
| 947 | // Rotation updates have been paused temporarily. Defer the update until |
| 948 | // updates have been resumed. |
| 949 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Deferring rotation, rotation is paused."); |
| 950 | return false; |
| 951 | } |
| 952 | |
| 953 | ScreenRotationAnimation screenRotationAnimation = |
| 954 | mService.mAnimator.getScreenRotationAnimationLocked(mDisplayId); |
| 955 | if (screenRotationAnimation != null && screenRotationAnimation.isAnimating()) { |
| 956 | // Rotation updates cannot be performed while the previous rotation change |
| 957 | // animation is still in progress. Skip this update. We will try updating |
| 958 | // again after the animation is finished and the display is unfrozen. |
| 959 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Deferring rotation, animation in progress."); |
| 960 | return false; |
| 961 | } |
| 962 | if (mService.mDisplayFrozen) { |
| 963 | // Even if the screen rotation animation has finished (e.g. isAnimating |
| 964 | // returns false), there is still some time where we haven't yet unfrozen |
| 965 | // the display. We also need to abort rotation here. |
| 966 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, |
| 967 | "Deferring rotation, still finishing previous rotation"); |
| 968 | return false; |
| 969 | } |
| 970 | |
| 971 | if (!mService.mDisplayEnabled) { |
| 972 | // No point choosing a rotation if the display is not enabled. |
| 973 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Deferring rotation, display is not enabled."); |
| 974 | return false; |
| 975 | } |
| 976 | |
| 977 | final int oldRotation = mRotation; |
| 978 | final int lastOrientation = mLastOrientation; |
| 979 | final boolean oldAltOrientation = mAltOrientation; |
| 980 | int rotation = mService.mPolicy.rotationForOrientationLw(lastOrientation, oldRotation); |
Robert Carr | 0e00727 | 2017-10-02 13:00:55 -0700 | [diff] [blame] | 981 | boolean mayRotateSeamlessly = mService.mPolicy.shouldRotateSeamlessly(oldRotation, |
Robert Carr | 897215d | 2017-03-29 12:25:50 -0700 | [diff] [blame] | 982 | rotation); |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 983 | |
Robert Carr | 0e00727 | 2017-10-02 13:00:55 -0700 | [diff] [blame] | 984 | if (mayRotateSeamlessly) { |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 985 | final WindowState seamlessRotated = getWindow((w) -> w.mSeamlesslyRotated); |
| 986 | if (seamlessRotated != null) { |
| 987 | // We can't rotate (seamlessly or not) while waiting for the last seamless rotation |
| 988 | // to complete (that is, waiting for windows to redraw). It's tempting to check |
| 989 | // w.mSeamlessRotationCount but that could be incorrect in the case of |
| 990 | // window-removal. |
| 991 | return false; |
| 992 | } |
Robert Carr | 0e00727 | 2017-10-02 13:00:55 -0700 | [diff] [blame] | 993 | |
| 994 | // In the presence of the PINNED stack or System Alert |
Wale Ogunwale | 44f036f | 2017-09-29 05:09:09 -0700 | [diff] [blame] | 995 | // windows we unfortunately can not seamlessly rotate. |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 996 | if (hasPinnedStack()) { |
Robert Carr | 0e00727 | 2017-10-02 13:00:55 -0700 | [diff] [blame] | 997 | mayRotateSeamlessly = false; |
| 998 | } |
| 999 | for (int i = 0; i < mService.mSessions.size(); i++) { |
| 1000 | if (mService.mSessions.valueAt(i).hasAlertWindowSurfaces()) { |
| 1001 | mayRotateSeamlessly = false; |
| 1002 | break; |
| 1003 | } |
| 1004 | } |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 1005 | } |
Robert Carr | 0e00727 | 2017-10-02 13:00:55 -0700 | [diff] [blame] | 1006 | final boolean rotateSeamlessly = mayRotateSeamlessly; |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 1007 | |
| 1008 | // TODO: Implement forced rotation changes. |
| 1009 | // Set mAltOrientation to indicate that the application is receiving |
| 1010 | // an orientation that has different metrics than it expected. |
| 1011 | // eg. Portrait instead of Landscape. |
| 1012 | |
| 1013 | final boolean altOrientation = !mService.mPolicy.rotationHasCompatibleMetricsLw( |
| 1014 | lastOrientation, rotation); |
| 1015 | |
| 1016 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Selected orientation " + lastOrientation |
| 1017 | + ", got rotation " + rotation + " which has " |
| 1018 | + (altOrientation ? "incompatible" : "compatible") + " metrics"); |
| 1019 | |
| 1020 | if (oldRotation == rotation && oldAltOrientation == altOrientation) { |
| 1021 | // No change. |
| 1022 | return false; |
| 1023 | } |
| 1024 | |
| 1025 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Rotation changed to " + rotation |
| 1026 | + (altOrientation ? " (alt)" : "") + " from " + oldRotation |
| 1027 | + (oldAltOrientation ? " (alt)" : "") + ", lastOrientation=" + lastOrientation); |
| 1028 | |
| 1029 | if (DisplayContent.deltaRotation(rotation, oldRotation) != 2) { |
| 1030 | mService.mWaitingForConfig = true; |
| 1031 | } |
| 1032 | |
| 1033 | mRotation = rotation; |
| 1034 | mAltOrientation = altOrientation; |
| 1035 | if (isDefaultDisplay) { |
| 1036 | mService.mPolicy.setRotationLw(rotation); |
| 1037 | } |
| 1038 | |
| 1039 | mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_ACTIVE; |
| 1040 | mService.mH.removeMessages(WindowManagerService.H.WINDOW_FREEZE_TIMEOUT); |
| 1041 | mService.mH.sendEmptyMessageDelayed(WindowManagerService.H.WINDOW_FREEZE_TIMEOUT, |
| 1042 | WINDOW_FREEZE_TIMEOUT_DURATION); |
| 1043 | |
| 1044 | setLayoutNeeded(); |
| 1045 | final int[] anim = new int[2]; |
Robert Carr | f59b8dd | 2017-10-02 18:58:36 -0700 | [diff] [blame] | 1046 | mService.mPolicy.selectRotationAnimationLw(anim); |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 1047 | |
| 1048 | if (!rotateSeamlessly) { |
Bryce Lee | 8f85358 | 2017-06-05 17:25:59 -0700 | [diff] [blame] | 1049 | mService.startFreezingDisplayLocked(inTransaction, anim[0], anim[1], this); |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 1050 | // startFreezingDisplayLocked can reset the ScreenRotationAnimation. |
| 1051 | screenRotationAnimation = mService.mAnimator.getScreenRotationAnimationLocked( |
| 1052 | mDisplayId); |
| 1053 | } else { |
| 1054 | // The screen rotation animation uses a screenshot to freeze the screen |
| 1055 | // while windows resize underneath. |
| 1056 | // When we are rotating seamlessly, we allow the elements to transition |
| 1057 | // to their rotated state independently and without a freeze required. |
| 1058 | screenRotationAnimation = null; |
| 1059 | |
| 1060 | // We have to reset this in case a window was removed before it |
| 1061 | // finished seamless rotation. |
| 1062 | mService.mSeamlessRotationCount = 0; |
| 1063 | } |
| 1064 | |
| 1065 | // We need to update our screen size information to match the new rotation. If the rotation |
| 1066 | // has actually changed then this method will return true and, according to the comment at |
| 1067 | // the top of the method, the caller is obligated to call computeNewConfigurationLocked(). |
| 1068 | // By updating the Display info here it will be available to |
| 1069 | // #computeScreenConfiguration() later. |
| 1070 | updateDisplayAndOrientation(getConfiguration().uiMode); |
| 1071 | |
| 1072 | if (!inTransaction) { |
| 1073 | if (SHOW_TRANSACTIONS) { |
| 1074 | Slog.i(TAG_WM, ">>> OPEN TRANSACTION setRotationUnchecked"); |
| 1075 | } |
| 1076 | mService.openSurfaceTransaction(); |
| 1077 | } |
| 1078 | try { |
| 1079 | // NOTE: We disable the rotation in the emulator because |
| 1080 | // it doesn't support hardware OpenGL emulation yet. |
| 1081 | if (CUSTOM_SCREEN_ROTATION && screenRotationAnimation != null |
| 1082 | && screenRotationAnimation.hasScreenshot()) { |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 1083 | if (screenRotationAnimation.setRotationInTransaction(rotation, |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 1084 | MAX_ANIMATION_DURATION, mService.getTransitionAnimationScaleLocked(), |
| 1085 | mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight)) { |
| 1086 | mService.scheduleAnimationLocked(); |
| 1087 | } |
| 1088 | } |
| 1089 | |
| 1090 | if (rotateSeamlessly) { |
| 1091 | forAllWindows(w -> { |
| 1092 | w.mWinAnimator.seamlesslyRotateWindow(oldRotation, rotation); |
| 1093 | }, true /* traverseTopToBottom */); |
| 1094 | } |
| 1095 | |
| 1096 | mService.mDisplayManagerInternal.performTraversalInTransactionFromWindowManager(); |
| 1097 | } finally { |
| 1098 | if (!inTransaction) { |
Adrian Roos | 111aff9 | 2017-09-27 18:11:46 +0200 | [diff] [blame] | 1099 | mService.closeSurfaceTransaction("setRotationUnchecked"); |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 1100 | if (SHOW_LIGHT_TRANSACTIONS) { |
| 1101 | Slog.i(TAG_WM, "<<< CLOSE TRANSACTION setRotationUnchecked"); |
| 1102 | } |
| 1103 | } |
| 1104 | } |
| 1105 | |
| 1106 | forAllWindows(w -> { |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 1107 | if (w.mHasSurface && !rotateSeamlessly) { |
| 1108 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Set mOrientationChanging of " + w); |
Bryce Lee | 8c3cf38 | 2017-07-06 19:47:10 -0700 | [diff] [blame] | 1109 | w.setOrientationChanging(true); |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 1110 | mService.mRoot.mOrientationChangeComplete = false; |
| 1111 | w.mLastFreezeDuration = 0; |
| 1112 | } |
| 1113 | w.mReportOrientationChanged = true; |
| 1114 | }, true /* traverseTopToBottom */); |
| 1115 | |
| 1116 | if (rotateSeamlessly) { |
| 1117 | mService.mH.removeMessages(WindowManagerService.H.SEAMLESS_ROTATION_TIMEOUT); |
| 1118 | mService.mH.sendEmptyMessageDelayed(WindowManagerService.H.SEAMLESS_ROTATION_TIMEOUT, |
| 1119 | SEAMLESS_ROTATION_TIMEOUT_DURATION); |
| 1120 | } |
| 1121 | |
| 1122 | for (int i = mService.mRotationWatchers.size() - 1; i >= 0; i--) { |
| 1123 | final WindowManagerService.RotationWatcher rotationWatcher |
| 1124 | = mService.mRotationWatchers.get(i); |
| 1125 | if (rotationWatcher.mDisplayId == mDisplayId) { |
| 1126 | try { |
| 1127 | rotationWatcher.mWatcher.onRotationChanged(rotation); |
| 1128 | } catch (RemoteException e) { |
| 1129 | // Ignore |
| 1130 | } |
| 1131 | } |
| 1132 | } |
| 1133 | |
| 1134 | // TODO (multi-display): Magnification is supported only for the default display. |
| 1135 | // Announce rotation only if we will not animate as we already have the |
| 1136 | // windows in final state. Otherwise, we make this call at the rotation end. |
| 1137 | if (screenRotationAnimation == null && mService.mAccessibilityController != null |
| 1138 | && isDefaultDisplay) { |
| 1139 | mService.mAccessibilityController.onRotationChangedLocked(this); |
| 1140 | } |
| 1141 | |
| 1142 | return true; |
| 1143 | } |
| 1144 | |
Wale Ogunwale | 828ff7e | 2017-11-14 01:01:29 +0000 | [diff] [blame] | 1145 | void configureDisplayPolicy() { |
| 1146 | mService.mPolicy.setInitialDisplaySize(getDisplay(), |
| 1147 | mBaseDisplayWidth, mBaseDisplayHeight, mBaseDisplayDensity); |
| 1148 | |
| 1149 | mDisplayFrames.onDisplayInfoUpdated(mDisplayInfo); |
| 1150 | } |
| 1151 | |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 1152 | /** |
| 1153 | * Update {@link #mDisplayInfo} and other internal variables when display is rotated or config |
| 1154 | * changed. |
| 1155 | * Do not call if {@link WindowManagerService#mDisplayReady} == false. |
| 1156 | */ |
| 1157 | private DisplayInfo updateDisplayAndOrientation(int uiMode) { |
| 1158 | // Use the effective "visual" dimensions based on current rotation |
| 1159 | final boolean rotated = (mRotation == ROTATION_90 || mRotation == ROTATION_270); |
| 1160 | final int realdw = rotated ? mBaseDisplayHeight : mBaseDisplayWidth; |
| 1161 | final int realdh = rotated ? mBaseDisplayWidth : mBaseDisplayHeight; |
| 1162 | int dw = realdw; |
| 1163 | int dh = realdh; |
| 1164 | |
| 1165 | if (mAltOrientation) { |
| 1166 | if (realdw > realdh) { |
| 1167 | // Turn landscape into portrait. |
| 1168 | int maxw = (int)(realdh/1.3f); |
| 1169 | if (maxw < realdw) { |
| 1170 | dw = maxw; |
| 1171 | } |
| 1172 | } else { |
| 1173 | // Turn portrait into landscape. |
| 1174 | int maxh = (int)(realdw/1.3f); |
| 1175 | if (maxh < realdh) { |
| 1176 | dh = maxh; |
| 1177 | } |
| 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | // Update application display metrics. |
| 1182 | final int appWidth = mService.mPolicy.getNonDecorDisplayWidth(dw, dh, mRotation, uiMode, |
| 1183 | mDisplayId); |
| 1184 | final int appHeight = mService.mPolicy.getNonDecorDisplayHeight(dw, dh, mRotation, uiMode, |
| 1185 | mDisplayId); |
| 1186 | mDisplayInfo.rotation = mRotation; |
| 1187 | mDisplayInfo.logicalWidth = dw; |
| 1188 | mDisplayInfo.logicalHeight = dh; |
| 1189 | mDisplayInfo.logicalDensityDpi = mBaseDisplayDensity; |
| 1190 | mDisplayInfo.appWidth = appWidth; |
| 1191 | mDisplayInfo.appHeight = appHeight; |
| 1192 | if (isDefaultDisplay) { |
| 1193 | mDisplayInfo.getLogicalMetrics(mRealDisplayMetrics, |
| 1194 | CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null); |
| 1195 | } |
| 1196 | mDisplayInfo.getAppMetrics(mDisplayMetrics); |
| 1197 | if (mDisplayScalingDisabled) { |
| 1198 | mDisplayInfo.flags |= Display.FLAG_SCALING_DISABLED; |
| 1199 | } else { |
| 1200 | mDisplayInfo.flags &= ~Display.FLAG_SCALING_DISABLED; |
| 1201 | } |
| 1202 | |
| 1203 | mService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(mDisplayId, |
| 1204 | mDisplayInfo); |
| 1205 | |
| 1206 | mBaseDisplayRect.set(0, 0, dw, dh); |
| 1207 | |
| 1208 | if (isDefaultDisplay) { |
| 1209 | mCompatibleScreenScale = CompatibilityInfo.computeCompatibleScaling(mDisplayMetrics, |
| 1210 | mCompatDisplayMetrics); |
| 1211 | } |
Bryce Lee | f3c6a47 | 2017-11-14 14:53:06 -0800 | [diff] [blame] | 1212 | |
| 1213 | updateBounds(); |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 1214 | return mDisplayInfo; |
| 1215 | } |
| 1216 | |
| 1217 | /** |
| 1218 | * Compute display configuration based on display properties and policy settings. |
| 1219 | * Do not call if mDisplayReady == false. |
| 1220 | */ |
| 1221 | void computeScreenConfiguration(Configuration config) { |
| 1222 | final DisplayInfo displayInfo = updateDisplayAndOrientation(config.uiMode); |
| 1223 | |
| 1224 | final int dw = displayInfo.logicalWidth; |
| 1225 | final int dh = displayInfo.logicalHeight; |
Wale Ogunwale | 687b427 | 2017-07-27 02:56:23 -0700 | [diff] [blame] | 1226 | config.orientation = (dw <= dh) ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE; |
| 1227 | // TODO: Probably best to set this based on some setting in the display content object, |
| 1228 | // so the display can be configured for things like fullscreen. |
| 1229 | config.windowConfiguration.setWindowingMode(WINDOWING_MODE_FULLSCREEN); |
Bryce Lee | c1f2f2a | 2017-06-22 15:29:42 -0700 | [diff] [blame] | 1230 | |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 1231 | config.screenWidthDp = |
| 1232 | (int)(mService.mPolicy.getConfigDisplayWidth(dw, dh, displayInfo.rotation, |
| 1233 | config.uiMode, mDisplayId) / mDisplayMetrics.density); |
| 1234 | config.screenHeightDp = |
| 1235 | (int)(mService.mPolicy.getConfigDisplayHeight(dw, dh, displayInfo.rotation, |
| 1236 | config.uiMode, mDisplayId) / mDisplayMetrics.density); |
Bryce Lee | 7566d76 | 2017-03-30 09:34:15 -0700 | [diff] [blame] | 1237 | |
| 1238 | mService.mPolicy.getNonDecorInsetsLw(displayInfo.rotation, dw, dh, mTmpRect); |
| 1239 | final int leftInset = mTmpRect.left; |
| 1240 | final int topInset = mTmpRect.top; |
| 1241 | // appBounds at the root level should mirror the app screen size. |
Wale Ogunwale | 822e512 | 2017-07-26 06:02:24 -0700 | [diff] [blame] | 1242 | config.windowConfiguration.setAppBounds(leftInset /* left */, topInset /* top */, |
| 1243 | leftInset + displayInfo.appWidth /* right */, |
| 1244 | topInset + displayInfo.appHeight /* bottom */); |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 1245 | final boolean rotated = (displayInfo.rotation == Surface.ROTATION_90 |
| 1246 | || displayInfo.rotation == Surface.ROTATION_270); |
| 1247 | |
| 1248 | computeSizeRangesAndScreenLayout(displayInfo, mDisplayId, rotated, config.uiMode, dw, dh, |
| 1249 | mDisplayMetrics.density, config); |
| 1250 | |
| 1251 | config.screenLayout = (config.screenLayout & ~Configuration.SCREENLAYOUT_ROUND_MASK) |
| 1252 | | ((displayInfo.flags & Display.FLAG_ROUND) != 0 |
| 1253 | ? Configuration.SCREENLAYOUT_ROUND_YES |
| 1254 | : Configuration.SCREENLAYOUT_ROUND_NO); |
| 1255 | |
| 1256 | config.compatScreenWidthDp = (int)(config.screenWidthDp / mCompatibleScreenScale); |
| 1257 | config.compatScreenHeightDp = (int)(config.screenHeightDp / mCompatibleScreenScale); |
| 1258 | config.compatSmallestScreenWidthDp = computeCompatSmallestWidth(rotated, config.uiMode, dw, |
| 1259 | dh, mDisplayId); |
| 1260 | config.densityDpi = displayInfo.logicalDensityDpi; |
| 1261 | |
| 1262 | config.colorMode = |
| 1263 | (displayInfo.isHdr() |
| 1264 | ? Configuration.COLOR_MODE_HDR_YES |
| 1265 | : Configuration.COLOR_MODE_HDR_NO) |
Romain Guy | e89d0bb | 2017-06-20 12:23:42 -0700 | [diff] [blame] | 1266 | | (displayInfo.isWideColorGamut() && mService.hasWideColorGamutSupport() |
Andrii Kulian | 06d07d6 | 2017-03-14 11:11:47 -0700 | [diff] [blame] | 1267 | ? Configuration.COLOR_MODE_WIDE_COLOR_GAMUT_YES |
| 1268 | : Configuration.COLOR_MODE_WIDE_COLOR_GAMUT_NO); |
| 1269 | |
| 1270 | // Update the configuration based on available input devices, lid switch, |
| 1271 | // and platform configuration. |
| 1272 | config.touchscreen = Configuration.TOUCHSCREEN_NOTOUCH; |
| 1273 | config.keyboard = Configuration.KEYBOARD_NOKEYS; |
| 1274 | config.navigation = Configuration.NAVIGATION_NONAV; |
| 1275 | |
| 1276 | int keyboardPresence = 0; |
| 1277 | int navigationPresence = 0; |
| 1278 | final InputDevice[] devices = mService.mInputManager.getInputDevices(); |
| 1279 | final int len = devices != null ? devices.length : 0; |
| 1280 | for (int i = 0; i < len; i++) { |
| 1281 | InputDevice device = devices[i]; |
| 1282 | if (!device.isVirtual()) { |
| 1283 | final int sources = device.getSources(); |
| 1284 | final int presenceFlag = device.isExternal() ? |
| 1285 | WindowManagerPolicy.PRESENCE_EXTERNAL : |
| 1286 | WindowManagerPolicy.PRESENCE_INTERNAL; |
| 1287 | |
| 1288 | // TODO(multi-display): Configure on per-display basis. |
| 1289 | if (mService.mIsTouchDevice) { |
| 1290 | if ((sources & InputDevice.SOURCE_TOUCHSCREEN) == |
| 1291 | InputDevice.SOURCE_TOUCHSCREEN) { |
| 1292 | config.touchscreen = Configuration.TOUCHSCREEN_FINGER; |
| 1293 | } |
| 1294 | } else { |
| 1295 | config.touchscreen = Configuration.TOUCHSCREEN_NOTOUCH; |
| 1296 | } |
| 1297 | |
| 1298 | if ((sources & InputDevice.SOURCE_TRACKBALL) == InputDevice.SOURCE_TRACKBALL) { |
| 1299 | config.navigation = Configuration.NAVIGATION_TRACKBALL; |
| 1300 | navigationPresence |= presenceFlag; |
| 1301 | } else if ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD |
| 1302 | && config.navigation == Configuration.NAVIGATION_NONAV) { |
| 1303 | config.navigation = Configuration.NAVIGATION_DPAD; |
| 1304 | navigationPresence |= presenceFlag; |
| 1305 | } |
| 1306 | |
| 1307 | if (device.getKeyboardType() == InputDevice.KEYBOARD_TYPE_ALPHABETIC) { |
| 1308 | config.keyboard = Configuration.KEYBOARD_QWERTY; |
| 1309 | keyboardPresence |= presenceFlag; |
| 1310 | } |
| 1311 | } |
| 1312 | } |
| 1313 | |
| 1314 | if (config.navigation == Configuration.NAVIGATION_NONAV && mService.mHasPermanentDpad) { |
| 1315 | config.navigation = Configuration.NAVIGATION_DPAD; |
| 1316 | navigationPresence |= WindowManagerPolicy.PRESENCE_INTERNAL; |
| 1317 | } |
| 1318 | |
| 1319 | // Determine whether a hard keyboard is available and enabled. |
| 1320 | // TODO(multi-display): Should the hardware keyboard be tied to a display or to a device? |
| 1321 | boolean hardKeyboardAvailable = config.keyboard != Configuration.KEYBOARD_NOKEYS; |
| 1322 | if (hardKeyboardAvailable != mService.mHardKeyboardAvailable) { |
| 1323 | mService.mHardKeyboardAvailable = hardKeyboardAvailable; |
| 1324 | mService.mH.removeMessages(WindowManagerService.H.REPORT_HARD_KEYBOARD_STATUS_CHANGE); |
| 1325 | mService.mH.sendEmptyMessage(WindowManagerService.H.REPORT_HARD_KEYBOARD_STATUS_CHANGE); |
| 1326 | } |
| 1327 | |
| 1328 | // Let the policy update hidden states. |
| 1329 | config.keyboardHidden = Configuration.KEYBOARDHIDDEN_NO; |
| 1330 | config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_NO; |
| 1331 | config.navigationHidden = Configuration.NAVIGATIONHIDDEN_NO; |
| 1332 | mService.mPolicy.adjustConfigurationLw(config, keyboardPresence, navigationPresence); |
| 1333 | } |
| 1334 | |
| 1335 | private int computeCompatSmallestWidth(boolean rotated, int uiMode, int dw, int dh, |
| 1336 | int displayId) { |
| 1337 | mTmpDisplayMetrics.setTo(mDisplayMetrics); |
| 1338 | final DisplayMetrics tmpDm = mTmpDisplayMetrics; |
| 1339 | final int unrotDw, unrotDh; |
| 1340 | if (rotated) { |
| 1341 | unrotDw = dh; |
| 1342 | unrotDh = dw; |
| 1343 | } else { |
| 1344 | unrotDw = dw; |
| 1345 | unrotDh = dh; |
| 1346 | } |
| 1347 | int sw = reduceCompatConfigWidthSize(0, Surface.ROTATION_0, uiMode, tmpDm, unrotDw, unrotDh, |
| 1348 | displayId); |
| 1349 | sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_90, uiMode, tmpDm, unrotDh, unrotDw, |
| 1350 | displayId); |
| 1351 | sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_180, uiMode, tmpDm, unrotDw, unrotDh, |
| 1352 | displayId); |
| 1353 | sw = reduceCompatConfigWidthSize(sw, Surface.ROTATION_270, uiMode, tmpDm, unrotDh, unrotDw, |
| 1354 | displayId); |
| 1355 | return sw; |
| 1356 | } |
| 1357 | |
| 1358 | private int reduceCompatConfigWidthSize(int curSize, int rotation, int uiMode, |
| 1359 | DisplayMetrics dm, int dw, int dh, int displayId) { |
| 1360 | dm.noncompatWidthPixels = mService.mPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode, |
| 1361 | displayId); |
| 1362 | dm.noncompatHeightPixels = mService.mPolicy.getNonDecorDisplayHeight(dw, dh, rotation, |
| 1363 | uiMode, displayId); |
| 1364 | float scale = CompatibilityInfo.computeCompatibleScaling(dm, null); |
| 1365 | int size = (int)(((dm.noncompatWidthPixels / scale) / dm.density) + .5f); |
| 1366 | if (curSize == 0 || size < curSize) { |
| 1367 | curSize = size; |
| 1368 | } |
| 1369 | return curSize; |
| 1370 | } |
| 1371 | |
| 1372 | private void computeSizeRangesAndScreenLayout(DisplayInfo displayInfo, int displayId, |
| 1373 | boolean rotated, int uiMode, int dw, int dh, float density, Configuration outConfig) { |
| 1374 | |
| 1375 | // We need to determine the smallest width that will occur under normal |
| 1376 | // operation. To this, start with the base screen size and compute the |
| 1377 | // width under the different possible rotations. We need to un-rotate |
| 1378 | // the current screen dimensions before doing this. |
| 1379 | int unrotDw, unrotDh; |
| 1380 | if (rotated) { |
| 1381 | unrotDw = dh; |
| 1382 | unrotDh = dw; |
| 1383 | } else { |
| 1384 | unrotDw = dw; |
| 1385 | unrotDh = dh; |
| 1386 | } |
| 1387 | displayInfo.smallestNominalAppWidth = 1<<30; |
| 1388 | displayInfo.smallestNominalAppHeight = 1<<30; |
| 1389 | displayInfo.largestNominalAppWidth = 0; |
| 1390 | displayInfo.largestNominalAppHeight = 0; |
| 1391 | adjustDisplaySizeRanges(displayInfo, displayId, Surface.ROTATION_0, uiMode, unrotDw, |
| 1392 | unrotDh); |
| 1393 | adjustDisplaySizeRanges(displayInfo, displayId, Surface.ROTATION_90, uiMode, unrotDh, |
| 1394 | unrotDw); |
| 1395 | adjustDisplaySizeRanges(displayInfo, displayId, Surface.ROTATION_180, uiMode, unrotDw, |
| 1396 | unrotDh); |
| 1397 | adjustDisplaySizeRanges(displayInfo, displayId, Surface.ROTATION_270, uiMode, unrotDh, |
| 1398 | unrotDw); |
| 1399 | int sl = Configuration.resetScreenLayout(outConfig.screenLayout); |
| 1400 | sl = reduceConfigLayout(sl, Surface.ROTATION_0, density, unrotDw, unrotDh, uiMode, |
| 1401 | displayId); |
| 1402 | sl = reduceConfigLayout(sl, Surface.ROTATION_90, density, unrotDh, unrotDw, uiMode, |
| 1403 | displayId); |
| 1404 | sl = reduceConfigLayout(sl, Surface.ROTATION_180, density, unrotDw, unrotDh, uiMode, |
| 1405 | displayId); |
| 1406 | sl = reduceConfigLayout(sl, Surface.ROTATION_270, density, unrotDh, unrotDw, uiMode, |
| 1407 | displayId); |
| 1408 | outConfig.smallestScreenWidthDp = (int)(displayInfo.smallestNominalAppWidth / density); |
| 1409 | outConfig.screenLayout = sl; |
| 1410 | } |
| 1411 | |
| 1412 | private int reduceConfigLayout(int curLayout, int rotation, float density, int dw, int dh, |
| 1413 | int uiMode, int displayId) { |
| 1414 | // Get the app screen size at this rotation. |
| 1415 | int w = mService.mPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode, displayId); |
| 1416 | int h = mService.mPolicy.getNonDecorDisplayHeight(dw, dh, rotation, uiMode, displayId); |
| 1417 | |
| 1418 | // Compute the screen layout size class for this rotation. |
| 1419 | int longSize = w; |
| 1420 | int shortSize = h; |
| 1421 | if (longSize < shortSize) { |
| 1422 | int tmp = longSize; |
| 1423 | longSize = shortSize; |
| 1424 | shortSize = tmp; |
| 1425 | } |
| 1426 | longSize = (int)(longSize/density); |
| 1427 | shortSize = (int)(shortSize/density); |
| 1428 | return Configuration.reduceScreenLayout(curLayout, longSize, shortSize); |
| 1429 | } |
| 1430 | |
| 1431 | private void adjustDisplaySizeRanges(DisplayInfo displayInfo, int displayId, int rotation, |
| 1432 | int uiMode, int dw, int dh) { |
| 1433 | final int width = mService.mPolicy.getConfigDisplayWidth(dw, dh, rotation, uiMode, |
| 1434 | displayId); |
| 1435 | if (width < displayInfo.smallestNominalAppWidth) { |
| 1436 | displayInfo.smallestNominalAppWidth = width; |
| 1437 | } |
| 1438 | if (width > displayInfo.largestNominalAppWidth) { |
| 1439 | displayInfo.largestNominalAppWidth = width; |
| 1440 | } |
| 1441 | final int height = mService.mPolicy.getConfigDisplayHeight(dw, dh, rotation, uiMode, |
| 1442 | displayId); |
| 1443 | if (height < displayInfo.smallestNominalAppHeight) { |
| 1444 | displayInfo.smallestNominalAppHeight = height; |
| 1445 | } |
| 1446 | if (height > displayInfo.largestNominalAppHeight) { |
| 1447 | displayInfo.largestNominalAppHeight = height; |
| 1448 | } |
| 1449 | } |
| 1450 | |
Jorim Jaggi | 61f39a7 | 2015-10-29 16:54:18 +0100 | [diff] [blame] | 1451 | DockedStackDividerController getDockedDividerController() { |
| 1452 | return mDividerControllerLocked; |
| 1453 | } |
| 1454 | |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 1455 | PinnedStackController getPinnedStackController() { |
| 1456 | return mPinnedStackControllerLocked; |
| 1457 | } |
| 1458 | |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 1459 | /** |
| 1460 | * Returns true if the specified UID has access to this display. |
| 1461 | */ |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 1462 | boolean hasAccess(int uid) { |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 1463 | return mDisplay.hasAccess(uid); |
| 1464 | } |
| 1465 | |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 1466 | boolean isPrivate() { |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 1467 | return (mDisplay.getFlags() & FLAG_PRIVATE) != 0; |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1468 | } |
| 1469 | |
Craig Mautner | d5d5d0f | 2013-04-03 15:08:21 -0700 | [diff] [blame] | 1470 | TaskStack getHomeStack() { |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1471 | return mTaskStackContainers.getHomeStack(); |
Craig Mautner | d5d5d0f | 2013-04-03 15:08:21 -0700 | [diff] [blame] | 1472 | } |
| 1473 | |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1474 | /** |
| 1475 | * @return The primary split-screen stack, but only if it is visible, and {@code null} otherwise. |
| 1476 | */ |
Matthew Ng | 64e77cf | 2017-10-31 14:01:31 -0700 | [diff] [blame] | 1477 | TaskStack getSplitScreenPrimaryStack() { |
| 1478 | TaskStack stack = mTaskStackContainers.getSplitScreenPrimaryStack(); |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1479 | return (stack != null && stack.isVisible()) ? stack : null; |
| 1480 | } |
| 1481 | |
| 1482 | /** |
Matthew Ng | 64e77cf | 2017-10-31 14:01:31 -0700 | [diff] [blame] | 1483 | * Like {@link #getSplitScreenPrimaryStack}, but also returns the stack if it's currently |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1484 | * not visible. |
| 1485 | */ |
Matthew Ng | 64e77cf | 2017-10-31 14:01:31 -0700 | [diff] [blame] | 1486 | TaskStack getSplitScreenPrimaryStackIgnoringVisibility() { |
| 1487 | return mTaskStackContainers.getSplitScreenPrimaryStack(); |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1488 | } |
| 1489 | |
| 1490 | TaskStack getPinnedStack() { |
| 1491 | return mTaskStackContainers.getPinnedStack(); |
| 1492 | } |
| 1493 | |
| 1494 | private boolean hasPinnedStack() { |
| 1495 | return mTaskStackContainers.getPinnedStack() != null; |
Chong Zhang | d9d35bd | 2016-08-04 17:55:21 -0700 | [diff] [blame] | 1496 | } |
| 1497 | |
Wale Ogunwale | b62139d | 2017-09-20 15:37:35 -0700 | [diff] [blame] | 1498 | /** |
| 1499 | * Returns the topmost stack on the display that is compatible with the input windowing mode. |
| 1500 | * Null is no compatible stack on the display. |
| 1501 | */ |
Wale Ogunwale | 30e441d | 2017-11-09 08:28:45 -0800 | [diff] [blame] | 1502 | TaskStack getTopStackInWindowingMode(int windowingMode) { |
Wale Ogunwale | b62139d | 2017-09-20 15:37:35 -0700 | [diff] [blame] | 1503 | return getStack(windowingMode, ACTIVITY_TYPE_UNDEFINED); |
| 1504 | } |
| 1505 | |
| 1506 | /** |
| 1507 | * Returns the topmost stack on the display that is compatible with the input windowing mode and |
| 1508 | * activity type. Null is no compatible stack on the display. |
| 1509 | */ |
Wale Ogunwale | 6827856 | 2017-09-23 17:13:55 -0700 | [diff] [blame] | 1510 | TaskStack getStack(int windowingMode, int activityType) { |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1511 | return mTaskStackContainers.getStack(windowingMode, activityType); |
Wale Ogunwale | b62139d | 2017-09-20 15:37:35 -0700 | [diff] [blame] | 1512 | } |
| 1513 | |
Bryce Lee | 48f4b57 | 2017-04-10 10:54:15 -0700 | [diff] [blame] | 1514 | @VisibleForTesting |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1515 | TaskStack getTopStack() { |
| 1516 | return mTaskStackContainers.getTopStack(); |
Bryce Lee | 48f4b57 | 2017-04-10 10:54:15 -0700 | [diff] [blame] | 1517 | } |
| 1518 | |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1519 | void onStackWindowingModeChanged(TaskStack stack) { |
| 1520 | mTaskStackContainers.onStackWindowingModeChanged(stack); |
Bryce Lee | 48f4b57 | 2017-04-10 10:54:15 -0700 | [diff] [blame] | 1521 | } |
| 1522 | |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 1523 | @Override |
Wale Ogunwale | 98d6231 | 2017-07-12 09:24:56 -0700 | [diff] [blame] | 1524 | public void onConfigurationChanged(Configuration newParentConfig) { |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 1525 | super.onConfigurationChanged(newParentConfig); |
| 1526 | |
Andrii Kulian | 3a507b5 | 2016-09-19 18:14:12 -0700 | [diff] [blame] | 1527 | // The display size information is heavily dependent on the resources in the current |
| 1528 | // configuration, so we need to reconfigure it every time the configuration changes. |
| 1529 | // See {@link PhoneWindowManager#setInitialDisplaySize}...sigh... |
| 1530 | mService.reconfigureDisplayLocked(this); |
| 1531 | |
Bryce Lee | f3c6a47 | 2017-11-14 14:53:06 -0800 | [diff] [blame] | 1532 | final DockedStackDividerController dividerController = getDockedDividerController(); |
| 1533 | |
| 1534 | if (dividerController != null) { |
| 1535 | getDockedDividerController().onConfigurationChanged(); |
| 1536 | } |
| 1537 | |
| 1538 | final PinnedStackController pinnedStackController = getPinnedStackController(); |
| 1539 | |
| 1540 | if (pinnedStackController != null) { |
| 1541 | getPinnedStackController().onConfigurationChanged(); |
| 1542 | } |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 1543 | } |
Andrii Kulian | 3a507b5 | 2016-09-19 18:14:12 -0700 | [diff] [blame] | 1544 | |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 1545 | /** |
| 1546 | * Callback used to trigger bounds update after configuration change and get ids of stacks whose |
| 1547 | * bounds were updated. |
| 1548 | */ |
| 1549 | void updateStackBoundsAfterConfigChange(@NonNull List<Integer> changedStackList) { |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1550 | for (int i = mTaskStackContainers.getChildCount() - 1; i >= 0; --i) { |
| 1551 | final TaskStack stack = mTaskStackContainers.getChildAt(i); |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 1552 | if (stack.updateBoundsAfterConfigChange()) { |
Andrii Kulian | 3a507b5 | 2016-09-19 18:14:12 -0700 | [diff] [blame] | 1553 | changedStackList.add(stack.mStackId); |
| 1554 | } |
| 1555 | } |
Winson Chung | 32c566f | 2017-04-11 18:31:21 -0700 | [diff] [blame] | 1556 | |
| 1557 | // If there was no pinned stack, we still need to notify the controller of the display info |
| 1558 | // update as a result of the config change. We do this here to consolidate the flow between |
| 1559 | // changes when there is and is not a stack. |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1560 | if (!hasPinnedStack()) { |
Winson Chung | 32c566f | 2017-04-11 18:31:21 -0700 | [diff] [blame] | 1561 | mPinnedStackControllerLocked.onDisplayInfoChanged(); |
| 1562 | } |
Andrii Kulian | 3a507b5 | 2016-09-19 18:14:12 -0700 | [diff] [blame] | 1563 | } |
| 1564 | |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 1565 | @Override |
| 1566 | boolean fillsParent() { |
| 1567 | return true; |
| 1568 | } |
| 1569 | |
| 1570 | @Override |
| 1571 | boolean isVisible() { |
| 1572 | return true; |
| 1573 | } |
| 1574 | |
| 1575 | @Override |
Wale Ogunwale | 9adfe57 | 2016-09-08 20:43:58 -0700 | [diff] [blame] | 1576 | void onAppTransitionDone() { |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 1577 | super.onAppTransitionDone(); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 1578 | mService.mWindowsChanged = true; |
Wale Ogunwale | 9adfe57 | 2016-09-08 20:43:58 -0700 | [diff] [blame] | 1579 | } |
| 1580 | |
Wale Ogunwale | ba51ca2 | 2016-09-23 06:06:54 -0700 | [diff] [blame] | 1581 | @Override |
Wale Ogunwale | 3c1170d | 2016-12-02 14:44:52 -0800 | [diff] [blame] | 1582 | boolean forAllWindows(ToBooleanFunction<WindowState> callback, boolean traverseTopToBottom) { |
| 1583 | // Special handling so we can process IME windows with #forAllImeWindows above their IME |
| 1584 | // target, or here in order if there isn't an IME target. |
| 1585 | if (traverseTopToBottom) { |
| 1586 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 1587 | final DisplayChildWindowContainer child = mChildren.get(i); |
| 1588 | if (child == mImeWindowsContainers && mService.mInputMethodTarget != null) { |
| 1589 | // In this case the Ime windows will be processed above their target so we skip |
| 1590 | // here. |
| 1591 | continue; |
| 1592 | } |
| 1593 | if (child.forAllWindows(callback, traverseTopToBottom)) { |
| 1594 | return true; |
| 1595 | } |
| 1596 | } |
| 1597 | } else { |
| 1598 | final int count = mChildren.size(); |
| 1599 | for (int i = 0; i < count; i++) { |
| 1600 | final DisplayChildWindowContainer child = mChildren.get(i); |
| 1601 | if (child == mImeWindowsContainers && mService.mInputMethodTarget != null) { |
| 1602 | // In this case the Ime windows will be processed above their target so we skip |
| 1603 | // here. |
| 1604 | continue; |
| 1605 | } |
| 1606 | if (child.forAllWindows(callback, traverseTopToBottom)) { |
| 1607 | return true; |
| 1608 | } |
| 1609 | } |
| 1610 | } |
| 1611 | return false; |
| 1612 | } |
| 1613 | |
| 1614 | boolean forAllImeWindows(ToBooleanFunction<WindowState> callback, boolean traverseTopToBottom) { |
| 1615 | return mImeWindowsContainers.forAllWindows(callback, traverseTopToBottom); |
| 1616 | } |
| 1617 | |
Wale Ogunwale | 399c869 | 2017-05-08 14:22:42 -0700 | [diff] [blame] | 1618 | @Override |
| 1619 | int getOrientation() { |
Wale Ogunwale | e6f806e | 2016-10-20 15:29:42 -0700 | [diff] [blame] | 1620 | final WindowManagerPolicy policy = mService.mPolicy; |
| 1621 | |
Wale Ogunwale | e6f806e | 2016-10-20 15:29:42 -0700 | [diff] [blame] | 1622 | if (mService.mDisplayFrozen) { |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 1623 | if (mLastWindowForcedOrientation != SCREEN_ORIENTATION_UNSPECIFIED) { |
Wale Ogunwale | e6f806e | 2016-10-20 15:29:42 -0700 | [diff] [blame] | 1624 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 1625 | "Display is frozen, return " + mLastWindowForcedOrientation); |
Wale Ogunwale | e6f806e | 2016-10-20 15:29:42 -0700 | [diff] [blame] | 1626 | // If the display is frozen, some activities may be in the middle of restarting, and |
| 1627 | // thus have removed their old window. If the window has the flag to hide the lock |
| 1628 | // screen, then the lock screen can re-appear and inflict its own orientation on us. |
| 1629 | // Keep the orientation stable until this all settles down. |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 1630 | return mLastWindowForcedOrientation; |
Wale Ogunwale | e6f806e | 2016-10-20 15:29:42 -0700 | [diff] [blame] | 1631 | } else if (policy.isKeyguardLocked()) { |
| 1632 | // Use the last orientation the while the display is frozen with the keyguard |
| 1633 | // locked. This could be the keyguard forced orientation or from a SHOW_WHEN_LOCKED |
| 1634 | // window. We don't want to check the show when locked window directly though as |
| 1635 | // things aren't stable while the display is frozen, for example the window could be |
| 1636 | // momentarily unavailable due to activity relaunch. |
| 1637 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, "Display is frozen while keyguard locked, " |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 1638 | + "return " + mLastOrientation); |
| 1639 | return mLastOrientation; |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 1640 | } |
Wale Ogunwale | e6f806e | 2016-10-20 15:29:42 -0700 | [diff] [blame] | 1641 | } else { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 1642 | final int orientation = mAboveAppWindowsContainers.getOrientation(); |
| 1643 | if (orientation != SCREEN_ORIENTATION_UNSET) { |
| 1644 | return orientation; |
Wale Ogunwale | e6f806e | 2016-10-20 15:29:42 -0700 | [diff] [blame] | 1645 | } |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 1646 | } |
| 1647 | |
Wale Ogunwale | 399c869 | 2017-05-08 14:22:42 -0700 | [diff] [blame] | 1648 | // Top system windows are not requesting an orientation. Start searching from apps. |
| 1649 | return mTaskStackContainers.getOrientation(); |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 1650 | } |
| 1651 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1652 | void updateDisplayInfo() { |
Andrii Kulian | cd09799 | 2017-03-23 18:31:59 -0700 | [diff] [blame] | 1653 | // Check if display metrics changed and update base values if needed. |
| 1654 | updateBaseDisplayMetricsIfNeeded(); |
| 1655 | |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 1656 | mDisplay.getDisplayInfo(mDisplayInfo); |
Wale Ogunwale | 231b06e | 2015-09-16 12:03:09 -0700 | [diff] [blame] | 1657 | mDisplay.getMetrics(mDisplayMetrics); |
Andrii Kulian | cd09799 | 2017-03-23 18:31:59 -0700 | [diff] [blame] | 1658 | |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1659 | for (int i = mTaskStackContainers.getChildCount() - 1; i >= 0; --i) { |
| 1660 | mTaskStackContainers.getChildAt(i).updateDisplayInfo(null); |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 1661 | } |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 1662 | } |
| 1663 | |
Wale Ogunwale | fd04d8c | 2015-09-30 10:09:39 -0700 | [diff] [blame] | 1664 | void initializeDisplayBaseInfo() { |
Wale Ogunwale | b699ce0 | 2016-07-18 12:05:30 -0700 | [diff] [blame] | 1665 | final DisplayManagerInternal displayManagerInternal = mService.mDisplayManagerInternal; |
| 1666 | if (displayManagerInternal != null) { |
| 1667 | // Bootstrap the default logical display from the display manager. |
| 1668 | final DisplayInfo newDisplayInfo = displayManagerInternal.getDisplayInfo(mDisplayId); |
| 1669 | if (newDisplayInfo != null) { |
| 1670 | mDisplayInfo.copyFrom(newDisplayInfo); |
| 1671 | } |
Wale Ogunwale | fd04d8c | 2015-09-30 10:09:39 -0700 | [diff] [blame] | 1672 | } |
Wale Ogunwale | b699ce0 | 2016-07-18 12:05:30 -0700 | [diff] [blame] | 1673 | |
Andrii Kulian | cd09799 | 2017-03-23 18:31:59 -0700 | [diff] [blame] | 1674 | updateBaseDisplayMetrics(mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight, |
| 1675 | mDisplayInfo.logicalDensityDpi); |
| 1676 | mInitialDisplayWidth = mDisplayInfo.logicalWidth; |
| 1677 | mInitialDisplayHeight = mDisplayInfo.logicalHeight; |
| 1678 | mInitialDisplayDensity = mDisplayInfo.logicalDensityDpi; |
Wale Ogunwale | fd04d8c | 2015-09-30 10:09:39 -0700 | [diff] [blame] | 1679 | } |
| 1680 | |
Andrii Kulian | cd09799 | 2017-03-23 18:31:59 -0700 | [diff] [blame] | 1681 | /** |
| 1682 | * If display metrics changed, overrides are not set and it's not just a rotation - update base |
| 1683 | * values. |
| 1684 | */ |
| 1685 | private void updateBaseDisplayMetricsIfNeeded() { |
| 1686 | // Get real display metrics without overrides from WM. |
| 1687 | mService.mDisplayManagerInternal.getNonOverrideDisplayInfo(mDisplayId, mDisplayInfo); |
| 1688 | final int orientation = mDisplayInfo.rotation; |
| 1689 | final boolean rotated = (orientation == ROTATION_90 || orientation == ROTATION_270); |
| 1690 | final int newWidth = rotated ? mDisplayInfo.logicalHeight : mDisplayInfo.logicalWidth; |
| 1691 | final int newHeight = rotated ? mDisplayInfo.logicalWidth : mDisplayInfo.logicalHeight; |
| 1692 | final int newDensity = mDisplayInfo.logicalDensityDpi; |
| 1693 | |
| 1694 | final boolean displayMetricsChanged = mInitialDisplayWidth != newWidth |
| 1695 | || mInitialDisplayHeight != newHeight |
| 1696 | || mInitialDisplayDensity != mDisplayInfo.logicalDensityDpi; |
| 1697 | |
| 1698 | if (displayMetricsChanged) { |
| 1699 | // Check if display size or density is forced. |
| 1700 | final boolean isDisplaySizeForced = mBaseDisplayWidth != mInitialDisplayWidth |
| 1701 | || mBaseDisplayHeight != mInitialDisplayHeight; |
| 1702 | final boolean isDisplayDensityForced = mBaseDisplayDensity != mInitialDisplayDensity; |
| 1703 | |
| 1704 | // If there is an override set for base values - use it, otherwise use new values. |
| 1705 | updateBaseDisplayMetrics(isDisplaySizeForced ? mBaseDisplayWidth : newWidth, |
| 1706 | isDisplaySizeForced ? mBaseDisplayHeight : newHeight, |
| 1707 | isDisplayDensityForced ? mBaseDisplayDensity : newDensity); |
| 1708 | |
| 1709 | // Real display metrics changed, so we should also update initial values. |
| 1710 | mInitialDisplayWidth = newWidth; |
| 1711 | mInitialDisplayHeight = newHeight; |
| 1712 | mInitialDisplayDensity = newDensity; |
| 1713 | mService.reconfigureDisplayLocked(this); |
| 1714 | } |
| 1715 | } |
| 1716 | |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 1717 | /** Sets the maximum width the screen resolution can be */ |
| 1718 | void setMaxUiWidth(int width) { |
| 1719 | if (DEBUG_DISPLAY) { |
| 1720 | Slog.v(TAG_WM, "Setting max ui width:" + width + " on display:" + getDisplayId()); |
| 1721 | } |
| 1722 | |
| 1723 | mMaxUiWidth = width; |
| 1724 | |
| 1725 | // Update existing metrics. |
| 1726 | updateBaseDisplayMetrics(mBaseDisplayWidth, mBaseDisplayHeight, mBaseDisplayDensity); |
| 1727 | } |
| 1728 | |
| 1729 | /** Update base (override) display metrics. */ |
| 1730 | void updateBaseDisplayMetrics(int baseWidth, int baseHeight, int baseDensity) { |
| 1731 | mBaseDisplayWidth = baseWidth; |
| 1732 | mBaseDisplayHeight = baseHeight; |
| 1733 | mBaseDisplayDensity = baseDensity; |
| 1734 | |
| 1735 | if (mMaxUiWidth > 0 && mBaseDisplayWidth > mMaxUiWidth) { |
| 1736 | mBaseDisplayHeight = (mMaxUiWidth * mBaseDisplayHeight) / mBaseDisplayWidth; |
| 1737 | mBaseDisplayDensity = (mMaxUiWidth * mBaseDisplayDensity) / mBaseDisplayWidth; |
| 1738 | mBaseDisplayWidth = mMaxUiWidth; |
| 1739 | |
| 1740 | if (DEBUG_DISPLAY) { |
| 1741 | Slog.v(TAG_WM, "Applying config restraints:" + mBaseDisplayWidth + "x" |
| 1742 | + mBaseDisplayHeight + " at density:" + mBaseDisplayDensity |
| 1743 | + " on display:" + getDisplayId()); |
| 1744 | } |
| 1745 | } |
| 1746 | |
| 1747 | mBaseDisplayRect.set(0, 0, mBaseDisplayWidth, mBaseDisplayHeight); |
Bryce Lee | f3c6a47 | 2017-11-14 14:53:06 -0800 | [diff] [blame] | 1748 | |
| 1749 | updateBounds(); |
Bryce Lee | 27cec32 | 2017-03-21 09:41:37 -0700 | [diff] [blame] | 1750 | } |
| 1751 | |
Wale Ogunwale | db50619 | 2017-12-08 10:57:32 -0800 | [diff] [blame] | 1752 | void getStableRect(Rect out) { |
| 1753 | out.set(mDisplayFrames.mStable); |
Chong Zhang | f66db43 | 2016-01-13 10:39:51 -0800 | [diff] [blame] | 1754 | } |
| 1755 | |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1756 | TaskStack createStack(int stackId, boolean onTop, StackWindowController controller) { |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 1757 | if (DEBUG_STACK) Slog.d(TAG_WM, "Create new stackId=" + stackId + " on displayId=" |
| 1758 | + mDisplayId); |
Andrii Kulian | 839def9 | 2016-11-02 10:58:58 -0700 | [diff] [blame] | 1759 | |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1760 | final TaskStack stack = new TaskStack(mService, stackId, controller); |
| 1761 | mTaskStackContainers.addStackToDisplay(stack, onTop); |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 1762 | return stack; |
Andrii Kulian | 839def9 | 2016-11-02 10:58:58 -0700 | [diff] [blame] | 1763 | } |
| 1764 | |
Andrii Kulian | 51c1b67 | 2017-04-07 18:39:32 -0700 | [diff] [blame] | 1765 | void moveStackToDisplay(TaskStack stack, boolean onTop) { |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 1766 | final DisplayContent prevDc = stack.getDisplayContent(); |
| 1767 | if (prevDc == null) { |
Andrii Kulian | 839def9 | 2016-11-02 10:58:58 -0700 | [diff] [blame] | 1768 | throw new IllegalStateException("Trying to move stackId=" + stack.mStackId |
| 1769 | + " which is not currently attached to any display"); |
| 1770 | } |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 1771 | if (prevDc.getDisplayId() == mDisplayId) { |
Andrii Kulian | 839def9 | 2016-11-02 10:58:58 -0700 | [diff] [blame] | 1772 | throw new IllegalArgumentException("Trying to move stackId=" + stack.mStackId |
| 1773 | + " to its current displayId=" + mDisplayId); |
| 1774 | } |
| 1775 | |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1776 | prevDc.mTaskStackContainers.removeChild(stack); |
Andrii Kulian | 51c1b67 | 2017-04-07 18:39:32 -0700 | [diff] [blame] | 1777 | mTaskStackContainers.addStackToDisplay(stack, onTop); |
Craig Mautner | c00204b | 2013-03-05 15:02:14 -0800 | [diff] [blame] | 1778 | } |
| 1779 | |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 1780 | @Override |
| 1781 | protected void addChild(DisplayChildWindowContainer child, |
| 1782 | Comparator<DisplayChildWindowContainer> comparator) { |
| 1783 | throw new UnsupportedOperationException("See DisplayChildWindowContainer"); |
| 1784 | } |
Wale Ogunwale | 1e60e0c | 2015-10-28 13:36:10 -0700 | [diff] [blame] | 1785 | |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 1786 | @Override |
| 1787 | protected void addChild(DisplayChildWindowContainer child, int index) { |
| 1788 | throw new UnsupportedOperationException("See DisplayChildWindowContainer"); |
| 1789 | } |
| 1790 | |
| 1791 | @Override |
| 1792 | protected void removeChild(DisplayChildWindowContainer child) { |
Wale Ogunwale | 601a3f0 | 2016-10-17 08:39:39 -0700 | [diff] [blame] | 1793 | // Only allow removal of direct children from this display if the display is in the process |
| 1794 | // of been removed. |
| 1795 | if (mRemovingDisplay) { |
| 1796 | super.removeChild(child); |
| 1797 | return; |
| 1798 | } |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 1799 | throw new UnsupportedOperationException("See DisplayChildWindowContainer"); |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 1800 | } |
| 1801 | |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 1802 | @Override |
| 1803 | void positionChildAt(int position, DisplayChildWindowContainer child, boolean includingParents) { |
| 1804 | // Children of the display are statically ordered, so the real intention here is to perform |
| 1805 | // the operation on the display and not the static direct children. |
| 1806 | getParent().positionChildAt(position, this, includingParents); |
| 1807 | } |
| 1808 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 1809 | int taskIdFromPoint(int x, int y) { |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1810 | for (int stackNdx = mTaskStackContainers.getChildCount() - 1; stackNdx >= 0; --stackNdx) { |
| 1811 | final TaskStack stack = mTaskStackContainers.getChildAt(stackNdx); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1812 | final int taskId = stack.taskIdFromPoint(x, y); |
| 1813 | if (taskId != -1) { |
| 1814 | return taskId; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1815 | } |
| 1816 | } |
Craig Mautner | bdc748af | 2013-12-02 14:08:25 -0800 | [diff] [blame] | 1817 | return -1; |
Craig Mautner | cf910b0 | 2013-04-23 11:23:27 -0700 | [diff] [blame] | 1818 | } |
| 1819 | |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 1820 | /** |
Chong Zhang | d8ceb85 | 2015-11-11 14:53:41 -0800 | [diff] [blame] | 1821 | * Find the task whose outside touch area (for resizing) (x, y) falls within. |
Chong Zhang | 9184ec6 | 2015-09-24 12:32:21 -0700 | [diff] [blame] | 1822 | * Returns null if the touch doesn't fall into a resizing area. |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 1823 | */ |
Wale Ogunwale | 15ead90 | 2016-09-02 14:30:11 -0700 | [diff] [blame] | 1824 | Task findTaskForResizePoint(int x, int y) { |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 1825 | final int delta = dipToPixel(RESIZE_HANDLE_WIDTH_IN_DP, mDisplayMetrics); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1826 | mTmpTaskForResizePointSearchResult.reset(); |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1827 | for (int stackNdx = mTaskStackContainers.getChildCount() - 1; stackNdx >= 0; --stackNdx) { |
| 1828 | final TaskStack stack = mTaskStackContainers.getChildAt(stackNdx); |
Wale Ogunwale | 3382ab1 | 2017-07-27 08:55:03 -0700 | [diff] [blame] | 1829 | if (!stack.getWindowConfiguration().canResizeTask()) { |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1830 | return null; |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 1831 | } |
Chong Zhang | 9184ec6 | 2015-09-24 12:32:21 -0700 | [diff] [blame] | 1832 | |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1833 | stack.findTaskForResizePoint(x, y, delta, mTmpTaskForResizePointSearchResult); |
| 1834 | if (mTmpTaskForResizePointSearchResult.searchDone) { |
| 1835 | return mTmpTaskForResizePointSearchResult.taskForResize; |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 1836 | } |
| 1837 | } |
Chong Zhang | 9184ec6 | 2015-09-24 12:32:21 -0700 | [diff] [blame] | 1838 | return null; |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 1839 | } |
| 1840 | |
Wale Ogunwale | e4a0c57 | 2015-06-30 08:40:31 -0700 | [diff] [blame] | 1841 | void setTouchExcludeRegion(Task focusedTask) { |
David Stevens | ee9e277 | 2017-02-09 16:30:27 -0800 | [diff] [blame] | 1842 | // The provided task is the task on this display with focus, so if WindowManagerService's |
| 1843 | // focused app is not on this display, focusedTask will be null. |
| 1844 | if (focusedTask == null) { |
| 1845 | mTouchExcludeRegion.setEmpty(); |
| 1846 | } else { |
| 1847 | mTouchExcludeRegion.set(mBaseDisplayRect); |
| 1848 | final int delta = dipToPixel(RESIZE_HANDLE_WIDTH_IN_DP, mDisplayMetrics); |
| 1849 | mTmpRect2.setEmpty(); |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1850 | for (int stackNdx = mTaskStackContainers.getChildCount() - 1; stackNdx >= 0; --stackNdx) { |
| 1851 | final TaskStack stack = mTaskStackContainers.getChildAt(stackNdx); |
Wale Ogunwale | 828ff7e | 2017-11-14 01:01:29 +0000 | [diff] [blame] | 1852 | stack.setTouchExcludeRegion(focusedTask, delta, mTouchExcludeRegion, |
| 1853 | mDisplayFrames.mContent, mTmpRect2); |
David Stevens | ee9e277 | 2017-02-09 16:30:27 -0800 | [diff] [blame] | 1854 | } |
| 1855 | // If we removed the focused task above, add it back and only leave its |
| 1856 | // outside touch area in the exclusion. TapDectector is not interested in |
| 1857 | // any touch inside the focused task itself. |
| 1858 | if (!mTmpRect2.isEmpty()) { |
| 1859 | mTouchExcludeRegion.op(mTmpRect2, Region.Op.UNION); |
| 1860 | } |
Chong Zhang | d8ceb85 | 2015-11-11 14:53:41 -0800 | [diff] [blame] | 1861 | } |
Filip Gruszczynski | 912d919 | 2015-12-01 16:14:04 -0800 | [diff] [blame] | 1862 | final WindowState inputMethod = mService.mInputMethodWindow; |
| 1863 | if (inputMethod != null && inputMethod.isVisibleLw()) { |
| 1864 | // If the input method is visible and the user is typing, we don't want these touch |
| 1865 | // events to be intercepted and used to change focus. This would likely cause a |
| 1866 | // disappearance of the input method. |
| 1867 | inputMethod.getTouchableRegion(mTmpRegion); |
Andrii Kulian | 7a31b77 | 2017-05-02 13:22:42 -0700 | [diff] [blame] | 1868 | if (inputMethod.getDisplayId() == mDisplayId) { |
| 1869 | mTouchExcludeRegion.op(mTmpRegion, Op.UNION); |
| 1870 | } else { |
| 1871 | // IME is on a different display, so we need to update its tap detector. |
| 1872 | // TODO(multidisplay): Remove when IME will always appear on same display. |
| 1873 | inputMethod.getDisplayContent().setTouchExcludeRegion(null /* focusedTask */); |
| 1874 | } |
Filip Gruszczynski | 912d919 | 2015-12-01 16:14:04 -0800 | [diff] [blame] | 1875 | } |
Filip Gruszczynski | ecf6722 | 2015-12-11 15:16:36 -0800 | [diff] [blame] | 1876 | for (int i = mTapExcludedWindows.size() - 1; i >= 0; i--) { |
| 1877 | WindowState win = mTapExcludedWindows.get(i); |
| 1878 | win.getTouchableRegion(mTmpRegion); |
| 1879 | mTouchExcludeRegion.op(mTmpRegion, Region.Op.UNION); |
| 1880 | } |
Andrii Kulian | 03c403d | 2016-11-11 11:14:12 -0800 | [diff] [blame] | 1881 | // TODO(multi-display): Support docked stacks on secondary displays. |
Matthew Ng | 64e77cf | 2017-10-31 14:01:31 -0700 | [diff] [blame] | 1882 | if (mDisplayId == DEFAULT_DISPLAY && getSplitScreenPrimaryStack() != null) { |
Jorim Jaggi | d47e7e1 | 2016-03-01 09:57:38 +0100 | [diff] [blame] | 1883 | mDividerControllerLocked.getTouchRegion(mTmpRect); |
Jorim Jaggi | 7f19cb8 | 2016-03-25 19:37:44 -0700 | [diff] [blame] | 1884 | mTmpRegion.set(mTmpRect); |
Jorim Jaggi | d47e7e1 | 2016-03-01 09:57:38 +0100 | [diff] [blame] | 1885 | mTouchExcludeRegion.op(mTmpRegion, Op.UNION); |
| 1886 | } |
Craig Mautner | 1bef389 | 2015-02-17 15:09:47 -0800 | [diff] [blame] | 1887 | if (mTapDetector != null) { |
Chong Zhang | 2e2c81a | 2016-07-15 11:28:17 -0700 | [diff] [blame] | 1888 | mTapDetector.setTouchExcludeRegion(mTouchExcludeRegion); |
Craig Mautner | 1bef389 | 2015-02-17 15:09:47 -0800 | [diff] [blame] | 1889 | } |
Craig Mautner | 6601b7b | 2013-04-29 10:29:11 -0700 | [diff] [blame] | 1890 | } |
| 1891 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 1892 | @Override |
Wale Ogunwale | e05f501 | 2016-09-16 16:27:29 -0700 | [diff] [blame] | 1893 | void switchUser() { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 1894 | super.switchUser(); |
| 1895 | mService.mWindowsChanged = true; |
Craig Mautner | 858d8a6 | 2013-04-23 17:08:34 -0700 | [diff] [blame] | 1896 | } |
| 1897 | |
Wale Ogunwale | ac2561e | 2016-11-01 15:43:46 -0700 | [diff] [blame] | 1898 | private void resetAnimationBackgroundAnimator() { |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1899 | for (int stackNdx = mTaskStackContainers.getChildCount() - 1; stackNdx >= 0; --stackNdx) { |
| 1900 | mTaskStackContainers.getChildAt(stackNdx).resetAnimationBackgroundAnimator(); |
Craig Mautner | 05d2903 | 2013-05-03 13:40:13 -0700 | [diff] [blame] | 1901 | } |
| 1902 | } |
| 1903 | |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 1904 | @Override |
| 1905 | void removeIfPossible() { |
| 1906 | if (isAnimating()) { |
| 1907 | mDeferredRemoval = true; |
| 1908 | return; |
Craig Mautner | 2eb1534 | 2013-08-07 13:13:35 -0700 | [diff] [blame] | 1909 | } |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 1910 | removeImmediately(); |
Craig Mautner | 2eb1534 | 2013-08-07 13:13:35 -0700 | [diff] [blame] | 1911 | } |
| 1912 | |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 1913 | @Override |
| 1914 | void removeImmediately() { |
Wale Ogunwale | 601a3f0 | 2016-10-17 08:39:39 -0700 | [diff] [blame] | 1915 | mRemovingDisplay = true; |
| 1916 | try { |
| 1917 | super.removeImmediately(); |
| 1918 | if (DEBUG_DISPLAY) Slog.v(TAG_WM, "Removing display=" + this); |
Tarandeep Singh | 7ac8d3a | 2017-09-05 11:09:39 -0700 | [diff] [blame] | 1919 | if (mService.canDispatchPointerEvents()) { |
| 1920 | if (mTapDetector != null) { |
| 1921 | mService.unregisterPointerEventListener(mTapDetector); |
| 1922 | } |
| 1923 | if (mDisplayId == DEFAULT_DISPLAY && mService.mMousePositionTracker != null) { |
| 1924 | mService.unregisterPointerEventListener(mService.mMousePositionTracker); |
| 1925 | } |
Wale Ogunwale | 601a3f0 | 2016-10-17 08:39:39 -0700 | [diff] [blame] | 1926 | } |
Jorim Jaggi | a384403 | 2018-01-03 15:54:43 +0100 | [diff] [blame] | 1927 | mService.mAnimator.removeDisplayLocked(mDisplayId); |
| 1928 | |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 1929 | // The pending transaction won't be applied so we should |
| 1930 | // just clean up any surfaces pending destruction. |
| 1931 | onPendingTransactionApplied(); |
Wale Ogunwale | 601a3f0 | 2016-10-17 08:39:39 -0700 | [diff] [blame] | 1932 | } finally { |
| 1933 | mRemovingDisplay = false; |
Craig Mautner | 95da108 | 2014-02-24 17:54:35 -0800 | [diff] [blame] | 1934 | } |
Craig Mautner | 95da108 | 2014-02-24 17:54:35 -0800 | [diff] [blame] | 1935 | } |
| 1936 | |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1937 | /** Returns true if a removal action is still being deferred. */ |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 1938 | @Override |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1939 | boolean checkCompleteDeferredRemoval() { |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 1940 | final boolean stillDeferringRemoval = super.checkCompleteDeferredRemoval(); |
| 1941 | |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1942 | if (!stillDeferringRemoval && mDeferredRemoval) { |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 1943 | removeImmediately(); |
Craig Mautner | 95da108 | 2014-02-24 17:54:35 -0800 | [diff] [blame] | 1944 | mService.onDisplayRemoved(mDisplayId); |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1945 | return false; |
Craig Mautner | 95da108 | 2014-02-24 17:54:35 -0800 | [diff] [blame] | 1946 | } |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 1947 | return true; |
Craig Mautner | 95da108 | 2014-02-24 17:54:35 -0800 | [diff] [blame] | 1948 | } |
| 1949 | |
Andrii Kulian | 0214ed9 | 2017-05-16 13:44:05 -0700 | [diff] [blame] | 1950 | /** @return 'true' if removal of this display content is deferred due to active animation. */ |
| 1951 | boolean isRemovalDeferred() { |
| 1952 | return mDeferredRemoval; |
| 1953 | } |
| 1954 | |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 1955 | boolean animateForIme(float interpolatedValue, float animationTarget, |
| 1956 | float dividerAnimationTarget) { |
| 1957 | boolean updated = false; |
| 1958 | |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1959 | for (int i = mTaskStackContainers.getChildCount() - 1; i >= 0; --i) { |
| 1960 | final TaskStack stack = mTaskStackContainers.getChildAt(i); |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 1961 | if (stack == null || !stack.isAdjustedForIme()) { |
| 1962 | continue; |
| 1963 | } |
| 1964 | |
| 1965 | if (interpolatedValue >= 1f && animationTarget == 0f && dividerAnimationTarget == 0f) { |
| 1966 | stack.resetAdjustedForIme(true /* adjustBoundsNow */); |
| 1967 | updated = true; |
| 1968 | } else { |
| 1969 | mDividerControllerLocked.mLastAnimationProgress = |
| 1970 | mDividerControllerLocked.getInterpolatedAnimationValue(interpolatedValue); |
| 1971 | mDividerControllerLocked.mLastDividerProgress = |
| 1972 | mDividerControllerLocked.getInterpolatedDividerValue(interpolatedValue); |
| 1973 | updated |= stack.updateAdjustForIme( |
| 1974 | mDividerControllerLocked.mLastAnimationProgress, |
| 1975 | mDividerControllerLocked.mLastDividerProgress, |
| 1976 | false /* force */); |
| 1977 | } |
| 1978 | if (interpolatedValue >= 1f) { |
| 1979 | stack.endImeAdjustAnimation(); |
| 1980 | } |
| 1981 | } |
| 1982 | |
| 1983 | return updated; |
| 1984 | } |
| 1985 | |
| 1986 | boolean clearImeAdjustAnimation() { |
| 1987 | boolean changed = false; |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1988 | for (int i = mTaskStackContainers.getChildCount() - 1; i >= 0; --i) { |
| 1989 | final TaskStack stack = mTaskStackContainers.getChildAt(i); |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 1990 | if (stack != null && stack.isAdjustedForIme()) { |
| 1991 | stack.resetAdjustedForIme(true /* adjustBoundsNow */); |
| 1992 | changed = true; |
| 1993 | } |
| 1994 | } |
| 1995 | return changed; |
| 1996 | } |
| 1997 | |
| 1998 | void beginImeAdjustAnimation() { |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 1999 | for (int i = mTaskStackContainers.getChildCount() - 1; i >= 0; --i) { |
| 2000 | final TaskStack stack = mTaskStackContainers.getChildAt(i); |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 2001 | if (stack.isVisible() && stack.isAdjustedForIme()) { |
| 2002 | stack.beginImeAdjustAnimation(); |
| 2003 | } |
| 2004 | } |
| 2005 | } |
| 2006 | |
| 2007 | void adjustForImeIfNeeded() { |
| 2008 | final WindowState imeWin = mService.mInputMethodWindow; |
| 2009 | final boolean imeVisible = imeWin != null && imeWin.isVisibleLw() && imeWin.isDisplayedLw() |
| 2010 | && !mDividerControllerLocked.isImeHideRequested(); |
Wale Ogunwale | 44f036f | 2017-09-29 05:09:09 -0700 | [diff] [blame] | 2011 | final boolean dockVisible = isStackVisible(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY); |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 2012 | final TaskStack imeTargetStack = mService.getImeFocusStackLocked(); |
| 2013 | final int imeDockSide = (dockVisible && imeTargetStack != null) ? |
| 2014 | imeTargetStack.getDockSide() : DOCKED_INVALID; |
| 2015 | final boolean imeOnTop = (imeDockSide == DOCKED_TOP); |
| 2016 | final boolean imeOnBottom = (imeDockSide == DOCKED_BOTTOM); |
| 2017 | final boolean dockMinimized = mDividerControllerLocked.isMinimizedDock(); |
Wale Ogunwale | 828ff7e | 2017-11-14 01:01:29 +0000 | [diff] [blame] | 2018 | final int imeHeight = mDisplayFrames.getInputMethodWindowVisibleHeight(); |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 2019 | final boolean imeHeightChanged = imeVisible && |
| 2020 | imeHeight != mDividerControllerLocked.getImeHeightAdjustedFor(); |
| 2021 | |
| 2022 | // The divider could be adjusted for IME position, or be thinner than usual, |
| 2023 | // or both. There are three possible cases: |
| 2024 | // - If IME is visible, and focus is on top, divider is not moved for IME but thinner. |
| 2025 | // - If IME is visible, and focus is on bottom, divider is moved for IME and thinner. |
| 2026 | // - If IME is not visible, divider is not moved and is normal width. |
| 2027 | |
| 2028 | if (imeVisible && dockVisible && (imeOnTop || imeOnBottom) && !dockMinimized) { |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 2029 | for (int i = mTaskStackContainers.getChildCount() - 1; i >= 0; --i) { |
| 2030 | final TaskStack stack = mTaskStackContainers.getChildAt(i); |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 2031 | final boolean isDockedOnBottom = stack.getDockSide() == DOCKED_BOTTOM; |
Wale Ogunwale | 6827856 | 2017-09-23 17:13:55 -0700 | [diff] [blame] | 2032 | if (stack.isVisible() && (imeOnBottom || isDockedOnBottom) |
| 2033 | && stack.inSplitScreenWindowingMode()) { |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 2034 | stack.setAdjustedForIme(imeWin, imeOnBottom && imeHeightChanged); |
| 2035 | } else { |
| 2036 | stack.resetAdjustedForIme(false); |
| 2037 | } |
| 2038 | } |
| 2039 | mDividerControllerLocked.setAdjustedForIme( |
| 2040 | imeOnBottom /*ime*/, true /*divider*/, true /*animate*/, imeWin, imeHeight); |
| 2041 | } else { |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 2042 | for (int i = mTaskStackContainers.getChildCount() - 1; i >= 0; --i) { |
| 2043 | final TaskStack stack = mTaskStackContainers.getChildAt(i); |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 2044 | stack.resetAdjustedForIme(!dockVisible); |
| 2045 | } |
| 2046 | mDividerControllerLocked.setAdjustedForIme( |
| 2047 | false /*ime*/, false /*divider*/, dockVisible /*animate*/, imeWin, imeHeight); |
| 2048 | } |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 2049 | mPinnedStackControllerLocked.setAdjustedForIme(imeVisible, imeHeight); |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 2050 | } |
| 2051 | |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2052 | /** |
| 2053 | * If a window that has an animation specifying a colored background and the current wallpaper |
| 2054 | * is visible, then the color goes *below* the wallpaper so we don't cause the wallpaper to |
| 2055 | * suddenly disappear. |
| 2056 | */ |
| 2057 | int getLayerForAnimationBackground(WindowStateAnimator winAnimator) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2058 | final WindowState visibleWallpaper = mBelowAppWindowsContainers.getWindow( |
| 2059 | w -> w.mIsWallpaper && w.isVisibleNow()); |
| 2060 | |
| 2061 | if (visibleWallpaper != null) { |
| 2062 | return visibleWallpaper.mWinAnimator.mAnimLayer; |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2063 | } |
| 2064 | return winAnimator.mAnimLayer; |
| 2065 | } |
| 2066 | |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 2067 | void prepareFreezingTaskBounds() { |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 2068 | for (int stackNdx = mTaskStackContainers.getChildCount() - 1; stackNdx >= 0; --stackNdx) { |
| 2069 | final TaskStack stack = mTaskStackContainers.getChildAt(stackNdx); |
Wale Ogunwale | 1012458 | 2016-09-15 20:25:50 -0700 | [diff] [blame] | 2070 | stack.prepareFreezingTaskBounds(); |
| 2071 | } |
| 2072 | } |
| 2073 | |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 2074 | void rotateBounds(int oldRotation, int newRotation, Rect bounds) { |
Bryce Lee | f3c6a47 | 2017-11-14 14:53:06 -0800 | [diff] [blame] | 2075 | getBounds(mTmpRect, newRotation); |
Andrii Kulian | 4dfb9c4 | 2016-10-11 20:06:27 -0700 | [diff] [blame] | 2076 | |
| 2077 | // Compute a transform matrix to undo the coordinate space transformation, |
| 2078 | // and present the window at the same physical position it previously occupied. |
| 2079 | final int deltaRotation = deltaRotation(newRotation, oldRotation); |
| 2080 | createRotationMatrix(deltaRotation, mTmpRect.width(), mTmpRect.height(), mTmpMatrix); |
| 2081 | |
| 2082 | mTmpRectF.set(bounds); |
| 2083 | mTmpMatrix.mapRect(mTmpRectF); |
| 2084 | mTmpRectF.round(bounds); |
Wale Ogunwale | 9474421 | 2015-09-21 19:01:47 -0700 | [diff] [blame] | 2085 | } |
| 2086 | |
Wale Ogunwale | 4a02d81 | 2015-02-12 23:01:38 -0800 | [diff] [blame] | 2087 | static int deltaRotation(int oldRotation, int newRotation) { |
| 2088 | int delta = newRotation - oldRotation; |
| 2089 | if (delta < 0) delta += 4; |
| 2090 | return delta; |
| 2091 | } |
| 2092 | |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 2093 | private static void createRotationMatrix(int rotation, float displayWidth, float displayHeight, |
Andrii Kulian | 4dfb9c4 | 2016-10-11 20:06:27 -0700 | [diff] [blame] | 2094 | Matrix outMatrix) { |
| 2095 | // For rotations without Z-ordering we don't need the target rectangle's position. |
| 2096 | createRotationMatrix(rotation, 0 /* rectLeft */, 0 /* rectTop */, displayWidth, |
| 2097 | displayHeight, outMatrix); |
| 2098 | } |
| 2099 | |
| 2100 | static void createRotationMatrix(int rotation, float rectLeft, float rectTop, |
| 2101 | float displayWidth, float displayHeight, Matrix outMatrix) { |
| 2102 | switch (rotation) { |
| 2103 | case ROTATION_0: |
| 2104 | outMatrix.reset(); |
| 2105 | break; |
| 2106 | case ROTATION_270: |
| 2107 | outMatrix.setRotate(270, 0, 0); |
| 2108 | outMatrix.postTranslate(0, displayHeight); |
| 2109 | outMatrix.postTranslate(rectTop, 0); |
| 2110 | break; |
| 2111 | case ROTATION_180: |
| 2112 | outMatrix.reset(); |
| 2113 | break; |
| 2114 | case ROTATION_90: |
| 2115 | outMatrix.setRotate(90, 0, 0); |
| 2116 | outMatrix.postTranslate(displayWidth, 0); |
| 2117 | outMatrix.postTranslate(-rectTop, rectLeft); |
| 2118 | break; |
| 2119 | } |
| 2120 | } |
| 2121 | |
Wale Ogunwale | 0d5609b | 2017-09-13 05:55:07 -0700 | [diff] [blame] | 2122 | @CallSuper |
| 2123 | @Override |
Adrian Roos | 4921ccf | 2017-09-28 16:54:06 +0200 | [diff] [blame] | 2124 | public void writeToProto(ProtoOutputStream proto, long fieldId, boolean trim) { |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 2125 | final long token = proto.start(fieldId); |
Adrian Roos | 4921ccf | 2017-09-28 16:54:06 +0200 | [diff] [blame] | 2126 | super.writeToProto(proto, WINDOW_CONTAINER, trim); |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 2127 | proto.write(ID, mDisplayId); |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 2128 | for (int stackNdx = mTaskStackContainers.getChildCount() - 1; stackNdx >= 0; --stackNdx) { |
| 2129 | final TaskStack stack = mTaskStackContainers.getChildAt(stackNdx); |
Adrian Roos | 4921ccf | 2017-09-28 16:54:06 +0200 | [diff] [blame] | 2130 | stack.writeToProto(proto, STACKS, trim); |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 2131 | } |
| 2132 | mDividerControllerLocked.writeToProto(proto, DOCKED_STACK_DIVIDER_CONTROLLER); |
| 2133 | mPinnedStackControllerLocked.writeToProto(proto, PINNED_STACK_CONTROLLER); |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 2134 | for (int i = mAboveAppWindowsContainers.getChildCount() - 1; i >= 0; --i) { |
| 2135 | final WindowToken windowToken = mAboveAppWindowsContainers.getChildAt(i); |
Adrian Roos | 4921ccf | 2017-09-28 16:54:06 +0200 | [diff] [blame] | 2136 | windowToken.writeToProto(proto, ABOVE_APP_WINDOWS, trim); |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 2137 | } |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 2138 | for (int i = mBelowAppWindowsContainers.getChildCount() - 1; i >= 0; --i) { |
| 2139 | final WindowToken windowToken = mBelowAppWindowsContainers.getChildAt(i); |
Adrian Roos | 4921ccf | 2017-09-28 16:54:06 +0200 | [diff] [blame] | 2140 | windowToken.writeToProto(proto, BELOW_APP_WINDOWS, trim); |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 2141 | } |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 2142 | for (int i = mImeWindowsContainers.getChildCount() - 1; i >= 0; --i) { |
| 2143 | final WindowToken windowToken = mImeWindowsContainers.getChildAt(i); |
Adrian Roos | 4921ccf | 2017-09-28 16:54:06 +0200 | [diff] [blame] | 2144 | windowToken.writeToProto(proto, IME_WINDOWS, trim); |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 2145 | } |
| 2146 | proto.write(DPI, mBaseDisplayDensity); |
| 2147 | mDisplayInfo.writeToProto(proto, DISPLAY_INFO); |
Steven Timotius | f2d6889 | 2017-08-28 17:00:01 -0700 | [diff] [blame] | 2148 | proto.write(ROTATION, mRotation); |
| 2149 | final ScreenRotationAnimation screenRotationAnimation = |
| 2150 | mService.mAnimator.getScreenRotationAnimationLocked(mDisplayId); |
| 2151 | if (screenRotationAnimation != null) { |
| 2152 | screenRotationAnimation.writeToProto(proto, SCREEN_ROTATION_ANIMATION); |
| 2153 | } |
Wale Ogunwale | 828ff7e | 2017-11-14 01:01:29 +0000 | [diff] [blame] | 2154 | mDisplayFrames.writeToProto(proto, DISPLAY_FRAMES); |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 2155 | proto.end(token); |
| 2156 | } |
| 2157 | |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 2158 | @Override |
| 2159 | public void dump(PrintWriter pw, String prefix, boolean dumpAll) { |
| 2160 | super.dump(pw, prefix, dumpAll); |
Craig Mautner | a91f9e2 | 2012-09-14 16:22:08 -0700 | [diff] [blame] | 2161 | pw.print(prefix); pw.print("Display: mDisplayId="); pw.println(mDisplayId); |
| 2162 | final String subPrefix = " " + prefix; |
| 2163 | pw.print(subPrefix); pw.print("init="); pw.print(mInitialDisplayWidth); pw.print("x"); |
| 2164 | pw.print(mInitialDisplayHeight); pw.print(" "); pw.print(mInitialDisplayDensity); |
| 2165 | pw.print("dpi"); |
| 2166 | if (mInitialDisplayWidth != mBaseDisplayWidth |
| 2167 | || mInitialDisplayHeight != mBaseDisplayHeight |
| 2168 | || mInitialDisplayDensity != mBaseDisplayDensity) { |
| 2169 | pw.print(" base="); |
| 2170 | pw.print(mBaseDisplayWidth); pw.print("x"); pw.print(mBaseDisplayHeight); |
| 2171 | pw.print(" "); pw.print(mBaseDisplayDensity); pw.print("dpi"); |
| 2172 | } |
Jeff Brown | d46747a | 2015-04-15 19:02:36 -0700 | [diff] [blame] | 2173 | if (mDisplayScalingDisabled) { |
| 2174 | pw.println(" noscale"); |
| 2175 | } |
Craig Mautner | a91f9e2 | 2012-09-14 16:22:08 -0700 | [diff] [blame] | 2176 | pw.print(" cur="); |
| 2177 | pw.print(mDisplayInfo.logicalWidth); |
| 2178 | pw.print("x"); pw.print(mDisplayInfo.logicalHeight); |
| 2179 | pw.print(" app="); |
| 2180 | pw.print(mDisplayInfo.appWidth); |
| 2181 | pw.print("x"); pw.print(mDisplayInfo.appHeight); |
| 2182 | pw.print(" rng="); pw.print(mDisplayInfo.smallestNominalAppWidth); |
| 2183 | pw.print("x"); pw.print(mDisplayInfo.smallestNominalAppHeight); |
| 2184 | pw.print("-"); pw.print(mDisplayInfo.largestNominalAppWidth); |
| 2185 | pw.print("x"); pw.println(mDisplayInfo.largestNominalAppHeight); |
David Stevens | f833ba9 | 2017-03-16 19:00:20 -0700 | [diff] [blame] | 2186 | pw.print(subPrefix + "deferred=" + mDeferredRemoval |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 2187 | + " mLayoutNeeded=" + mLayoutNeeded); |
David Stevens | f833ba9 | 2017-03-16 19:00:20 -0700 | [diff] [blame] | 2188 | pw.println(" mTouchExcludeRegion=" + mTouchExcludeRegion); |
Wale Ogunwale | b429e68 | 2016-01-06 12:36:34 -0800 | [diff] [blame] | 2189 | |
Craig Mautner | dc54848 | 2014-02-05 13:35:24 -0800 | [diff] [blame] | 2190 | pw.println(); |
Jorim Jaggi | ad5d284 | 2016-11-01 18:22:53 -0700 | [diff] [blame] | 2191 | pw.println(prefix + "Application tokens in top down Z order:"); |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 2192 | for (int stackNdx = mTaskStackContainers.getChildCount() - 1; stackNdx >= 0; --stackNdx) { |
| 2193 | final TaskStack stack = mTaskStackContainers.getChildAt(stackNdx); |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 2194 | stack.dump(pw, prefix + " ", dumpAll); |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 2195 | } |
Wale Ogunwale | b429e68 | 2016-01-06 12:36:34 -0800 | [diff] [blame] | 2196 | |
Craig Mautner | dc54848 | 2014-02-05 13:35:24 -0800 | [diff] [blame] | 2197 | pw.println(); |
| 2198 | if (!mExitingTokens.isEmpty()) { |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 2199 | pw.println(); |
| 2200 | pw.println(" Exiting tokens:"); |
Wale Ogunwale | b429e68 | 2016-01-06 12:36:34 -0800 | [diff] [blame] | 2201 | for (int i = mExitingTokens.size() - 1; i >= 0; i--) { |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 2202 | final WindowToken token = mExitingTokens.get(i); |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 2203 | pw.print(" Exiting #"); pw.print(i); |
| 2204 | pw.print(' '); pw.print(token); |
| 2205 | pw.println(':'); |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 2206 | token.dump(pw, " ", dumpAll); |
Craig Mautner | b1fd65c0 | 2013-02-05 13:34:57 -0800 | [diff] [blame] | 2207 | } |
Craig Mautner | de4ef02 | 2013-04-07 19:01:33 -0700 | [diff] [blame] | 2208 | } |
Robert Carr | f59b8dd | 2017-10-02 18:58:36 -0700 | [diff] [blame] | 2209 | |
Jorim Jaggi | 31f7170 | 2016-05-04 16:43:04 -0700 | [diff] [blame] | 2210 | pw.println(); |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 2211 | |
| 2212 | // Dump stack references |
| 2213 | final TaskStack homeStack = getHomeStack(); |
| 2214 | if (homeStack != null) { |
| 2215 | pw.println(prefix + "homeStack=" + homeStack.getName()); |
| 2216 | } |
| 2217 | final TaskStack pinnedStack = getPinnedStack(); |
| 2218 | if (pinnedStack != null) { |
| 2219 | pw.println(prefix + "pinnedStack=" + pinnedStack.getName()); |
| 2220 | } |
Matthew Ng | 64e77cf | 2017-10-31 14:01:31 -0700 | [diff] [blame] | 2221 | final TaskStack splitScreenPrimaryStack = getSplitScreenPrimaryStack(); |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 2222 | if (splitScreenPrimaryStack != null) { |
| 2223 | pw.println(prefix + "splitScreenPrimaryStack=" + splitScreenPrimaryStack.getName()); |
| 2224 | } |
| 2225 | |
| 2226 | pw.println(); |
Jorim Jaggi | ad5d284 | 2016-11-01 18:22:53 -0700 | [diff] [blame] | 2227 | mDividerControllerLocked.dump(prefix, pw); |
Winson Chung | 655332c | 2016-10-31 13:14:28 -0700 | [diff] [blame] | 2228 | pw.println(); |
Jorim Jaggi | ad5d284 | 2016-11-01 18:22:53 -0700 | [diff] [blame] | 2229 | mPinnedStackControllerLocked.dump(prefix, pw); |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 2230 | |
Wale Ogunwale | 828ff7e | 2017-11-14 01:01:29 +0000 | [diff] [blame] | 2231 | pw.println(); |
| 2232 | mDisplayFrames.dump(prefix, pw); |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 2233 | } |
Craig Mautner | e0a3884 | 2013-12-16 16:14:02 -0800 | [diff] [blame] | 2234 | |
| 2235 | @Override |
| 2236 | public String toString() { |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 2237 | return "Display " + mDisplayId + " info=" + mDisplayInfo + " stacks=" + mChildren; |
Wale Ogunwale | 9adfe57 | 2016-09-08 20:43:58 -0700 | [diff] [blame] | 2238 | } |
| 2239 | |
| 2240 | String getName() { |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 2241 | return "Display " + mDisplayId + " name=\"" + mDisplayInfo.name + "\""; |
Craig Mautner | e0a3884 | 2013-12-16 16:14:02 -0800 | [diff] [blame] | 2242 | } |
Filip Gruszczynski | 466f321 | 2015-09-21 17:57:57 -0700 | [diff] [blame] | 2243 | |
Wale Ogunwale | 44f036f | 2017-09-29 05:09:09 -0700 | [diff] [blame] | 2244 | /** Returns true if the stack in the windowing mode is visible. */ |
| 2245 | boolean isStackVisible(int windowingMode) { |
Wale Ogunwale | 30e441d | 2017-11-09 08:28:45 -0800 | [diff] [blame] | 2246 | final TaskStack stack = getTopStackInWindowingMode(windowingMode); |
Wale Ogunwale | 44f036f | 2017-09-29 05:09:09 -0700 | [diff] [blame] | 2247 | return stack != null && stack.isVisible(); |
Andrii Kulian | 7cd7c2d | 2017-01-18 12:14:37 -0800 | [diff] [blame] | 2248 | } |
| 2249 | |
Wale Ogunwale | 9adfe57 | 2016-09-08 20:43:58 -0700 | [diff] [blame] | 2250 | /** Find the visible, touch-deliverable window under the given point */ |
Vladislav Kaznacheev | 5d6bdeb | 2016-02-12 17:07:20 -0800 | [diff] [blame] | 2251 | WindowState getTouchableWinAtPointLocked(float xf, float yf) { |
Vladislav Kaznacheev | 5d6bdeb | 2016-02-12 17:07:20 -0800 | [diff] [blame] | 2252 | final int x = (int) xf; |
| 2253 | final int y = (int) yf; |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2254 | final WindowState touchedWin = getWindow(w -> { |
| 2255 | final int flags = w.mAttrs.flags; |
| 2256 | if (!w.isVisibleLw()) { |
| 2257 | return false; |
Vladislav Kaznacheev | 5d6bdeb | 2016-02-12 17:07:20 -0800 | [diff] [blame] | 2258 | } |
| 2259 | if ((flags & FLAG_NOT_TOUCHABLE) != 0) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2260 | return false; |
Vladislav Kaznacheev | 5d6bdeb | 2016-02-12 17:07:20 -0800 | [diff] [blame] | 2261 | } |
| 2262 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2263 | w.getVisibleBounds(mTmpRect); |
Vladislav Kaznacheev | 5d6bdeb | 2016-02-12 17:07:20 -0800 | [diff] [blame] | 2264 | if (!mTmpRect.contains(x, y)) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2265 | return false; |
Vladislav Kaznacheev | 5d6bdeb | 2016-02-12 17:07:20 -0800 | [diff] [blame] | 2266 | } |
| 2267 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2268 | w.getTouchableRegion(mTmpRegion); |
Vladislav Kaznacheev | 5d6bdeb | 2016-02-12 17:07:20 -0800 | [diff] [blame] | 2269 | |
| 2270 | final int touchFlags = flags & (FLAG_NOT_FOCUSABLE | FLAG_NOT_TOUCH_MODAL); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2271 | return mTmpRegion.contains(x, y) || touchFlags == 0; |
| 2272 | }); |
Vladislav Kaznacheev | 5d6bdeb | 2016-02-12 17:07:20 -0800 | [diff] [blame] | 2273 | |
| 2274 | return touchedWin; |
| 2275 | } |
Jorim Jaggi | 6626f54 | 2016-08-22 13:08:44 -0700 | [diff] [blame] | 2276 | |
Svetoslav Ganov | aa07653 | 2016-08-01 19:16:43 -0700 | [diff] [blame] | 2277 | boolean canAddToastWindowForUid(int uid) { |
| 2278 | // We allow one toast window per UID being shown at a time. |
Svet Ganov | daca8ee | 2017-01-21 17:40:40 -0800 | [diff] [blame] | 2279 | // Also if the app is focused adding more than one toast at |
| 2280 | // a time for better backwards compatibility. |
| 2281 | final WindowState focusedWindowForUid = getWindow(w -> |
| 2282 | w.mOwnerUid == uid && w.isFocused()); |
| 2283 | if (focusedWindowForUid != null) { |
| 2284 | return true; |
| 2285 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2286 | final WindowState win = getWindow(w -> |
| 2287 | w.mAttrs.type == TYPE_TOAST && w.mOwnerUid == uid && !w.mPermanentlyHidden |
| 2288 | && !w.mWindowRemovalAllowed); |
| 2289 | return win == null; |
Svetoslav Ganov | aa07653 | 2016-08-01 19:16:43 -0700 | [diff] [blame] | 2290 | } |
| 2291 | |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 2292 | void scheduleToastWindowsTimeoutIfNeededLocked(WindowState oldFocus, WindowState newFocus) { |
Svetoslav Ganov | aa07653 | 2016-08-01 19:16:43 -0700 | [diff] [blame] | 2293 | if (oldFocus == null || (newFocus != null && newFocus.mOwnerUid == oldFocus.mOwnerUid)) { |
| 2294 | return; |
| 2295 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2296 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 2297 | // Used to communicate the old focus to the callback method. |
| 2298 | mTmpWindow = oldFocus; |
| 2299 | |
| 2300 | forAllWindows(mScheduleToastTimeout, false /* traverseTopToBottom */); |
Svetoslav Ganov | aa07653 | 2016-08-01 19:16:43 -0700 | [diff] [blame] | 2301 | } |
Wale Ogunwale | 63d4ecc | 2016-09-08 18:48:26 -0700 | [diff] [blame] | 2302 | |
| 2303 | WindowState findFocusedWindow() { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2304 | mTmpWindow = null; |
Wale Ogunwale | 63d4ecc | 2016-09-08 18:48:26 -0700 | [diff] [blame] | 2305 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 2306 | forAllWindows(mFindFocusedWindow, true /* traverseTopToBottom */); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2307 | |
| 2308 | if (mTmpWindow == null) { |
| 2309 | if (DEBUG_FOCUS_LIGHT) Slog.v(TAG_WM, "findFocusedWindow: No focusable windows."); |
| 2310 | return null; |
Wale Ogunwale | 63d4ecc | 2016-09-08 18:48:26 -0700 | [diff] [blame] | 2311 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2312 | return mTmpWindow; |
Wale Ogunwale | ec73115 | 2016-09-08 20:18:57 -0700 | [diff] [blame] | 2313 | } |
| 2314 | |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 2315 | /** Updates the layer assignment of windows on this display. */ |
| 2316 | void assignWindowLayers(boolean setLayoutNeeded) { |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 2317 | Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "assignWindowLayers"); |
Robert Carr | f59b8dd | 2017-10-02 18:58:36 -0700 | [diff] [blame] | 2318 | assignChildLayers(getPendingTransaction()); |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 2319 | if (setLayoutNeeded) { |
| 2320 | setLayoutNeeded(); |
| 2321 | } |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 2322 | |
Robert Carr | f59b8dd | 2017-10-02 18:58:36 -0700 | [diff] [blame] | 2323 | // We accumlate the layer changes in-to "getPendingTransaction()" but we defer |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 2324 | // the application of this transaction until the animation pass triggers |
| 2325 | // prepareSurfaces. This allows us to synchronize Z-ordering changes with |
| 2326 | // the hiding and showing of surfaces. |
| 2327 | scheduleAnimation(); |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 2328 | Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER); |
Wale Ogunwale | c69694a | 2016-10-18 13:51:15 -0700 | [diff] [blame] | 2329 | } |
| 2330 | |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 2331 | // TODO: This should probably be called any time a visual change is made to the hierarchy like |
| 2332 | // moving containers or resizing them. Need to investigate the best way to have it automatically |
| 2333 | // happen so we don't run into issues with programmers forgetting to do it. |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2334 | void layoutAndAssignWindowLayersIfNeeded() { |
| 2335 | mService.mWindowsChanged = true; |
| 2336 | setLayoutNeeded(); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2337 | |
| 2338 | if (!mService.updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES, |
| 2339 | false /*updateInputWindows*/)) { |
| 2340 | assignWindowLayers(false /* setLayoutNeeded */); |
| 2341 | } |
| 2342 | |
| 2343 | mService.mInputMonitor.setUpdateInputWindowsNeededLw(); |
| 2344 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
| 2345 | mService.mInputMonitor.updateInputWindowsLw(false /*force*/); |
| 2346 | } |
| 2347 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2348 | /** Returns true if a leaked surface was destroyed */ |
| 2349 | boolean destroyLeakedSurfaces() { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2350 | // Used to indicate that a surface was leaked. |
| 2351 | mTmpWindow = null; |
| 2352 | forAllWindows(w -> { |
| 2353 | final WindowStateAnimator wsa = w.mWinAnimator; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2354 | if (wsa.mSurfaceController == null) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2355 | return; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2356 | } |
| 2357 | if (!mService.mSessions.contains(wsa.mSession)) { |
| 2358 | Slog.w(TAG_WM, "LEAKED SURFACE (session doesn't exist): " |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2359 | + w + " surface=" + wsa.mSurfaceController |
| 2360 | + " token=" + w.mToken |
| 2361 | + " pid=" + w.mSession.mPid |
| 2362 | + " uid=" + w.mSession.mUid); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2363 | wsa.destroySurface(); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2364 | mService.mForceRemoves.add(w); |
| 2365 | mTmpWindow = w; |
Wale Ogunwale | 8997322 | 2017-04-23 18:39:45 -0700 | [diff] [blame] | 2366 | } else if (w.mAppToken != null && w.mAppToken.isClientHidden()) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2367 | Slog.w(TAG_WM, "LEAKED SURFACE (app token hidden): " |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2368 | + w + " surface=" + wsa.mSurfaceController |
Jorim Jaggi | e7d2b85 | 2017-08-28 17:55:15 +0200 | [diff] [blame] | 2369 | + " token=" + w.mAppToken); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2370 | if (SHOW_TRANSACTIONS) logSurface(w, "LEAK DESTROY", false); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2371 | wsa.destroySurface(); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2372 | mTmpWindow = w; |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2373 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2374 | }, false /* traverseTopToBottom */); |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2375 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2376 | return mTmpWindow != null; |
Jorim Jaggi | ffa5a9d | 2016-11-23 16:59:19 +0000 | [diff] [blame] | 2377 | } |
| 2378 | |
| 2379 | /** |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2380 | * Determine and return the window that should be the IME target. |
| 2381 | * @param updateImeTarget If true the system IME target will be updated to match what we found. |
| 2382 | * @return The window that should be used as the IME target or null if there isn't any. |
Jorim Jaggi | ffa5a9d | 2016-11-23 16:59:19 +0000 | [diff] [blame] | 2383 | */ |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2384 | WindowState computeImeTarget(boolean updateImeTarget) { |
| 2385 | if (mService.mInputMethodWindow == null) { |
| 2386 | // There isn't an IME so there shouldn't be a target...That was easy! |
| 2387 | if (updateImeTarget) { |
| 2388 | if (DEBUG_INPUT_METHOD) Slog.w(TAG_WM, "Moving IM target from " |
| 2389 | + mService.mInputMethodTarget + " to null since mInputMethodWindow is null"); |
Jorim Jaggi | b0fc817 | 2017-11-23 17:04:08 +0000 | [diff] [blame] | 2390 | setInputMethodTarget(null, mService.mInputMethodTargetWaitingAnim); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2391 | } |
| 2392 | return null; |
| 2393 | } |
| 2394 | |
Jorim Jaggi | ffa5a9d | 2016-11-23 16:59:19 +0000 | [diff] [blame] | 2395 | // TODO(multidisplay): Needs some serious rethought when the target and IME are not on the |
| 2396 | // same display. Or even when the current IME/target are not on the same screen as the next |
| 2397 | // IME/target. For now only look for input windows on the main screen. |
Wale Ogunwale | 8e44f6c | 2017-03-09 15:25:10 -0800 | [diff] [blame] | 2398 | mUpdateImeTarget = updateImeTarget; |
| 2399 | WindowState target = getWindow(mComputeImeTargetPredicate); |
Jorim Jaggi | ffa5a9d | 2016-11-23 16:59:19 +0000 | [diff] [blame] | 2400 | |
Jorim Jaggi | ffa5a9d | 2016-11-23 16:59:19 +0000 | [diff] [blame] | 2401 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2402 | // Yet more tricksyness! If this window is a "starting" window, we do actually want |
| 2403 | // to be on top of it, but it is not -really- where input will go. So look down below |
| 2404 | // for a real window to target... |
| 2405 | if (target != null && target.mAttrs.type == TYPE_APPLICATION_STARTING) { |
| 2406 | final AppWindowToken token = target.mAppToken; |
| 2407 | if (token != null) { |
| 2408 | final WindowState betterTarget = token.getImeTargetBelowWindow(target); |
| 2409 | if (betterTarget != null) { |
| 2410 | target = betterTarget; |
Jorim Jaggi | ffa5a9d | 2016-11-23 16:59:19 +0000 | [diff] [blame] | 2411 | } |
Jorim Jaggi | ffa5a9d | 2016-11-23 16:59:19 +0000 | [diff] [blame] | 2412 | } |
| 2413 | } |
| 2414 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2415 | if (DEBUG_INPUT_METHOD && updateImeTarget) Slog.v(TAG_WM, |
| 2416 | "Proposed new IME target: " + target); |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2417 | |
| 2418 | // Now, a special case -- if the last target's window is in the process of exiting, and is |
| 2419 | // above the new target, keep on the last target to avoid flicker. Consider for example a |
| 2420 | // Dialog with the IME shown: when the Dialog is dismissed, we want to keep the IME above it |
| 2421 | // until it is completely gone so it doesn't drop behind the dialog or its full-screen |
| 2422 | // scrim. |
| 2423 | final WindowState curTarget = mService.mInputMethodTarget; |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2424 | if (curTarget != null && curTarget.isDisplayedLw() && curTarget.isClosing() |
| 2425 | && (target == null |
| 2426 | || curTarget.mWinAnimator.mAnimLayer > target.mWinAnimator.mAnimLayer)) { |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2427 | if (DEBUG_INPUT_METHOD) Slog.v(TAG_WM, "Current target higher, not changing"); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2428 | return curTarget; |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2429 | } |
| 2430 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2431 | if (DEBUG_INPUT_METHOD) Slog.v(TAG_WM, "Desired input method target=" + target |
| 2432 | + " updateImeTarget=" + updateImeTarget); |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2433 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2434 | if (target == null) { |
| 2435 | if (updateImeTarget) { |
| 2436 | if (DEBUG_INPUT_METHOD) Slog.w(TAG_WM, "Moving IM target from " + curTarget |
| 2437 | + " to null." + (SHOW_STACK_CRAWLS ? " Callers=" |
| 2438 | + Debug.getCallers(4) : "")); |
Jorim Jaggi | b0fc817 | 2017-11-23 17:04:08 +0000 | [diff] [blame] | 2439 | setInputMethodTarget(null, mService.mInputMethodTargetWaitingAnim); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2440 | } |
| 2441 | |
| 2442 | return null; |
| 2443 | } |
| 2444 | |
| 2445 | if (updateImeTarget) { |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2446 | AppWindowToken token = curTarget == null ? null : curTarget.mAppToken; |
| 2447 | if (token != null) { |
| 2448 | |
| 2449 | // Now some fun for dealing with window animations that modify the Z order. We need |
| 2450 | // to look at all windows below the current target that are in this app, finding the |
| 2451 | // highest visible one in layering. |
| 2452 | WindowState highestTarget = null; |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 2453 | if (token.isSelfAnimating()) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2454 | highestTarget = token.getHighestAnimLayerWindow(curTarget); |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2455 | } |
| 2456 | |
| 2457 | if (highestTarget != null) { |
| 2458 | final AppTransition appTransition = mService.mAppTransition; |
| 2459 | if (DEBUG_INPUT_METHOD) Slog.v(TAG_WM, appTransition + " " + highestTarget |
| 2460 | + " animating=" + highestTarget.mWinAnimator.isAnimationSet() |
| 2461 | + " layer=" + highestTarget.mWinAnimator.mAnimLayer |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2462 | + " new layer=" + target.mWinAnimator.mAnimLayer); |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2463 | |
| 2464 | if (appTransition.isTransitionSet()) { |
| 2465 | // If we are currently setting up for an animation, hold everything until we |
| 2466 | // can find out what will happen. |
Jorim Jaggi | b0fc817 | 2017-11-23 17:04:08 +0000 | [diff] [blame] | 2467 | setInputMethodTarget(highestTarget, true); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2468 | return highestTarget; |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2469 | } else if (highestTarget.mWinAnimator.isAnimationSet() && |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2470 | highestTarget.mWinAnimator.mAnimLayer > target.mWinAnimator.mAnimLayer) { |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2471 | // If the window we are currently targeting is involved with an animation, |
| 2472 | // and it is on top of the next target we will be over, then hold off on |
| 2473 | // moving until that is done. |
Jorim Jaggi | b0fc817 | 2017-11-23 17:04:08 +0000 | [diff] [blame] | 2474 | setInputMethodTarget(highestTarget, true); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2475 | return highestTarget; |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2476 | } |
| 2477 | } |
| 2478 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2479 | |
| 2480 | if (DEBUG_INPUT_METHOD) Slog.w(TAG_WM, "Moving IM target from " + curTarget + " to " |
| 2481 | + target + (SHOW_STACK_CRAWLS ? " Callers=" + Debug.getCallers(4) : "")); |
Jorim Jaggi | b0fc817 | 2017-11-23 17:04:08 +0000 | [diff] [blame] | 2482 | setInputMethodTarget(target, false); |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2483 | } |
| 2484 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2485 | return target; |
Jorim Jaggi | ffa5a9d | 2016-11-23 16:59:19 +0000 | [diff] [blame] | 2486 | } |
| 2487 | |
Jorim Jaggi | b0fc817 | 2017-11-23 17:04:08 +0000 | [diff] [blame] | 2488 | private void setInputMethodTarget(WindowState target, boolean targetWaitingAnim) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2489 | if (target == mService.mInputMethodTarget |
Jorim Jaggi | b0fc817 | 2017-11-23 17:04:08 +0000 | [diff] [blame] | 2490 | && mService.mInputMethodTargetWaitingAnim == targetWaitingAnim) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2491 | return; |
Jorim Jaggi | ffa5a9d | 2016-11-23 16:59:19 +0000 | [diff] [blame] | 2492 | } |
| 2493 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2494 | mService.mInputMethodTarget = target; |
| 2495 | mService.mInputMethodTargetWaitingAnim = targetWaitingAnim; |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2496 | assignWindowLayers(false /* setLayoutNeeded */); |
| 2497 | } |
| 2498 | |
| 2499 | boolean getNeedsMenu(WindowState top, WindowManagerPolicy.WindowState bottom) { |
| 2500 | if (top.mAttrs.needsMenuKey != NEEDS_MENU_UNSET) { |
| 2501 | return top.mAttrs.needsMenuKey == NEEDS_MENU_SET_TRUE; |
| 2502 | } |
| 2503 | |
| 2504 | // Used to indicate we have reached the first window in the range we are interested in. |
| 2505 | mTmpWindow = null; |
| 2506 | |
| 2507 | // TODO: Figure-out a more efficient way to do this. |
| 2508 | final WindowState candidate = getWindow(w -> { |
| 2509 | if (w == top) { |
| 2510 | // Reached the first window in the range we are interested in. |
| 2511 | mTmpWindow = w; |
Jorim Jaggi | ffa5a9d | 2016-11-23 16:59:19 +0000 | [diff] [blame] | 2512 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2513 | if (mTmpWindow == null) { |
| 2514 | return false; |
| 2515 | } |
Jorim Jaggi | ffa5a9d | 2016-11-23 16:59:19 +0000 | [diff] [blame] | 2516 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2517 | if (w.mAttrs.needsMenuKey != NEEDS_MENU_UNSET) { |
| 2518 | return true; |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2519 | } |
| 2520 | // If we reached the bottom of the range of windows we are considering, |
| 2521 | // assume no menu is needed. |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2522 | if (w == bottom) { |
| 2523 | return true; |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2524 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2525 | return false; |
| 2526 | }); |
| 2527 | |
| 2528 | return candidate != null && candidate.mAttrs.needsMenuKey == NEEDS_MENU_SET_TRUE; |
Wale Ogunwale | ae9adbf | 2016-10-18 15:17:06 -0700 | [diff] [blame] | 2529 | } |
| 2530 | |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 2531 | void setLayoutNeeded() { |
| 2532 | if (DEBUG_LAYOUT) Slog.w(TAG_WM, "setLayoutNeeded: callers=" + Debug.getCallers(3)); |
| 2533 | mLayoutNeeded = true; |
| 2534 | } |
| 2535 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2536 | private void clearLayoutNeeded() { |
Wale Ogunwale | 2b06bfc | 2016-09-28 14:17:05 -0700 | [diff] [blame] | 2537 | if (DEBUG_LAYOUT) Slog.w(TAG_WM, "clearLayoutNeeded: callers=" + Debug.getCallers(3)); |
| 2538 | mLayoutNeeded = false; |
| 2539 | } |
| 2540 | |
| 2541 | boolean isLayoutNeeded() { |
| 2542 | return mLayoutNeeded; |
| 2543 | } |
| 2544 | |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 2545 | void dumpTokens(PrintWriter pw, boolean dumpAll) { |
| 2546 | if (mTokenMap.isEmpty()) { |
| 2547 | return; |
| 2548 | } |
| 2549 | pw.println(" Display #" + mDisplayId); |
| 2550 | final Iterator<WindowToken> it = mTokenMap.values().iterator(); |
| 2551 | while (it.hasNext()) { |
| 2552 | final WindowToken token = it.next(); |
| 2553 | pw.print(" "); |
| 2554 | pw.print(token); |
| 2555 | if (dumpAll) { |
| 2556 | pw.println(':'); |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 2557 | token.dump(pw, " ", dumpAll); |
Wale Ogunwale | 02319a6 | 2016-09-26 15:21:22 -0700 | [diff] [blame] | 2558 | } else { |
| 2559 | pw.println(); |
| 2560 | } |
| 2561 | } |
| 2562 | } |
| 2563 | |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 2564 | void dumpWindowAnimators(PrintWriter pw, String subPrefix) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2565 | final int[] index = new int[1]; |
| 2566 | forAllWindows(w -> { |
| 2567 | final WindowStateAnimator wAnim = w.mWinAnimator; |
| 2568 | pw.println(subPrefix + "Window #" + index[0] + ": " + wAnim); |
| 2569 | index[0] = index[0] + 1; |
| 2570 | }, false /* traverseTopToBottom */); |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 2571 | } |
| 2572 | |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 2573 | void enableSurfaceTrace(FileDescriptor fd) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2574 | forAllWindows(w -> { |
| 2575 | w.mWinAnimator.enableSurfaceTrace(fd); |
| 2576 | }, true /* traverseTopToBottom */); |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 2577 | } |
| 2578 | |
| 2579 | void disableSurfaceTrace() { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2580 | forAllWindows(w -> { |
| 2581 | w.mWinAnimator.disableSurfaceTrace(); |
| 2582 | }, true /* traverseTopToBottom */); |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 2583 | } |
| 2584 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 2585 | /** |
| 2586 | * Starts the Keyguard exit animation on all windows that don't belong to an app token. |
| 2587 | */ |
| 2588 | void startKeyguardExitOnNonAppWindows(boolean onWallpaper, boolean goingToShade) { |
| 2589 | final WindowManagerPolicy policy = mService.mPolicy; |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2590 | forAllWindows(w -> { |
Jorim Jaggi | c6ae42a | 2017-05-08 23:42:02 +0200 | [diff] [blame] | 2591 | if (w.mAppToken == null && policy.canBeHiddenByKeyguardLw(w) |
| 2592 | && w.wouldBeVisibleIfPolicyIgnored() && !w.isVisible()) { |
Jorim Jaggi | a5e1057 | 2017-11-15 14:36:26 +0100 | [diff] [blame] | 2593 | w.startAnimation(policy.createHiddenByKeyguardExit(onWallpaper, goingToShade)); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 2594 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2595 | }, true /* traverseTopToBottom */); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 2596 | } |
| 2597 | |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2598 | boolean checkWaitingForWindows() { |
| 2599 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2600 | mHaveBootMsg = false; |
| 2601 | mHaveApp = false; |
| 2602 | mHaveWallpaper = false; |
| 2603 | mHaveKeyguard = true; |
| 2604 | |
| 2605 | final WindowState visibleWindow = getWindow(w -> { |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2606 | if (w.isVisibleLw() && !w.mObscured && !w.isDrawnLw()) { |
| 2607 | return true; |
| 2608 | } |
| 2609 | if (w.isDrawnLw()) { |
| 2610 | if (w.mAttrs.type == TYPE_BOOT_PROGRESS) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2611 | mHaveBootMsg = true; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2612 | } else if (w.mAttrs.type == TYPE_APPLICATION |
| 2613 | || w.mAttrs.type == TYPE_DRAWN_APPLICATION) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2614 | mHaveApp = true; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2615 | } else if (w.mAttrs.type == TYPE_WALLPAPER) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2616 | mHaveWallpaper = true; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2617 | } else if (w.mAttrs.type == TYPE_STATUS_BAR) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2618 | mHaveKeyguard = mService.mPolicy.isKeyguardDrawnLw(); |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2619 | } |
| 2620 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2621 | return false; |
| 2622 | }); |
| 2623 | |
| 2624 | if (visibleWindow != null) { |
| 2625 | // We have a visible window. |
| 2626 | return true; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2627 | } |
| 2628 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2629 | // if the wallpaper service is disabled on the device, we're never going to have |
| 2630 | // wallpaper, don't bother waiting for it |
| 2631 | boolean wallpaperEnabled = mService.mContext.getResources().getBoolean( |
| 2632 | com.android.internal.R.bool.config_enableWallpaperService) |
| 2633 | && !mService.mOnlyCore; |
| 2634 | |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2635 | if (DEBUG_SCREEN_ON || DEBUG_BOOT) Slog.i(TAG_WM, |
| 2636 | "******** booted=" + mService.mSystemBooted |
| 2637 | + " msg=" + mService.mShowingBootMessages |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2638 | + " haveBoot=" + mHaveBootMsg + " haveApp=" + mHaveApp |
| 2639 | + " haveWall=" + mHaveWallpaper + " wallEnabled=" + wallpaperEnabled |
| 2640 | + " haveKeyguard=" + mHaveKeyguard); |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2641 | |
| 2642 | // If we are turning on the screen to show the boot message, don't do it until the boot |
| 2643 | // message is actually displayed. |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2644 | if (!mService.mSystemBooted && !mHaveBootMsg) { |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2645 | return true; |
| 2646 | } |
| 2647 | |
| 2648 | // If we are turning on the screen after the boot is completed normally, don't do so until |
| 2649 | // we have the application and wallpaper. |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2650 | if (mService.mSystemBooted |
| 2651 | && ((!mHaveApp && !mHaveKeyguard) || (wallpaperEnabled && !mHaveWallpaper))) { |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2652 | return true; |
| 2653 | } |
| 2654 | |
| 2655 | return false; |
| 2656 | } |
| 2657 | |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 2658 | void updateWindowsForAnimator(WindowAnimator animator) { |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 2659 | mTmpWindowAnimator = animator; |
| 2660 | forAllWindows(mUpdateWindowsForAnimator, true /* traverseTopToBottom */); |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 2661 | } |
| 2662 | |
| 2663 | void updateWallpaperForAnimator(WindowAnimator animator) { |
Jorim Jaggi | 7156b65 | 2016-10-25 08:31:58 -0700 | [diff] [blame] | 2664 | resetAnimationBackgroundAnimator(); |
| 2665 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2666 | // Used to indicate a detached wallpaper. |
| 2667 | mTmpWindow = null; |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 2668 | mTmpWindowAnimator = animator; |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 2669 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 2670 | forAllWindows(mUpdateWallpaperForAnimator, true /* traverseTopToBottom */); |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 2671 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2672 | if (animator.mWindowDetachedWallpaper != mTmpWindow) { |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 2673 | if (DEBUG_WALLPAPER) Slog.v(TAG, "Detached wallpaper changed from " |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2674 | + animator.mWindowDetachedWallpaper + " to " + mTmpWindow); |
| 2675 | animator.mWindowDetachedWallpaper = mTmpWindow; |
Wale Ogunwale | 824ab5c | 2016-10-20 09:31:56 -0700 | [diff] [blame] | 2676 | animator.mBulkUpdateParams |= SET_WALLPAPER_MAY_CHANGE; |
| 2677 | } |
| 2678 | } |
| 2679 | |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2680 | boolean inputMethodClientHasFocus(IInputMethodClient client) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2681 | final WindowState imFocus = computeImeTarget(false /* updateImeTarget */); |
Jorim Jaggi | ffa5a9d | 2016-11-23 16:59:19 +0000 | [diff] [blame] | 2682 | if (imFocus == null) { |
| 2683 | return false; |
| 2684 | } |
| 2685 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2686 | if (DEBUG_INPUT_METHOD) { |
| 2687 | Slog.i(TAG_WM, "Desired input method target: " + imFocus); |
| 2688 | Slog.i(TAG_WM, "Current focus: " + mService.mCurrentFocus); |
| 2689 | Slog.i(TAG_WM, "Last focus: " + mService.mLastFocus); |
Jorim Jaggi | ffa5a9d | 2016-11-23 16:59:19 +0000 | [diff] [blame] | 2690 | } |
| 2691 | |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2692 | final IInputMethodClient imeClient = imFocus.mSession.mClient; |
| 2693 | |
| 2694 | if (DEBUG_INPUT_METHOD) { |
| 2695 | Slog.i(TAG_WM, "IM target client: " + imeClient); |
| 2696 | if (imeClient != null) { |
| 2697 | Slog.i(TAG_WM, "IM target client binder: " + imeClient.asBinder()); |
| 2698 | Slog.i(TAG_WM, "Requesting client binder: " + client.asBinder()); |
| 2699 | } |
| 2700 | } |
| 2701 | |
| 2702 | return imeClient != null && imeClient.asBinder() == client.asBinder(); |
| 2703 | } |
| 2704 | |
| 2705 | boolean hasSecureWindowOnScreen() { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2706 | final WindowState win = getWindow( |
| 2707 | w -> w.isOnScreen() && (w.mAttrs.flags & FLAG_SECURE) != 0); |
| 2708 | return win != null; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2709 | } |
| 2710 | |
| 2711 | void updateSystemUiVisibility(int visibility, int globalDiff) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2712 | forAllWindows(w -> { |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2713 | try { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2714 | final int curValue = w.mSystemUiVisibility; |
| 2715 | final int diff = (curValue ^ visibility) & globalDiff; |
| 2716 | final int newValue = (curValue & ~diff) | (visibility & diff); |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2717 | if (newValue != curValue) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2718 | w.mSeq++; |
| 2719 | w.mSystemUiVisibility = newValue; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2720 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2721 | if (newValue != curValue || w.mAttrs.hasSystemUiListeners) { |
| 2722 | w.mClient.dispatchSystemUiVisibilityChanged(w.mSeq, |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2723 | visibility, newValue, diff); |
| 2724 | } |
| 2725 | } catch (RemoteException e) { |
| 2726 | // so sorry |
| 2727 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2728 | }, true /* traverseTopToBottom */); |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2729 | } |
| 2730 | |
| 2731 | void onWindowFreezeTimeout() { |
| 2732 | Slog.w(TAG_WM, "Window freeze timeout expired."); |
| 2733 | mService.mWindowsFreezingScreen = WINDOWS_FREEZING_SCREENS_TIMEOUT; |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2734 | |
| 2735 | forAllWindows(w -> { |
Bryce Lee | 8c3cf38 | 2017-07-06 19:47:10 -0700 | [diff] [blame] | 2736 | if (!w.getOrientationChanging()) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2737 | return; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2738 | } |
Robert Carr | 9c1c3a0 | 2017-08-08 12:59:01 -0700 | [diff] [blame] | 2739 | w.orientationChangeTimedOut(); |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2740 | w.mLastFreezeDuration = (int)(SystemClock.elapsedRealtime() |
| 2741 | - mService.mDisplayFreezeTime); |
| 2742 | Slog.w(TAG_WM, "Force clearing orientation change: " + w); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2743 | }, true /* traverseTopToBottom */); |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2744 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
| 2745 | } |
| 2746 | |
| 2747 | void waitForAllWindowsDrawn() { |
| 2748 | final WindowManagerPolicy policy = mService.mPolicy; |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2749 | forAllWindows(w -> { |
| 2750 | final boolean keyguard = policy.isKeyguardHostWindow(w.mAttrs); |
| 2751 | if (w.isVisibleLw() && (w.mAppToken != null || keyguard)) { |
| 2752 | w.mWinAnimator.mDrawState = DRAW_PENDING; |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2753 | // Force add to mResizingWindows. |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2754 | w.mLastContentInsets.set(-1, -1, -1, -1); |
| 2755 | mService.mWaitingForDrawn.add(w); |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2756 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2757 | }, true /* traverseTopToBottom */); |
Wale Ogunwale | 494009b8 | 2016-10-21 09:01:38 -0700 | [diff] [blame] | 2758 | } |
| 2759 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2760 | // TODO: Super crazy long method that should be broken down... |
| 2761 | boolean applySurfaceChangesTransaction(boolean recoveringMemory) { |
| 2762 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2763 | final int dw = mDisplayInfo.logicalWidth; |
| 2764 | final int dh = mDisplayInfo.logicalHeight; |
| 2765 | final WindowSurfacePlacer surfacePlacer = mService.mWindowPlacerLocked; |
| 2766 | |
| 2767 | mTmpUpdateAllDrawn.clear(); |
| 2768 | |
| 2769 | int repeats = 0; |
| 2770 | do { |
| 2771 | repeats++; |
| 2772 | if (repeats > 6) { |
| 2773 | Slog.w(TAG, "Animation repeat aborted after too many iterations"); |
| 2774 | clearLayoutNeeded(); |
| 2775 | break; |
| 2776 | } |
| 2777 | |
| 2778 | if (DEBUG_LAYOUT_REPEATS) surfacePlacer.debugLayoutRepeats("On entry to LockedInner", |
| 2779 | pendingLayoutChanges); |
| 2780 | |
Andrii Kulian | 839def9 | 2016-11-02 10:58:58 -0700 | [diff] [blame] | 2781 | // TODO(multi-display): For now adjusting wallpaper only on primary display to avoid |
| 2782 | // the wallpaper window jumping across displays. |
| 2783 | // Remove check for default display when there will be support for multiple wallpaper |
| 2784 | // targets (on different displays). |
| 2785 | if (isDefaultDisplay && (pendingLayoutChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2786 | mWallpaperController.adjustWallpaperWindows(this); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2787 | } |
| 2788 | |
| 2789 | if (isDefaultDisplay && (pendingLayoutChanges & FINISH_LAYOUT_REDO_CONFIG) != 0) { |
| 2790 | if (DEBUG_LAYOUT) Slog.v(TAG, "Computing new config from layout"); |
| 2791 | if (mService.updateOrientationFromAppTokensLocked(true, mDisplayId)) { |
| 2792 | setLayoutNeeded(); |
Andrii Kulian | b17e869 | 2016-11-01 10:37:22 -0700 | [diff] [blame] | 2793 | mService.mH.obtainMessage(SEND_NEW_CONFIGURATION, mDisplayId).sendToTarget(); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2794 | } |
| 2795 | } |
| 2796 | |
| 2797 | if ((pendingLayoutChanges & FINISH_LAYOUT_REDO_LAYOUT) != 0) { |
| 2798 | setLayoutNeeded(); |
| 2799 | } |
| 2800 | |
| 2801 | // FIRST LOOP: Perform a layout, if needed. |
| 2802 | if (repeats < LAYOUT_REPEAT_THRESHOLD) { |
| 2803 | performLayout(repeats == 1, false /* updateInputWindows */); |
| 2804 | } else { |
| 2805 | Slog.w(TAG, "Layout repeat skipped after too many iterations"); |
| 2806 | } |
| 2807 | |
| 2808 | // FIRST AND ONE HALF LOOP: Make WindowManagerPolicy think it is animating. |
| 2809 | pendingLayoutChanges = 0; |
| 2810 | |
| 2811 | if (isDefaultDisplay) { |
| 2812 | mService.mPolicy.beginPostLayoutPolicyLw(dw, dh); |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 2813 | forAllWindows(mApplyPostLayoutPolicy, true /* traverseTopToBottom */); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2814 | pendingLayoutChanges |= mService.mPolicy.finishPostLayoutPolicyLw(); |
| 2815 | if (DEBUG_LAYOUT_REPEATS) surfacePlacer.debugLayoutRepeats( |
| 2816 | "after finishPostLayoutPolicyLw", pendingLayoutChanges); |
| 2817 | } |
| 2818 | } while (pendingLayoutChanges != 0); |
| 2819 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2820 | mTmpApplySurfaceChangesTransactionState.reset(); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2821 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 2822 | mTmpRecoveringMemory = recoveringMemory; |
| 2823 | forAllWindows(mApplySurfaceChangesTransaction, true /* traverseTopToBottom */); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2824 | |
| 2825 | mService.mDisplayManagerInternal.setDisplayProperties(mDisplayId, |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2826 | mTmpApplySurfaceChangesTransactionState.displayHasContent, |
| 2827 | mTmpApplySurfaceChangesTransactionState.preferredRefreshRate, |
| 2828 | mTmpApplySurfaceChangesTransactionState.preferredModeId, |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2829 | true /* inTraversal, must call performTraversalInTrans... below */); |
| 2830 | |
Lucas Dupin | 1ead7fc | 2017-05-24 14:14:44 -0700 | [diff] [blame] | 2831 | final boolean wallpaperVisible = mWallpaperController.isWallpaperVisible(); |
| 2832 | if (wallpaperVisible != mLastWallpaperVisible) { |
| 2833 | mLastWallpaperVisible = wallpaperVisible; |
| 2834 | mService.mWallpaperVisibilityListeners.notifyWallpaperVisibilityChanged(this); |
| 2835 | } |
| 2836 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2837 | while (!mTmpUpdateAllDrawn.isEmpty()) { |
| 2838 | final AppWindowToken atoken = mTmpUpdateAllDrawn.removeLast(); |
| 2839 | // See if any windows have been drawn, so they (and others associated with them) |
| 2840 | // can now be shown. |
Matthew Ng | 498c71d | 2017-04-18 13:55:45 -0700 | [diff] [blame] | 2841 | atoken.updateAllDrawn(); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2842 | } |
| 2843 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2844 | return mTmpApplySurfaceChangesTransactionState.focusDisplayed; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2845 | } |
| 2846 | |
Bryce Lee | f3c6a47 | 2017-11-14 14:53:06 -0800 | [diff] [blame] | 2847 | private void updateBounds() { |
| 2848 | calculateBounds(mTmpBounds); |
| 2849 | setBounds(mTmpBounds); |
| 2850 | } |
| 2851 | |
| 2852 | // Determines the current display bounds based on the current state |
| 2853 | private void calculateBounds(Rect out) { |
| 2854 | // Uses same calculation as in LogicalDisplay#configureDisplayInTransactionLocked. |
| 2855 | final int orientation = mDisplayInfo.rotation; |
| 2856 | boolean rotated = (orientation == ROTATION_90 || orientation == ROTATION_270); |
| 2857 | final int physWidth = rotated ? mBaseDisplayHeight : mBaseDisplayWidth; |
| 2858 | final int physHeight = rotated ? mBaseDisplayWidth : mBaseDisplayHeight; |
| 2859 | int width = mDisplayInfo.logicalWidth; |
| 2860 | int left = (physWidth - width) / 2; |
| 2861 | int height = mDisplayInfo.logicalHeight; |
| 2862 | int top = (physHeight - height) / 2; |
| 2863 | out.set(left, top, left + width, top + height); |
| 2864 | } |
| 2865 | |
| 2866 | @Override |
| 2867 | public void getBounds(Rect out) { |
| 2868 | calculateBounds(out); |
| 2869 | } |
| 2870 | |
| 2871 | private void getBounds(Rect out, int orientation) { |
| 2872 | getBounds(out); |
| 2873 | |
| 2874 | // Rotate the Rect if needed. |
| 2875 | final int currentRotation = mDisplayInfo.rotation; |
| 2876 | final int rotationDelta = deltaRotation(currentRotation, orientation); |
| 2877 | if (rotationDelta == ROTATION_90 || rotationDelta == ROTATION_270) { |
| 2878 | createRotationMatrix(rotationDelta, mBaseDisplayWidth, mBaseDisplayHeight, mTmpMatrix); |
| 2879 | mTmpRectF.set(out); |
| 2880 | mTmpMatrix.mapRect(mTmpRectF); |
| 2881 | mTmpRectF.round(out); |
| 2882 | } |
| 2883 | } |
| 2884 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2885 | void performLayout(boolean initial, boolean updateInputWindows) { |
| 2886 | if (!isLayoutNeeded()) { |
| 2887 | return; |
| 2888 | } |
| 2889 | clearLayoutNeeded(); |
| 2890 | |
| 2891 | final int dw = mDisplayInfo.logicalWidth; |
| 2892 | final int dh = mDisplayInfo.logicalHeight; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2893 | if (DEBUG_LAYOUT) { |
| 2894 | Slog.v(TAG, "-------------------------------------"); |
| 2895 | Slog.v(TAG, "performLayout: needed=" + isLayoutNeeded() + " dw=" + dw + " dh=" + dh); |
| 2896 | } |
| 2897 | |
Wale Ogunwale | 828ff7e | 2017-11-14 01:01:29 +0000 | [diff] [blame] | 2898 | mDisplayFrames.onDisplayInfoUpdated(mDisplayInfo); |
| 2899 | // TODO: Not sure if we really need to set the rotation here since we are updating from the |
| 2900 | // display info above... |
| 2901 | mDisplayFrames.mRotation = mRotation; |
| 2902 | mService.mPolicy.beginLayoutLw(mDisplayFrames, getConfiguration().uiMode); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2903 | if (isDefaultDisplay) { |
| 2904 | // Not needed on non-default displays. |
| 2905 | mService.mSystemDecorLayer = mService.mPolicy.getSystemDecorLayerLw(); |
| 2906 | mService.mScreenRect.set(0, 0, dw, dh); |
| 2907 | } |
| 2908 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2909 | int seq = mService.mLayoutSeq + 1; |
| 2910 | if (seq < 0) seq = 0; |
| 2911 | mService.mLayoutSeq = seq; |
| 2912 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2913 | // Used to indicate that we have processed the dream window and all additional windows are |
| 2914 | // behind it. |
| 2915 | mTmpWindow = null; |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 2916 | mTmpInitial = initial; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2917 | |
| 2918 | // First perform layout of any root windows (not attached to another window). |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 2919 | forAllWindows(mPerformLayout, true /* traverseTopToBottom */); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2920 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2921 | // Used to indicate that we have processed the dream window and all additional attached |
| 2922 | // windows are behind it. |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 2923 | mTmpWindow2 = mTmpWindow; |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 2924 | mTmpWindow = null; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2925 | |
| 2926 | // Now perform layout of attached windows, which usually depend on the position of the |
| 2927 | // window they are attached to. XXX does not deal with windows that are attached to windows |
| 2928 | // that are themselves attached. |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 2929 | forAllWindows(mPerformLayoutAttached, true /* traverseTopToBottom */); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2930 | |
| 2931 | // Window frames may have changed. Tell the input dispatcher about it. |
| 2932 | mService.mInputMonitor.layoutInputConsumers(dw, dh); |
| 2933 | mService.mInputMonitor.setUpdateInputWindowsNeededLw(); |
| 2934 | if (updateInputWindows) { |
| 2935 | mService.mInputMonitor.updateInputWindowsLw(false /*force*/); |
| 2936 | } |
| 2937 | |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2938 | mService.mH.sendEmptyMessage(UPDATE_DOCKED_STACK_DIVIDER); |
| 2939 | } |
| 2940 | |
| 2941 | /** |
| 2942 | * Takes a snapshot of the display. In landscape mode this grabs the whole screen. |
| 2943 | * In portrait mode, it grabs the full screenshot. |
| 2944 | * |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2945 | * @param config of the output bitmap |
| 2946 | * @param wallpaperOnly true if only the wallpaper layer should be included in the screenshot |
| 2947 | */ |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 2948 | Bitmap screenshotDisplay(Bitmap.Config config, boolean wallpaperOnly) { |
| 2949 | synchronized (mService.mWindowMap) { |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 2950 | if (!mService.mPolicy.isScreenOn()) { |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 2951 | if (DEBUG_SCREENSHOT) { |
| 2952 | Slog.i(TAG_WM, "Attempted to take screenshot while display was off."); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2953 | } |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2954 | return null; |
| 2955 | } |
| 2956 | |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 2957 | if (wallpaperOnly && !shouldScreenshotWallpaper()) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2958 | return null; |
| 2959 | } |
| 2960 | |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 2961 | int dw = mDisplayInfo.logicalWidth; |
| 2962 | int dh = mDisplayInfo.logicalHeight; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2963 | |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 2964 | if (dw <= 0 || dh <= 0) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2965 | return null; |
| 2966 | } |
| 2967 | |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 2968 | final Rect frame = new Rect(0, 0, dw, dh); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2969 | |
| 2970 | // The screenshot API does not apply the current screen rotation. |
| 2971 | int rot = mDisplay.getRotation(); |
| 2972 | |
| 2973 | if (rot == ROTATION_90 || rot == ROTATION_270) { |
| 2974 | rot = (rot == ROTATION_90) ? ROTATION_270 : ROTATION_90; |
| 2975 | } |
| 2976 | |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 2977 | // SurfaceFlinger is not aware of orientation, so convert our logical |
| 2978 | // crop to SurfaceFlinger's portrait orientation. |
| 2979 | convertCropForSurfaceFlinger(frame, rot, dw, dh); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2980 | |
| 2981 | final ScreenRotationAnimation screenRotationAnimation = |
| 2982 | mService.mAnimator.getScreenRotationAnimationLocked(DEFAULT_DISPLAY); |
| 2983 | final boolean inRotation = screenRotationAnimation != null && |
| 2984 | screenRotationAnimation.isAnimating(); |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 2985 | if (DEBUG_SCREENSHOT && inRotation) Slog.v(TAG_WM, "Taking screenshot while rotating"); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2986 | |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 2987 | // TODO(b/68392460): We should screenshot Task controls directly |
| 2988 | // but it's difficult at the moment as the Task doesn't have the |
| 2989 | // correct size set. |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 2990 | final Bitmap bitmap = SurfaceControl.screenshot(frame, dw, dh, 0, 1, inRotation, rot); |
Jorim Jaggi | 6a7a859 | 2017-01-12 00:44:33 +0100 | [diff] [blame] | 2991 | if (bitmap == null) { |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 2992 | Slog.w(TAG_WM, "Failed to take screenshot"); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 2993 | return null; |
| 2994 | } |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 2995 | |
| 2996 | // Create a copy of the screenshot that is immutable and backed in ashmem. |
| 2997 | // This greatly reduces the overhead of passing the bitmap between processes. |
| 2998 | final Bitmap ret = bitmap.createAshmemBitmap(config); |
| 2999 | bitmap.recycle(); |
| 3000 | return ret; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 3001 | } |
chaviw | fbe47df | 2017-11-10 16:14:49 -0800 | [diff] [blame] | 3002 | } |
| 3003 | |
| 3004 | private boolean shouldScreenshotWallpaper() { |
| 3005 | MutableBoolean screenshotReady = new MutableBoolean(false); |
| 3006 | |
| 3007 | forAllWindows(w -> { |
| 3008 | if (!w.mIsWallpaper) { |
| 3009 | return false; |
| 3010 | } |
| 3011 | |
| 3012 | // Found the wallpaper window |
| 3013 | final WindowStateAnimator winAnim = w.mWinAnimator; |
| 3014 | |
| 3015 | if (winAnim.getShown() && winAnim.mLastAlpha > 0f) { |
| 3016 | screenshotReady.value = true; |
| 3017 | } |
| 3018 | |
| 3019 | return true; |
| 3020 | }, true /* traverseTopToBottom */); |
| 3021 | |
| 3022 | return screenshotReady.value; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 3023 | } |
| 3024 | |
| 3025 | // TODO: Can this use createRotationMatrix()? |
| 3026 | private static void convertCropForSurfaceFlinger(Rect crop, int rot, int dw, int dh) { |
| 3027 | if (rot == Surface.ROTATION_90) { |
| 3028 | final int tmp = crop.top; |
| 3029 | crop.top = dw - crop.right; |
| 3030 | crop.right = crop.bottom; |
| 3031 | crop.bottom = dw - crop.left; |
| 3032 | crop.left = tmp; |
| 3033 | } else if (rot == Surface.ROTATION_180) { |
| 3034 | int tmp = crop.top; |
| 3035 | crop.top = dh - crop.bottom; |
| 3036 | crop.bottom = dh - tmp; |
| 3037 | tmp = crop.right; |
| 3038 | crop.right = dw - crop.left; |
| 3039 | crop.left = dw - tmp; |
| 3040 | } else if (rot == Surface.ROTATION_270) { |
| 3041 | final int tmp = crop.top; |
| 3042 | crop.top = crop.left; |
| 3043 | crop.left = dh - crop.bottom; |
| 3044 | crop.bottom = crop.right; |
| 3045 | crop.right = dh - tmp; |
| 3046 | } |
| 3047 | } |
| 3048 | |
| 3049 | void onSeamlessRotationTimeout() { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 3050 | // Used to indicate the layout is needed. |
| 3051 | mTmpWindow = null; |
| 3052 | |
| 3053 | forAllWindows(w -> { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 3054 | if (!w.mSeamlesslyRotated) { |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 3055 | return; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 3056 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 3057 | mTmpWindow = w; |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 3058 | w.setDisplayLayoutNeeded(); |
| 3059 | mService.markForSeamlessRotation(w, false); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 3060 | }, true /* traverseTopToBottom */); |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 3061 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 3062 | if (mTmpWindow != null) { |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 3063 | mService.mWindowPlacerLocked.performSurfacePlacement(); |
| 3064 | } |
| 3065 | } |
| 3066 | |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 3067 | void setExitingTokensHasVisible(boolean hasVisible) { |
| 3068 | for (int i = mExitingTokens.size() - 1; i >= 0; i--) { |
| 3069 | mExitingTokens.get(i).hasVisible = hasVisible; |
| 3070 | } |
| 3071 | |
| 3072 | // Initialize state of exiting applications. |
| 3073 | mTaskStackContainers.setExitingTokensHasVisible(hasVisible); |
| 3074 | } |
| 3075 | |
| 3076 | void removeExistingTokensIfPossible() { |
| 3077 | for (int i = mExitingTokens.size() - 1; i >= 0; i--) { |
| 3078 | final WindowToken token = mExitingTokens.get(i); |
| 3079 | if (!token.hasVisible) { |
| 3080 | mExitingTokens.remove(i); |
| 3081 | } |
| 3082 | } |
| 3083 | |
| 3084 | // Time to remove any exiting applications? |
| 3085 | mTaskStackContainers.removeExistingAppTokensIfPossible(); |
| 3086 | } |
| 3087 | |
Wale Ogunwale | 55ddf8f | 2017-03-20 08:56:38 -0700 | [diff] [blame] | 3088 | @Override |
| 3089 | void onDescendantOverrideConfigurationChanged() { |
| 3090 | setLayoutNeeded(); |
| 3091 | mService.requestTraversal(); |
| 3092 | } |
| 3093 | |
David Stevens | 9440dc8 | 2017-03-16 19:00:20 -0700 | [diff] [blame] | 3094 | boolean okToDisplay() { |
| 3095 | if (mDisplayId == DEFAULT_DISPLAY) { |
| 3096 | return !mService.mDisplayFrozen |
| 3097 | && mService.mDisplayEnabled && mService.mPolicy.isScreenOn(); |
| 3098 | } |
| 3099 | return mDisplayInfo.state == Display.STATE_ON; |
| 3100 | } |
| 3101 | |
| 3102 | boolean okToAnimate() { |
| 3103 | return okToDisplay() && |
| 3104 | (mDisplayId != DEFAULT_DISPLAY || mService.mPolicy.okToAnimate()); |
| 3105 | } |
| 3106 | |
Wale Ogunwale | 3f4433d | 2016-08-18 20:42:42 -0700 | [diff] [blame] | 3107 | static final class TaskForResizePointSearchResult { |
| 3108 | boolean searchDone; |
| 3109 | Task taskForResize; |
| 3110 | |
| 3111 | void reset() { |
| 3112 | searchDone = false; |
| 3113 | taskForResize = null; |
| 3114 | } |
| 3115 | } |
Robert Carr | 3b71624 | 2016-08-16 16:02:21 -0700 | [diff] [blame] | 3116 | |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 3117 | private static final class ApplySurfaceChangesTransactionState { |
| 3118 | boolean displayHasContent; |
| 3119 | boolean obscured; |
| 3120 | boolean syswin; |
| 3121 | boolean focusDisplayed; |
| 3122 | float preferredRefreshRate; |
| 3123 | int preferredModeId; |
| 3124 | |
| 3125 | void reset() { |
| 3126 | displayHasContent = false; |
| 3127 | obscured = false; |
| 3128 | syswin = false; |
| 3129 | focusDisplayed = false; |
| 3130 | preferredRefreshRate = 0; |
| 3131 | preferredModeId = 0; |
| 3132 | } |
| 3133 | } |
| 3134 | |
| 3135 | private static final class ScreenshotApplicationState { |
| 3136 | WindowState appWin; |
| 3137 | int maxLayer; |
| 3138 | int minLayer; |
| 3139 | boolean screenshotReady; |
| 3140 | |
| 3141 | void reset(boolean screenshotReady) { |
| 3142 | appWin = null; |
| 3143 | maxLayer = 0; |
| 3144 | minLayer = 0; |
| 3145 | this.screenshotReady = screenshotReady; |
| 3146 | minLayer = (screenshotReady) ? 0 : Integer.MAX_VALUE; |
| 3147 | } |
| 3148 | } |
| 3149 | |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 3150 | /** |
| 3151 | * Base class for any direct child window container of {@link #DisplayContent} need to inherit |
| 3152 | * from. This is mainly a pass through class that allows {@link #DisplayContent} to have |
| 3153 | * homogeneous children type which is currently required by sub-classes of |
| 3154 | * {@link WindowContainer} class. |
| 3155 | */ |
| 3156 | static class DisplayChildWindowContainer<E extends WindowContainer> extends WindowContainer<E> { |
| 3157 | |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 3158 | DisplayChildWindowContainer(WindowManagerService service) { |
| 3159 | super(service); |
| 3160 | } |
| 3161 | |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 3162 | @Override |
| 3163 | boolean fillsParent() { |
| 3164 | return true; |
| 3165 | } |
| 3166 | |
| 3167 | @Override |
| 3168 | boolean isVisible() { |
| 3169 | return true; |
Robert Carr | 3b71624 | 2016-08-16 16:02:21 -0700 | [diff] [blame] | 3170 | } |
| 3171 | } |
| 3172 | |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 3173 | /** |
| 3174 | * Window container class that contains all containers on this display relating to Apps. |
| 3175 | * I.e Activities. |
| 3176 | */ |
Wale Ogunwale | 3a93169 | 2016-11-02 16:49:48 -0700 | [diff] [blame] | 3177 | private final class TaskStackContainers extends DisplayChildWindowContainer<TaskStack> { |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3178 | /** |
| 3179 | * A control placed at the appropriate level for transitions to occur. |
| 3180 | */ |
chaviw | 23ee71c | 2017-12-18 11:29:41 -0800 | [diff] [blame] | 3181 | SurfaceControl mAppAnimationLayer = null; |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 3182 | |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 3183 | // Cached reference to some special stacks we tend to get a lot so we don't need to loop |
| 3184 | // through the list to find them. |
| 3185 | private TaskStack mHomeStack = null; |
| 3186 | private TaskStack mPinnedStack = null; |
| 3187 | private TaskStack mSplitScreenPrimaryStack = null; |
| 3188 | |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 3189 | TaskStackContainers(WindowManagerService service) { |
| 3190 | super(service); |
| 3191 | } |
| 3192 | |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 3193 | /** |
| 3194 | * Returns the topmost stack on the display that is compatible with the input windowing mode |
| 3195 | * and activity type. Null is no compatible stack on the display. |
| 3196 | */ |
| 3197 | TaskStack getStack(int windowingMode, int activityType) { |
| 3198 | if (activityType == ACTIVITY_TYPE_HOME) { |
| 3199 | return mHomeStack; |
| 3200 | } |
| 3201 | if (windowingMode == WINDOWING_MODE_PINNED) { |
| 3202 | return mPinnedStack; |
| 3203 | } else if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { |
| 3204 | return mSplitScreenPrimaryStack; |
| 3205 | } |
| 3206 | for (int i = mTaskStackContainers.getChildCount() - 1; i >= 0; --i) { |
| 3207 | final TaskStack stack = mTaskStackContainers.getChildAt(i); |
Wale Ogunwale | 30e441d | 2017-11-09 08:28:45 -0800 | [diff] [blame] | 3208 | if (activityType == ACTIVITY_TYPE_UNDEFINED |
| 3209 | && windowingMode == stack.getWindowingMode()) { |
| 3210 | // Passing in undefined type means we want to match the topmost stack with the |
| 3211 | // windowing mode. |
| 3212 | return stack; |
| 3213 | } |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 3214 | if (stack.isCompatible(windowingMode, activityType)) { |
| 3215 | return stack; |
| 3216 | } |
| 3217 | } |
| 3218 | return null; |
| 3219 | } |
| 3220 | |
| 3221 | @VisibleForTesting |
| 3222 | TaskStack getTopStack() { |
| 3223 | return mTaskStackContainers.getChildCount() > 0 |
| 3224 | ? mTaskStackContainers.getChildAt(mTaskStackContainers.getChildCount() - 1) : null; |
| 3225 | } |
| 3226 | |
| 3227 | TaskStack getHomeStack() { |
| 3228 | if (mHomeStack == null && mDisplayId == DEFAULT_DISPLAY) { |
| 3229 | Slog.e(TAG_WM, "getHomeStack: Returning null from this=" + this); |
| 3230 | } |
| 3231 | return mHomeStack; |
| 3232 | } |
| 3233 | |
| 3234 | TaskStack getPinnedStack() { |
| 3235 | return mPinnedStack; |
| 3236 | } |
| 3237 | |
Matthew Ng | 64e77cf | 2017-10-31 14:01:31 -0700 | [diff] [blame] | 3238 | TaskStack getSplitScreenPrimaryStack() { |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 3239 | return mSplitScreenPrimaryStack; |
| 3240 | } |
| 3241 | |
Andrii Kulian | 839def9 | 2016-11-02 10:58:58 -0700 | [diff] [blame] | 3242 | /** |
| 3243 | * Adds the stack to this container. |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 3244 | * @see DisplayContent#createStack(int, boolean, StackWindowController) |
Andrii Kulian | 839def9 | 2016-11-02 10:58:58 -0700 | [diff] [blame] | 3245 | */ |
| 3246 | void addStackToDisplay(TaskStack stack, boolean onTop) { |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 3247 | addStackReferenceIfNeeded(stack); |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 3248 | addChild(stack, onTop); |
| 3249 | stack.onDisplayChanged(DisplayContent.this); |
Robert Carr | 3b71624 | 2016-08-16 16:02:21 -0700 | [diff] [blame] | 3250 | } |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 3251 | |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 3252 | void onStackWindowingModeChanged(TaskStack stack) { |
| 3253 | removeStackReferenceIfNeeded(stack); |
| 3254 | addStackReferenceIfNeeded(stack); |
| 3255 | if (stack == mPinnedStack && getTopStack() != stack) { |
| 3256 | // Looks like this stack changed windowing mode to pinned. Move it to the top. |
| 3257 | positionChildAt(POSITION_TOP, stack, false /* includingParents */); |
| 3258 | } |
| 3259 | } |
| 3260 | |
| 3261 | private void addStackReferenceIfNeeded(TaskStack stack) { |
| 3262 | if (stack.isActivityTypeHome()) { |
| 3263 | if (mHomeStack != null) { |
| 3264 | throw new IllegalArgumentException("addStackReferenceIfNeeded: home stack=" |
| 3265 | + mHomeStack + " already exist on display=" + this + " stack=" + stack); |
| 3266 | } |
| 3267 | mHomeStack = stack; |
| 3268 | } |
| 3269 | final int windowingMode = stack.getWindowingMode(); |
| 3270 | if (windowingMode == WINDOWING_MODE_PINNED) { |
| 3271 | if (mPinnedStack != null) { |
| 3272 | throw new IllegalArgumentException("addStackReferenceIfNeeded: pinned stack=" |
| 3273 | + mPinnedStack + " already exist on display=" + this |
| 3274 | + " stack=" + stack); |
| 3275 | } |
| 3276 | mPinnedStack = stack; |
| 3277 | } else if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { |
| 3278 | if (mSplitScreenPrimaryStack != null) { |
| 3279 | throw new IllegalArgumentException("addStackReferenceIfNeeded:" |
| 3280 | + " split-screen-primary" + " stack=" + mSplitScreenPrimaryStack |
| 3281 | + " already exist on display=" + this + " stack=" + stack); |
| 3282 | } |
| 3283 | mSplitScreenPrimaryStack = stack; |
Wale Ogunwale | 30e441d | 2017-11-09 08:28:45 -0800 | [diff] [blame] | 3284 | mDividerControllerLocked.notifyDockedStackExistsChanged(true); |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 3285 | } |
| 3286 | } |
| 3287 | |
| 3288 | private void removeStackReferenceIfNeeded(TaskStack stack) { |
| 3289 | if (stack == mHomeStack) { |
| 3290 | mHomeStack = null; |
| 3291 | } else if (stack == mPinnedStack) { |
| 3292 | mPinnedStack = null; |
| 3293 | } else if (stack == mSplitScreenPrimaryStack) { |
| 3294 | mSplitScreenPrimaryStack = null; |
Wale Ogunwale | 30e441d | 2017-11-09 08:28:45 -0800 | [diff] [blame] | 3295 | // Re-set the split-screen create mode whenever the split-screen stack is removed. |
| 3296 | mService.setDockedStackCreateStateLocked( |
| 3297 | SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT, null /* initialBounds */); |
| 3298 | mDividerControllerLocked.notifyDockedStackExistsChanged(false); |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 3299 | } |
Andrii Kulian | 839def9 | 2016-11-02 10:58:58 -0700 | [diff] [blame] | 3300 | } |
| 3301 | |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 3302 | private void addChild(TaskStack stack, boolean toTop) { |
Andrii Kulian | cd5dcb8b | 2017-01-03 17:09:45 -0800 | [diff] [blame] | 3303 | final int addIndex = findPositionForStack(toTop ? mChildren.size() : 0, stack, |
| 3304 | true /* adding */); |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 3305 | addChild(stack, addIndex); |
| 3306 | setLayoutNeeded(); |
| 3307 | } |
| 3308 | |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 3309 | @Override |
| 3310 | protected void removeChild(TaskStack stack) { |
| 3311 | super.removeChild(stack); |
| 3312 | removeStackReferenceIfNeeded(stack); |
| 3313 | } |
Bryce Lee | 00d586d | 2017-07-28 20:48:43 -0700 | [diff] [blame] | 3314 | |
| 3315 | @Override |
| 3316 | boolean isOnTop() { |
| 3317 | // Considered always on top |
| 3318 | return true; |
| 3319 | } |
| 3320 | |
Wale Ogunwale | e6f806e | 2016-10-20 15:29:42 -0700 | [diff] [blame] | 3321 | @Override |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 3322 | void positionChildAt(int position, TaskStack child, boolean includingParents) { |
Wale Ogunwale | 3382ab1 | 2017-07-27 08:55:03 -0700 | [diff] [blame] | 3323 | if (child.getWindowConfiguration().isAlwaysOnTop() |
| 3324 | && position != POSITION_TOP) { |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 3325 | // This stack is always-on-top, override the default behavior. |
| 3326 | Slog.w(TAG_WM, "Ignoring move of always-on-top stack=" + this + " to bottom"); |
| 3327 | |
| 3328 | // Moving to its current position, as we must call super but we don't want to |
| 3329 | // perform any meaningful action. |
| 3330 | final int currentPosition = mChildren.indexOf(child); |
| 3331 | super.positionChildAt(currentPosition, child, false /* includingParents */); |
| 3332 | return; |
| 3333 | } |
| 3334 | |
Andrii Kulian | cd5dcb8b | 2017-01-03 17:09:45 -0800 | [diff] [blame] | 3335 | final int targetPosition = findPositionForStack(position, child, false /* adding */); |
| 3336 | super.positionChildAt(targetPosition, child, includingParents); |
| 3337 | |
| 3338 | setLayoutNeeded(); |
| 3339 | } |
| 3340 | |
| 3341 | /** |
| 3342 | * When stack is added or repositioned, find a proper position for it. |
| 3343 | * This will make sure that pinned stack always stays on top. |
| 3344 | * @param requestedPosition Position requested by caller. |
| 3345 | * @param stack Stack to be added or positioned. |
| 3346 | * @param adding Flag indicates whether we're adding a new stack or positioning an existing. |
| 3347 | * @return The proper position for the stack. |
| 3348 | */ |
| 3349 | private int findPositionForStack(int requestedPosition, TaskStack stack, boolean adding) { |
| 3350 | final int topChildPosition = mChildren.size() - 1; |
| 3351 | boolean toTop = requestedPosition == POSITION_TOP; |
| 3352 | toTop |= adding ? requestedPosition >= topChildPosition + 1 |
| 3353 | : requestedPosition >= topChildPosition; |
| 3354 | int targetPosition = requestedPosition; |
| 3355 | |
Wale Ogunwale | 6191149 | 2017-10-11 08:50:50 -0700 | [diff] [blame] | 3356 | if (toTop && stack.getWindowingMode() != WINDOWING_MODE_PINNED && hasPinnedStack()) { |
Bryce Lee | 48f4b57 | 2017-04-10 10:54:15 -0700 | [diff] [blame] | 3357 | // The pinned stack is always the top most stack (always-on-top) when it is present. |
Andrii Kulian | cd5dcb8b | 2017-01-03 17:09:45 -0800 | [diff] [blame] | 3358 | TaskStack topStack = mChildren.get(topChildPosition); |
Wale Ogunwale | b62139d | 2017-09-20 15:37:35 -0700 | [diff] [blame] | 3359 | if (topStack.getWindowingMode() != WINDOWING_MODE_PINNED) { |
Andrii Kulian | cd5dcb8b | 2017-01-03 17:09:45 -0800 | [diff] [blame] | 3360 | throw new IllegalStateException("Pinned stack isn't top stack??? " + mChildren); |
| 3361 | } |
| 3362 | |
| 3363 | // So, stack is moved just below the pinned stack. |
| 3364 | // When we're adding a new stack the target is the current pinned stack position. |
| 3365 | // When we're positioning an existing stack the target is the position below pinned |
Andrii Kulian | 7cd7c2d | 2017-01-18 12:14:37 -0800 | [diff] [blame] | 3366 | // stack, because WindowContainer#positionAt() first removes element and then adds |
| 3367 | // it to specified place. |
Andrii Kulian | cd5dcb8b | 2017-01-03 17:09:45 -0800 | [diff] [blame] | 3368 | targetPosition = adding ? topChildPosition : topChildPosition - 1; |
| 3369 | } |
| 3370 | |
| 3371 | return targetPosition; |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 3372 | } |
| 3373 | |
| 3374 | @Override |
Wale Ogunwale | f4ebe2e | 2016-11-09 13:24:43 -0800 | [diff] [blame] | 3375 | boolean forAllWindows(ToBooleanFunction<WindowState> callback, |
| 3376 | boolean traverseTopToBottom) { |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 3377 | if (traverseTopToBottom) { |
Wale Ogunwale | f4ebe2e | 2016-11-09 13:24:43 -0800 | [diff] [blame] | 3378 | if (super.forAllWindows(callback, traverseTopToBottom)) { |
| 3379 | return true; |
| 3380 | } |
| 3381 | if (forAllExitingAppTokenWindows(callback, traverseTopToBottom)) { |
| 3382 | return true; |
| 3383 | } |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 3384 | } else { |
Wale Ogunwale | f4ebe2e | 2016-11-09 13:24:43 -0800 | [diff] [blame] | 3385 | if (forAllExitingAppTokenWindows(callback, traverseTopToBottom)) { |
| 3386 | return true; |
| 3387 | } |
| 3388 | if (super.forAllWindows(callback, traverseTopToBottom)) { |
| 3389 | return true; |
| 3390 | } |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 3391 | } |
Wale Ogunwale | f4ebe2e | 2016-11-09 13:24:43 -0800 | [diff] [blame] | 3392 | return false; |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 3393 | } |
| 3394 | |
Wale Ogunwale | f4ebe2e | 2016-11-09 13:24:43 -0800 | [diff] [blame] | 3395 | private boolean forAllExitingAppTokenWindows(ToBooleanFunction<WindowState> callback, |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 3396 | boolean traverseTopToBottom) { |
| 3397 | // For legacy reasons we process the TaskStack.mExitingAppTokens first here before the |
| 3398 | // app tokens. |
| 3399 | // TODO: Investigate if we need to continue to do this or if we can just process them |
| 3400 | // in-order. |
| 3401 | if (traverseTopToBottom) { |
| 3402 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 3403 | final AppTokenList appTokens = mChildren.get(i).mExitingAppTokens; |
| 3404 | for (int j = appTokens.size() - 1; j >= 0; --j) { |
Wale Ogunwale | f4ebe2e | 2016-11-09 13:24:43 -0800 | [diff] [blame] | 3405 | if (appTokens.get(j).forAllWindowsUnchecked(callback, |
| 3406 | traverseTopToBottom)) { |
| 3407 | return true; |
| 3408 | } |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 3409 | } |
| 3410 | } |
| 3411 | } else { |
| 3412 | final int count = mChildren.size(); |
| 3413 | for (int i = 0; i < count; ++i) { |
| 3414 | final AppTokenList appTokens = mChildren.get(i).mExitingAppTokens; |
| 3415 | final int appTokensCount = appTokens.size(); |
| 3416 | for (int j = 0; j < appTokensCount; j++) { |
Wale Ogunwale | f4ebe2e | 2016-11-09 13:24:43 -0800 | [diff] [blame] | 3417 | if (appTokens.get(j).forAllWindowsUnchecked(callback, |
| 3418 | traverseTopToBottom)) { |
| 3419 | return true; |
| 3420 | } |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 3421 | } |
| 3422 | } |
| 3423 | } |
Wale Ogunwale | f4ebe2e | 2016-11-09 13:24:43 -0800 | [diff] [blame] | 3424 | return false; |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 3425 | } |
| 3426 | |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 3427 | void setExitingTokensHasVisible(boolean hasVisible) { |
| 3428 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 3429 | final AppTokenList appTokens = mChildren.get(i).mExitingAppTokens; |
| 3430 | for (int j = appTokens.size() - 1; j >= 0; --j) { |
| 3431 | appTokens.get(j).hasVisible = hasVisible; |
| 3432 | } |
| 3433 | } |
| 3434 | } |
| 3435 | |
| 3436 | void removeExistingAppTokensIfPossible() { |
| 3437 | for (int i = mChildren.size() - 1; i >= 0; --i) { |
| 3438 | final AppTokenList appTokens = mChildren.get(i).mExitingAppTokens; |
| 3439 | for (int j = appTokens.size() - 1; j >= 0; --j) { |
| 3440 | final AppWindowToken token = appTokens.get(j); |
| 3441 | if (!token.hasVisible && !mService.mClosingApps.contains(token) |
| 3442 | && (!token.mIsExiting || token.isEmpty())) { |
| 3443 | // Make sure there is no animation running on this token, so any windows |
| 3444 | // associated with it will be removed as soon as their animations are |
| 3445 | // complete. |
Jorim Jaggi | f5f9e12 | 2017-10-24 18:21:09 +0200 | [diff] [blame] | 3446 | cancelAnimation(); |
Wale Ogunwale | 1666e31 | 2016-12-16 11:27:18 -0800 | [diff] [blame] | 3447 | if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, |
| 3448 | "performLayout: App token exiting now removed" + token); |
| 3449 | token.removeIfPossible(); |
| 3450 | } |
| 3451 | } |
| 3452 | } |
| 3453 | } |
| 3454 | |
Wale Ogunwale | b783fd8 | 2016-11-04 09:51:54 -0700 | [diff] [blame] | 3455 | @Override |
Wale Ogunwale | e6f806e | 2016-10-20 15:29:42 -0700 | [diff] [blame] | 3456 | int getOrientation() { |
Wale Ogunwale | 44f036f | 2017-09-29 05:09:09 -0700 | [diff] [blame] | 3457 | if (isStackVisible(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) |
| 3458 | || isStackVisible(WINDOWING_MODE_FREEFORM)) { |
Wale Ogunwale | e6f806e | 2016-10-20 15:29:42 -0700 | [diff] [blame] | 3459 | // Apps and their containers are not allowed to specify an orientation while the |
| 3460 | // docked or freeform stack is visible...except for the home stack/task if the |
| 3461 | // docked stack is minimized and it actually set something. |
| 3462 | if (mHomeStack != null && mHomeStack.isVisible() |
| 3463 | && mDividerControllerLocked.isMinimizedDock()) { |
| 3464 | final int orientation = mHomeStack.getOrientation(); |
| 3465 | if (orientation != SCREEN_ORIENTATION_UNSET) { |
| 3466 | return orientation; |
| 3467 | } |
| 3468 | } |
| 3469 | return SCREEN_ORIENTATION_UNSPECIFIED; |
| 3470 | } |
| 3471 | |
| 3472 | final int orientation = super.getOrientation(); |
Dean Harding | 3e5a152 | 2017-10-06 09:19:01 -0700 | [diff] [blame] | 3473 | boolean isCar = mService.mContext.getPackageManager().hasSystemFeature( |
| 3474 | PackageManager.FEATURE_AUTOMOTIVE); |
| 3475 | if (isCar) { |
| 3476 | // In a car, you cannot physically rotate the screen, so it doesn't make sense to |
| 3477 | // allow anything but the default orientation. |
| 3478 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, |
| 3479 | "Forcing UNSPECIFIED orientation in car. Ignoring " + orientation); |
| 3480 | return SCREEN_ORIENTATION_UNSPECIFIED; |
| 3481 | } |
| 3482 | |
Wale Ogunwale | e6f806e | 2016-10-20 15:29:42 -0700 | [diff] [blame] | 3483 | if (orientation != SCREEN_ORIENTATION_UNSET |
| 3484 | && orientation != SCREEN_ORIENTATION_BEHIND) { |
| 3485 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, |
| 3486 | "App is requesting an orientation, return " + orientation); |
| 3487 | return orientation; |
| 3488 | } |
| 3489 | |
| 3490 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 3491 | "No app is requesting an orientation, return " + mLastOrientation); |
Wale Ogunwale | e6f806e | 2016-10-20 15:29:42 -0700 | [diff] [blame] | 3492 | // The next app has not been requested to be visible, so we keep the current orientation |
| 3493 | // to prevent freezing/unfreezing the display too early. |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 3494 | return mLastOrientation; |
Wale Ogunwale | e6f806e | 2016-10-20 15:29:42 -0700 | [diff] [blame] | 3495 | } |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3496 | |
| 3497 | @Override |
| 3498 | void assignChildLayers(SurfaceControl.Transaction t) { |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 3499 | int layer = 0; |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3500 | |
| 3501 | // We allow stacks to change visual order from the AM specified order due to |
| 3502 | // Z-boosting during animations. However we must take care to ensure TaskStacks |
| 3503 | // which are marked as alwaysOnTop remain that way. |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 3504 | for (int i = 0; i < mChildren.size(); i++) { |
| 3505 | final TaskStack s = mChildren.get(i); |
| 3506 | s.assignChildLayers(); |
| 3507 | if (!s.needsZBoost() && !s.isAlwaysOnTop()) { |
| 3508 | s.assignLayer(t, layer++); |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3509 | } |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 3510 | } |
| 3511 | for (int i = 0; i < mChildren.size(); i++) { |
| 3512 | final TaskStack s = mChildren.get(i); |
| 3513 | if (s.needsZBoost() && !s.isAlwaysOnTop()) { |
| 3514 | s.assignLayer(t, layer++); |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3515 | } |
| 3516 | } |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 3517 | for (int i = 0; i < mChildren.size(); i++) { |
| 3518 | final TaskStack s = mChildren.get(i); |
| 3519 | if (s.isAlwaysOnTop()) { |
| 3520 | s.assignLayer(t, layer++); |
| 3521 | } |
| 3522 | } |
| 3523 | |
| 3524 | // The appropriate place for App-Transitions to occur is right |
| 3525 | // above all other animations but still below things in the Picture-and-Picture |
| 3526 | // windowing mode. |
chaviw | 23ee71c | 2017-12-18 11:29:41 -0800 | [diff] [blame] | 3527 | if (mAppAnimationLayer != null) { |
| 3528 | t.setLayer(mAppAnimationLayer, layer++); |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 3529 | } |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3530 | } |
| 3531 | |
| 3532 | @Override |
chaviw | 23ee71c | 2017-12-18 11:29:41 -0800 | [diff] [blame] | 3533 | SurfaceControl getAppAnimationLayer() { |
| 3534 | return mAppAnimationLayer; |
| 3535 | } |
| 3536 | |
| 3537 | @Override |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3538 | void onParentSet() { |
| 3539 | super.onParentSet(); |
| 3540 | if (getParent() != null) { |
chaviw | 23ee71c | 2017-12-18 11:29:41 -0800 | [diff] [blame] | 3541 | mAppAnimationLayer = makeChildSurface(null) |
| 3542 | .setName("animationLayer") |
| 3543 | .build(); |
| 3544 | getPendingTransaction().show(mAppAnimationLayer); |
| 3545 | scheduleAnimation(); |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3546 | } else { |
chaviw | 23ee71c | 2017-12-18 11:29:41 -0800 | [diff] [blame] | 3547 | mAppAnimationLayer.destroy(); |
| 3548 | mAppAnimationLayer = null; |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3549 | } |
| 3550 | } |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 3551 | } |
| 3552 | |
Robert Carr | ee4d4b9 | 2017-11-22 12:21:46 -0800 | [diff] [blame] | 3553 | private final class AboveAppWindowContainers extends NonAppWindowContainers { |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 3554 | AboveAppWindowContainers(String name, WindowManagerService service) { |
| 3555 | super(name, service); |
Robert Carr | ee4d4b9 | 2017-11-22 12:21:46 -0800 | [diff] [blame] | 3556 | } |
| 3557 | |
| 3558 | void assignChildLayers(SurfaceControl.Transaction t, WindowContainer imeContainer) { |
| 3559 | boolean needAssignIme = imeContainer != null |
| 3560 | && imeContainer.getSurfaceControl() != null; |
| 3561 | for (int j = 0; j < mChildren.size(); ++j) { |
| 3562 | final WindowToken wt = mChildren.get(j); |
| 3563 | wt.assignLayer(t, j); |
| 3564 | wt.assignChildLayers(t); |
| 3565 | |
| 3566 | int layer = mService.mPolicy.getWindowLayerFromTypeLw( |
| 3567 | wt.windowType, wt.mOwnerCanManageAppTokens); |
Robert Carr | b8e78fa | 2017-11-28 13:07:58 -0800 | [diff] [blame] | 3568 | |
| 3569 | if (needAssignIme && layer >= mService.mPolicy.getWindowLayerFromTypeLw( |
| 3570 | TYPE_INPUT_METHOD_DIALOG, true)) { |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 3571 | imeContainer.assignRelativeLayer(t, wt.getSurfaceControl(), -1); |
Robert Carr | ee4d4b9 | 2017-11-22 12:21:46 -0800 | [diff] [blame] | 3572 | needAssignIme = false; |
| 3573 | } |
| 3574 | } |
| 3575 | if (needAssignIme) { |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 3576 | imeContainer.assignRelativeLayer(t, getSurfaceControl(), Integer.MAX_VALUE); |
Robert Carr | ee4d4b9 | 2017-11-22 12:21:46 -0800 | [diff] [blame] | 3577 | } |
| 3578 | } |
| 3579 | } |
| 3580 | |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 3581 | /** |
| 3582 | * Window container class that contains all containers on this display that are not related to |
| 3583 | * Apps. E.g. status bar. |
| 3584 | */ |
Robert Carr | ee4d4b9 | 2017-11-22 12:21:46 -0800 | [diff] [blame] | 3585 | private class NonAppWindowContainers extends DisplayChildWindowContainer<WindowToken> { |
Wale Ogunwale | 3a93169 | 2016-11-02 16:49:48 -0700 | [diff] [blame] | 3586 | /** |
| 3587 | * Compares two child window tokens returns -1 if the first is lesser than the second in |
| 3588 | * terms of z-order and 1 otherwise. |
| 3589 | */ |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 3590 | private final Comparator<WindowToken> mWindowComparator = (token1, token2) -> |
Wale Ogunwale | 3a93169 | 2016-11-02 16:49:48 -0700 | [diff] [blame] | 3591 | // Tokens with higher base layer are z-ordered on-top. |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 3592 | mService.mPolicy.getWindowLayerFromTypeLw(token1.windowType, |
| 3593 | token1.mOwnerCanManageAppTokens) |
| 3594 | < mService.mPolicy.getWindowLayerFromTypeLw(token2.windowType, |
| 3595 | token2.mOwnerCanManageAppTokens) ? -1 : 1; |
Wale Ogunwale | 19e452e | 2016-10-12 12:36:29 -0700 | [diff] [blame] | 3596 | |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 3597 | private final Predicate<WindowState> mGetOrientingWindow = w -> { |
| 3598 | if (!w.isVisibleLw() || !w.mPolicyVisibilityAfterAnim) { |
| 3599 | return false; |
| 3600 | } |
| 3601 | final int req = w.mAttrs.screenOrientation; |
| 3602 | if(req == SCREEN_ORIENTATION_UNSPECIFIED || req == SCREEN_ORIENTATION_BEHIND |
| 3603 | || req == SCREEN_ORIENTATION_UNSET) { |
| 3604 | return false; |
| 3605 | } |
| 3606 | return true; |
| 3607 | }; |
| 3608 | |
Wale Ogunwale | 3a93169 | 2016-11-02 16:49:48 -0700 | [diff] [blame] | 3609 | private final String mName; |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 3610 | NonAppWindowContainers(String name, WindowManagerService service) { |
| 3611 | super(service); |
Wale Ogunwale | 3a93169 | 2016-11-02 16:49:48 -0700 | [diff] [blame] | 3612 | mName = name; |
| 3613 | } |
| 3614 | |
| 3615 | void addChild(WindowToken token) { |
| 3616 | addChild(token, mWindowComparator); |
| 3617 | } |
| 3618 | |
| 3619 | @Override |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 3620 | int getOrientation() { |
| 3621 | final WindowManagerPolicy policy = mService.mPolicy; |
| 3622 | // Find a window requesting orientation. |
Wale Ogunwale | 1e129a4 | 2016-11-21 13:03:47 -0800 | [diff] [blame] | 3623 | final WindowState win = getWindow(mGetOrientingWindow); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 3624 | |
| 3625 | if (win != null) { |
| 3626 | final int req = win.mAttrs.screenOrientation; |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 3627 | if (policy.isKeyguardHostWindow(win.mAttrs)) { |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 3628 | mLastKeyguardForcedOrientation = req; |
Wale Ogunwale | bfa81ad | 2017-05-24 15:14:42 -0700 | [diff] [blame] | 3629 | if (mService.mKeyguardGoingAway) { |
| 3630 | // Keyguard can't affect the orientation if it is going away... |
| 3631 | mLastWindowForcedOrientation = SCREEN_ORIENTATION_UNSPECIFIED; |
| 3632 | return SCREEN_ORIENTATION_UNSET; |
| 3633 | } |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 3634 | } |
Wale Ogunwale | bfa81ad | 2017-05-24 15:14:42 -0700 | [diff] [blame] | 3635 | if (DEBUG_ORIENTATION) Slog.v(TAG_WM, win + " forcing orientation to " + req); |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 3636 | return (mLastWindowForcedOrientation = req); |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 3637 | } |
| 3638 | |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 3639 | mLastWindowForcedOrientation = SCREEN_ORIENTATION_UNSPECIFIED; |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 3640 | |
Jorim Jaggi | 75520d5 | 2017-08-24 17:23:19 +0200 | [diff] [blame] | 3641 | if (policy.isKeyguardShowingAndNotOccluded() |
| 3642 | || mService.mAppTransition.getAppTransition() == TRANSIT_KEYGUARD_UNOCCLUDE) { |
Andrii Kulian | 8ee7285 | 2017-03-10 10:36:45 -0800 | [diff] [blame] | 3643 | return mLastKeyguardForcedOrientation; |
Wale Ogunwale | 6213caa | 2016-12-02 16:47:15 +0000 | [diff] [blame] | 3644 | } |
| 3645 | |
| 3646 | return SCREEN_ORIENTATION_UNSET; |
| 3647 | } |
| 3648 | |
| 3649 | @Override |
Wale Ogunwale | 3a93169 | 2016-11-02 16:49:48 -0700 | [diff] [blame] | 3650 | String getName() { |
| 3651 | return mName; |
| 3652 | } |
Robert Carr | 3b71624 | 2016-08-16 16:02:21 -0700 | [diff] [blame] | 3653 | } |
Jorim Jaggi | 6a7a859 | 2017-01-12 00:44:33 +0100 | [diff] [blame] | 3654 | |
Robert Carr | 9034d96 | 2018-01-04 18:27:42 -0800 | [diff] [blame] | 3655 | private class NonMagnifiableWindowContainers extends NonAppWindowContainers { |
| 3656 | NonMagnifiableWindowContainers(String name, WindowManagerService service) { |
| 3657 | super(name, service); |
| 3658 | } |
| 3659 | |
| 3660 | @Override |
| 3661 | void applyMagnificationSpec(Transaction t, MagnificationSpec spec) { |
| 3662 | } |
| 3663 | }; |
| 3664 | |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3665 | SurfaceControl.Builder makeSurface(SurfaceSession s) { |
| 3666 | return mService.makeSurfaceBuilder(s) |
| 3667 | .setParent(mWindowingLayer); |
| 3668 | } |
| 3669 | |
| 3670 | @Override |
| 3671 | SurfaceSession getSession() { |
| 3672 | return mSession; |
| 3673 | } |
| 3674 | |
| 3675 | @Override |
| 3676 | SurfaceControl.Builder makeChildSurface(WindowContainer child) { |
Robert Carr | f59b8dd | 2017-10-02 18:58:36 -0700 | [diff] [blame] | 3677 | SurfaceSession s = child != null ? child.getSession() : getSession(); |
| 3678 | final SurfaceControl.Builder b = mService.makeSurfaceBuilder(s); |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3679 | b.setSize(mSurfaceSize, mSurfaceSize); |
Robert Carr | f59b8dd | 2017-10-02 18:58:36 -0700 | [diff] [blame] | 3680 | |
| 3681 | if (child == null) { |
| 3682 | return b; |
| 3683 | } |
| 3684 | |
Robert Carr | ee4d4b9 | 2017-11-22 12:21:46 -0800 | [diff] [blame] | 3685 | return b.setName(child.getName()) |
| 3686 | .setParent(mWindowingLayer); |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3687 | } |
| 3688 | |
| 3689 | /** |
| 3690 | * The makeSurface variants are for use by the window-container |
| 3691 | * hierarchy. makeOverlay here is a function for various non windowing |
| 3692 | * overlays like the ScreenRotation screenshot, the Strict Mode Flash |
| 3693 | * and other potpourii. |
| 3694 | */ |
| 3695 | SurfaceControl.Builder makeOverlay() { |
| 3696 | return mService.makeSurfaceBuilder(mSession) |
| 3697 | .setParent(mOverlayLayer); |
| 3698 | } |
| 3699 | |
| 3700 | void applyMagnificationSpec(MagnificationSpec spec) { |
Robert Carr | f59b8dd | 2017-10-02 18:58:36 -0700 | [diff] [blame] | 3701 | applyMagnificationSpec(getPendingTransaction(), spec); |
| 3702 | getPendingTransaction().apply(); |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3703 | } |
| 3704 | |
| 3705 | @Override |
| 3706 | void onParentSet() { |
| 3707 | // Since we are the top of the SurfaceControl hierarchy here |
| 3708 | // we create the root surfaces explicitly rather than chaining |
| 3709 | // up as the default implementation in onParentSet does. So we |
| 3710 | // explicitly do NOT call super here. |
| 3711 | } |
| 3712 | |
| 3713 | @Override |
| 3714 | void assignChildLayers(SurfaceControl.Transaction t) { |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3715 | |
| 3716 | // These are layers as children of "mWindowingLayer" |
| 3717 | mBelowAppWindowsContainers.assignLayer(t, 0); |
| 3718 | mTaskStackContainers.assignLayer(t, 1); |
| 3719 | mAboveAppWindowsContainers.assignLayer(t, 2); |
| 3720 | |
| 3721 | WindowState imeTarget = mService.mInputMethodTarget; |
Robert Carr | ee4d4b9 | 2017-11-22 12:21:46 -0800 | [diff] [blame] | 3722 | boolean needAssignIme = true; |
Robert Carr | 1cafdf8 | 2017-11-22 13:56:43 -0800 | [diff] [blame] | 3723 | |
Robert Carr | ee4d4b9 | 2017-11-22 12:21:46 -0800 | [diff] [blame] | 3724 | // In the case where we have an IME target that is not in split-screen |
| 3725 | // mode IME assignment is easy. We just need the IME to go directly above |
| 3726 | // the target. This way children of the target will naturally go above the IME |
| 3727 | // and everyone is happy. |
Robert Carr | 1cafdf8 | 2017-11-22 13:56:43 -0800 | [diff] [blame] | 3728 | // |
Robert Carr | ee4d4b9 | 2017-11-22 12:21:46 -0800 | [diff] [blame] | 3729 | // In the case of split-screen windowing mode, we need to elevate the IME above the |
| 3730 | // docked divider while keeping the app itself below the docked divider, so instead |
| 3731 | // we use relative layering of the IME targets child windows, and place the |
| 3732 | // IME in the non-app layer (see {@link AboveAppWindowContainers#assignChildLayers}). |
Robert Carr | 1cafdf8 | 2017-11-22 13:56:43 -0800 | [diff] [blame] | 3733 | // |
Robert Carr | ee4d4b9 | 2017-11-22 12:21:46 -0800 | [diff] [blame] | 3734 | // In the case where we have no IME target we assign it where it's base layer would |
| 3735 | // place it in the AboveAppWindowContainers. |
| 3736 | if (imeTarget != null && !imeTarget.inSplitScreenWindowingMode() |
| 3737 | && (imeTarget.getSurfaceControl() != null)) { |
Jorim Jaggi | ffe128d | 2017-11-30 13:54:36 +0100 | [diff] [blame] | 3738 | mImeWindowsContainers.assignRelativeLayer(t, imeTarget.getSurfaceControl(), |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3739 | // TODO: We need to use an extra level on the app surface to ensure |
| 3740 | // this is always above SurfaceView but always below attached window. |
| 3741 | 1); |
Robert Carr | ee4d4b9 | 2017-11-22 12:21:46 -0800 | [diff] [blame] | 3742 | needAssignIme = false; |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3743 | } |
| 3744 | |
| 3745 | // Above we have assigned layers to our children, now we ask them to assign |
| 3746 | // layers to their children. |
| 3747 | mBelowAppWindowsContainers.assignChildLayers(t); |
| 3748 | mTaskStackContainers.assignChildLayers(t); |
Robert Carr | ee4d4b9 | 2017-11-22 12:21:46 -0800 | [diff] [blame] | 3749 | mAboveAppWindowsContainers.assignChildLayers(t, |
| 3750 | needAssignIme == true ? mImeWindowsContainers : null); |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3751 | mImeWindowsContainers.assignChildLayers(t); |
| 3752 | } |
| 3753 | |
| 3754 | /** |
| 3755 | * Here we satisfy an unfortunate special case of the IME in split-screen mode. Imagine |
| 3756 | * that the IME target is one of the docked applications. We'd like the docked divider to be |
| 3757 | * above both of the applications, and we'd like the IME to be above the docked divider. |
| 3758 | * However we need child windows of the applications to be above the IME (Text drag handles). |
| 3759 | * This is a non-strictly hierarcical layering and we need to break out of the Z ordering |
| 3760 | * somehow. We do this by relatively ordering children of the target to the IME in cooperation |
| 3761 | * with {@link #WindowState#assignLayer} |
| 3762 | */ |
| 3763 | void assignRelativeLayerForImeTargetChild(SurfaceControl.Transaction t, WindowContainer child) { |
| 3764 | t.setRelativeLayer(child.getSurfaceControl(), mImeWindowsContainers.getSurfaceControl(), 1); |
| 3765 | } |
| 3766 | |
| 3767 | @Override |
Jorim Jaggi | a5e1057 | 2017-11-15 14:36:26 +0100 | [diff] [blame] | 3768 | public void destroyAfterPendingTransaction(SurfaceControl surface) { |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3769 | mPendingDestroyingSurfaces.add(surface); |
| 3770 | } |
| 3771 | |
| 3772 | /** |
| 3773 | * Destroys any surfaces that have been put into the pending list with |
Jorim Jaggi | a5e1057 | 2017-11-15 14:36:26 +0100 | [diff] [blame] | 3774 | * {@link #destroyAfterPendingTransaction}. |
Robert Carr | b1579c8 | 2017-09-05 14:54:47 -0700 | [diff] [blame] | 3775 | */ |
| 3776 | void onPendingTransactionApplied() { |
| 3777 | for (int i = mPendingDestroyingSurfaces.size() - 1; i >= 0; i--) { |
| 3778 | mPendingDestroyingSurfaces.get(i).destroy(); |
| 3779 | } |
| 3780 | mPendingDestroyingSurfaces.clear(); |
| 3781 | } |
Jorim Jaggi | 9af095b | 2017-12-12 17:18:57 +0100 | [diff] [blame] | 3782 | |
| 3783 | @Override |
| 3784 | void prepareSurfaces() { |
| 3785 | final ScreenRotationAnimation screenRotationAnimation = |
| 3786 | mService.mAnimator.getScreenRotationAnimationLocked(mDisplayId); |
| 3787 | if (screenRotationAnimation != null && screenRotationAnimation.isAnimating()) { |
| 3788 | screenRotationAnimation.getEnterTransformation().getMatrix().getValues(mTmpFloats); |
| 3789 | mPendingTransaction.setMatrix(mWindowingLayer, |
| 3790 | mTmpFloats[Matrix.MSCALE_X], mTmpFloats[Matrix.MSKEW_Y], |
| 3791 | mTmpFloats[Matrix.MSKEW_X], mTmpFloats[Matrix.MSCALE_Y]); |
| 3792 | mPendingTransaction.setPosition(mWindowingLayer, |
| 3793 | mTmpFloats[Matrix.MTRANS_X], mTmpFloats[Matrix.MTRANS_Y]); |
| 3794 | mPendingTransaction.setAlpha(mWindowingLayer, |
| 3795 | screenRotationAnimation.getEnterTransformation().getAlpha()); |
| 3796 | } |
| 3797 | super.prepareSurfaces(); |
| 3798 | } |
Craig Mautner | 59c0097 | 2012-07-30 12:10:24 -0700 | [diff] [blame] | 3799 | } |