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 | a570dee | 2018-08-17 14:56:00 +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 | 8c854f8 | 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 | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 136 | @UnsupportedAppUsage |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 137 | private static WindowManagerGlobal sDefaultWindowManager; |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 138 | @UnsupportedAppUsage |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 139 | private static IWindowManager sWindowManagerService; |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +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 | a570dee | 2018-08-17 14:56:00 +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 | a570dee | 2018-08-17 14:56:00 +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 | a570dee | 2018-08-17 14:56:00 +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 | a570dee | 2018-08-17 14:56:00 +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 | a570dee | 2018-08-17 14:56:00 +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 | a570dee | 2018-08-17 14:56:00 +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 | a570dee | 2018-08-17 14:56:00 +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 | a570dee | 2018-08-17 14:56:00 +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 { |
Yohei Yukawa | 6c07572 | 2018-09-21 14:52:12 -0700 | [diff] [blame] | 199 | // Emulate the legacy behavior. The global instance of InputMethodManager |
| 200 | // was instantiated here. |
| 201 | // TODO(b/116157766): Remove this hack after cleaning up @UnsupportedAppUsage |
| 202 | InputMethodManager.ensureDefaultInstanceForDefaultDisplayIfNecessary(); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 203 | IWindowManager windowManager = getWindowManagerService(); |
| 204 | sWindowSession = windowManager.openSession( |
Dianne Hackborn | eb94fa7 | 2014-06-03 17:48:12 -0700 | [diff] [blame] | 205 | new IWindowSessionCallback.Stub() { |
| 206 | @Override |
| 207 | public void onAnimatorScaleChanged(float scale) { |
| 208 | ValueAnimator.setDurationScale(scale); |
| 209 | } |
Yohei Yukawa | a71bb25 | 2018-09-19 19:21:24 -0700 | [diff] [blame] | 210 | }); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 211 | } catch (RemoteException e) { |
Jeff Sharkey | d136e51 | 2016-03-09 22:30:56 -0700 | [diff] [blame] | 212 | throw e.rethrowFromSystemServer(); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 213 | } |
| 214 | } |
| 215 | return sWindowSession; |
| 216 | } |
| 217 | } |
| 218 | |
Mathew Inwood | 8c854f8 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 219 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 220 | public static IWindowSession peekWindowSession() { |
| 221 | synchronized (WindowManagerGlobal.class) { |
| 222 | return sWindowSession; |
| 223 | } |
| 224 | } |
| 225 | |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 226 | @UnsupportedAppUsage |
Siva Velusamy | 945bfb6 | 2013-01-06 16:03:12 -0800 | [diff] [blame] | 227 | public String[] getViewRootNames() { |
| 228 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 229 | final int numRoots = mRoots.size(); |
| 230 | String[] mViewRoots = new String[numRoots]; |
| 231 | for (int i = 0; i < numRoots; ++i) { |
| 232 | mViewRoots[i] = getWindowName(mRoots.get(i)); |
Siva Velusamy | 945bfb6 | 2013-01-06 16:03:12 -0800 | [diff] [blame] | 233 | } |
| 234 | return mViewRoots; |
| 235 | } |
| 236 | } |
| 237 | |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 238 | @UnsupportedAppUsage |
Dianne Hackborn | a7bb6fb | 2015-02-03 18:13:40 -0800 | [diff] [blame] | 239 | public ArrayList<ViewRootImpl> getRootViews(IBinder token) { |
| 240 | ArrayList<ViewRootImpl> views = new ArrayList<>(); |
| 241 | synchronized (mLock) { |
| 242 | final int numRoots = mRoots.size(); |
| 243 | for (int i = 0; i < numRoots; ++i) { |
| 244 | WindowManager.LayoutParams params = mParams.get(i); |
| 245 | if (params.token == null) { |
| 246 | continue; |
| 247 | } |
| 248 | if (params.token != token) { |
| 249 | boolean isChild = false; |
| 250 | if (params.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW |
| 251 | && params.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 252 | for (int j = 0 ; j < numRoots; ++j) { |
| 253 | View viewj = mViews.get(j); |
| 254 | WindowManager.LayoutParams paramsj = mParams.get(j); |
| 255 | if (params.token == viewj.getWindowToken() |
| 256 | && paramsj.token == token) { |
| 257 | isChild = true; |
| 258 | break; |
| 259 | } |
| 260 | } |
| 261 | } |
| 262 | if (!isChild) { |
| 263 | continue; |
| 264 | } |
| 265 | } |
| 266 | views.add(mRoots.get(i)); |
| 267 | } |
| 268 | } |
| 269 | return views; |
| 270 | } |
| 271 | |
Vladislav Kaznacheev | 7039cbc | 2017-01-04 10:15:31 -0800 | [diff] [blame] | 272 | public View getWindowView(IBinder windowToken) { |
| 273 | synchronized (mLock) { |
| 274 | final int numViews = mViews.size(); |
| 275 | for (int i = 0; i < numViews; ++i) { |
| 276 | final View view = mViews.get(i); |
| 277 | if (view.getWindowToken() == windowToken) { |
| 278 | return view; |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | return null; |
| 283 | } |
| 284 | |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 285 | @UnsupportedAppUsage |
Siva Velusamy | 945bfb6 | 2013-01-06 16:03:12 -0800 | [diff] [blame] | 286 | public View getRootView(String name) { |
| 287 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 288 | for (int i = mRoots.size() - 1; i >= 0; --i) { |
| 289 | final ViewRootImpl root = mRoots.get(i); |
Siva Velusamy | 945bfb6 | 2013-01-06 16:03:12 -0800 | [diff] [blame] | 290 | if (name.equals(getWindowName(root))) return root.getView(); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | return null; |
| 295 | } |
| 296 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 297 | public void addView(View view, ViewGroup.LayoutParams params, |
| 298 | Display display, Window parentWindow) { |
| 299 | if (view == null) { |
| 300 | throw new IllegalArgumentException("view must not be null"); |
| 301 | } |
| 302 | if (display == null) { |
| 303 | throw new IllegalArgumentException("display must not be null"); |
| 304 | } |
| 305 | if (!(params instanceof WindowManager.LayoutParams)) { |
| 306 | throw new IllegalArgumentException("Params must be WindowManager.LayoutParams"); |
| 307 | } |
| 308 | |
Alan Viverette | 9ecb73c | 2014-12-15 13:40:28 -0800 | [diff] [blame] | 309 | final WindowManager.LayoutParams wparams = (WindowManager.LayoutParams) params; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 310 | if (parentWindow != null) { |
| 311 | parentWindow.adjustLayoutParamsForSubWindow(wparams); |
Alan Viverette | 9b0ab65 | 2015-03-18 14:21:04 -0700 | [diff] [blame] | 312 | } else { |
| 313 | // If there's no parent, then hardware acceleration for this view is |
| 314 | // set from the application's hardware acceleration setting. |
Alan Viverette | 5e1565e | 2014-07-29 16:14:25 -0700 | [diff] [blame] | 315 | final Context context = view.getContext(); |
Alan Viverette | 9b0ab65 | 2015-03-18 14:21:04 -0700 | [diff] [blame] | 316 | if (context != null |
Alan Viverette | d70b9e7 | 2015-05-27 14:29:20 -0700 | [diff] [blame] | 317 | && (context.getApplicationInfo().flags |
| 318 | & ApplicationInfo.FLAG_HARDWARE_ACCELERATED) != 0) { |
Alan Viverette | 5e1565e | 2014-07-29 16:14:25 -0700 | [diff] [blame] | 319 | wparams.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 320 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | ViewRootImpl root; |
| 324 | View panelParentView = null; |
| 325 | |
| 326 | synchronized (mLock) { |
| 327 | // Start watching for system property changes. |
| 328 | if (mSystemPropertyUpdater == null) { |
| 329 | mSystemPropertyUpdater = new Runnable() { |
| 330 | @Override public void run() { |
| 331 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 332 | for (int i = mRoots.size() - 1; i >= 0; --i) { |
| 333 | mRoots.get(i).loadSystemProperties(); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 334 | } |
| 335 | } |
| 336 | } |
| 337 | }; |
| 338 | SystemProperties.addChangeCallback(mSystemPropertyUpdater); |
| 339 | } |
| 340 | |
| 341 | int index = findViewLocked(view, false); |
| 342 | if (index >= 0) { |
Craig Mautner | 8f303ad | 2013-06-14 11:32:22 -0700 | [diff] [blame] | 343 | if (mDyingViews.contains(view)) { |
| 344 | // Don't wait for MSG_DIE to make it's way through root's queue. |
| 345 | mRoots.get(index).doDie(); |
| 346 | } else { |
| 347 | throw new IllegalStateException("View " + view |
| 348 | + " has already been added to the window manager."); |
| 349 | } |
| 350 | // The previous removeView() had not completed executing. Now it has. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | // If this is a panel window, then find the window it is being |
| 354 | // attached to for future reference. |
| 355 | if (wparams.type >= WindowManager.LayoutParams.FIRST_SUB_WINDOW && |
| 356 | wparams.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 357 | final int count = mViews.size(); |
| 358 | for (int i = 0; i < count; i++) { |
| 359 | if (mRoots.get(i).mWindow.asBinder() == wparams.token) { |
| 360 | panelParentView = mViews.get(i); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 361 | } |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | root = new ViewRootImpl(view.getContext(), display); |
| 366 | |
| 367 | view.setLayoutParams(wparams); |
| 368 | |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 369 | mViews.add(view); |
| 370 | mRoots.add(root); |
| 371 | mParams.add(wparams); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 372 | |
Gopal Krishna Shukla | f7abcda | 2016-07-06 08:14:59 +0530 | [diff] [blame] | 373 | // do this last because it fires off messages to start doing things |
| 374 | try { |
| 375 | root.setView(view, wparams, panelParentView); |
| 376 | } catch (RuntimeException e) { |
| 377 | // BadTokenException or InvalidDisplayException, clean up. |
Craig Mautner | 6018aee | 2012-10-23 14:27:49 -0700 | [diff] [blame] | 378 | if (index >= 0) { |
| 379 | removeViewLocked(index, true); |
| 380 | } |
Gopal Krishna Shukla | f7abcda | 2016-07-06 08:14:59 +0530 | [diff] [blame] | 381 | throw e; |
Craig Mautner | 6018aee | 2012-10-23 14:27:49 -0700 | [diff] [blame] | 382 | } |
Craig Mautner | 6018aee | 2012-10-23 14:27:49 -0700 | [diff] [blame] | 383 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | public void updateViewLayout(View view, ViewGroup.LayoutParams params) { |
| 387 | if (view == null) { |
| 388 | throw new IllegalArgumentException("view must not be null"); |
| 389 | } |
| 390 | if (!(params instanceof WindowManager.LayoutParams)) { |
| 391 | throw new IllegalArgumentException("Params must be WindowManager.LayoutParams"); |
| 392 | } |
| 393 | |
| 394 | final WindowManager.LayoutParams wparams = (WindowManager.LayoutParams)params; |
| 395 | |
| 396 | view.setLayoutParams(wparams); |
| 397 | |
| 398 | synchronized (mLock) { |
| 399 | int index = findViewLocked(view, true); |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 400 | ViewRootImpl root = mRoots.get(index); |
| 401 | mParams.remove(index); |
| 402 | mParams.add(index, wparams); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 403 | root.setLayoutParams(wparams, false); |
| 404 | } |
| 405 | } |
| 406 | |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 407 | @UnsupportedAppUsage |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 408 | public void removeView(View view, boolean immediate) { |
| 409 | if (view == null) { |
| 410 | throw new IllegalArgumentException("view must not be null"); |
| 411 | } |
| 412 | |
| 413 | synchronized (mLock) { |
| 414 | int index = findViewLocked(view, true); |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 415 | View curView = mRoots.get(index).getView(); |
Craig Mautner | 05eb730 | 2013-06-03 17:24:21 -0700 | [diff] [blame] | 416 | removeViewLocked(index, immediate); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 417 | if (curView == view) { |
| 418 | return; |
| 419 | } |
| 420 | |
| 421 | throw new IllegalStateException("Calling with view " + view |
| 422 | + " but the ViewAncestor is attached to " + curView); |
| 423 | } |
| 424 | } |
| 425 | |
Andrii Kulian | eac0ea5 | 2016-05-11 15:50:24 -0700 | [diff] [blame] | 426 | /** |
| 427 | * Remove all roots with specified token. |
| 428 | * |
| 429 | * @param token app or window token. |
| 430 | * @param who name of caller, used in logs. |
| 431 | * @param what type of caller, used in logs. |
| 432 | */ |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 433 | public void closeAll(IBinder token, String who, String what) { |
Andrii Kulian | eac0ea5 | 2016-05-11 15:50:24 -0700 | [diff] [blame] | 434 | closeAllExceptView(token, null /* view */, who, what); |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * Remove all roots with specified token, except maybe one view. |
| 439 | * |
| 440 | * @param token app or window token. |
| 441 | * @param view view that should be should be preserved along with it's root. |
| 442 | * Pass null if everything should be removed. |
| 443 | * @param who name of caller, used in logs. |
| 444 | * @param what type of caller, used in logs. |
| 445 | */ |
| 446 | public void closeAllExceptView(IBinder token, View view, String who, String what) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 447 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 448 | int count = mViews.size(); |
Craig Mautner | 05eb730 | 2013-06-03 17:24:21 -0700 | [diff] [blame] | 449 | for (int i = 0; i < count; i++) { |
Andrii Kulian | eac0ea5 | 2016-05-11 15:50:24 -0700 | [diff] [blame] | 450 | if ((view == null || mViews.get(i) != view) |
| 451 | && (token == null || mParams.get(i).token == token)) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 452 | ViewRootImpl root = mRoots.get(i); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 453 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 454 | if (who != null) { |
| 455 | WindowLeaked leak = new WindowLeaked( |
| 456 | what + " " + who + " has leaked window " |
| 457 | + root.getView() + " that was originally added here"); |
| 458 | leak.setStackTrace(root.getLocation().getStackTrace()); |
Craig Mautner | 05eb730 | 2013-06-03 17:24:21 -0700 | [diff] [blame] | 459 | Log.e(TAG, "", leak); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | removeViewLocked(i, false); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 463 | } |
| 464 | } |
| 465 | } |
| 466 | } |
| 467 | |
Craig Mautner | 05eb730 | 2013-06-03 17:24:21 -0700 | [diff] [blame] | 468 | private void removeViewLocked(int index, boolean immediate) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 469 | ViewRootImpl root = mRoots.get(index); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 470 | View view = root.getView(); |
| 471 | |
| 472 | if (view != null) { |
Yohei Yukawa | 484d4af | 2018-09-17 16:47:08 -0700 | [diff] [blame] | 473 | InputMethodManager imm = view.getContext().getSystemService(InputMethodManager.class); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 474 | if (imm != null) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 475 | imm.windowDismissed(mViews.get(index).getWindowToken()); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 476 | } |
| 477 | } |
Craig Mautner | 8f303ad | 2013-06-14 11:32:22 -0700 | [diff] [blame] | 478 | boolean deferred = root.die(immediate); |
Craig Mautner | 92098c7 | 2013-06-10 11:27:26 -0700 | [diff] [blame] | 479 | if (view != null) { |
| 480 | view.assignParent(null); |
Craig Mautner | 8f303ad | 2013-06-14 11:32:22 -0700 | [diff] [blame] | 481 | if (deferred) { |
| 482 | mDyingViews.add(view); |
| 483 | } |
Craig Mautner | 92098c7 | 2013-06-10 11:27:26 -0700 | [diff] [blame] | 484 | } |
Craig Mautner | 05eb730 | 2013-06-03 17:24:21 -0700 | [diff] [blame] | 485 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 486 | |
Craig Mautner | 05eb730 | 2013-06-03 17:24:21 -0700 | [diff] [blame] | 487 | void doRemoveView(ViewRootImpl root) { |
| 488 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 489 | final int index = mRoots.indexOf(root); |
| 490 | if (index >= 0) { |
| 491 | mRoots.remove(index); |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 492 | mParams.remove(index); |
Craig Mautner | 8f303ad | 2013-06-14 11:32:22 -0700 | [diff] [blame] | 493 | final View view = mViews.remove(index); |
| 494 | mDyingViews.remove(view); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 495 | } |
| 496 | } |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 497 | if (ThreadedRenderer.sTrimForeground && ThreadedRenderer.isAvailable()) { |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 498 | doTrimForeground(); |
| 499 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | private int findViewLocked(View view, boolean required) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 503 | final int index = mViews.indexOf(view); |
| 504 | if (required && index < 0) { |
Craig Mautner | 05eb730 | 2013-06-03 17:24:21 -0700 | [diff] [blame] | 505 | throw new IllegalArgumentException("View=" + view + " not attached to window manager"); |
Craig Mautner | 6018aee | 2012-10-23 14:27:49 -0700 | [diff] [blame] | 506 | } |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 507 | return index; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 508 | } |
| 509 | |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 510 | public static boolean shouldDestroyEglContext(int trimLevel) { |
| 511 | // On low-end gfx devices we trim when memory is moderate; |
| 512 | // on high-end devices we do this when low. |
| 513 | if (trimLevel >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) { |
| 514 | return true; |
| 515 | } |
| 516 | if (trimLevel >= ComponentCallbacks2.TRIM_MEMORY_MODERATE |
| 517 | && !ActivityManager.isHighEndGfx()) { |
| 518 | return true; |
| 519 | } |
| 520 | return false; |
| 521 | } |
| 522 | |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 523 | @UnsupportedAppUsage |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 524 | public void trimMemory(int level) { |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 525 | if (ThreadedRenderer.isAvailable()) { |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 526 | if (shouldDestroyEglContext(level)) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 527 | // Destroy all hardware surfaces and resources associated to |
| 528 | // known windows |
| 529 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 530 | for (int i = mRoots.size() - 1; i >= 0; --i) { |
Romain Guy | 46bfc48 | 2013-08-16 18:38:29 -0700 | [diff] [blame] | 531 | mRoots.get(i).destroyHardwareResources(); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 532 | } |
| 533 | } |
| 534 | // Force a full memory flush |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 535 | level = ComponentCallbacks2.TRIM_MEMORY_COMPLETE; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 536 | } |
| 537 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 538 | ThreadedRenderer.trimMemory(level); |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 539 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 540 | if (ThreadedRenderer.sTrimForeground) { |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 541 | doTrimForeground(); |
| 542 | } |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | public static void trimForeground() { |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 547 | if (ThreadedRenderer.sTrimForeground && ThreadedRenderer.isAvailable()) { |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 548 | WindowManagerGlobal wm = WindowManagerGlobal.getInstance(); |
| 549 | wm.doTrimForeground(); |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | private void doTrimForeground() { |
| 554 | boolean hasVisibleWindows = false; |
| 555 | synchronized (mLock) { |
| 556 | for (int i = mRoots.size() - 1; i >= 0; --i) { |
John Reck | ccf2fa0 | 2014-09-25 08:33:05 -0700 | [diff] [blame] | 557 | final ViewRootImpl root = mRoots.get(i); |
| 558 | if (root.mView != null && root.getHostVisibility() == View.VISIBLE |
Stan Iliev | 45faba5 | 2016-06-28 13:33:15 -0400 | [diff] [blame] | 559 | && root.mAttachInfo.mThreadedRenderer != null) { |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 560 | hasVisibleWindows = true; |
| 561 | } else { |
John Reck | ccf2fa0 | 2014-09-25 08:33:05 -0700 | [diff] [blame] | 562 | root.destroyHardwareResources(); |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 563 | } |
| 564 | } |
| 565 | } |
| 566 | if (!hasVisibleWindows) { |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 567 | ThreadedRenderer.trimMemory( |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 568 | ComponentCallbacks2.TRIM_MEMORY_COMPLETE); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 569 | } |
| 570 | } |
| 571 | |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 572 | public void dumpGfxInfo(FileDescriptor fd, String[] args) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 573 | FileOutputStream fout = new FileOutputStream(fd); |
Dianne Hackborn | 8c84109 | 2013-06-24 13:46:13 -0700 | [diff] [blame] | 574 | PrintWriter pw = new FastPrintWriter(fout); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 575 | try { |
| 576 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 577 | final int count = mViews.size(); |
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 | pw.println("Profile data in ms:"); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 580 | |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 581 | for (int i = 0; i < count; i++) { |
| 582 | ViewRootImpl root = mRoots.get(i); |
| 583 | String name = getWindowName(root); |
John Reck | 73840ea | 2014-09-22 07:39:18 -0700 | [diff] [blame] | 584 | pw.printf("\n\t%s (visibility=%d)", name, root.getHostVisibility()); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 585 | |
John Reck | 51aaf90 | 2015-12-02 15:08:07 -0800 | [diff] [blame] | 586 | ThreadedRenderer renderer = |
Stan Iliev | 45faba5 | 2016-06-28 13:33:15 -0400 | [diff] [blame] | 587 | root.getView().mAttachInfo.mThreadedRenderer; |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 588 | if (renderer != null) { |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 589 | renderer.dumpGfxInfo(pw, fd, args); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 590 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 591 | } |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 592 | |
| 593 | pw.println("\nView hierarchy:\n"); |
| 594 | |
| 595 | int viewsCount = 0; |
| 596 | int displayListsSize = 0; |
| 597 | int[] info = new int[2]; |
| 598 | |
| 599 | for (int i = 0; i < count; i++) { |
| 600 | ViewRootImpl root = mRoots.get(i); |
| 601 | root.dumpGfxInfo(info); |
| 602 | |
| 603 | String name = getWindowName(root); |
| 604 | pw.printf(" %s\n %d views, %.2f kB of display lists", |
| 605 | name, info[0], info[1] / 1024.0f); |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 606 | pw.printf("\n\n"); |
| 607 | |
| 608 | viewsCount += info[0]; |
| 609 | displayListsSize += info[1]; |
| 610 | } |
| 611 | |
| 612 | pw.printf("\nTotal ViewRootImpl: %d\n", count); |
| 613 | pw.printf("Total Views: %d\n", viewsCount); |
| 614 | pw.printf("Total DisplayList: %.2f kB\n\n", displayListsSize / 1024.0f); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 615 | } |
| 616 | } finally { |
| 617 | pw.flush(); |
| 618 | } |
| 619 | } |
| 620 | |
| 621 | private static String getWindowName(ViewRootImpl root) { |
| 622 | return root.mWindowAttributes.getTitle() + "/" + |
| 623 | root.getClass().getName() + '@' + Integer.toHexString(root.hashCode()); |
| 624 | } |
| 625 | |
| 626 | public void setStoppedState(IBinder token, boolean stopped) { |
| 627 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 628 | int count = mViews.size(); |
Tetsutoki Shiozawa | 978e7f8 | 2017-11-01 11:38:34 +0900 | [diff] [blame] | 629 | for (int i = count - 1; i >= 0; i--) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 630 | if (token == null || mParams.get(i).token == token) { |
| 631 | ViewRootImpl root = mRoots.get(i); |
Tetsutoki Shiozawa | 978e7f8 | 2017-11-01 11:38:34 +0900 | [diff] [blame] | 632 | // Client might remove the view by "stopped" event. |
George Mount | 41725de | 2015-04-09 08:23:05 -0700 | [diff] [blame] | 633 | root.setWindowStopped(stopped); |
Robert Carr | 3f7bd97 | 2018-04-02 15:09:10 -0700 | [diff] [blame] | 634 | // Recursively forward stopped state to View's attached |
| 635 | // to this Window rather than the root application token, |
| 636 | // e.g. PopupWindow's. |
| 637 | setStoppedState(root.mAttachInfo.mWindowToken, stopped); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 638 | } |
| 639 | } |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | public void reportNewConfiguration(Configuration config) { |
| 644 | synchronized (mLock) { |
Craig Mautner | 652fdfa | 2013-06-06 07:51:57 -0700 | [diff] [blame] | 645 | int count = mViews.size(); |
| 646 | config = new Configuration(config); |
| 647 | for (int i=0; i < count; i++) { |
| 648 | ViewRootImpl root = mRoots.get(i); |
| 649 | root.requestUpdateConfiguration(config); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 650 | } |
| 651 | } |
| 652 | } |
Craig Mautner | bc57cd1 | 2013-08-19 15:47:42 -0700 | [diff] [blame] | 653 | |
| 654 | /** @hide */ |
| 655 | public void changeCanvasOpacity(IBinder token, boolean opaque) { |
| 656 | if (token == null) { |
| 657 | return; |
| 658 | } |
| 659 | synchronized (mLock) { |
| 660 | for (int i = mParams.size() - 1; i >= 0; --i) { |
| 661 | if (mParams.get(i).token == token) { |
| 662 | mRoots.get(i).changeCanvasOpacity(opaque); |
| 663 | return; |
| 664 | } |
| 665 | } |
| 666 | } |
| 667 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | final class WindowLeaked extends AndroidRuntimeException { |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 671 | @UnsupportedAppUsage |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 672 | public WindowLeaked(String msg) { |
| 673 | super(msg); |
| 674 | } |
| 675 | } |