Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | |
Jorim Jaggi | f12ec0f | 2017-08-23 16:14:10 +0200 | [diff] [blame] | 19 | import static android.Manifest.permission.DEVICE_POWER; |
Wale Ogunwale | 01ad434 | 2017-06-30 07:07:01 -0700 | [diff] [blame] | 20 | import static android.Manifest.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS; |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 21 | import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; |
| 22 | import static android.content.pm.PackageManager.PERMISSION_GRANTED; |
Wale Ogunwale | 4958ad2 | 2017-06-22 09:08:14 -0700 | [diff] [blame] | 23 | import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; |
Wale Ogunwale | d993a57 | 2017-02-05 13:52:09 -0800 | [diff] [blame] | 24 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 25 | import static android.view.WindowManager.LayoutParams.isSystemAlertWindowType; |
Adrian Roos | 5c6b622 | 2017-11-07 17:36:10 +0100 | [diff] [blame] | 26 | |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 27 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_POSITIONING; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 28 | import static com.android.server.wm.WindowManagerDebugConfig.SHOW_TRANSACTIONS; |
| 29 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 30 | |
| 31 | import android.content.ClipData; |
| 32 | import android.content.Context; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 33 | import android.graphics.Rect; |
| 34 | import android.graphics.Region; |
| 35 | import android.os.Binder; |
| 36 | import android.os.Bundle; |
| 37 | import android.os.IBinder; |
| 38 | import android.os.Parcel; |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 39 | import android.os.Process; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 40 | import android.os.RemoteException; |
| 41 | import android.os.ServiceManager; |
Wale Ogunwale | 4958ad2 | 2017-06-22 09:08:14 -0700 | [diff] [blame] | 42 | import android.os.Trace; |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 43 | import android.os.UserHandle; |
Andrii Kulian | 4460796 | 2017-03-16 11:06:24 -0700 | [diff] [blame] | 44 | import android.util.MergedConfiguration; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 45 | import android.util.Slog; |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 46 | import android.view.Display; |
Adrian Roos | 5c6b622 | 2017-11-07 17:36:10 +0100 | [diff] [blame] | 47 | import android.view.DisplayCutout; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 48 | import android.view.IWindow; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 49 | import android.view.IWindowId; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 50 | import android.view.IWindowSession; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 51 | import android.view.IWindowSessionCallback; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 52 | import android.view.InputChannel; |
| 53 | import android.view.Surface; |
Daichi Hirono | a1fb9be | 2017-12-18 17:02:54 +0900 | [diff] [blame] | 54 | import android.view.SurfaceControl; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 55 | import android.view.SurfaceSession; |
| 56 | import android.view.WindowManager; |
| 57 | |
Chenjie Yu | e890419 | 2017-12-08 19:12:57 -0800 | [diff] [blame] | 58 | import com.android.internal.os.logging.MetricsLoggerWrapper; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 59 | import com.android.internal.view.IInputContext; |
| 60 | import com.android.internal.view.IInputMethodClient; |
| 61 | import com.android.internal.view.IInputMethodManager; |
| 62 | import com.android.server.wm.WindowManagerService.H; |
| 63 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 64 | import java.io.PrintWriter; |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 65 | import java.util.HashSet; |
| 66 | import java.util.Set; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 67 | |
| 68 | /** |
| 69 | * This class represents an active client session. There is generally one |
| 70 | * Session object per process that is interacting with the window manager. |
| 71 | */ |
Bryce Lee | a559286 | 2017-10-23 12:57:37 -0700 | [diff] [blame] | 72 | class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 73 | final WindowManagerService mService; |
Dianne Hackborn | eb94fa7 | 2014-06-03 17:48:12 -0700 | [diff] [blame] | 74 | final IWindowSessionCallback mCallback; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 75 | final IInputMethodClient mClient; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 76 | final int mUid; |
| 77 | final int mPid; |
Wale Ogunwale | cfca258 | 2016-10-19 09:53:25 -0700 | [diff] [blame] | 78 | private final String mStringName; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 79 | SurfaceSession mSurfaceSession; |
Wale Ogunwale | cfca258 | 2016-10-19 09:53:25 -0700 | [diff] [blame] | 80 | private int mNumWindow = 0; |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 81 | // Set of visible application overlay window surfaces connected to this session. |
| 82 | private final Set<WindowSurfaceController> mAppOverlaySurfaces = new HashSet<>(); |
| 83 | // Set of visible alert window surfaces connected to this session. |
| 84 | private final Set<WindowSurfaceController> mAlertWindowSurfaces = new HashSet<>(); |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 85 | private final DragDropController mDragDropController; |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 86 | final boolean mCanAddInternalSystemWindow; |
Wale Ogunwale | 01ad434 | 2017-06-30 07:07:01 -0700 | [diff] [blame] | 87 | final boolean mCanHideNonSystemOverlayWindows; |
Jorim Jaggi | f12ec0f | 2017-08-23 16:14:10 +0200 | [diff] [blame] | 88 | final boolean mCanAcquireSleepToken; |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 89 | private AlertWindowNotification mAlertWindowNotification; |
Wale Ogunwale | a10fc7e | 2017-04-06 07:09:51 -0700 | [diff] [blame] | 90 | private boolean mShowingAlertWindowNotificationAllowed; |
Wale Ogunwale | cfca258 | 2016-10-19 09:53:25 -0700 | [diff] [blame] | 91 | private boolean mClientDead = false; |
| 92 | private float mLastReportedAnimatorScale; |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 93 | private String mPackageName; |
Wale Ogunwale | 4958ad2 | 2017-06-22 09:08:14 -0700 | [diff] [blame] | 94 | private String mRelayoutTag; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 95 | |
Dianne Hackborn | eb94fa7 | 2014-06-03 17:48:12 -0700 | [diff] [blame] | 96 | public Session(WindowManagerService service, IWindowSessionCallback callback, |
| 97 | IInputMethodClient client, IInputContext inputContext) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 98 | mService = service; |
Dianne Hackborn | eb94fa7 | 2014-06-03 17:48:12 -0700 | [diff] [blame] | 99 | mCallback = callback; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 100 | mClient = client; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 101 | mUid = Binder.getCallingUid(); |
| 102 | mPid = Binder.getCallingPid(); |
Dianne Hackborn | eb94fa7 | 2014-06-03 17:48:12 -0700 | [diff] [blame] | 103 | mLastReportedAnimatorScale = service.getCurrentAnimatorScale(); |
Wale Ogunwale | 5aa8683 | 2017-02-28 10:40:27 -0800 | [diff] [blame] | 104 | mCanAddInternalSystemWindow = service.mContext.checkCallingOrSelfPermission( |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 105 | INTERNAL_SYSTEM_WINDOW) == PERMISSION_GRANTED; |
Wale Ogunwale | 01ad434 | 2017-06-30 07:07:01 -0700 | [diff] [blame] | 106 | mCanHideNonSystemOverlayWindows = service.mContext.checkCallingOrSelfPermission( |
| 107 | HIDE_NON_SYSTEM_OVERLAY_WINDOWS) == PERMISSION_GRANTED; |
Jorim Jaggi | f12ec0f | 2017-08-23 16:14:10 +0200 | [diff] [blame] | 108 | mCanAcquireSleepToken = service.mContext.checkCallingOrSelfPermission(DEVICE_POWER) |
| 109 | == PERMISSION_GRANTED; |
Wale Ogunwale | a10fc7e | 2017-04-06 07:09:51 -0700 | [diff] [blame] | 110 | mShowingAlertWindowNotificationAllowed = mService.mShowAlertWindowNotifications; |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 111 | mDragDropController = mService.mDragDropController; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 112 | StringBuilder sb = new StringBuilder(); |
| 113 | sb.append("Session{"); |
| 114 | sb.append(Integer.toHexString(System.identityHashCode(this))); |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 115 | sb.append(" "); |
| 116 | sb.append(mPid); |
| 117 | if (mUid < Process.FIRST_APPLICATION_UID) { |
| 118 | sb.append(":"); |
| 119 | sb.append(mUid); |
| 120 | } else { |
| 121 | sb.append(":u"); |
| 122 | sb.append(UserHandle.getUserId(mUid)); |
| 123 | sb.append('a'); |
| 124 | sb.append(UserHandle.getAppId(mUid)); |
| 125 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 126 | sb.append("}"); |
| 127 | mStringName = sb.toString(); |
| 128 | |
| 129 | synchronized (mService.mWindowMap) { |
| 130 | if (mService.mInputMethodManager == null && mService.mHaveInputMethods) { |
| 131 | IBinder b = ServiceManager.getService( |
| 132 | Context.INPUT_METHOD_SERVICE); |
| 133 | mService.mInputMethodManager = IInputMethodManager.Stub.asInterface(b); |
| 134 | } |
| 135 | } |
| 136 | long ident = Binder.clearCallingIdentity(); |
| 137 | try { |
| 138 | // Note: it is safe to call in to the input method manager |
| 139 | // here because we are not holding our lock. |
| 140 | if (mService.mInputMethodManager != null) { |
| 141 | mService.mInputMethodManager.addClient(client, inputContext, |
| 142 | mUid, mPid); |
| 143 | } else { |
| 144 | client.setUsingInputMethod(false); |
| 145 | } |
| 146 | client.asBinder().linkToDeath(this, 0); |
| 147 | } catch (RemoteException e) { |
| 148 | // The caller has died, so we can just forget about this. |
| 149 | try { |
| 150 | if (mService.mInputMethodManager != null) { |
| 151 | mService.mInputMethodManager.removeClient(client); |
| 152 | } |
| 153 | } catch (RemoteException ee) { |
| 154 | } |
| 155 | } finally { |
| 156 | Binder.restoreCallingIdentity(ident); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | @Override |
| 161 | public boolean onTransact(int code, Parcel data, Parcel reply, int flags) |
| 162 | throws RemoteException { |
| 163 | try { |
| 164 | return super.onTransact(code, data, reply, flags); |
| 165 | } catch (RuntimeException e) { |
| 166 | // Log all 'real' exceptions thrown to the caller |
| 167 | if (!(e instanceof SecurityException)) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 168 | Slog.wtf(TAG_WM, "Window Session Crash", e); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 169 | } |
| 170 | throw e; |
| 171 | } |
| 172 | } |
| 173 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 174 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 175 | public void binderDied() { |
| 176 | // Note: it is safe to call in to the input method manager |
| 177 | // here because we are not holding our lock. |
| 178 | try { |
| 179 | if (mService.mInputMethodManager != null) { |
| 180 | mService.mInputMethodManager.removeClient(mClient); |
| 181 | } |
| 182 | } catch (RemoteException e) { |
| 183 | } |
| 184 | synchronized(mService.mWindowMap) { |
| 185 | mClient.asBinder().unlinkToDeath(this, 0); |
| 186 | mClientDead = true; |
| 187 | killSessionLocked(); |
| 188 | } |
| 189 | } |
| 190 | |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 191 | @Override |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 192 | public int add(IWindow window, int seq, WindowManager.LayoutParams attrs, |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 193 | int viewVisibility, Rect outContentInsets, Rect outStableInsets, |
| 194 | InputChannel outInputChannel) { |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 195 | return addToDisplay(window, seq, attrs, viewVisibility, Display.DEFAULT_DISPLAY, |
Adrian Roos | 9e370f2 | 2018-03-06 18:19:45 +0100 | [diff] [blame] | 196 | new Rect() /* outFrame */, outContentInsets, outStableInsets, null /* outOutsets */, |
Daichi Hirono | 4ab9e82 | 2018-04-11 13:29:20 +0900 | [diff] [blame] | 197 | new DisplayCutout.ParcelableWrapper() /* cutout */, outInputChannel); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 198 | } |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 199 | |
| 200 | @Override |
| 201 | public int addToDisplay(IWindow window, int seq, WindowManager.LayoutParams attrs, |
Adrian Roos | 9e370f2 | 2018-03-06 18:19:45 +0100 | [diff] [blame] | 202 | int viewVisibility, int displayId, Rect outFrame, Rect outContentInsets, |
| 203 | Rect outStableInsets, Rect outOutsets, |
| 204 | DisplayCutout.ParcelableWrapper outDisplayCutout, InputChannel outInputChannel) { |
| 205 | return mService.addWindow(this, window, seq, attrs, viewVisibility, displayId, outFrame, |
Adrian Roos | 5c6b622 | 2017-11-07 17:36:10 +0100 | [diff] [blame] | 206 | outContentInsets, outStableInsets, outOutsets, outDisplayCutout, outInputChannel); |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | @Override |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 210 | public int addWithoutInputChannel(IWindow window, int seq, WindowManager.LayoutParams attrs, |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 211 | int viewVisibility, Rect outContentInsets, Rect outStableInsets) { |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 212 | return addToDisplayWithoutInputChannel(window, seq, attrs, viewVisibility, |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 213 | Display.DEFAULT_DISPLAY, outContentInsets, outStableInsets); |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | @Override |
| 217 | public int addToDisplayWithoutInputChannel(IWindow window, int seq, WindowManager.LayoutParams attrs, |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 218 | int viewVisibility, int displayId, Rect outContentInsets, Rect outStableInsets) { |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 219 | return mService.addWindow(this, window, seq, attrs, viewVisibility, displayId, |
Adrian Roos | 9e370f2 | 2018-03-06 18:19:45 +0100 | [diff] [blame] | 220 | new Rect() /* outFrame */, outContentInsets, outStableInsets, null /* outOutsets */, |
Daichi Hirono | 4ab9e82 | 2018-04-11 13:29:20 +0900 | [diff] [blame] | 221 | new DisplayCutout.ParcelableWrapper() /* cutout */, null /* outInputChannel */); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 222 | } |
| 223 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 224 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 225 | public void remove(IWindow window) { |
| 226 | mService.removeWindow(this, window); |
| 227 | } |
| 228 | |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 229 | @Override |
Robert Carr | 77bdfb5 | 2016-05-02 18:18:31 -0700 | [diff] [blame] | 230 | public void prepareToReplaceWindows(IBinder appToken, boolean childrenOnly) { |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 231 | mService.setWillReplaceWindows(appToken, childrenOnly); |
Robert Carr | 23fa16b | 2016-01-13 13:19:58 -0800 | [diff] [blame] | 232 | } |
| 233 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 234 | @Override |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 235 | public int relayout(IWindow window, int seq, WindowManager.LayoutParams attrs, |
chaviw | be43ac8 | 2018-04-04 15:14:49 -0700 | [diff] [blame] | 236 | int requestedWidth, int requestedHeight, int viewFlags, int flags, long frameNumber, |
| 237 | Rect outFrame, Rect outOverscanInsets, Rect outContentInsets, Rect outVisibleInsets, |
| 238 | Rect outStableInsets, Rect outsets, Rect outBackdropFrame, |
| 239 | DisplayCutout.ParcelableWrapper cutout, MergedConfiguration mergedConfiguration, |
| 240 | Surface outSurface) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 241 | if (false) Slog.d(TAG_WM, ">>>>>> ENTERED relayout from " |
Dianne Hackborn | b961cd2 | 2011-06-21 12:13:37 -0700 | [diff] [blame] | 242 | + Binder.getCallingPid()); |
Wale Ogunwale | 4958ad2 | 2017-06-22 09:08:14 -0700 | [diff] [blame] | 243 | Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, mRelayoutTag); |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 244 | int res = mService.relayoutWindow(this, window, seq, attrs, |
chaviw | be43ac8 | 2018-04-04 15:14:49 -0700 | [diff] [blame] | 245 | requestedWidth, requestedHeight, viewFlags, flags, frameNumber, |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 246 | outFrame, outOverscanInsets, outContentInsets, outVisibleInsets, |
Adrian Roos | 5c6b622 | 2017-11-07 17:36:10 +0100 | [diff] [blame] | 247 | outStableInsets, outsets, outBackdropFrame, cutout, |
| 248 | mergedConfiguration, outSurface); |
Wale Ogunwale | 4958ad2 | 2017-06-22 09:08:14 -0700 | [diff] [blame] | 249 | Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 250 | if (false) Slog.d(TAG_WM, "<<<<<< EXITING relayout to " |
Dianne Hackborn | b961cd2 | 2011-06-21 12:13:37 -0700 | [diff] [blame] | 251 | + Binder.getCallingPid()); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 252 | return res; |
| 253 | } |
| 254 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 255 | @Override |
Dianne Hackborn | 6482517 | 2011-03-02 21:32:58 -0800 | [diff] [blame] | 256 | public boolean outOfMemory(IWindow window) { |
| 257 | return mService.outOfMemoryWindow(this, window); |
| 258 | } |
| 259 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 260 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 261 | public void setTransparentRegion(IWindow window, Region region) { |
| 262 | mService.setTransparentRegionWindow(this, window, region); |
| 263 | } |
| 264 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 265 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 266 | public void setInsets(IWindow window, int touchableInsets, |
| 267 | Rect contentInsets, Rect visibleInsets, Region touchableArea) { |
| 268 | mService.setInsetsWindow(this, window, touchableInsets, contentInsets, |
| 269 | visibleInsets, touchableArea); |
| 270 | } |
| 271 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 272 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 273 | public void getDisplayFrame(IWindow window, Rect outDisplayFrame) { |
| 274 | mService.getWindowDisplayFrame(this, window, outDisplayFrame); |
| 275 | } |
| 276 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 277 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 278 | public void finishDrawing(IWindow window) { |
| 279 | if (WindowManagerService.localLOGV) Slog.v( |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 280 | TAG_WM, "IWindow finishDrawing called for " + window); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 281 | mService.finishDrawingWindow(this, window); |
| 282 | } |
| 283 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 284 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 285 | public void setInTouchMode(boolean mode) { |
| 286 | synchronized(mService.mWindowMap) { |
| 287 | mService.mInTouchMode = mode; |
| 288 | } |
| 289 | } |
| 290 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 291 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 292 | public boolean getInTouchMode() { |
| 293 | synchronized(mService.mWindowMap) { |
| 294 | return mService.mInTouchMode; |
| 295 | } |
| 296 | } |
| 297 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 298 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 299 | public boolean performHapticFeedback(IWindow window, int effectId, |
| 300 | boolean always) { |
| 301 | synchronized(mService.mWindowMap) { |
| 302 | long ident = Binder.clearCallingIdentity(); |
| 303 | try { |
| 304 | return mService.mPolicy.performHapticFeedbackLw( |
| 305 | mService.windowForClientLocked(this, window, true), |
| 306 | effectId, always); |
| 307 | } finally { |
| 308 | Binder.restoreCallingIdentity(ident); |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | /* Drag/drop */ |
Daichi Hirono | fabca09 | 2017-12-19 15:02:50 +0900 | [diff] [blame] | 314 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 315 | @Override |
Daichi Hirono | fabca09 | 2017-12-19 15:02:50 +0900 | [diff] [blame] | 316 | public IBinder performDrag(IWindow window, int flags, SurfaceControl surface, int touchSource, |
| 317 | float touchX, float touchY, float thumbCenterX, float thumbCenterY, ClipData data) { |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 318 | final int callerPid = Binder.getCallingPid(); |
| 319 | final int callerUid = Binder.getCallingUid(); |
| 320 | final long ident = Binder.clearCallingIdentity(); |
| 321 | try { |
Daichi Hirono | fabca09 | 2017-12-19 15:02:50 +0900 | [diff] [blame] | 322 | return mDragDropController.performDrag(mSurfaceSession, callerPid, callerUid, window, |
| 323 | flags, surface, touchSource, touchX, touchY, thumbCenterX, thumbCenterY, data); |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 324 | } finally { |
| 325 | Binder.restoreCallingIdentity(ident); |
| 326 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 327 | } |
| 328 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 329 | @Override |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 330 | public void reportDropResult(IWindow window, boolean consumed) { |
| 331 | final long ident = Binder.clearCallingIdentity(); |
| 332 | try { |
Daichi Hirono | 58e25e1 | 2017-10-25 15:48:08 +0900 | [diff] [blame] | 333 | mDragDropController.reportDropResult(window, consumed); |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 334 | } finally { |
| 335 | Binder.restoreCallingIdentity(ident); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 336 | } |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 337 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 338 | |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 339 | @Override |
| 340 | public void cancelDragAndDrop(IBinder dragToken) { |
| 341 | final long ident = Binder.clearCallingIdentity(); |
| 342 | try { |
Daichi Hirono | 58e25e1 | 2017-10-25 15:48:08 +0900 | [diff] [blame] | 343 | mDragDropController.cancelDragAndDrop(dragToken); |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 344 | } finally { |
| 345 | Binder.restoreCallingIdentity(ident); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 346 | } |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 347 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 348 | |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 349 | @Override |
| 350 | public void dragRecipientEntered(IWindow window) { |
| 351 | mDragDropController.dragRecipientEntered(window); |
| 352 | } |
| 353 | |
| 354 | @Override |
| 355 | public void dragRecipientExited(IWindow window) { |
| 356 | mDragDropController.dragRecipientExited(window); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 357 | } |
| 358 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 359 | @Override |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 360 | public boolean startMovingTask(IWindow window, float startX, float startY) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 361 | if (DEBUG_TASK_POSITIONING) Slog.d( |
| 362 | TAG_WM, "startMovingTask: {" + startX + "," + startY + "}"); |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 363 | |
Wale Ogunwale | 09e1b8d | 2016-02-23 10:38:35 -0800 | [diff] [blame] | 364 | long ident = Binder.clearCallingIdentity(); |
| 365 | try { |
Daichi Hirono | 34fb731 | 2017-12-04 10:00:24 +0900 | [diff] [blame] | 366 | return mService.mTaskPositioningController.startMovingTask(window, startX, startY); |
Wale Ogunwale | 09e1b8d | 2016-02-23 10:38:35 -0800 | [diff] [blame] | 367 | } finally { |
| 368 | Binder.restoreCallingIdentity(ident); |
| 369 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 370 | } |
| 371 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 372 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 373 | public void setWallpaperPosition(IBinder window, float x, float y, float xStep, float yStep) { |
| 374 | synchronized(mService.mWindowMap) { |
| 375 | long ident = Binder.clearCallingIdentity(); |
| 376 | try { |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 377 | mService.mRoot.mWallpaperController.setWindowWallpaperPosition( |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 378 | mService.windowForClientLocked(this, window, true), |
| 379 | x, y, xStep, yStep); |
| 380 | } finally { |
| 381 | Binder.restoreCallingIdentity(ident); |
| 382 | } |
| 383 | } |
| 384 | } |
| 385 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 386 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 387 | public void wallpaperOffsetsComplete(IBinder window) { |
Wale Ogunwale | e8069dc | 2015-08-18 09:52:01 -0700 | [diff] [blame] | 388 | synchronized (mService.mWindowMap) { |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 389 | mService.mRoot.mWallpaperController.wallpaperOffsetsComplete(window); |
Wale Ogunwale | e8069dc | 2015-08-18 09:52:01 -0700 | [diff] [blame] | 390 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 391 | } |
| 392 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 393 | @Override |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 394 | public void setWallpaperDisplayOffset(IBinder window, int x, int y) { |
| 395 | synchronized(mService.mWindowMap) { |
| 396 | long ident = Binder.clearCallingIdentity(); |
| 397 | try { |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 398 | mService.mRoot.mWallpaperController.setWindowWallpaperDisplayOffset( |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 399 | mService.windowForClientLocked(this, window, true), x, y); |
| 400 | } finally { |
| 401 | Binder.restoreCallingIdentity(ident); |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 406 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 407 | public Bundle sendWallpaperCommand(IBinder window, String action, int x, int y, |
| 408 | int z, Bundle extras, boolean sync) { |
| 409 | synchronized(mService.mWindowMap) { |
| 410 | long ident = Binder.clearCallingIdentity(); |
| 411 | try { |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 412 | return mService.mRoot.mWallpaperController.sendWindowWallpaperCommand( |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 413 | mService.windowForClientLocked(this, window, true), |
| 414 | action, x, y, z, extras, sync); |
| 415 | } finally { |
| 416 | Binder.restoreCallingIdentity(ident); |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 421 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 422 | public void wallpaperCommandComplete(IBinder window, Bundle result) { |
Wale Ogunwale | e8069dc | 2015-08-18 09:52:01 -0700 | [diff] [blame] | 423 | synchronized (mService.mWindowMap) { |
Wale Ogunwale | 0303c57 | 2016-10-20 10:16:29 -0700 | [diff] [blame] | 424 | mService.mRoot.mWallpaperController.wallpaperCommandComplete(window); |
Wale Ogunwale | e8069dc | 2015-08-18 09:52:01 -0700 | [diff] [blame] | 425 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 426 | } |
| 427 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 428 | @Override |
Svetoslav | f7174e8 | 2014-06-12 11:29:35 -0700 | [diff] [blame] | 429 | public void onRectangleOnScreenRequested(IBinder token, Rect rectangle) { |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 430 | synchronized(mService.mWindowMap) { |
| 431 | final long identity = Binder.clearCallingIdentity(); |
| 432 | try { |
Svetoslav | f7174e8 | 2014-06-12 11:29:35 -0700 | [diff] [blame] | 433 | mService.onRectangleOnScreenRequested(token, rectangle); |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 434 | } finally { |
| 435 | Binder.restoreCallingIdentity(identity); |
| 436 | } |
| 437 | } |
| 438 | } |
| 439 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 440 | @Override |
Dianne Hackborn | e3f23a3 | 2013-03-01 13:25:35 -0800 | [diff] [blame] | 441 | public IWindowId getWindowId(IBinder window) { |
| 442 | return mService.getWindowId(window); |
| 443 | } |
| 444 | |
Jeff Brown | c2932a1 | 2014-11-20 18:04:05 -0800 | [diff] [blame] | 445 | @Override |
| 446 | public void pokeDrawLock(IBinder window) { |
| 447 | final long identity = Binder.clearCallingIdentity(); |
| 448 | try { |
| 449 | mService.pokeDrawLock(this, window); |
| 450 | } finally { |
| 451 | Binder.restoreCallingIdentity(identity); |
| 452 | } |
| 453 | } |
| 454 | |
Vladislav Kaznacheev | 989b58a | 2016-02-10 12:19:33 -0800 | [diff] [blame] | 455 | @Override |
| 456 | public void updatePointerIcon(IWindow window) { |
| 457 | final long identity = Binder.clearCallingIdentity(); |
| 458 | try { |
| 459 | mService.updatePointerIcon(window); |
| 460 | } finally { |
| 461 | Binder.restoreCallingIdentity(identity); |
| 462 | } |
| 463 | } |
| 464 | |
Andrii Kulian | 4b6599e | 2018-01-15 17:24:08 -0800 | [diff] [blame] | 465 | @Override |
| 466 | public void updateTapExcludeRegion(IWindow window, int regionId, int left, int top, int width, |
| 467 | int height) { |
| 468 | final long identity = Binder.clearCallingIdentity(); |
| 469 | try { |
| 470 | mService.updateTapExcludeRegion(window, regionId, left, top, width, height); |
| 471 | } finally { |
| 472 | Binder.restoreCallingIdentity(identity); |
| 473 | } |
| 474 | } |
| 475 | |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 476 | void windowAddedLocked(String packageName) { |
| 477 | mPackageName = packageName; |
Wale Ogunwale | 4958ad2 | 2017-06-22 09:08:14 -0700 | [diff] [blame] | 478 | mRelayoutTag = "relayoutWindow: " + mPackageName; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 479 | if (mSurfaceSession == null) { |
| 480 | if (WindowManagerService.localLOGV) Slog.v( |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 481 | TAG_WM, "First window added to " + this + ", creating SurfaceSession"); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 482 | mSurfaceSession = new SurfaceSession(); |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 483 | if (SHOW_TRANSACTIONS) Slog.i( |
| 484 | TAG_WM, " NEW SURFACE SESSION " + mSurfaceSession); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 485 | mService.mSessions.add(this); |
Dianne Hackborn | eb94fa7 | 2014-06-03 17:48:12 -0700 | [diff] [blame] | 486 | if (mLastReportedAnimatorScale != mService.getCurrentAnimatorScale()) { |
| 487 | mService.dispatchNewAnimatorScaleLocked(this); |
| 488 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 489 | } |
| 490 | mNumWindow++; |
| 491 | } |
| 492 | |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 493 | void windowRemovedLocked() { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 494 | mNumWindow--; |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 495 | killSessionLocked(); |
| 496 | } |
| 497 | |
| 498 | |
| 499 | void onWindowSurfaceVisibilityChanged(WindowSurfaceController surfaceController, |
| 500 | boolean visible, int type) { |
| 501 | |
| 502 | if (!isSystemAlertWindowType(type)) { |
| 503 | return; |
| 504 | } |
| 505 | |
| 506 | boolean changed; |
| 507 | |
| 508 | if (!mCanAddInternalSystemWindow) { |
| 509 | // We want to track non-system signature apps adding alert windows so we can post an |
| 510 | // on-going notification for the user to control their visibility. |
| 511 | if (visible) { |
| 512 | changed = mAlertWindowSurfaces.add(surfaceController); |
Chenjie Yu | 08d6d72 | 2018-02-28 10:19:54 -0800 | [diff] [blame] | 513 | MetricsLoggerWrapper.logAppOverlayEnter(mUid, mPackageName, changed, type, true); |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 514 | } else { |
| 515 | changed = mAlertWindowSurfaces.remove(surfaceController); |
Chenjie Yu | 08d6d72 | 2018-02-28 10:19:54 -0800 | [diff] [blame] | 516 | MetricsLoggerWrapper.logAppOverlayExit(mUid, mPackageName, changed, type, true); |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | if (changed) { |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 520 | if (mAlertWindowSurfaces.isEmpty()) { |
| 521 | cancelAlertWindowNotification(); |
| 522 | } else if (mAlertWindowNotification == null){ |
Wale Ogunwale | d76881e | 2017-03-10 13:17:56 -0800 | [diff] [blame] | 523 | mAlertWindowNotification = new AlertWindowNotification(mService, mPackageName); |
Wale Ogunwale | a10fc7e | 2017-04-06 07:09:51 -0700 | [diff] [blame] | 524 | if (mShowingAlertWindowNotificationAllowed) { |
| 525 | mAlertWindowNotification.post(); |
| 526 | } |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 527 | } |
Wale Ogunwale | d993a57 | 2017-02-05 13:52:09 -0800 | [diff] [blame] | 528 | } |
| 529 | } |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 530 | |
| 531 | if (type != TYPE_APPLICATION_OVERLAY) { |
| 532 | return; |
| 533 | } |
| 534 | |
| 535 | if (visible) { |
| 536 | changed = mAppOverlaySurfaces.add(surfaceController); |
Chenjie Yu | 08d6d72 | 2018-02-28 10:19:54 -0800 | [diff] [blame] | 537 | MetricsLoggerWrapper.logAppOverlayEnter(mUid, mPackageName, changed, type, false); |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 538 | } else { |
| 539 | changed = mAppOverlaySurfaces.remove(surfaceController); |
Chenjie Yu | 08d6d72 | 2018-02-28 10:19:54 -0800 | [diff] [blame] | 540 | MetricsLoggerWrapper.logAppOverlayExit(mUid, mPackageName, changed, type, false); |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | if (changed) { |
| 544 | // Notify activity manager of changes to app overlay windows so it can adjust the |
| 545 | // importance score for the process. |
| 546 | setHasOverlayUi(!mAppOverlaySurfaces.isEmpty()); |
| 547 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 548 | } |
| 549 | |
Wale Ogunwale | a10fc7e | 2017-04-06 07:09:51 -0700 | [diff] [blame] | 550 | void setShowingAlertWindowNotificationAllowed(boolean allowed) { |
| 551 | mShowingAlertWindowNotificationAllowed = allowed; |
| 552 | if (mAlertWindowNotification != null) { |
| 553 | if (allowed) { |
| 554 | mAlertWindowNotification.post(); |
| 555 | } else { |
Wale Ogunwale | 6c8f2e4 | 2018-02-01 09:07:34 -0800 | [diff] [blame] | 556 | mAlertWindowNotification.cancel(false /* deleteChannel */); |
Wale Ogunwale | a10fc7e | 2017-04-06 07:09:51 -0700 | [diff] [blame] | 557 | } |
| 558 | } |
| 559 | } |
| 560 | |
Wale Ogunwale | d993a57 | 2017-02-05 13:52:09 -0800 | [diff] [blame] | 561 | private void killSessionLocked() { |
| 562 | if (mNumWindow > 0 || !mClientDead) { |
| 563 | return; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 564 | } |
Wale Ogunwale | d993a57 | 2017-02-05 13:52:09 -0800 | [diff] [blame] | 565 | |
| 566 | mService.mSessions.remove(this); |
| 567 | if (mSurfaceSession == null) { |
| 568 | return; |
| 569 | } |
| 570 | |
| 571 | if (WindowManagerService.localLOGV) Slog.v(TAG_WM, "Last window removed from " + this |
| 572 | + ", destroying " + mSurfaceSession); |
| 573 | if (SHOW_TRANSACTIONS) Slog.i(TAG_WM, " KILL SURFACE SESSION " + mSurfaceSession); |
| 574 | try { |
| 575 | mSurfaceSession.kill(); |
| 576 | } catch (Exception e) { |
| 577 | Slog.w(TAG_WM, "Exception thrown when killing surface session " + mSurfaceSession |
| 578 | + " in session " + this + ": " + e.toString()); |
| 579 | } |
| 580 | mSurfaceSession = null; |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 581 | mAlertWindowSurfaces.clear(); |
| 582 | mAppOverlaySurfaces.clear(); |
Wale Ogunwale | d993a57 | 2017-02-05 13:52:09 -0800 | [diff] [blame] | 583 | setHasOverlayUi(false); |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 584 | cancelAlertWindowNotification(); |
Wale Ogunwale | d993a57 | 2017-02-05 13:52:09 -0800 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | private void setHasOverlayUi(boolean hasOverlayUi) { |
| 588 | mService.mH.obtainMessage(H.SET_HAS_OVERLAY_UI, mPid, hasOverlayUi ? 1 : 0).sendToTarget(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 589 | } |
| 590 | |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 591 | private void cancelAlertWindowNotification() { |
| 592 | if (mAlertWindowNotification == null) { |
| 593 | return; |
| 594 | } |
Wale Ogunwale | 6c8f2e4 | 2018-02-01 09:07:34 -0800 | [diff] [blame] | 595 | mAlertWindowNotification.cancel(true /* deleteChannel */); |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 596 | mAlertWindowNotification = null; |
| 597 | } |
| 598 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 599 | void dump(PrintWriter pw, String prefix) { |
| 600 | pw.print(prefix); pw.print("mNumWindow="); pw.print(mNumWindow); |
Wale Ogunwale | 5aa8683 | 2017-02-28 10:40:27 -0800 | [diff] [blame] | 601 | pw.print(" mCanAddInternalSystemWindow="); pw.print(mCanAddInternalSystemWindow); |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 602 | pw.print(" mAppOverlaySurfaces="); pw.print(mAppOverlaySurfaces); |
| 603 | pw.print(" mAlertWindowSurfaces="); pw.print(mAlertWindowSurfaces); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 604 | pw.print(" mClientDead="); pw.print(mClientDead); |
| 605 | pw.print(" mSurfaceSession="); pw.println(mSurfaceSession); |
Wale Ogunwale | 4958ad2 | 2017-06-22 09:08:14 -0700 | [diff] [blame] | 606 | pw.print(prefix); pw.print("mPackageName="); pw.println(mPackageName); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | @Override |
| 610 | public String toString() { |
| 611 | return mStringName; |
| 612 | } |
Robert Carr | 0e00727 | 2017-10-02 13:00:55 -0700 | [diff] [blame] | 613 | |
| 614 | boolean hasAlertWindowSurfaces() { |
| 615 | return !mAlertWindowSurfaces.isEmpty(); |
| 616 | } |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 617 | } |