Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -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 android.view; |
| 18 | |
| 19 | import android.animation.ValueAnimator; |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 20 | import android.annotation.UnsupportedAppUsage; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 21 | import android.app.ActivityManager; |
| 22 | import android.content.ComponentCallbacks2; |
Alan Viverette | 5e1565e | 2014-07-29 16:14:25 -0700 | [diff] [blame] | 23 | import android.content.Context; |
Alan Viverette | d70b9e7 | 2015-05-27 14:29:20 -0700 | [diff] [blame] | 24 | import android.content.pm.ApplicationInfo; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 25 | import android.content.res.Configuration; |
Mathew Inwood | 45d2c25 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 26 | import android.os.Build; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 27 | import android.os.IBinder; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 28 | import android.os.RemoteException; |
| 29 | import android.os.ServiceManager; |
| 30 | import android.os.SystemProperties; |
| 31 | import android.util.AndroidRuntimeException; |
Craig Mautner | 8f303ad | 2013-06-14 11:32:22 -0700 | [diff] [blame] | 32 | import android.util.ArraySet; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 33 | import android.util.Log; |
| 34 | import android.view.inputmethod.InputMethodManager; |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 35 | |
Dianne Hackborn | 8c84109 | 2013-06-24 13:46:13 -0700 | [diff] [blame] | 36 | import com.android.internal.util.FastPrintWriter; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 37 | |
| 38 | import java.io.FileDescriptor; |
| 39 | import java.io.FileOutputStream; |
| 40 | import java.io.PrintWriter; |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 41 | import java.util.ArrayList; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 42 | |
| 43 | /** |
| 44 | * Provides low-level communication with the system window manager for |
| 45 | * operations that are not associated with any particular context. |
| 46 | * |
| 47 | * This class is only used internally to implement global functions where |
| 48 | * the caller already knows the display and relevant compatibility information |
| 49 | * for the operation. For most purposes, you should use {@link WindowManager} instead |
| 50 | * since it is bound to a context. |
| 51 | * |
| 52 | * @see WindowManagerImpl |
| 53 | * @hide |
| 54 | */ |
| 55 | public final class WindowManagerGlobal { |
| 56 | private static final String TAG = "WindowManager"; |
| 57 | |
| 58 | /** |
| 59 | * The user is navigating with keys (not the touch screen), so |
| 60 | * navigational focus should be shown. |
| 61 | */ |
| 62 | public static final int RELAYOUT_RES_IN_TOUCH_MODE = 0x1; |
| 63 | |
| 64 | /** |
| 65 | * This is the first time the window is being drawn, |
| 66 | * so the client must call drawingFinished() when done |
| 67 | */ |
| 68 | public static final int RELAYOUT_RES_FIRST_TIME = 0x2; |
| 69 | |
| 70 | /** |
| 71 | * The window manager has changed the surface from the last call. |
| 72 | */ |
| 73 | public static final int RELAYOUT_RES_SURFACE_CHANGED = 0x4; |
| 74 | |
| 75 | /** |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 76 | * The window is being resized by dragging on the docked divider. The client should render |
| 77 | * at (0, 0) and extend its background to the background frame passed into |
| 78 | * {@link IWindow#resized}. |
| 79 | */ |
| 80 | public static final int RELAYOUT_RES_DRAG_RESIZING_DOCKED = 0x8; |
| 81 | |
| 82 | /** |
Chong Zhang | 0275e39 | 2015-09-17 10:41:44 -0700 | [diff] [blame] | 83 | * The window is being resized by dragging one of the window corners, |
Filip Gruszczynski | 63a35e2 | 2015-11-05 15:38:59 -0800 | [diff] [blame] | 84 | * in this case the surface would be fullscreen-sized. The client should |
Chong Zhang | 0275e39 | 2015-09-17 10:41:44 -0700 | [diff] [blame] | 85 | * render to the actual frame location (instead of (0,curScrollY)). |
| 86 | */ |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 87 | public static final int RELAYOUT_RES_DRAG_RESIZING_FREEFORM = 0x10; |
Chong Zhang | 0275e39 | 2015-09-17 10:41:44 -0700 | [diff] [blame] | 88 | |
| 89 | /** |
Chong Zhang | f4abc2b | 2015-11-12 23:40:58 -0800 | [diff] [blame] | 90 | * The window manager has changed the size of the surface from the last call. |
| 91 | */ |
Jorim Jaggi | 4846ee3 | 2016-01-07 17:39:12 +0100 | [diff] [blame] | 92 | public static final int RELAYOUT_RES_SURFACE_RESIZED = 0x20; |
Chong Zhang | f4abc2b | 2015-11-12 23:40:58 -0800 | [diff] [blame] | 93 | |
| 94 | /** |
Jorim Jaggi | 0ffd49c | 2016-02-12 15:04:21 -0800 | [diff] [blame] | 95 | * In multi-window we force show the navigation bar. Because we don't want that the surface size |
| 96 | * changes in this mode, we instead have a flag whether the navigation bar size should always be |
| 97 | * consumed, so the app is treated like there is no virtual navigation bar at all. |
| 98 | */ |
| 99 | public static final int RELAYOUT_RES_CONSUME_ALWAYS_NAV_BAR = 0x40; |
| 100 | |
| 101 | /** |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 102 | * Flag for relayout: the client will be later giving |
| 103 | * internal insets; as a result, the window will not impact other window |
| 104 | * layouts until the insets are given. |
| 105 | */ |
| 106 | public static final int RELAYOUT_INSETS_PENDING = 0x1; |
| 107 | |
| 108 | /** |
| 109 | * Flag for relayout: the client may be currently using the current surface, |
| 110 | * so if it is to be destroyed as a part of the relayout the destroy must |
| 111 | * be deferred until later. The client will call performDeferredDestroy() |
| 112 | * when it is okay. |
| 113 | */ |
| 114 | public static final int RELAYOUT_DEFER_SURFACE_DESTROY = 0x2; |
| 115 | |
| 116 | public static final int ADD_FLAG_APP_VISIBLE = 0x2; |
| 117 | public static final int ADD_FLAG_IN_TOUCH_MODE = RELAYOUT_RES_IN_TOUCH_MODE; |
| 118 | |
Jorim Jaggi | 0ffd49c | 2016-02-12 15:04:21 -0800 | [diff] [blame] | 119 | /** |
| 120 | * Like {@link #RELAYOUT_RES_CONSUME_ALWAYS_NAV_BAR}, but as a "hint" when adding the window. |
| 121 | */ |
| 122 | public static final int ADD_FLAG_ALWAYS_CONSUME_NAV_BAR = 0x4; |
| 123 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 124 | public static final int ADD_OKAY = 0; |
| 125 | public static final int ADD_BAD_APP_TOKEN = -1; |
| 126 | public static final int ADD_BAD_SUBWINDOW_TOKEN = -2; |
| 127 | public static final int ADD_NOT_APP_TOKEN = -3; |
| 128 | public static final int ADD_APP_EXITING = -4; |
| 129 | public static final int ADD_DUPLICATE_ADD = -5; |
| 130 | public static final int ADD_STARTING_NOT_NEEDED = -6; |
| 131 | public static final int ADD_MULTIPLE_SINGLETON = -7; |
| 132 | public static final int ADD_PERMISSION_DENIED = -8; |
Craig Mautner | 2d5618c | 2012-10-18 13:55:47 -0700 | [diff] [blame] | 133 | public static final int ADD_INVALID_DISPLAY = -9; |
Wale Ogunwale | 74bf065 | 2015-01-12 10:24:36 -0800 | [diff] [blame] | 134 | public static final int ADD_INVALID_TYPE = -10; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 135 | |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 136 | @UnsupportedAppUsage |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 137 | private static WindowManagerGlobal sDefaultWindowManager; |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 138 | @UnsupportedAppUsage |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 139 | private static IWindowManager sWindowManagerService; |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 140 | @UnsupportedAppUsage |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 141 | private static IWindowSession sWindowSession; |
| 142 | |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 143 | @UnsupportedAppUsage |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 144 | private final Object mLock = new Object(); |
| 145 | |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 146 | @UnsupportedAppUsage |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 147 | private final ArrayList<View> mViews = new ArrayList<View>(); |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 148 | @UnsupportedAppUsage |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 149 | private final ArrayList<ViewRootImpl> mRoots = new ArrayList<ViewRootImpl>(); |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 150 | @UnsupportedAppUsage |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 151 | private final ArrayList<WindowManager.LayoutParams> mParams = |
| 152 | new ArrayList<WindowManager.LayoutParams>(); |
Craig Mautner | 8f303ad | 2013-06-14 11:32:22 -0700 | [diff] [blame] | 153 | private final ArraySet<View> mDyingViews = new ArraySet<View>(); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 154 | |
| 155 | private Runnable mSystemPropertyUpdater; |
| 156 | |
| 157 | private WindowManagerGlobal() { |
| 158 | } |
| 159 | |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 160 | @UnsupportedAppUsage |
Chet Haase | 0d1c27a | 2014-11-03 18:35:16 +0000 | [diff] [blame] | 161 | public static void initialize() { |
| 162 | getWindowManagerService(); |
| 163 | } |
| 164 | |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 165 | @UnsupportedAppUsage |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 166 | public static WindowManagerGlobal getInstance() { |
| 167 | synchronized (WindowManagerGlobal.class) { |
| 168 | if (sDefaultWindowManager == null) { |
| 169 | sDefaultWindowManager = new WindowManagerGlobal(); |
| 170 | } |
| 171 | return sDefaultWindowManager; |
| 172 | } |
| 173 | } |
| 174 | |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 175 | @UnsupportedAppUsage |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 176 | public static IWindowManager getWindowManagerService() { |
| 177 | synchronized (WindowManagerGlobal.class) { |
| 178 | if (sWindowManagerService == null) { |
| 179 | sWindowManagerService = IWindowManager.Stub.asInterface( |
| 180 | ServiceManager.getService("window")); |
Chet Haase | 0d1c27a | 2014-11-03 18:35:16 +0000 | [diff] [blame] | 181 | try { |
Phil Weaver | 7eec379 | 2017-02-14 16:51:55 -0800 | [diff] [blame] | 182 | if (sWindowManagerService != null) { |
| 183 | ValueAnimator.setDurationScale( |
| 184 | sWindowManagerService.getCurrentAnimatorScale()); |
| 185 | } |
Chet Haase | 0d1c27a | 2014-11-03 18:35:16 +0000 | [diff] [blame] | 186 | } catch (RemoteException e) { |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 187 | throw e.rethrowFromSystemServer(); |
Chet Haase | 0d1c27a | 2014-11-03 18:35:16 +0000 | [diff] [blame] | 188 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 189 | } |
| 190 | return sWindowManagerService; |
| 191 | } |
| 192 | } |
| 193 | |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 194 | @UnsupportedAppUsage |
Jeff Brown | f9e989d | 2013-04-04 23:04:03 -0700 | [diff] [blame] | 195 | public static IWindowSession getWindowSession() { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 196 | synchronized (WindowManagerGlobal.class) { |
| 197 | if (sWindowSession == null) { |
| 198 | try { |
Jeff Brown | f9e989d | 2013-04-04 23:04:03 -0700 | [diff] [blame] | 199 | InputMethodManager imm = InputMethodManager.getInstance(); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 200 | IWindowManager windowManager = getWindowManagerService(); |
| 201 | sWindowSession = windowManager.openSession( |
Dianne Hackborn | eb94fa7 | 2014-06-03 17:48:12 -0700 | [diff] [blame] | 202 | new IWindowSessionCallback.Stub() { |
| 203 | @Override |
| 204 | public void onAnimatorScaleChanged(float scale) { |
| 205 | ValueAnimator.setDurationScale(scale); |
| 206 | } |
| 207 | }, |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 208 | imm.getClient(), imm.getInputContext()); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 209 | } catch (RemoteException e) { |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 210 | throw e.rethrowFromSystemServer(); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 211 | } |
| 212 | } |
| 213 | return sWindowSession; |
| 214 | } |
| 215 | } |
| 216 | |
Mathew Inwood | 45d2c25 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 217 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 218 | public static IWindowSession peekWindowSession() { |
| 219 | synchronized (WindowManagerGlobal.class) { |
| 220 | return sWindowSession; |
| 221 | } |
| 222 | } |
| 223 | |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 224 | @UnsupportedAppUsage |
Siva Velusamy | 945bfb6 | 2013-01-06 16:03:12 -0800 | [diff] [blame] | 225 | public String[] getViewRootNames() { |
| 226 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 227 | final int numRoots = mRoots.size(); |
| 228 | String[] mViewRoots = new String[numRoots]; |
| 229 | for (int i = 0; i < numRoots; ++i) { |
| 230 | mViewRoots[i] = getWindowName(mRoots.get(i)); |
Siva Velusamy | 945bfb6 | 2013-01-06 16:03:12 -0800 | [diff] [blame] | 231 | } |
| 232 | return mViewRoots; |
| 233 | } |
| 234 | } |
| 235 | |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 236 | @UnsupportedAppUsage |
Dianne Hackborn | a7bb6fb | 2015-02-03 18:13:40 -0800 | [diff] [blame] | 237 | public ArrayList<ViewRootImpl> getRootViews(IBinder token) { |
| 238 | ArrayList<ViewRootImpl> views = new ArrayList<>(); |
| 239 | synchronized (mLock) { |
| 240 | final int numRoots = mRoots.size(); |
| 241 | for (int i = 0; i < numRoots; ++i) { |
| 242 | WindowManager.LayoutParams params = mParams.get(i); |
| 243 | if (params.token == null) { |
| 244 | continue; |
| 245 | } |
| 246 | if (params.token != token) { |
| 247 | boolean isChild = false; |
| 248 | if (params.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW |
| 249 | && params.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 250 | for (int j = 0 ; j < numRoots; ++j) { |
| 251 | View viewj = mViews.get(j); |
| 252 | WindowManager.LayoutParams paramsj = mParams.get(j); |
| 253 | if (params.token == viewj.getWindowToken() |
| 254 | && paramsj.token == token) { |
| 255 | isChild = true; |
| 256 | break; |
| 257 | } |
| 258 | } |
| 259 | } |
| 260 | if (!isChild) { |
| 261 | continue; |
| 262 | } |
| 263 | } |
| 264 | views.add(mRoots.get(i)); |
| 265 | } |
| 266 | } |
| 267 | return views; |
| 268 | } |
| 269 | |
Vladislav Kaznacheev | 7039cbc | 2017-01-04 10:15:31 -0800 | [diff] [blame] | 270 | public View getWindowView(IBinder windowToken) { |
| 271 | synchronized (mLock) { |
| 272 | final int numViews = mViews.size(); |
| 273 | for (int i = 0; i < numViews; ++i) { |
| 274 | final View view = mViews.get(i); |
| 275 | if (view.getWindowToken() == windowToken) { |
| 276 | return view; |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | return null; |
| 281 | } |
| 282 | |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 283 | @UnsupportedAppUsage |
Siva Velusamy | 945bfb6 | 2013-01-06 16:03:12 -0800 | [diff] [blame] | 284 | public View getRootView(String name) { |
| 285 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 286 | for (int i = mRoots.size() - 1; i >= 0; --i) { |
| 287 | final ViewRootImpl root = mRoots.get(i); |
Siva Velusamy | 945bfb6 | 2013-01-06 16:03:12 -0800 | [diff] [blame] | 288 | if (name.equals(getWindowName(root))) return root.getView(); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | return null; |
| 293 | } |
| 294 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 295 | public void addView(View view, ViewGroup.LayoutParams params, |
| 296 | Display display, Window parentWindow) { |
| 297 | if (view == null) { |
| 298 | throw new IllegalArgumentException("view must not be null"); |
| 299 | } |
| 300 | if (display == null) { |
| 301 | throw new IllegalArgumentException("display must not be null"); |
| 302 | } |
| 303 | if (!(params instanceof WindowManager.LayoutParams)) { |
| 304 | throw new IllegalArgumentException("Params must be WindowManager.LayoutParams"); |
| 305 | } |
| 306 | |
Alan Viverette | 9ecb73c | 2014-12-15 13:40:28 -0800 | [diff] [blame] | 307 | final WindowManager.LayoutParams wparams = (WindowManager.LayoutParams) params; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 308 | if (parentWindow != null) { |
| 309 | parentWindow.adjustLayoutParamsForSubWindow(wparams); |
Alan Viverette | 9b0ab65 | 2015-03-18 14:21:04 -0700 | [diff] [blame] | 310 | } else { |
| 311 | // If there's no parent, then hardware acceleration for this view is |
| 312 | // set from the application's hardware acceleration setting. |
Alan Viverette | 5e1565e | 2014-07-29 16:14:25 -0700 | [diff] [blame] | 313 | final Context context = view.getContext(); |
Alan Viverette | 9b0ab65 | 2015-03-18 14:21:04 -0700 | [diff] [blame] | 314 | if (context != null |
Alan Viverette | d70b9e7 | 2015-05-27 14:29:20 -0700 | [diff] [blame] | 315 | && (context.getApplicationInfo().flags |
| 316 | & ApplicationInfo.FLAG_HARDWARE_ACCELERATED) != 0) { |
Alan Viverette | 5e1565e | 2014-07-29 16:14:25 -0700 | [diff] [blame] | 317 | wparams.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 318 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | ViewRootImpl root; |
| 322 | View panelParentView = null; |
| 323 | |
| 324 | synchronized (mLock) { |
| 325 | // Start watching for system property changes. |
| 326 | if (mSystemPropertyUpdater == null) { |
| 327 | mSystemPropertyUpdater = new Runnable() { |
| 328 | @Override public void run() { |
| 329 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 330 | for (int i = mRoots.size() - 1; i >= 0; --i) { |
| 331 | mRoots.get(i).loadSystemProperties(); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 332 | } |
| 333 | } |
| 334 | } |
| 335 | }; |
| 336 | SystemProperties.addChangeCallback(mSystemPropertyUpdater); |
| 337 | } |
| 338 | |
| 339 | int index = findViewLocked(view, false); |
| 340 | if (index >= 0) { |
Craig Mautner | 8f303ad | 2013-06-14 11:32:22 -0700 | [diff] [blame] | 341 | if (mDyingViews.contains(view)) { |
| 342 | // Don't wait for MSG_DIE to make it's way through root's queue. |
| 343 | mRoots.get(index).doDie(); |
| 344 | } else { |
| 345 | throw new IllegalStateException("View " + view |
| 346 | + " has already been added to the window manager."); |
| 347 | } |
| 348 | // The previous removeView() had not completed executing. Now it has. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | // If this is a panel window, then find the window it is being |
| 352 | // attached to for future reference. |
| 353 | if (wparams.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW && |
| 354 | wparams.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 355 | final int count = mViews.size(); |
| 356 | for (int i = 0; i < count; i++) { |
| 357 | if (mRoots.get(i).mWindow.asBinder() == wparams.token) { |
| 358 | panelParentView = mViews.get(i); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 359 | } |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | root = new ViewRootImpl(view.getContext(), display); |
| 364 | |
| 365 | view.setLayoutParams(wparams); |
| 366 | |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 367 | mViews.add(view); |
| 368 | mRoots.add(root); |
| 369 | mParams.add(wparams); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 370 | |
Gopal Krishna Shukla | f7abcda | 2016-07-06 08:14:59 +0530 | [diff] [blame] | 371 | // do this last because it fires off messages to start doing things |
| 372 | try { |
| 373 | root.setView(view, wparams, panelParentView); |
| 374 | } catch (RuntimeException e) { |
| 375 | // BadTokenException or InvalidDisplayException, clean up. |
Craig Mautner | 6018aee | 2012-10-23 14:27:49 -0700 | [diff] [blame] | 376 | if (index >= 0) { |
| 377 | removeViewLocked(index, true); |
| 378 | } |
Gopal Krishna Shukla | f7abcda | 2016-07-06 08:14:59 +0530 | [diff] [blame] | 379 | throw e; |
Craig Mautner | 6018aee | 2012-10-23 14:27:49 -0700 | [diff] [blame] | 380 | } |
Craig Mautner | 6018aee | 2012-10-23 14:27:49 -0700 | [diff] [blame] | 381 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | public void updateViewLayout(View view, ViewGroup.LayoutParams params) { |
| 385 | if (view == null) { |
| 386 | throw new IllegalArgumentException("view must not be null"); |
| 387 | } |
| 388 | if (!(params instanceof WindowManager.LayoutParams)) { |
| 389 | throw new IllegalArgumentException("Params must be WindowManager.LayoutParams"); |
| 390 | } |
| 391 | |
| 392 | final WindowManager.LayoutParams wparams = (WindowManager.LayoutParams)params; |
| 393 | |
| 394 | view.setLayoutParams(wparams); |
| 395 | |
| 396 | synchronized (mLock) { |
| 397 | int index = findViewLocked(view, true); |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 398 | ViewRootImpl root = mRoots.get(index); |
| 399 | mParams.remove(index); |
| 400 | mParams.add(index, wparams); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 401 | root.setLayoutParams(wparams, false); |
| 402 | } |
| 403 | } |
| 404 | |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 405 | @UnsupportedAppUsage |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 406 | public void removeView(View view, boolean immediate) { |
| 407 | if (view == null) { |
| 408 | throw new IllegalArgumentException("view must not be null"); |
| 409 | } |
| 410 | |
| 411 | synchronized (mLock) { |
| 412 | int index = findViewLocked(view, true); |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 413 | View curView = mRoots.get(index).getView(); |
Craig Mautner | 05eb730 | 2013-06-03 17:24:21 -0700 | [diff] [blame] | 414 | removeViewLocked(index, immediate); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 415 | if (curView == view) { |
| 416 | return; |
| 417 | } |
| 418 | |
| 419 | throw new IllegalStateException("Calling with view " + view |
| 420 | + " but the ViewAncestor is attached to " + curView); |
| 421 | } |
| 422 | } |
| 423 | |
Andrii Kulian | eac0ea5 | 2016-05-11 15:50:24 -0700 | [diff] [blame] | 424 | /** |
| 425 | * Remove all roots with specified token. |
| 426 | * |
| 427 | * @param token app or window token. |
| 428 | * @param who name of caller, used in logs. |
| 429 | * @param what type of caller, used in logs. |
| 430 | */ |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 431 | public void closeAll(IBinder token, String who, String what) { |
Andrii Kulian | eac0ea5 | 2016-05-11 15:50:24 -0700 | [diff] [blame] | 432 | closeAllExceptView(token, null /* view */, who, what); |
| 433 | } |
| 434 | |
| 435 | /** |
| 436 | * Remove all roots with specified token, except maybe one view. |
| 437 | * |
| 438 | * @param token app or window token. |
| 439 | * @param view view that should be should be preserved along with it's root. |
| 440 | * Pass null if everything should be removed. |
| 441 | * @param who name of caller, used in logs. |
| 442 | * @param what type of caller, used in logs. |
| 443 | */ |
| 444 | public void closeAllExceptView(IBinder token, View view, String who, String what) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 445 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 446 | int count = mViews.size(); |
Craig Mautner | 05eb730 | 2013-06-03 17:24:21 -0700 | [diff] [blame] | 447 | for (int i = 0; i < count; i++) { |
Andrii Kulian | eac0ea5 | 2016-05-11 15:50:24 -0700 | [diff] [blame] | 448 | if ((view == null || mViews.get(i) != view) |
| 449 | && (token == null || mParams.get(i).token == token)) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 450 | ViewRootImpl root = mRoots.get(i); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 451 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 452 | if (who != null) { |
| 453 | WindowLeaked leak = new WindowLeaked( |
| 454 | what + " " + who + " has leaked window " |
| 455 | + root.getView() + " that was originally added here"); |
| 456 | leak.setStackTrace(root.getLocation().getStackTrace()); |
Craig Mautner | 05eb730 | 2013-06-03 17:24:21 -0700 | [diff] [blame] | 457 | Log.e(TAG, "", leak); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | removeViewLocked(i, false); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 461 | } |
| 462 | } |
| 463 | } |
| 464 | } |
| 465 | |
Craig Mautner | 05eb730 | 2013-06-03 17:24:21 -0700 | [diff] [blame] | 466 | private void removeViewLocked(int index, boolean immediate) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 467 | ViewRootImpl root = mRoots.get(index); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 468 | View view = root.getView(); |
| 469 | |
| 470 | if (view != null) { |
Jeff Brown | f9e989d | 2013-04-04 23:04:03 -0700 | [diff] [blame] | 471 | InputMethodManager imm = InputMethodManager.getInstance(); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 472 | if (imm != null) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 473 | imm.windowDismissed(mViews.get(index).getWindowToken()); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 474 | } |
| 475 | } |
Craig Mautner | 8f303ad | 2013-06-14 11:32:22 -0700 | [diff] [blame] | 476 | boolean deferred = root.die(immediate); |
Craig Mautner | 92098c7 | 2013-06-10 11:27:26 -0700 | [diff] [blame] | 477 | if (view != null) { |
| 478 | view.assignParent(null); |
Craig Mautner | 8f303ad | 2013-06-14 11:32:22 -0700 | [diff] [blame] | 479 | if (deferred) { |
| 480 | mDyingViews.add(view); |
| 481 | } |
Craig Mautner | 92098c7 | 2013-06-10 11:27:26 -0700 | [diff] [blame] | 482 | } |
Craig Mautner | 05eb730 | 2013-06-03 17:24:21 -0700 | [diff] [blame] | 483 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 484 | |
Craig Mautner | 05eb730 | 2013-06-03 17:24:21 -0700 | [diff] [blame] | 485 | void doRemoveView(ViewRootImpl root) { |
| 486 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 487 | final int index = mRoots.indexOf(root); |
| 488 | if (index >= 0) { |
| 489 | mRoots.remove(index); |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 490 | mParams.remove(index); |
Craig Mautner | 8f303ad | 2013-06-14 11:32:22 -0700 | [diff] [blame] | 491 | final View view = mViews.remove(index); |
| 492 | mDyingViews.remove(view); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 493 | } |
| 494 | } |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 495 | if (ThreadedRenderer.sTrimForeground && ThreadedRenderer.isAvailable()) { |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 496 | doTrimForeground(); |
| 497 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | private int findViewLocked(View view, boolean required) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 501 | final int index = mViews.indexOf(view); |
| 502 | if (required && index < 0) { |
Craig Mautner | 05eb730 | 2013-06-03 17:24:21 -0700 | [diff] [blame] | 503 | throw new IllegalArgumentException("View=" + view + " not attached to window manager"); |
Craig Mautner | 6018aee | 2012-10-23 14:27:49 -0700 | [diff] [blame] | 504 | } |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 505 | return index; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 506 | } |
| 507 | |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 508 | public static boolean shouldDestroyEglContext(int trimLevel) { |
| 509 | // On low-end gfx devices we trim when memory is moderate; |
| 510 | // on high-end devices we do this when low. |
| 511 | if (trimLevel >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) { |
| 512 | return true; |
| 513 | } |
| 514 | if (trimLevel >= ComponentCallbacks2.TRIM_MEMORY_MODERATE |
| 515 | && !ActivityManager.isHighEndGfx()) { |
| 516 | return true; |
| 517 | } |
| 518 | return false; |
| 519 | } |
| 520 | |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 521 | @UnsupportedAppUsage |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 522 | public void trimMemory(int level) { |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 523 | if (ThreadedRenderer.isAvailable()) { |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 524 | if (shouldDestroyEglContext(level)) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 525 | // Destroy all hardware surfaces and resources associated to |
| 526 | // known windows |
| 527 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 528 | for (int i = mRoots.size() - 1; i >= 0; --i) { |
Romain Guy | 46bfc48 | 2013-08-16 18:38:29 -0700 | [diff] [blame] | 529 | mRoots.get(i).destroyHardwareResources(); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 530 | } |
| 531 | } |
| 532 | // Force a full memory flush |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 533 | level = ComponentCallbacks2.TRIM_MEMORY_COMPLETE; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 534 | } |
| 535 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 536 | ThreadedRenderer.trimMemory(level); |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 537 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 538 | if (ThreadedRenderer.sTrimForeground) { |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 539 | doTrimForeground(); |
| 540 | } |
| 541 | } |
| 542 | } |
| 543 | |
| 544 | public static void trimForeground() { |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 545 | if (ThreadedRenderer.sTrimForeground && ThreadedRenderer.isAvailable()) { |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 546 | WindowManagerGlobal wm = WindowManagerGlobal.getInstance(); |
| 547 | wm.doTrimForeground(); |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | private void doTrimForeground() { |
| 552 | boolean hasVisibleWindows = false; |
| 553 | synchronized (mLock) { |
| 554 | for (int i = mRoots.size() - 1; i >= 0; --i) { |
John Reck | ccf2fa0 | 2014-09-25 08:33:05 -0700 | [diff] [blame] | 555 | final ViewRootImpl root = mRoots.get(i); |
| 556 | if (root.mView != null && root.getHostVisibility() == View.VISIBLE |
Stan Iliev | 45faba5 | 2016-06-28 13:33:15 -0400 | [diff] [blame] | 557 | && root.mAttachInfo.mThreadedRenderer != null) { |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 558 | hasVisibleWindows = true; |
| 559 | } else { |
John Reck | ccf2fa0 | 2014-09-25 08:33:05 -0700 | [diff] [blame] | 560 | root.destroyHardwareResources(); |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 561 | } |
| 562 | } |
| 563 | } |
| 564 | if (!hasVisibleWindows) { |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 565 | ThreadedRenderer.trimMemory( |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 566 | ComponentCallbacks2.TRIM_MEMORY_COMPLETE); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 567 | } |
| 568 | } |
| 569 | |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 570 | public void dumpGfxInfo(FileDescriptor fd, String[] args) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 571 | FileOutputStream fout = new FileOutputStream(fd); |
Dianne Hackborn | 8c84109 | 2013-06-24 13:46:13 -0700 | [diff] [blame] | 572 | PrintWriter pw = new FastPrintWriter(fout); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 573 | try { |
| 574 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 575 | final int count = mViews.size(); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 576 | |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 577 | pw.println("Profile data in ms:"); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 578 | |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 579 | for (int i = 0; i < count; i++) { |
| 580 | ViewRootImpl root = mRoots.get(i); |
| 581 | String name = getWindowName(root); |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 582 | pw.printf("\n\t%s (visibility=%d)", name, root.getHostVisibility()); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 583 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 584 | ThreadedRenderer renderer = |
Stan Iliev | 45faba5 | 2016-06-28 13:33:15 -0400 | [diff] [blame] | 585 | root.getView().mAttachInfo.mThreadedRenderer; |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 586 | if (renderer != null) { |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 587 | renderer.dumpGfxInfo(pw, fd, args); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 588 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 589 | } |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 590 | |
| 591 | pw.println("\nView hierarchy:\n"); |
| 592 | |
| 593 | int viewsCount = 0; |
| 594 | int displayListsSize = 0; |
| 595 | int[] info = new int[2]; |
| 596 | |
| 597 | for (int i = 0; i < count; i++) { |
| 598 | ViewRootImpl root = mRoots.get(i); |
| 599 | root.dumpGfxInfo(info); |
| 600 | |
| 601 | String name = getWindowName(root); |
| 602 | pw.printf(" %s\n %d views, %.2f kB of display lists", |
| 603 | name, info[0], info[1] / 1024.0f); |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 604 | pw.printf("\n\n"); |
| 605 | |
| 606 | viewsCount += info[0]; |
| 607 | displayListsSize += info[1]; |
| 608 | } |
| 609 | |
| 610 | pw.printf("\nTotal ViewRootImpl: %d\n", count); |
| 611 | pw.printf("Total Views: %d\n", viewsCount); |
| 612 | pw.printf("Total DisplayList: %.2f kB\n\n", displayListsSize / 1024.0f); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 613 | } |
| 614 | } finally { |
| 615 | pw.flush(); |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | private static String getWindowName(ViewRootImpl root) { |
| 620 | return root.mWindowAttributes.getTitle() + "/" + |
| 621 | root.getClass().getName() + '@' + Integer.toHexString(root.hashCode()); |
| 622 | } |
| 623 | |
| 624 | public void setStoppedState(IBinder token, boolean stopped) { |
| 625 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 626 | int count = mViews.size(); |
Tetsutoki Shiozawa | 978e7f8 | 2017-11-01 11:38:34 +0900 | [diff] [blame] | 627 | for (int i = count - 1; i >= 0; i--) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 628 | if (token == null || mParams.get(i).token == token) { |
| 629 | ViewRootImpl root = mRoots.get(i); |
Tetsutoki Shiozawa | 978e7f8 | 2017-11-01 11:38:34 +0900 | [diff] [blame] | 630 | // Client might remove the view by "stopped" event. |
George Mount | 41725de | 2015-04-09 08:23:05 -0700 | [diff] [blame] | 631 | root.setWindowStopped(stopped); |
Robert Carr | 3f7bd97 | 2018-04-02 15:09:10 -0700 | [diff] [blame] | 632 | // Recursively forward stopped state to View's attached |
| 633 | // to this Window rather than the root application token, |
| 634 | // e.g. PopupWindow's. |
| 635 | setStoppedState(root.mAttachInfo.mWindowToken, stopped); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 636 | } |
| 637 | } |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | public void reportNewConfiguration(Configuration config) { |
| 642 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 643 | int count = mViews.size(); |
| 644 | config = new Configuration(config); |
| 645 | for (int i=0; i < count; i++) { |
| 646 | ViewRootImpl root = mRoots.get(i); |
| 647 | root.requestUpdateConfiguration(config); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 648 | } |
| 649 | } |
| 650 | } |
Craig Mautner | bc57cd1 | 2013-08-19 15:47:42 -0700 | [diff] [blame] | 651 | |
| 652 | /** @hide */ |
| 653 | public void changeCanvasOpacity(IBinder token, boolean opaque) { |
| 654 | if (token == null) { |
| 655 | return; |
| 656 | } |
| 657 | synchronized (mLock) { |
| 658 | for (int i = mParams.size() - 1; i >= 0; --i) { |
| 659 | if (mParams.get(i).token == token) { |
| 660 | mRoots.get(i).changeCanvasOpacity(opaque); |
| 661 | return; |
| 662 | } |
| 663 | } |
| 664 | } |
| 665 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | final class WindowLeaked extends AndroidRuntimeException { |
Mathew Inwood | e5ad598 | 2018-08-17 15:07:52 +0100 | [diff] [blame] | 669 | @UnsupportedAppUsage |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 670 | public WindowLeaked(String msg) { |
| 671 | super(msg); |
| 672 | } |
| 673 | } |