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 | |
Adrian Roos | b125e0b | 2019-10-02 14:55:14 +0200 | [diff] [blame] | 27 | import static com.android.server.wm.ProtoLogGroup.WM_SHOW_TRANSACTIONS; |
Adam Pardyl | 8c2d19c | 2019-09-16 17:15:38 +0200 | [diff] [blame] | 28 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 29 | import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_POSITIONING; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 30 | import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 31 | |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 32 | import android.annotation.Nullable; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 33 | import android.content.ClipData; |
Valerie Hau | 3036055 | 2020-01-14 16:12:01 -0800 | [diff] [blame] | 34 | import android.graphics.Point; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 35 | import android.graphics.Rect; |
| 36 | import android.graphics.Region; |
| 37 | import android.os.Binder; |
| 38 | import android.os.Bundle; |
| 39 | import android.os.IBinder; |
| 40 | import android.os.Parcel; |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 41 | import android.os.Process; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 42 | import android.os.RemoteException; |
Wale Ogunwale | 4958ad2 | 2017-06-22 09:08:14 -0700 | [diff] [blame] | 43 | import android.os.Trace; |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 44 | import android.os.UserHandle; |
Riddle Hsu | ccf0940 | 2019-08-13 00:33:06 +0800 | [diff] [blame] | 45 | import android.util.ArraySet; |
Andrii Kulian | 4460796 | 2017-03-16 11:06:24 -0700 | [diff] [blame] | 46 | import android.util.MergedConfiguration; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 47 | import android.util.Slog; |
Adrian Roos | 5c6b622 | 2017-11-07 17:36:10 +0100 | [diff] [blame] | 48 | import android.view.DisplayCutout; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 49 | import android.view.IWindow; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 50 | import android.view.IWindowId; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 51 | import android.view.IWindowSession; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 52 | import android.view.IWindowSessionCallback; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 53 | import android.view.InputChannel; |
Tiger Huang | 0426a33 | 2020-03-29 01:17:08 +0800 | [diff] [blame] | 54 | import android.view.InsetsSourceControl; |
Tiger Huang | dda14a7 | 2019-01-10 17:20:27 +0800 | [diff] [blame] | 55 | import android.view.InsetsState; |
Daichi Hirono | a1fb9be | 2017-12-18 17:02:54 +0900 | [diff] [blame] | 56 | import android.view.SurfaceControl; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 57 | import android.view.SurfaceSession; |
| 58 | import android.view.WindowManager; |
| 59 | |
Chenjie Yu | e890419 | 2017-12-08 19:12:57 -0800 | [diff] [blame] | 60 | import com.android.internal.os.logging.MetricsLoggerWrapper; |
Adrian Roos | b125e0b | 2019-10-02 14:55:14 +0200 | [diff] [blame] | 61 | import com.android.server.protolog.common.ProtoLog; |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 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; |
Adrian Roos | 4ffc897 | 2019-02-07 20:45:11 +0100 | [diff] [blame] | 65 | import java.util.List; |
wilsonshih | c32538e | 2018-11-07 17:27:34 +0800 | [diff] [blame] | 66 | import java.util.function.BiConsumer; |
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 int mUid; |
| 76 | final int mPid; |
Wale Ogunwale | cfca258 | 2016-10-19 09:53:25 -0700 | [diff] [blame] | 77 | private final String mStringName; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 78 | SurfaceSession mSurfaceSession; |
Wale Ogunwale | cfca258 | 2016-10-19 09:53:25 -0700 | [diff] [blame] | 79 | private int mNumWindow = 0; |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 80 | // Set of visible application overlay window surfaces connected to this session. |
Riddle Hsu | ccf0940 | 2019-08-13 00:33:06 +0800 | [diff] [blame] | 81 | private final ArraySet<WindowSurfaceController> mAppOverlaySurfaces = new ArraySet<>(); |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 82 | // Set of visible alert window surfaces connected to this session. |
Riddle Hsu | ccf0940 | 2019-08-13 00:33:06 +0800 | [diff] [blame] | 83 | private final ArraySet<WindowSurfaceController> mAlertWindowSurfaces = new ArraySet<>(); |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 84 | private final DragDropController mDragDropController; |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 85 | final boolean mCanAddInternalSystemWindow; |
Wale Ogunwale | 01ad434 | 2017-06-30 07:07:01 -0700 | [diff] [blame] | 86 | final boolean mCanHideNonSystemOverlayWindows; |
Jorim Jaggi | f12ec0f | 2017-08-23 16:14:10 +0200 | [diff] [blame] | 87 | final boolean mCanAcquireSleepToken; |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 88 | private AlertWindowNotification mAlertWindowNotification; |
Wale Ogunwale | a10fc7e | 2017-04-06 07:09:51 -0700 | [diff] [blame] | 89 | private boolean mShowingAlertWindowNotificationAllowed; |
Wale Ogunwale | cfca258 | 2016-10-19 09:53:25 -0700 | [diff] [blame] | 90 | private boolean mClientDead = false; |
| 91 | private float mLastReportedAnimatorScale; |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 92 | private String mPackageName; |
Wale Ogunwale | 4958ad2 | 2017-06-22 09:08:14 -0700 | [diff] [blame] | 93 | private String mRelayoutTag; |
Tiger Huang | 57ea97e | 2020-05-08 19:39:18 +0800 | [diff] [blame] | 94 | private final InsetsSourceControl[] mDummyControls = new InsetsSourceControl[0]; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 95 | |
Yohei Yukawa | a71bb25 | 2018-09-19 19:21:24 -0700 | [diff] [blame] | 96 | public Session(WindowManagerService service, IWindowSessionCallback callback) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 97 | mService = service; |
Dianne Hackborn | eb94fa7 | 2014-06-03 17:48:12 -0700 | [diff] [blame] | 98 | mCallback = callback; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 99 | mUid = Binder.getCallingUid(); |
| 100 | mPid = Binder.getCallingPid(); |
Dianne Hackborn | eb94fa7 | 2014-06-03 17:48:12 -0700 | [diff] [blame] | 101 | mLastReportedAnimatorScale = service.getCurrentAnimatorScale(); |
Wale Ogunwale | 5aa8683 | 2017-02-28 10:40:27 -0800 | [diff] [blame] | 102 | mCanAddInternalSystemWindow = service.mContext.checkCallingOrSelfPermission( |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 103 | INTERNAL_SYSTEM_WINDOW) == PERMISSION_GRANTED; |
Wale Ogunwale | 01ad434 | 2017-06-30 07:07:01 -0700 | [diff] [blame] | 104 | mCanHideNonSystemOverlayWindows = service.mContext.checkCallingOrSelfPermission( |
| 105 | HIDE_NON_SYSTEM_OVERLAY_WINDOWS) == PERMISSION_GRANTED; |
Jorim Jaggi | f12ec0f | 2017-08-23 16:14:10 +0200 | [diff] [blame] | 106 | mCanAcquireSleepToken = service.mContext.checkCallingOrSelfPermission(DEVICE_POWER) |
| 107 | == PERMISSION_GRANTED; |
Wale Ogunwale | a10fc7e | 2017-04-06 07:09:51 -0700 | [diff] [blame] | 108 | mShowingAlertWindowNotificationAllowed = mService.mShowAlertWindowNotifications; |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 109 | mDragDropController = mService.mDragDropController; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 110 | StringBuilder sb = new StringBuilder(); |
| 111 | sb.append("Session{"); |
| 112 | sb.append(Integer.toHexString(System.identityHashCode(this))); |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 113 | sb.append(" "); |
| 114 | sb.append(mPid); |
| 115 | if (mUid < Process.FIRST_APPLICATION_UID) { |
| 116 | sb.append(":"); |
| 117 | sb.append(mUid); |
| 118 | } else { |
| 119 | sb.append(":u"); |
| 120 | sb.append(UserHandle.getUserId(mUid)); |
| 121 | sb.append('a'); |
| 122 | sb.append(UserHandle.getAppId(mUid)); |
| 123 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 124 | sb.append("}"); |
| 125 | mStringName = sb.toString(); |
| 126 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 127 | try { |
Yohei Yukawa | a71bb25 | 2018-09-19 19:21:24 -0700 | [diff] [blame] | 128 | mCallback.asBinder().linkToDeath(this, 0); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 129 | } catch (RemoteException e) { |
| 130 | // The caller has died, so we can just forget about this. |
Yohei Yukawa | a71bb25 | 2018-09-19 19:21:24 -0700 | [diff] [blame] | 131 | // Hmmm, should we call killSessionLocked()?? |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 132 | } |
| 133 | } |
| 134 | |
| 135 | @Override |
| 136 | public boolean onTransact(int code, Parcel data, Parcel reply, int flags) |
| 137 | throws RemoteException { |
| 138 | try { |
| 139 | return super.onTransact(code, data, reply, flags); |
| 140 | } catch (RuntimeException e) { |
| 141 | // Log all 'real' exceptions thrown to the caller |
| 142 | if (!(e instanceof SecurityException)) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 143 | Slog.wtf(TAG_WM, "Window Session Crash", e); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 144 | } |
| 145 | throw e; |
| 146 | } |
| 147 | } |
| 148 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 149 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 150 | public void binderDied() { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 151 | synchronized (mService.mGlobalLock) { |
Yohei Yukawa | a71bb25 | 2018-09-19 19:21:24 -0700 | [diff] [blame] | 152 | mCallback.asBinder().unlinkToDeath(this, 0); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 153 | mClientDead = true; |
| 154 | killSessionLocked(); |
| 155 | } |
| 156 | } |
| 157 | |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 158 | @Override |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 159 | public int addToDisplay(IWindow window, int seq, WindowManager.LayoutParams attrs, |
Adrian Roos | 9e370f2 | 2018-03-06 18:19:45 +0100 | [diff] [blame] | 160 | int viewVisibility, int displayId, Rect outFrame, Rect outContentInsets, |
Jorim Jaggi | f081f06 | 2019-10-24 16:24:54 +0200 | [diff] [blame] | 161 | Rect outStableInsets, |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 162 | DisplayCutout.ParcelableWrapper outDisplayCutout, InputChannel outInputChannel, |
Tiger Huang | 0426a33 | 2020-03-29 01:17:08 +0800 | [diff] [blame] | 163 | InsetsState outInsetsState, InsetsSourceControl[] outActiveControls) { |
Adrian Roos | 9e370f2 | 2018-03-06 18:19:45 +0100 | [diff] [blame] | 164 | return mService.addWindow(this, window, seq, attrs, viewVisibility, displayId, outFrame, |
Jorim Jaggi | f081f06 | 2019-10-24 16:24:54 +0200 | [diff] [blame] | 165 | outContentInsets, outStableInsets, outDisplayCutout, outInputChannel, |
wilsonshih | d0fc2ca | 2020-03-18 22:41:55 +0800 | [diff] [blame] | 166 | outInsetsState, outActiveControls, UserHandle.getUserId(mUid)); |
| 167 | } |
| 168 | |
| 169 | |
| 170 | @Override |
| 171 | public int addToDisplayAsUser(IWindow window, int seq, WindowManager.LayoutParams attrs, |
| 172 | int viewVisibility, int displayId, int userId, Rect outFrame, |
| 173 | Rect outContentInsets, Rect outStableInsets, |
| 174 | DisplayCutout.ParcelableWrapper outDisplayCutout, InputChannel outInputChannel, |
| 175 | InsetsState outInsetsState, InsetsSourceControl[] outActiveControls) { |
| 176 | return mService.addWindow(this, window, seq, attrs, viewVisibility, displayId, outFrame, |
| 177 | outContentInsets, outStableInsets, outDisplayCutout, outInputChannel, |
| 178 | outInsetsState, outActiveControls, userId); |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | @Override |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 182 | public int addToDisplayWithoutInputChannel(IWindow window, int seq, WindowManager.LayoutParams attrs, |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 183 | int viewVisibility, int displayId, Rect outContentInsets, Rect outStableInsets, |
| 184 | InsetsState outInsetsState) { |
Craig Mautner | 6881a10 | 2012-07-27 13:04:51 -0700 | [diff] [blame] | 185 | return mService.addWindow(this, window, seq, attrs, viewVisibility, displayId, |
Jorim Jaggi | f081f06 | 2019-10-24 16:24:54 +0200 | [diff] [blame] | 186 | new Rect() /* outFrame */, outContentInsets, outStableInsets, |
Jorim Jaggi | f96c90a | 2018-09-26 16:55:15 +0200 | [diff] [blame] | 187 | new DisplayCutout.ParcelableWrapper() /* cutout */, null /* outInputChannel */, |
Tiger Huang | 57ea97e | 2020-05-08 19:39:18 +0800 | [diff] [blame] | 188 | outInsetsState, mDummyControls, UserHandle.getUserId(mUid)); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 189 | } |
| 190 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 191 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 192 | public void remove(IWindow window) { |
| 193 | mService.removeWindow(this, window); |
| 194 | } |
| 195 | |
Rob Carr | 64e516f | 2015-10-29 00:20:45 +0000 | [diff] [blame] | 196 | @Override |
Robert Carr | 77bdfb5 | 2016-05-02 18:18:31 -0700 | [diff] [blame] | 197 | public void prepareToReplaceWindows(IBinder appToken, boolean childrenOnly) { |
Wale Ogunwale | 9bc4773 | 2016-08-10 14:44:22 -0700 | [diff] [blame] | 198 | mService.setWillReplaceWindows(appToken, childrenOnly); |
Robert Carr | 23fa16b | 2016-01-13 13:19:58 -0800 | [diff] [blame] | 199 | } |
| 200 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 201 | @Override |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 202 | public int relayout(IWindow window, int seq, WindowManager.LayoutParams attrs, |
chaviw | be43ac8 | 2018-04-04 15:14:49 -0700 | [diff] [blame] | 203 | int requestedWidth, int requestedHeight, int viewFlags, int flags, long frameNumber, |
Jorim Jaggi | f081f06 | 2019-10-24 16:24:54 +0200 | [diff] [blame] | 204 | Rect outFrame, Rect outContentInsets, Rect outVisibleInsets, |
| 205 | Rect outStableInsets, Rect outBackdropFrame, |
chaviw | be43ac8 | 2018-04-04 15:14:49 -0700 | [diff] [blame] | 206 | DisplayCutout.ParcelableWrapper cutout, MergedConfiguration mergedConfiguration, |
Valerie Hau | 3036055 | 2020-01-14 16:12:01 -0800 | [diff] [blame] | 207 | SurfaceControl outSurfaceControl, InsetsState outInsetsState, |
Tiger Huang | 0426a33 | 2020-03-29 01:17:08 +0800 | [diff] [blame] | 208 | InsetsSourceControl[] outActiveControls, Point outSurfaceSize, |
| 209 | SurfaceControl outBLASTSurfaceControl) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 210 | if (false) Slog.d(TAG_WM, ">>>>>> ENTERED relayout from " |
Dianne Hackborn | b961cd2 | 2011-06-21 12:13:37 -0700 | [diff] [blame] | 211 | + Binder.getCallingPid()); |
Wale Ogunwale | 4958ad2 | 2017-06-22 09:08:14 -0700 | [diff] [blame] | 212 | Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, mRelayoutTag); |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 213 | int res = mService.relayoutWindow(this, window, seq, attrs, |
chaviw | be43ac8 | 2018-04-04 15:14:49 -0700 | [diff] [blame] | 214 | requestedWidth, requestedHeight, viewFlags, flags, frameNumber, |
Jorim Jaggi | f081f06 | 2019-10-24 16:24:54 +0200 | [diff] [blame] | 215 | outFrame, outContentInsets, outVisibleInsets, |
| 216 | outStableInsets, outBackdropFrame, cutout, |
Tiger Huang | 0426a33 | 2020-03-29 01:17:08 +0800 | [diff] [blame] | 217 | mergedConfiguration, outSurfaceControl, outInsetsState, outActiveControls, |
| 218 | outSurfaceSize, outBLASTSurfaceControl); |
Wale Ogunwale | 4958ad2 | 2017-06-22 09:08:14 -0700 | [diff] [blame] | 219 | Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 220 | if (false) Slog.d(TAG_WM, "<<<<<< EXITING relayout to " |
Dianne Hackborn | b961cd2 | 2011-06-21 12:13:37 -0700 | [diff] [blame] | 221 | + Binder.getCallingPid()); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 222 | return res; |
| 223 | } |
| 224 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 225 | @Override |
Dianne Hackborn | 6482517 | 2011-03-02 21:32:58 -0800 | [diff] [blame] | 226 | public boolean outOfMemory(IWindow window) { |
| 227 | return mService.outOfMemoryWindow(this, window); |
| 228 | } |
| 229 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 230 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 231 | public void setTransparentRegion(IWindow window, Region region) { |
| 232 | mService.setTransparentRegionWindow(this, window, region); |
| 233 | } |
| 234 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 235 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 236 | public void setInsets(IWindow window, int touchableInsets, |
| 237 | Rect contentInsets, Rect visibleInsets, Region touchableArea) { |
| 238 | mService.setInsetsWindow(this, window, touchableInsets, contentInsets, |
| 239 | visibleInsets, touchableArea); |
| 240 | } |
| 241 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 242 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 243 | public void getDisplayFrame(IWindow window, Rect outDisplayFrame) { |
| 244 | mService.getWindowDisplayFrame(this, window, outDisplayFrame); |
| 245 | } |
| 246 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 247 | @Override |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 248 | public void finishDrawing(IWindow window, |
| 249 | @Nullable SurfaceControl.Transaction postDrawTransaction) { |
Adam Pardyl | 8c2d19c | 2019-09-16 17:15:38 +0200 | [diff] [blame] | 250 | if (DEBUG) Slog.v(TAG_WM, "IWindow finishDrawing called for " + window); |
Vishnu Nair | f7645aa | 2019-06-18 11:14:01 -0700 | [diff] [blame] | 251 | mService.finishDrawingWindow(this, window, postDrawTransaction); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 252 | } |
| 253 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 254 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 255 | public void setInTouchMode(boolean mode) { |
Arthur Hung | 6d1b7c5 | 2020-01-21 18:35:14 +0800 | [diff] [blame] | 256 | mService.setInTouchMode(mode); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 257 | } |
| 258 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 259 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 260 | public boolean getInTouchMode() { |
Arthur Hung | 6d1b7c5 | 2020-01-21 18:35:14 +0800 | [diff] [blame] | 261 | return mService.getInTouchMode(); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 262 | } |
| 263 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 264 | @Override |
Arthur Hung | a4c5206 | 2019-02-19 11:31:44 +0800 | [diff] [blame] | 265 | public boolean performHapticFeedback(int effectId, boolean always) { |
| 266 | long ident = Binder.clearCallingIdentity(); |
| 267 | try { |
| 268 | return mService.mPolicy.performHapticFeedback(mUid, mPackageName, |
Alexey Kuzmin | e1f06b8 | 2018-06-20 17:48:43 +0100 | [diff] [blame] | 269 | effectId, always, null); |
Arthur Hung | a4c5206 | 2019-02-19 11:31:44 +0800 | [diff] [blame] | 270 | } finally { |
| 271 | Binder.restoreCallingIdentity(ident); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 272 | } |
| 273 | } |
| 274 | |
| 275 | /* Drag/drop */ |
Daichi Hirono | fabca09 | 2017-12-19 15:02:50 +0900 | [diff] [blame] | 276 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 277 | @Override |
Daichi Hirono | fabca09 | 2017-12-19 15:02:50 +0900 | [diff] [blame] | 278 | public IBinder performDrag(IWindow window, int flags, SurfaceControl surface, int touchSource, |
| 279 | float touchX, float touchY, float thumbCenterX, float thumbCenterY, ClipData data) { |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 280 | final long ident = Binder.clearCallingIdentity(); |
| 281 | try { |
Vishnu Nair | 0e7536c | 2019-11-07 14:18:47 -0800 | [diff] [blame] | 282 | return mDragDropController.performDrag(mSurfaceSession, mPid, mUid, window, |
Daichi Hirono | fabca09 | 2017-12-19 15:02:50 +0900 | [diff] [blame] | 283 | flags, surface, touchSource, touchX, touchY, thumbCenterX, thumbCenterY, data); |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 284 | } finally { |
| 285 | Binder.restoreCallingIdentity(ident); |
| 286 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 287 | } |
| 288 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 289 | @Override |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 290 | public void reportDropResult(IWindow window, boolean consumed) { |
| 291 | final long ident = Binder.clearCallingIdentity(); |
| 292 | try { |
Daichi Hirono | 58e25e1 | 2017-10-25 15:48:08 +0900 | [diff] [blame] | 293 | mDragDropController.reportDropResult(window, consumed); |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 294 | } finally { |
| 295 | Binder.restoreCallingIdentity(ident); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 296 | } |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 297 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 298 | |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 299 | @Override |
Daichi Hirono | 3e9d510 | 2019-04-15 15:58:11 +0900 | [diff] [blame] | 300 | public void cancelDragAndDrop(IBinder dragToken, boolean skipAnimation) { |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 301 | final long ident = Binder.clearCallingIdentity(); |
| 302 | try { |
Daichi Hirono | 3e9d510 | 2019-04-15 15:58:11 +0900 | [diff] [blame] | 303 | mDragDropController.cancelDragAndDrop(dragToken, skipAnimation); |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 304 | } finally { |
| 305 | Binder.restoreCallingIdentity(ident); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 306 | } |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 307 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 308 | |
Daichi Hirono | df5cf62 | 2017-09-11 14:59:26 +0900 | [diff] [blame] | 309 | @Override |
| 310 | public void dragRecipientEntered(IWindow window) { |
| 311 | mDragDropController.dragRecipientEntered(window); |
| 312 | } |
| 313 | |
| 314 | @Override |
| 315 | public void dragRecipientExited(IWindow window) { |
| 316 | mDragDropController.dragRecipientExited(window); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 317 | } |
| 318 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 319 | @Override |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 320 | public boolean startMovingTask(IWindow window, float startX, float startY) { |
Filip Gruszczynski | 0bd180d | 2015-12-07 15:43:52 -0800 | [diff] [blame] | 321 | if (DEBUG_TASK_POSITIONING) Slog.d( |
| 322 | TAG_WM, "startMovingTask: {" + startX + "," + startY + "}"); |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 323 | |
Wale Ogunwale | 09e1b8d | 2016-02-23 10:38:35 -0800 | [diff] [blame] | 324 | long ident = Binder.clearCallingIdentity(); |
| 325 | try { |
Daichi Hirono | 34fb731 | 2017-12-04 10:00:24 +0900 | [diff] [blame] | 326 | return mService.mTaskPositioningController.startMovingTask(window, startX, startY); |
Wale Ogunwale | 09e1b8d | 2016-02-23 10:38:35 -0800 | [diff] [blame] | 327 | } finally { |
| 328 | Binder.restoreCallingIdentity(ident); |
| 329 | } |
Chong Zhang | 8e89b31 | 2015-09-09 15:09:30 -0700 | [diff] [blame] | 330 | } |
| 331 | |
Adrian Roos | 4ffc897 | 2019-02-07 20:45:11 +0100 | [diff] [blame] | 332 | @Override |
yj81.kwon | 19585ff | 2019-04-23 18:53:57 -0700 | [diff] [blame] | 333 | public void finishMovingTask(IWindow window) { |
| 334 | if (DEBUG_TASK_POSITIONING) Slog.d(TAG_WM, "finishMovingTask"); |
| 335 | |
| 336 | long ident = Binder.clearCallingIdentity(); |
| 337 | try { |
| 338 | mService.mTaskPositioningController.finishTaskPositioning(window); |
| 339 | } finally { |
| 340 | Binder.restoreCallingIdentity(ident); |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | @Override |
Adrian Roos | 4ffc897 | 2019-02-07 20:45:11 +0100 | [diff] [blame] | 345 | public void reportSystemGestureExclusionChanged(IWindow window, List<Rect> exclusionRects) { |
| 346 | long ident = Binder.clearCallingIdentity(); |
| 347 | try { |
| 348 | mService.reportSystemGestureExclusionChanged(this, window, exclusionRects); |
| 349 | } finally { |
| 350 | Binder.restoreCallingIdentity(ident); |
| 351 | } |
| 352 | } |
| 353 | |
wilsonshih | c32538e | 2018-11-07 17:27:34 +0800 | [diff] [blame] | 354 | private void actionOnWallpaper(IBinder window, |
| 355 | BiConsumer<WallpaperController, WindowState> action) { |
| 356 | final WindowState windowState = mService.windowForClientLocked(this, window, true); |
| 357 | action.accept(windowState.getDisplayContent().mWallpaperController, windowState); |
| 358 | } |
| 359 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 360 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 361 | public void setWallpaperPosition(IBinder window, float x, float y, float xStep, float yStep) { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 362 | synchronized (mService.mGlobalLock) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 363 | long ident = Binder.clearCallingIdentity(); |
| 364 | try { |
wilsonshih | c32538e | 2018-11-07 17:27:34 +0800 | [diff] [blame] | 365 | actionOnWallpaper(window, (wpController, windowState) -> |
| 366 | wpController.setWindowWallpaperPosition(windowState, x, y, xStep, yStep)); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 367 | } finally { |
| 368 | Binder.restoreCallingIdentity(ident); |
| 369 | } |
| 370 | } |
| 371 | } |
| 372 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 373 | @Override |
Lucas Dupin | 13f4b8a | 2020-02-19 13:41:52 -0800 | [diff] [blame] | 374 | public void setWallpaperZoomOut(IBinder window, float zoom) { |
| 375 | if (Float.compare(0f, zoom) > 0 || Float.compare(1f, zoom) < 0 || Float.isNaN(zoom)) { |
| 376 | throw new IllegalArgumentException("Zoom must be a valid float between 0 and 1: " |
| 377 | + zoom); |
| 378 | } |
| 379 | synchronized (mService.mGlobalLock) { |
| 380 | long ident = Binder.clearCallingIdentity(); |
| 381 | try { |
| 382 | actionOnWallpaper(window, (wpController, windowState) -> |
| 383 | wpController.setWallpaperZoomOut(windowState, zoom)); |
| 384 | } finally { |
| 385 | Binder.restoreCallingIdentity(ident); |
| 386 | } |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | @Override |
| 391 | public void setShouldZoomOutWallpaper(IBinder window, boolean shouldZoom) { |
| 392 | synchronized (mService.mGlobalLock) { |
| 393 | actionOnWallpaper(window, (wpController, windowState) -> |
| 394 | wpController.setShouldZoomOutWallpaper(windowState, shouldZoom)); |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 399 | public void wallpaperOffsetsComplete(IBinder window) { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 400 | synchronized (mService.mGlobalLock) { |
wilsonshih | c32538e | 2018-11-07 17:27:34 +0800 | [diff] [blame] | 401 | actionOnWallpaper(window, (wpController, windowState) -> |
| 402 | wpController.wallpaperOffsetsComplete(window)); |
Wale Ogunwale | e8069dc | 2015-08-18 09:52:01 -0700 | [diff] [blame] | 403 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 404 | } |
| 405 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 406 | @Override |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 407 | public void setWallpaperDisplayOffset(IBinder window, int x, int y) { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 408 | synchronized (mService.mGlobalLock) { |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 409 | long ident = Binder.clearCallingIdentity(); |
| 410 | try { |
wilsonshih | c32538e | 2018-11-07 17:27:34 +0800 | [diff] [blame] | 411 | actionOnWallpaper(window, (wpController, windowState) -> |
| 412 | wpController.setWindowWallpaperDisplayOffset(windowState, x, y)); |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 413 | } finally { |
| 414 | Binder.restoreCallingIdentity(ident); |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 419 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 420 | public Bundle sendWallpaperCommand(IBinder window, String action, int x, int y, |
| 421 | int z, Bundle extras, boolean sync) { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 422 | synchronized (mService.mGlobalLock) { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 423 | long ident = Binder.clearCallingIdentity(); |
| 424 | try { |
wilsonshih | c32538e | 2018-11-07 17:27:34 +0800 | [diff] [blame] | 425 | final WindowState windowState = mService.windowForClientLocked(this, window, true); |
| 426 | return windowState.getDisplayContent().mWallpaperController |
| 427 | .sendWindowWallpaperCommand(windowState, action, x, y, z, extras, sync); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 428 | } finally { |
| 429 | Binder.restoreCallingIdentity(ident); |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 434 | @Override |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 435 | public void wallpaperCommandComplete(IBinder window, Bundle result) { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 436 | synchronized (mService.mGlobalLock) { |
wilsonshih | c32538e | 2018-11-07 17:27:34 +0800 | [diff] [blame] | 437 | actionOnWallpaper(window, (wpController, windowState) -> |
| 438 | wpController.wallpaperCommandComplete(window)); |
Wale Ogunwale | e8069dc | 2015-08-18 09:52:01 -0700 | [diff] [blame] | 439 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 440 | } |
| 441 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 442 | @Override |
Svetoslav | f7174e8 | 2014-06-12 11:29:35 -0700 | [diff] [blame] | 443 | public void onRectangleOnScreenRequested(IBinder token, Rect rectangle) { |
Wale Ogunwale | db485de | 2018-10-29 09:47:07 -0700 | [diff] [blame] | 444 | synchronized (mService.mGlobalLock) { |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 445 | final long identity = Binder.clearCallingIdentity(); |
| 446 | try { |
Svetoslav | f7174e8 | 2014-06-12 11:29:35 -0700 | [diff] [blame] | 447 | mService.onRectangleOnScreenRequested(token, rectangle); |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 448 | } finally { |
| 449 | Binder.restoreCallingIdentity(identity); |
| 450 | } |
| 451 | } |
| 452 | } |
| 453 | |
Andrew Scull | 26f830d | 2017-05-19 12:16:10 +0100 | [diff] [blame] | 454 | @Override |
Dianne Hackborn | e3f23a3 | 2013-03-01 13:25:35 -0800 | [diff] [blame] | 455 | public IWindowId getWindowId(IBinder window) { |
| 456 | return mService.getWindowId(window); |
| 457 | } |
| 458 | |
Jeff Brown | c2932a1 | 2014-11-20 18:04:05 -0800 | [diff] [blame] | 459 | @Override |
| 460 | public void pokeDrawLock(IBinder window) { |
| 461 | final long identity = Binder.clearCallingIdentity(); |
| 462 | try { |
| 463 | mService.pokeDrawLock(this, window); |
| 464 | } finally { |
| 465 | Binder.restoreCallingIdentity(identity); |
| 466 | } |
| 467 | } |
| 468 | |
Vladislav Kaznacheev | 989b58a | 2016-02-10 12:19:33 -0800 | [diff] [blame] | 469 | @Override |
| 470 | public void updatePointerIcon(IWindow window) { |
| 471 | final long identity = Binder.clearCallingIdentity(); |
| 472 | try { |
| 473 | mService.updatePointerIcon(window); |
| 474 | } finally { |
| 475 | Binder.restoreCallingIdentity(identity); |
| 476 | } |
| 477 | } |
| 478 | |
Andrii Kulian | 4b6599e | 2018-01-15 17:24:08 -0800 | [diff] [blame] | 479 | @Override |
Tiger Huang | d8ec938 | 2019-04-18 14:35:09 -0700 | [diff] [blame] | 480 | public void reparentDisplayContent(IWindow window, SurfaceControl sc, int displayId) { |
| 481 | mService.reparentDisplayContent(window, sc, displayId); |
| 482 | } |
| 483 | |
| 484 | @Override |
| 485 | public void updateDisplayContentLocation(IWindow window, int x, int y, int displayId) { |
| 486 | mService.updateDisplayContentLocation(window, x, y, displayId); |
| 487 | } |
| 488 | |
| 489 | @Override |
chaviw | aa0d74e | 2019-12-26 14:13:40 -0800 | [diff] [blame] | 490 | public void updateTapExcludeRegion(IWindow window, Region region) { |
Andrii Kulian | 4b6599e | 2018-01-15 17:24:08 -0800 | [diff] [blame] | 491 | final long identity = Binder.clearCallingIdentity(); |
| 492 | try { |
chaviw | aa0d74e | 2019-12-26 14:13:40 -0800 | [diff] [blame] | 493 | mService.updateTapExcludeRegion(window, region); |
Andrii Kulian | 4b6599e | 2018-01-15 17:24:08 -0800 | [diff] [blame] | 494 | } finally { |
| 495 | Binder.restoreCallingIdentity(identity); |
| 496 | } |
| 497 | } |
| 498 | |
Jorim Jaggi | e35c059 | 2018-11-06 16:21:08 +0100 | [diff] [blame] | 499 | @Override |
| 500 | public void insetsModified(IWindow window, InsetsState state) { |
Tiger Huang | dda14a7 | 2019-01-10 17:20:27 +0800 | [diff] [blame] | 501 | synchronized (mService.mGlobalLock) { |
Jorim Jaggi | e35c059 | 2018-11-06 16:21:08 +0100 | [diff] [blame] | 502 | final WindowState windowState = mService.windowForClientLocked(this, window, |
| 503 | false /* throwOnError */); |
| 504 | if (windowState != null) { |
Jorim Jaggi | 0dd0cf9 | 2019-12-27 15:17:44 +0100 | [diff] [blame] | 505 | windowState.updateRequestedInsetsState(state); |
Jorim Jaggi | 956ca41 | 2019-01-07 14:49:14 +0100 | [diff] [blame] | 506 | windowState.getDisplayContent().getInsetsPolicy().onInsetsModified( |
Jorim Jaggi | e35c059 | 2018-11-06 16:21:08 +0100 | [diff] [blame] | 507 | windowState, state); |
| 508 | } |
| 509 | } |
| 510 | } |
| 511 | |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 512 | void windowAddedLocked(String packageName) { |
| 513 | mPackageName = packageName; |
Wale Ogunwale | 4958ad2 | 2017-06-22 09:08:14 -0700 | [diff] [blame] | 514 | mRelayoutTag = "relayoutWindow: " + mPackageName; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 515 | if (mSurfaceSession == null) { |
Adam Pardyl | 8c2d19c | 2019-09-16 17:15:38 +0200 | [diff] [blame] | 516 | if (DEBUG) { |
| 517 | Slog.v(TAG_WM, "First window added to " + this + ", creating SurfaceSession"); |
| 518 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 519 | mSurfaceSession = new SurfaceSession(); |
Adrian Roos | b125e0b | 2019-10-02 14:55:14 +0200 | [diff] [blame] | 520 | ProtoLog.i(WM_SHOW_TRANSACTIONS, " NEW SURFACE SESSION %s", mSurfaceSession); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 521 | mService.mSessions.add(this); |
Dianne Hackborn | eb94fa7 | 2014-06-03 17:48:12 -0700 | [diff] [blame] | 522 | if (mLastReportedAnimatorScale != mService.getCurrentAnimatorScale()) { |
| 523 | mService.dispatchNewAnimatorScaleLocked(this); |
| 524 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 525 | } |
| 526 | mNumWindow++; |
| 527 | } |
| 528 | |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 529 | void windowRemovedLocked() { |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 530 | mNumWindow--; |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 531 | killSessionLocked(); |
| 532 | } |
| 533 | |
| 534 | |
| 535 | void onWindowSurfaceVisibilityChanged(WindowSurfaceController surfaceController, |
| 536 | boolean visible, int type) { |
| 537 | |
| 538 | if (!isSystemAlertWindowType(type)) { |
| 539 | return; |
| 540 | } |
| 541 | |
| 542 | boolean changed; |
| 543 | |
| 544 | if (!mCanAddInternalSystemWindow) { |
| 545 | // We want to track non-system signature apps adding alert windows so we can post an |
| 546 | // on-going notification for the user to control their visibility. |
| 547 | if (visible) { |
| 548 | changed = mAlertWindowSurfaces.add(surfaceController); |
Chenjie Yu | 08d6d72 | 2018-02-28 10:19:54 -0800 | [diff] [blame] | 549 | MetricsLoggerWrapper.logAppOverlayEnter(mUid, mPackageName, changed, type, true); |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 550 | } else { |
| 551 | changed = mAlertWindowSurfaces.remove(surfaceController); |
Chenjie Yu | 08d6d72 | 2018-02-28 10:19:54 -0800 | [diff] [blame] | 552 | MetricsLoggerWrapper.logAppOverlayExit(mUid, mPackageName, changed, type, true); |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | if (changed) { |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 556 | if (mAlertWindowSurfaces.isEmpty()) { |
| 557 | cancelAlertWindowNotification(); |
| 558 | } else if (mAlertWindowNotification == null){ |
Wale Ogunwale | d76881e | 2017-03-10 13:17:56 -0800 | [diff] [blame] | 559 | mAlertWindowNotification = new AlertWindowNotification(mService, mPackageName); |
Wale Ogunwale | a10fc7e | 2017-04-06 07:09:51 -0700 | [diff] [blame] | 560 | if (mShowingAlertWindowNotificationAllowed) { |
| 561 | mAlertWindowNotification.post(); |
| 562 | } |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 563 | } |
Wale Ogunwale | d993a57 | 2017-02-05 13:52:09 -0800 | [diff] [blame] | 564 | } |
| 565 | } |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 566 | |
| 567 | if (type != TYPE_APPLICATION_OVERLAY) { |
| 568 | return; |
| 569 | } |
| 570 | |
| 571 | if (visible) { |
| 572 | changed = mAppOverlaySurfaces.add(surfaceController); |
Chenjie Yu | 08d6d72 | 2018-02-28 10:19:54 -0800 | [diff] [blame] | 573 | MetricsLoggerWrapper.logAppOverlayEnter(mUid, mPackageName, changed, type, false); |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 574 | } else { |
| 575 | changed = mAppOverlaySurfaces.remove(surfaceController); |
Chenjie Yu | 08d6d72 | 2018-02-28 10:19:54 -0800 | [diff] [blame] | 576 | MetricsLoggerWrapper.logAppOverlayExit(mUid, mPackageName, changed, type, false); |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | if (changed) { |
| 580 | // Notify activity manager of changes to app overlay windows so it can adjust the |
| 581 | // importance score for the process. |
| 582 | setHasOverlayUi(!mAppOverlaySurfaces.isEmpty()); |
| 583 | } |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 584 | } |
| 585 | |
Wale Ogunwale | a10fc7e | 2017-04-06 07:09:51 -0700 | [diff] [blame] | 586 | void setShowingAlertWindowNotificationAllowed(boolean allowed) { |
| 587 | mShowingAlertWindowNotificationAllowed = allowed; |
| 588 | if (mAlertWindowNotification != null) { |
| 589 | if (allowed) { |
| 590 | mAlertWindowNotification.post(); |
| 591 | } else { |
Wale Ogunwale | 6c8f2e4 | 2018-02-01 09:07:34 -0800 | [diff] [blame] | 592 | mAlertWindowNotification.cancel(false /* deleteChannel */); |
Wale Ogunwale | a10fc7e | 2017-04-06 07:09:51 -0700 | [diff] [blame] | 593 | } |
| 594 | } |
| 595 | } |
| 596 | |
Wale Ogunwale | d993a57 | 2017-02-05 13:52:09 -0800 | [diff] [blame] | 597 | private void killSessionLocked() { |
| 598 | if (mNumWindow > 0 || !mClientDead) { |
| 599 | return; |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 600 | } |
Wale Ogunwale | d993a57 | 2017-02-05 13:52:09 -0800 | [diff] [blame] | 601 | |
| 602 | mService.mSessions.remove(this); |
| 603 | if (mSurfaceSession == null) { |
| 604 | return; |
| 605 | } |
| 606 | |
Adam Pardyl | 8c2d19c | 2019-09-16 17:15:38 +0200 | [diff] [blame] | 607 | if (DEBUG) { |
| 608 | Slog.v(TAG_WM, "Last window removed from " + this |
| 609 | + ", destroying " + mSurfaceSession); |
| 610 | } |
Adrian Roos | b125e0b | 2019-10-02 14:55:14 +0200 | [diff] [blame] | 611 | ProtoLog.i(WM_SHOW_TRANSACTIONS, " KILL SURFACE SESSION %s", mSurfaceSession); |
Wale Ogunwale | d993a57 | 2017-02-05 13:52:09 -0800 | [diff] [blame] | 612 | try { |
| 613 | mSurfaceSession.kill(); |
| 614 | } catch (Exception e) { |
| 615 | Slog.w(TAG_WM, "Exception thrown when killing surface session " + mSurfaceSession |
| 616 | + " in session " + this + ": " + e.toString()); |
| 617 | } |
| 618 | mSurfaceSession = null; |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 619 | mAlertWindowSurfaces.clear(); |
| 620 | mAppOverlaySurfaces.clear(); |
Wale Ogunwale | d993a57 | 2017-02-05 13:52:09 -0800 | [diff] [blame] | 621 | setHasOverlayUi(false); |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 622 | cancelAlertWindowNotification(); |
Wale Ogunwale | d993a57 | 2017-02-05 13:52:09 -0800 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | private void setHasOverlayUi(boolean hasOverlayUi) { |
| 626 | 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] | 627 | } |
| 628 | |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 629 | private void cancelAlertWindowNotification() { |
| 630 | if (mAlertWindowNotification == null) { |
| 631 | return; |
| 632 | } |
Wale Ogunwale | 6c8f2e4 | 2018-02-01 09:07:34 -0800 | [diff] [blame] | 633 | mAlertWindowNotification.cancel(true /* deleteChannel */); |
Wale Ogunwale | 387e4c6 | 2017-02-13 09:50:02 -0800 | [diff] [blame] | 634 | mAlertWindowNotification = null; |
| 635 | } |
| 636 | |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 637 | void dump(PrintWriter pw, String prefix) { |
| 638 | pw.print(prefix); pw.print("mNumWindow="); pw.print(mNumWindow); |
Wale Ogunwale | 5aa8683 | 2017-02-28 10:40:27 -0800 | [diff] [blame] | 639 | pw.print(" mCanAddInternalSystemWindow="); pw.print(mCanAddInternalSystemWindow); |
Wale Ogunwale | 943002b | 2017-02-15 19:34:01 -0800 | [diff] [blame] | 640 | pw.print(" mAppOverlaySurfaces="); pw.print(mAppOverlaySurfaces); |
| 641 | pw.print(" mAlertWindowSurfaces="); pw.print(mAlertWindowSurfaces); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 642 | pw.print(" mClientDead="); pw.print(mClientDead); |
| 643 | pw.print(" mSurfaceSession="); pw.println(mSurfaceSession); |
Wale Ogunwale | 4958ad2 | 2017-06-22 09:08:14 -0700 | [diff] [blame] | 644 | pw.print(prefix); pw.print("mPackageName="); pw.println(mPackageName); |
Dianne Hackborn | 6e1eb76 | 2011-02-17 16:07:28 -0800 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | @Override |
| 648 | public String toString() { |
| 649 | return mStringName; |
| 650 | } |
Robert Carr | 0e00727 | 2017-10-02 13:00:55 -0700 | [diff] [blame] | 651 | |
Riddle Hsu | ccf0940 | 2019-08-13 00:33:06 +0800 | [diff] [blame] | 652 | /** @return {@code true} if there is an alert window surface on the given display. */ |
| 653 | boolean hasAlertWindowSurfaces(DisplayContent displayContent) { |
| 654 | for (int i = mAlertWindowSurfaces.size() - 1; i >= 0; i--) { |
| 655 | final WindowSurfaceController surfaceController = mAlertWindowSurfaces.valueAt(i); |
| 656 | if (surfaceController.mAnimator.mWin.getDisplayContent() == displayContent) { |
| 657 | return true; |
| 658 | } |
| 659 | } |
| 660 | return false; |
Robert Carr | 0e00727 | 2017-10-02 13:00:55 -0700 | [diff] [blame] | 661 | } |
Robert Carr | 9d431e1 | 2018-12-17 13:11:48 -0800 | [diff] [blame] | 662 | |
Vishnu Nair | ddbd251 | 2019-11-12 14:39:43 -0800 | [diff] [blame] | 663 | @Override |
Vishnu Nair | 5cf25319 | 2019-11-07 15:33:20 -0800 | [diff] [blame] | 664 | public void grantInputChannel(int displayId, SurfaceControl surface, |
arthurhung | d3f17d7 | 2020-05-08 17:20:38 +0800 | [diff] [blame] | 665 | IWindow window, IBinder hostInputToken, int flags, int type, |
| 666 | InputChannel outInputChannel) { |
Vishnu Nair | ddbd251 | 2019-11-12 14:39:43 -0800 | [diff] [blame] | 667 | if (hostInputToken == null && !mCanAddInternalSystemWindow) { |
| 668 | // Callers without INTERNAL_SYSTEM_WINDOW permission cannot grant input channel to |
| 669 | // embedded windows without providing a host window input token |
| 670 | throw new SecurityException("Requires INTERNAL_SYSTEM_WINDOW permission"); |
| 671 | } |
| 672 | |
arthurhung | d3f17d7 | 2020-05-08 17:20:38 +0800 | [diff] [blame] | 673 | if (!mCanAddInternalSystemWindow && type != 0) { |
| 674 | Slog.w(TAG_WM, "Requires INTERNAL_SYSTEM_WINDOW permission if assign type to" |
| 675 | + " input"); |
| 676 | } |
| 677 | |
Robert Carr | 9d431e1 | 2018-12-17 13:11:48 -0800 | [diff] [blame] | 678 | final long identity = Binder.clearCallingIdentity(); |
| 679 | try { |
Evan Rosky | 680377e | 2020-01-10 19:12:10 -0800 | [diff] [blame] | 680 | mService.grantInputChannel(mUid, mPid, displayId, surface, window, hostInputToken, |
arthurhung | d3f17d7 | 2020-05-08 17:20:38 +0800 | [diff] [blame] | 681 | flags, mCanAddInternalSystemWindow ? type : 0, outInputChannel); |
Evan Rosky | 680377e | 2020-01-10 19:12:10 -0800 | [diff] [blame] | 682 | } finally { |
| 683 | Binder.restoreCallingIdentity(identity); |
| 684 | } |
| 685 | } |
| 686 | |
| 687 | @Override |
| 688 | public void updateInputChannel(IBinder channelToken, int displayId, SurfaceControl surface, |
Evan Rosky | 1283728 | 2020-04-27 19:12:25 -0700 | [diff] [blame] | 689 | int flags, Region region) { |
Evan Rosky | 680377e | 2020-01-10 19:12:10 -0800 | [diff] [blame] | 690 | final long identity = Binder.clearCallingIdentity(); |
| 691 | try { |
Evan Rosky | 1283728 | 2020-04-27 19:12:25 -0700 | [diff] [blame] | 692 | mService.updateInputChannel(channelToken, displayId, surface, flags, region); |
Robert Carr | 9d431e1 | 2018-12-17 13:11:48 -0800 | [diff] [blame] | 693 | } finally { |
| 694 | Binder.restoreCallingIdentity(identity); |
| 695 | } |
| 696 | } |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 697 | } |