Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server.display; |
| 18 | |
Andrii Kulian | fc8f82b | 2017-01-26 13:17:27 -0800 | [diff] [blame] | 19 | import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR; |
| 20 | import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY; |
| 21 | import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC; |
| 22 | import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE; |
| 23 | import static android.hardware.display.DisplayManager |
Andrii Kulian | 7211d2e | 2017-01-27 15:58:05 -0800 | [diff] [blame] | 24 | .VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD; |
Andrii Kulian | fc8f82b | 2017-01-26 13:17:27 -0800 | [diff] [blame] | 25 | |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 26 | import com.android.internal.annotations.VisibleForTesting; |
Jeff Sharkey | fe9a53b | 2017-03-31 14:08:23 -0600 | [diff] [blame] | 27 | import com.android.internal.util.DumpUtils; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 28 | import com.android.internal.util.IndentingPrintWriter; |
| 29 | |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 30 | import android.Manifest; |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 31 | import android.annotation.NonNull; |
Kenny Guy | 05ce809 | 2018-01-17 13:44:20 +0000 | [diff] [blame] | 32 | import android.annotation.Nullable; |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 33 | import android.annotation.UserIdInt; |
Kenny Guy | 29aa30e | 2017-11-30 13:43:46 +0000 | [diff] [blame] | 34 | import android.app.AppOpsManager; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 35 | import android.content.Context; |
| 36 | import android.content.pm.PackageManager; |
Kenny Guy | 22bd044 | 2017-10-26 00:15:54 +0100 | [diff] [blame] | 37 | import android.content.pm.ParceledListSlice; |
Michael Wright | eedcbf1 | 2017-08-16 23:14:54 +0100 | [diff] [blame] | 38 | import android.content.res.Resources; |
| 39 | import android.graphics.Point; |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 40 | import android.hardware.SensorManager; |
Peeyush Agarwal | cc155dd | 2018-01-10 11:51:33 +0000 | [diff] [blame] | 41 | import android.hardware.display.AmbientBrightnessDayStats; |
Kenny Guy | 22bd044 | 2017-10-26 00:15:54 +0100 | [diff] [blame] | 42 | import android.hardware.display.BrightnessChangeEvent; |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 43 | import android.hardware.display.BrightnessConfiguration; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 44 | import android.hardware.display.DisplayManagerGlobal; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 45 | import android.hardware.display.DisplayManagerInternal; |
| 46 | import android.hardware.display.DisplayViewport; |
| 47 | import android.hardware.display.DisplayManagerInternal.DisplayTransactionListener; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 48 | import android.hardware.display.IDisplayManager; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 49 | import android.hardware.display.IDisplayManagerCallback; |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 50 | import android.hardware.display.IVirtualDisplayCallback; |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 51 | import android.hardware.display.WifiDisplayStatus; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 52 | import android.hardware.input.InputManagerInternal; |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 53 | import android.media.projection.IMediaProjection; |
| 54 | import android.media.projection.IMediaProjectionManager; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 55 | import android.os.Binder; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 56 | import android.os.Handler; |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 57 | import android.os.IBinder; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 58 | import android.os.IBinder.DeathRecipient; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 59 | import android.os.Looper; |
| 60 | import android.os.Message; |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 61 | import android.os.PowerManager; |
Craig Mautner | 4504de5 | 2013-12-20 09:06:56 -0800 | [diff] [blame] | 62 | import android.os.Process; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 63 | import android.os.RemoteException; |
Dan Gittik | 7a32fba | 2018-03-28 12:19:38 +0100 | [diff] [blame^] | 64 | import android.os.ResultReceiver; |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 65 | import android.os.ServiceManager; |
Dan Gittik | 7a32fba | 2018-03-28 12:19:38 +0100 | [diff] [blame^] | 66 | import android.os.ShellCallback; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 67 | import android.os.SystemClock; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 68 | import android.os.SystemProperties; |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 69 | import android.os.Trace; |
Kenny Guy | 22bd044 | 2017-10-26 00:15:54 +0100 | [diff] [blame] | 70 | import android.os.UserHandle; |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 71 | import android.os.UserManager; |
Dan Gittik | 7a32fba | 2018-03-28 12:19:38 +0100 | [diff] [blame^] | 72 | import android.provider.Settings; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 73 | import android.text.TextUtils; |
Andrii Kulian | fb1bf69 | 2017-01-17 11:17:34 -0800 | [diff] [blame] | 74 | import android.util.IntArray; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 75 | import android.util.Slog; |
| 76 | import android.util.SparseArray; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 77 | import android.view.Display; |
| 78 | import android.view.DisplayInfo; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 79 | import android.view.Surface; |
Robert Carr | ae606b4 | 2018-02-15 15:36:23 -0800 | [diff] [blame] | 80 | import android.view.SurfaceControl; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 81 | |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 82 | import com.android.internal.util.Preconditions; |
Jorim Jaggi | ed7993b | 2017-03-28 18:50:01 +0100 | [diff] [blame] | 83 | import com.android.server.AnimationThread; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 84 | import com.android.server.DisplayThread; |
| 85 | import com.android.server.LocalServices; |
| 86 | import com.android.server.SystemService; |
Dianne Hackborn | 8d044e8 | 2013-04-30 17:24:15 -0700 | [diff] [blame] | 87 | import com.android.server.UiThread; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 88 | import com.android.server.wm.WindowManagerInternal; |
Jorim Jaggi | 21c39a7 | 2017-10-20 15:47:51 +0200 | [diff] [blame] | 89 | import com.android.server.wm.SurfaceAnimationThread; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 90 | |
| 91 | import java.io.FileDescriptor; |
| 92 | import java.io.PrintWriter; |
| 93 | import java.util.ArrayList; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 94 | import java.util.Arrays; |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 95 | import java.util.List; |
Jeff Brown | 7f3994e | 2012-12-04 14:04:28 -0800 | [diff] [blame] | 96 | import java.util.concurrent.CopyOnWriteArrayList; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 97 | |
| 98 | /** |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 99 | * Manages attached displays. |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 100 | * <p> |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 101 | * The {@link DisplayManagerService} manages the global lifecycle of displays, |
| 102 | * decides how to configure logical displays based on the physical display devices currently |
| 103 | * attached, sends notifications to the system and to applications when the state |
| 104 | * changes, and so on. |
| 105 | * </p><p> |
| 106 | * The display manager service relies on a collection of {@link DisplayAdapter} components, |
| 107 | * for discovering and configuring physical display devices attached to the system. |
| 108 | * There are separate display adapters for each manner that devices are attached: |
| 109 | * one display adapter for built-in local displays, one for simulated non-functional |
| 110 | * displays when the system is headless, one for simulated overlay displays used for |
| 111 | * development, one for wifi displays, etc. |
| 112 | * </p><p> |
| 113 | * Display adapters are only weakly coupled to the display manager service. |
| 114 | * Display adapters communicate changes in display device state to the display manager |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 115 | * service asynchronously via a {@link DisplayAdapter.Listener} registered |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 116 | * by the display manager service. This separation of concerns is important for |
| 117 | * two main reasons. First, it neatly encapsulates the responsibilities of these |
| 118 | * two classes: display adapters handle individual display devices whereas |
| 119 | * the display manager service handles the global state. Second, it eliminates |
| 120 | * the potential for deadlocks resulting from asynchronous display device discovery. |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 121 | * </p> |
| 122 | * |
| 123 | * <h3>Synchronization</h3> |
| 124 | * <p> |
| 125 | * Because the display manager may be accessed by multiple threads, the synchronization |
| 126 | * story gets a little complicated. In particular, the window manager may call into |
| 127 | * the display manager while holding a surface transaction with the expectation that |
| 128 | * it can apply changes immediately. Unfortunately, that means we can't just do |
| 129 | * everything asynchronously (*grump*). |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 130 | * </p><p> |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 131 | * To make this work, all of the objects that belong to the display manager must |
| 132 | * use the same lock. We call this lock the synchronization root and it has a unique |
| 133 | * type {@link DisplayManagerService.SyncRoot}. Methods that require this lock are |
| 134 | * named with the "Locked" suffix. |
| 135 | * </p><p> |
| 136 | * Where things get tricky is that the display manager is not allowed to make |
| 137 | * any potentially reentrant calls, especially into the window manager. We generally |
| 138 | * avoid this by making all potentially reentrant out-calls asynchronous. |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 139 | * </p> |
| 140 | */ |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 141 | public final class DisplayManagerService extends SystemService { |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 142 | private static final String TAG = "DisplayManagerService"; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 143 | private static final boolean DEBUG = false; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 144 | |
Jeff Brown | bbd28a2 | 2012-09-20 16:47:15 -0700 | [diff] [blame] | 145 | // When this system property is set to 0, WFD is forcibly disabled on boot. |
| 146 | // When this system property is set to 1, WFD is forcibly enabled on boot. |
| 147 | // Otherwise WFD is enabled according to the value of config_enableWifiDisplay. |
| 148 | private static final String FORCE_WIFI_DISPLAY_ENABLE = "persist.debug.wfd.enable"; |
| 149 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 150 | private static final long WAIT_FOR_DEFAULT_DISPLAY_TIMEOUT = 10000; |
| 151 | |
Santos Cordon | c22c563 | 2017-06-21 16:03:49 -0700 | [diff] [blame] | 152 | private static final int MSG_REGISTER_DEFAULT_DISPLAY_ADAPTERS = 1; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 153 | private static final int MSG_REGISTER_ADDITIONAL_DISPLAY_ADAPTERS = 2; |
| 154 | private static final int MSG_DELIVER_DISPLAY_EVENT = 3; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 155 | private static final int MSG_REQUEST_TRAVERSAL = 4; |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 156 | private static final int MSG_UPDATE_VIEWPORT = 5; |
Kenny Guy | 22bd044 | 2017-10-26 00:15:54 +0100 | [diff] [blame] | 157 | private static final int MSG_REGISTER_BRIGHTNESS_TRACKER = 6; |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 158 | private static final int MSG_LOAD_BRIGHTNESS_CONFIGURATION = 7; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 159 | |
Jeff Brown | b880d88 | 2014-02-10 19:47:07 -0800 | [diff] [blame] | 160 | private final Context mContext; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 161 | private final DisplayManagerHandler mHandler; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 162 | private final Handler mUiHandler; |
| 163 | private final DisplayAdapterListener mDisplayAdapterListener; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 164 | private WindowManagerInternal mWindowManagerInternal; |
| 165 | private InputManagerInternal mInputManagerInternal; |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 166 | private IMediaProjectionManager mProjectionService; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 167 | |
| 168 | // The synchronization root for the display manager. |
| 169 | // This lock guards most of the display manager's state. |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 170 | // NOTE: This is synchronized on while holding WindowManagerService.mWindowMap so never call |
| 171 | // into WindowManagerService methods that require mWindowMap while holding this unless you are |
| 172 | // very very sure that no deadlock can occur. |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 173 | private final SyncRoot mSyncRoot = new SyncRoot(); |
| 174 | |
| 175 | // True if in safe mode. |
| 176 | // This option may disable certain display adapters. |
| 177 | public boolean mSafeMode; |
| 178 | |
| 179 | // True if we are in a special boot mode where only core applications and |
| 180 | // services should be started. This option may disable certain display adapters. |
| 181 | public boolean mOnlyCore; |
| 182 | |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 183 | // True if the display manager service should pretend there is only one display |
| 184 | // and only tell applications about the existence of the default logical display. |
| 185 | // The display manager can still mirror content to secondary displays but applications |
| 186 | // cannot present unique content on those displays. |
| 187 | // Used for demonstration purposes only. |
| 188 | private final boolean mSingleDisplayDemoMode; |
| 189 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 190 | // All callback records indexed by calling process id. |
| 191 | public final SparseArray<CallbackRecord> mCallbacks = |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 192 | new SparseArray<CallbackRecord>(); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 193 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 194 | // List of all currently registered display adapters. |
| 195 | private final ArrayList<DisplayAdapter> mDisplayAdapters = new ArrayList<DisplayAdapter>(); |
| 196 | |
| 197 | // List of all currently connected display devices. |
| 198 | private final ArrayList<DisplayDevice> mDisplayDevices = new ArrayList<DisplayDevice>(); |
| 199 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 200 | // List of all logical displays indexed by logical display id. |
| 201 | private final SparseArray<LogicalDisplay> mLogicalDisplays = |
| 202 | new SparseArray<LogicalDisplay>(); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 203 | private int mNextNonDefaultDisplayId = Display.DEFAULT_DISPLAY + 1; |
| 204 | |
Jeff Brown | 7f3994e | 2012-12-04 14:04:28 -0800 | [diff] [blame] | 205 | // List of all display transaction listeners. |
| 206 | private final CopyOnWriteArrayList<DisplayTransactionListener> mDisplayTransactionListeners = |
| 207 | new CopyOnWriteArrayList<DisplayTransactionListener>(); |
| 208 | |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 209 | // Display power controller. |
| 210 | private DisplayPowerController mDisplayPowerController; |
| 211 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 212 | // The overall display state, independent of changes that might influence one |
| 213 | // display or another in particular. |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 214 | private int mGlobalDisplayState = Display.STATE_ON; |
| 215 | |
| 216 | // The overall display brightness. |
| 217 | // For now, this only applies to the built-in display but we may split it up eventually. |
| 218 | private int mGlobalDisplayBrightness = PowerManager.BRIGHTNESS_DEFAULT; |
Jeff Brown | 9e316a1 | 2012-10-08 19:17:06 -0700 | [diff] [blame] | 219 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 220 | // Set to true when there are pending display changes that have yet to be applied |
| 221 | // to the surface flinger state. |
| 222 | private boolean mPendingTraversal; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 223 | |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 224 | // The Wifi display adapter, or null if not registered. |
| 225 | private WifiDisplayAdapter mWifiDisplayAdapter; |
| 226 | |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 227 | // The number of active wifi display scan requests. |
| 228 | private int mWifiDisplayScanRequestCount; |
| 229 | |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 230 | // The virtual display adapter, or null if not registered. |
| 231 | private VirtualDisplayAdapter mVirtualDisplayAdapter; |
| 232 | |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 233 | // The User ID of the current user |
| 234 | private @UserIdInt int mCurrentUserId; |
| 235 | |
Michael Wright | eedcbf1 | 2017-08-16 23:14:54 +0100 | [diff] [blame] | 236 | // The stable device screen height and width. These are not tied to a specific display, even |
| 237 | // the default display, because they need to be stable over the course of the device's entire |
| 238 | // life, even if the default display changes (e.g. a new monitor is plugged into a PC-like |
| 239 | // device). |
| 240 | private Point mStableDisplaySize = new Point(); |
| 241 | |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 242 | // Viewports of the default display and the display that should receive touch |
| 243 | // input from an external source. Used by the input system. |
| 244 | private final DisplayViewport mDefaultViewport = new DisplayViewport(); |
| 245 | private final DisplayViewport mExternalTouchViewport = new DisplayViewport(); |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 246 | private final ArrayList<DisplayViewport> mVirtualTouchViewports = new ArrayList<>(); |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 247 | |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 248 | // Persistent data store for all internal settings maintained by the display manager service. |
| 249 | private final PersistentDataStore mPersistentDataStore = new PersistentDataStore(); |
| 250 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 251 | // Temporary callback list, used when sending display events to applications. |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 252 | // May be used outside of the lock but only on the handler thread. |
| 253 | private final ArrayList<CallbackRecord> mTempCallbacks = new ArrayList<CallbackRecord>(); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 254 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 255 | // Temporary display info, used for comparing display configurations. |
| 256 | private final DisplayInfo mTempDisplayInfo = new DisplayInfo(); |
| 257 | |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 258 | // Temporary viewports, used when sending new viewport information to the |
| 259 | // input system. May be used outside of the lock but only on the handler thread. |
| 260 | private final DisplayViewport mTempDefaultViewport = new DisplayViewport(); |
| 261 | private final DisplayViewport mTempExternalTouchViewport = new DisplayViewport(); |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 262 | private final ArrayList<DisplayViewport> mTempVirtualTouchViewports = new ArrayList<>(); |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 263 | |
Damien Bargiacchi | 4364bbf | 2016-11-01 21:44:20 -0700 | [diff] [blame] | 264 | // The default color mode for default displays. Overrides the usual |
| 265 | // Display.Display.COLOR_MODE_DEFAULT for displays with the |
| 266 | // DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY flag set. |
| 267 | private final int mDefaultDisplayDefaultColorMode; |
| 268 | |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 269 | // Temporary list of deferred work to perform when setting the display state. |
| 270 | // Only used by requestDisplayState. The field is self-synchronized and only |
| 271 | // intended for use inside of the requestGlobalDisplayStateInternal function. |
| 272 | private final ArrayList<Runnable> mTempDisplayStateWorkQueue = new ArrayList<Runnable>(); |
| 273 | |
Andrii Kulian | fb1bf69 | 2017-01-17 11:17:34 -0800 | [diff] [blame] | 274 | // Lists of UIDs that are present on the displays. Maps displayId -> array of UIDs. |
| 275 | private final SparseArray<IntArray> mDisplayAccessUIDs = new SparseArray<>(); |
| 276 | |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 277 | private final Injector mInjector; |
| 278 | |
Jeff Brown | b880d88 | 2014-02-10 19:47:07 -0800 | [diff] [blame] | 279 | public DisplayManagerService(Context context) { |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 280 | this(context, new Injector()); |
| 281 | } |
| 282 | |
| 283 | @VisibleForTesting |
| 284 | DisplayManagerService(Context context, Injector injector) { |
Jeff Brown | b880d88 | 2014-02-10 19:47:07 -0800 | [diff] [blame] | 285 | super(context); |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 286 | mInjector = injector; |
Jeff Brown | b880d88 | 2014-02-10 19:47:07 -0800 | [diff] [blame] | 287 | mContext = context; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 288 | mHandler = new DisplayManagerHandler(DisplayThread.get().getLooper()); |
Dianne Hackborn | 8d044e8 | 2013-04-30 17:24:15 -0700 | [diff] [blame] | 289 | mUiHandler = UiThread.getHandler(); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 290 | mDisplayAdapterListener = new DisplayAdapterListener(); |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 291 | mSingleDisplayDemoMode = SystemProperties.getBoolean("persist.demo.singledisplay", false); |
Damien Bargiacchi | 4364bbf | 2016-11-01 21:44:20 -0700 | [diff] [blame] | 292 | mDefaultDisplayDefaultColorMode = mContext.getResources().getInteger( |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 293 | com.android.internal.R.integer.config_defaultDisplayDefaultColorMode); |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 294 | |
| 295 | PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
| 296 | mGlobalDisplayBrightness = pm.getDefaultScreenBrightnessSetting(); |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 297 | mCurrentUserId = UserHandle.USER_SYSTEM; |
Joel Fernandes | 2d314e1 | 2017-04-04 16:32:15 -0700 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | public void setupSchedulerPolicies() { |
Jorim Jaggi | ed7993b | 2017-03-28 18:50:01 +0100 | [diff] [blame] | 301 | // android.display and android.anim is critical to user experience and we should make sure |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 302 | // it is not in the default foregroup groups, add it to top-app to make sure it uses all |
| 303 | // the cores and scheduling settings for top-app when it runs. |
Jorim Jaggi | ed7993b | 2017-03-28 18:50:01 +0100 | [diff] [blame] | 304 | Process.setThreadGroupAndCpuset(DisplayThread.get().getThreadId(), |
| 305 | Process.THREAD_GROUP_TOP_APP); |
| 306 | Process.setThreadGroupAndCpuset(AnimationThread.get().getThreadId(), |
| 307 | Process.THREAD_GROUP_TOP_APP); |
Jorim Jaggi | 21c39a7 | 2017-10-20 15:47:51 +0200 | [diff] [blame] | 308 | Process.setThreadGroupAndCpuset(SurfaceAnimationThread.get().getThreadId(), |
| 309 | Process.THREAD_GROUP_TOP_APP); |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 310 | } |
| 311 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 312 | @Override |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 313 | public void onStart() { |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 314 | // We need to pre-load the persistent data store so it's ready before the default display |
| 315 | // adapter is up so that we have it's configuration. We could load it lazily, but since |
| 316 | // we're going to have to read it in eventually we may as well do it here rather than after |
Santos Cordon | c22c563 | 2017-06-21 16:03:49 -0700 | [diff] [blame] | 317 | // we've waited for the display to register itself with us. |
Michael Wright | eedcbf1 | 2017-08-16 23:14:54 +0100 | [diff] [blame] | 318 | synchronized(mSyncRoot) { |
| 319 | mPersistentDataStore.loadIfNeeded(); |
| 320 | loadStableDisplayValuesLocked(); |
| 321 | } |
Santos Cordon | c22c563 | 2017-06-21 16:03:49 -0700 | [diff] [blame] | 322 | mHandler.sendEmptyMessage(MSG_REGISTER_DEFAULT_DISPLAY_ADAPTERS); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 323 | |
| 324 | publishBinderService(Context.DISPLAY_SERVICE, new BinderService(), |
| 325 | true /*allowIsolated*/); |
| 326 | publishLocalService(DisplayManagerInternal.class, new LocalService()); |
Justin Klaassen | 22eb199 | 2016-07-11 20:52:23 -0700 | [diff] [blame] | 327 | publishLocalService(DisplayTransformManager.class, new DisplayTransformManager()); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | @Override |
| 331 | public void onBootPhase(int phase) { |
| 332 | if (phase == PHASE_WAIT_FOR_DEFAULT_DISPLAY) { |
| 333 | synchronized (mSyncRoot) { |
Santos Cordon | c22c563 | 2017-06-21 16:03:49 -0700 | [diff] [blame] | 334 | long timeout = SystemClock.uptimeMillis() |
| 335 | + mInjector.getDefaultDisplayDelayTimeout(); |
| 336 | while (mLogicalDisplays.get(Display.DEFAULT_DISPLAY) == null || |
| 337 | mVirtualDisplayAdapter == null) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 338 | long delay = timeout - SystemClock.uptimeMillis(); |
| 339 | if (delay <= 0) { |
| 340 | throw new RuntimeException("Timeout waiting for default display " |
Santos Cordon | c22c563 | 2017-06-21 16:03:49 -0700 | [diff] [blame] | 341 | + "to be initialized. DefaultDisplay=" |
| 342 | + mLogicalDisplays.get(Display.DEFAULT_DISPLAY) |
| 343 | + ", mVirtualDisplayAdapter=" + mVirtualDisplayAdapter); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 344 | } |
| 345 | if (DEBUG) { |
| 346 | Slog.d(TAG, "waitForDefaultDisplay: waiting, timeout=" + delay); |
| 347 | } |
| 348 | try { |
| 349 | mSyncRoot.wait(delay); |
| 350 | } catch (InterruptedException ex) { |
| 351 | } |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 352 | } |
| 353 | } |
| 354 | } |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 355 | } |
| 356 | |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 357 | @Override |
| 358 | public void onSwitchUser(@UserIdInt int newUserId) { |
| 359 | final int userSerial = getUserManager().getUserSerialNumber(newUserId); |
| 360 | synchronized (mSyncRoot) { |
| 361 | if (mCurrentUserId != newUserId) { |
| 362 | mCurrentUserId = newUserId; |
| 363 | BrightnessConfiguration config = |
| 364 | mPersistentDataStore.getBrightnessConfiguration(userSerial); |
| 365 | mDisplayPowerController.setBrightnessConfiguration(config); |
| 366 | } |
Peeyush Agarwal | cc155dd | 2018-01-10 11:51:33 +0000 | [diff] [blame] | 367 | mDisplayPowerController.onSwitchUser(newUserId); |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 368 | } |
| 369 | } |
| 370 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 371 | // TODO: Use dependencies or a boot phase |
| 372 | public void windowManagerAndInputReady() { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 373 | synchronized (mSyncRoot) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 374 | mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); |
| 375 | mInputManagerInternal = LocalServices.getService(InputManagerInternal.class); |
Craig Mautner | 65d11b3 | 2012-10-01 13:59:52 -0700 | [diff] [blame] | 376 | scheduleTraversalLocked(false); |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 377 | } |
| 378 | } |
| 379 | |
| 380 | /** |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 381 | * Called when the system is ready to go. |
| 382 | */ |
| 383 | public void systemReady(boolean safeMode, boolean onlyCore) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 384 | synchronized (mSyncRoot) { |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 385 | mSafeMode = safeMode; |
| 386 | mOnlyCore = onlyCore; |
| 387 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 388 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 389 | mHandler.sendEmptyMessage(MSG_REGISTER_ADDITIONAL_DISPLAY_ADAPTERS); |
Kenny Guy | 22bd044 | 2017-10-26 00:15:54 +0100 | [diff] [blame] | 390 | mHandler.sendEmptyMessage(MSG_REGISTER_BRIGHTNESS_TRACKER); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 391 | } |
| 392 | |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 393 | @VisibleForTesting |
| 394 | Handler getDisplayHandler() { |
| 395 | return mHandler; |
| 396 | } |
| 397 | |
Michael Wright | eedcbf1 | 2017-08-16 23:14:54 +0100 | [diff] [blame] | 398 | private void loadStableDisplayValuesLocked() { |
| 399 | final Point size = mPersistentDataStore.getStableDisplaySize(); |
| 400 | if (size.x > 0 && size.y > 0) { |
| 401 | // Just set these values directly so we don't write the display persistent data again |
| 402 | // unnecessarily |
| 403 | mStableDisplaySize.set(size.x, size.y); |
| 404 | } else { |
| 405 | final Resources res = mContext.getResources(); |
| 406 | final int width = res.getInteger( |
| 407 | com.android.internal.R.integer.config_stableDeviceDisplayWidth); |
| 408 | final int height = res.getInteger( |
| 409 | com.android.internal.R.integer.config_stableDeviceDisplayHeight); |
| 410 | if (width > 0 && height > 0) { |
| 411 | setStableDisplaySizeLocked(width, height); |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | private Point getStableDisplaySizeInternal() { |
| 417 | Point r = new Point(); |
| 418 | synchronized (mSyncRoot) { |
| 419 | if (mStableDisplaySize.x > 0 && mStableDisplaySize.y > 0) { |
| 420 | r.set(mStableDisplaySize.x, mStableDisplaySize.y); |
| 421 | } |
| 422 | } |
| 423 | return r; |
| 424 | } |
| 425 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 426 | private void registerDisplayTransactionListenerInternal( |
| 427 | DisplayTransactionListener listener) { |
Jeff Brown | 7f3994e | 2012-12-04 14:04:28 -0800 | [diff] [blame] | 428 | // List is self-synchronized copy-on-write. |
| 429 | mDisplayTransactionListeners.add(listener); |
| 430 | } |
| 431 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 432 | private void unregisterDisplayTransactionListenerInternal( |
| 433 | DisplayTransactionListener listener) { |
Jeff Brown | 7f3994e | 2012-12-04 14:04:28 -0800 | [diff] [blame] | 434 | // List is self-synchronized copy-on-write. |
| 435 | mDisplayTransactionListeners.remove(listener); |
| 436 | } |
| 437 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 438 | private void setDisplayInfoOverrideFromWindowManagerInternal( |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 439 | int displayId, DisplayInfo info) { |
| 440 | synchronized (mSyncRoot) { |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 441 | LogicalDisplay display = mLogicalDisplays.get(displayId); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 442 | if (display != null) { |
Jeff Brown | ef981a4 | 2013-08-07 14:13:37 -0700 | [diff] [blame] | 443 | if (display.setDisplayInfoOverrideFromWindowManagerLocked(info)) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 444 | sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED); |
Craig Mautner | 65d11b3 | 2012-10-01 13:59:52 -0700 | [diff] [blame] | 445 | scheduleTraversalLocked(false); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 446 | } |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 447 | } |
| 448 | } |
| 449 | } |
| 450 | |
Andrii Kulian | cd09799 | 2017-03-23 18:31:59 -0700 | [diff] [blame] | 451 | /** |
| 452 | * @see DisplayManagerInternal#getNonOverrideDisplayInfo(int, DisplayInfo) |
| 453 | */ |
| 454 | private void getNonOverrideDisplayInfoInternal(int displayId, DisplayInfo outInfo) { |
| 455 | synchronized (mSyncRoot) { |
| 456 | final LogicalDisplay display = mLogicalDisplays.get(displayId); |
| 457 | if (display != null) { |
| 458 | display.getNonOverrideDisplayInfoLocked(outInfo); |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 463 | @VisibleForTesting |
Robert Carr | ae606b4 | 2018-02-15 15:36:23 -0800 | [diff] [blame] | 464 | void performTraversalInternal(SurfaceControl.Transaction t) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 465 | synchronized (mSyncRoot) { |
| 466 | if (!mPendingTraversal) { |
| 467 | return; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 468 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 469 | mPendingTraversal = false; |
| 470 | |
Robert Carr | ae606b4 | 2018-02-15 15:36:23 -0800 | [diff] [blame] | 471 | performTraversalLocked(t); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 472 | } |
Jeff Brown | 7f3994e | 2012-12-04 14:04:28 -0800 | [diff] [blame] | 473 | |
| 474 | // List is self-synchronized copy-on-write. |
| 475 | for (DisplayTransactionListener listener : mDisplayTransactionListeners) { |
| 476 | listener.onDisplayTransaction(); |
| 477 | } |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 478 | } |
| 479 | |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 480 | private void requestGlobalDisplayStateInternal(int state, int brightness) { |
| 481 | if (state == Display.STATE_UNKNOWN) { |
| 482 | state = Display.STATE_ON; |
| 483 | } |
| 484 | if (state == Display.STATE_OFF) { |
| 485 | brightness = PowerManager.BRIGHTNESS_OFF; |
| 486 | } else if (brightness < 0) { |
| 487 | brightness = PowerManager.BRIGHTNESS_DEFAULT; |
| 488 | } else if (brightness > PowerManager.BRIGHTNESS_ON) { |
| 489 | brightness = PowerManager.BRIGHTNESS_ON; |
| 490 | } |
| 491 | |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 492 | synchronized (mTempDisplayStateWorkQueue) { |
| 493 | try { |
| 494 | // Update the display state within the lock. |
Jeff Brown | 8e5d33e | 2015-06-10 13:05:50 -0700 | [diff] [blame] | 495 | // Note that we do not need to schedule traversals here although it |
| 496 | // may happen as a side-effect of displays changing state. |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 497 | synchronized (mSyncRoot) { |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 498 | if (mGlobalDisplayState == state |
| 499 | && mGlobalDisplayBrightness == brightness) { |
| 500 | return; // no change |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 501 | } |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 502 | |
| 503 | Trace.traceBegin(Trace.TRACE_TAG_POWER, "requestGlobalDisplayState(" |
| 504 | + Display.stateToString(state) |
| 505 | + ", brightness=" + brightness + ")"); |
| 506 | mGlobalDisplayState = state; |
| 507 | mGlobalDisplayBrightness = brightness; |
Jeff Brown | 8e5d33e | 2015-06-10 13:05:50 -0700 | [diff] [blame] | 508 | applyGlobalDisplayStateLocked(mTempDisplayStateWorkQueue); |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | // Setting the display power state can take hundreds of milliseconds |
| 512 | // to complete so we defer the most expensive part of the work until |
| 513 | // after we have exited the critical section to avoid blocking other |
| 514 | // threads for a long time. |
| 515 | for (int i = 0; i < mTempDisplayStateWorkQueue.size(); i++) { |
| 516 | mTempDisplayStateWorkQueue.get(i).run(); |
| 517 | } |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 518 | Trace.traceEnd(Trace.TRACE_TAG_POWER); |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 519 | } finally { |
| 520 | mTempDisplayStateWorkQueue.clear(); |
Jeff Brown | 9e316a1 | 2012-10-08 19:17:06 -0700 | [diff] [blame] | 521 | } |
| 522 | } |
| 523 | } |
| 524 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 525 | private DisplayInfo getDisplayInfoInternal(int displayId, int callingUid) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 526 | synchronized (mSyncRoot) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 527 | LogicalDisplay display = mLogicalDisplays.get(displayId); |
| 528 | if (display != null) { |
| 529 | DisplayInfo info = display.getDisplayInfoLocked(); |
Andrii Kulian | fb1bf69 | 2017-01-17 11:17:34 -0800 | [diff] [blame] | 530 | if (info.hasAccess(callingUid) |
| 531 | || isUidPresentOnDisplayInternal(callingUid, displayId)) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 532 | return info; |
| 533 | } |
| 534 | } |
| 535 | return null; |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | private int[] getDisplayIdsInternal(int callingUid) { |
| 540 | synchronized (mSyncRoot) { |
| 541 | final int count = mLogicalDisplays.size(); |
| 542 | int[] displayIds = new int[count]; |
| 543 | int n = 0; |
| 544 | for (int i = 0; i < count; i++) { |
| 545 | LogicalDisplay display = mLogicalDisplays.valueAt(i); |
| 546 | DisplayInfo info = display.getDisplayInfoLocked(); |
| 547 | if (info.hasAccess(callingUid)) { |
| 548 | displayIds[n++] = mLogicalDisplays.keyAt(i); |
| 549 | } |
| 550 | } |
| 551 | if (n != count) { |
| 552 | displayIds = Arrays.copyOfRange(displayIds, 0, n); |
| 553 | } |
| 554 | return displayIds; |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | private void registerCallbackInternal(IDisplayManagerCallback callback, int callingPid) { |
| 559 | synchronized (mSyncRoot) { |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 560 | if (mCallbacks.get(callingPid) != null) { |
| 561 | throw new SecurityException("The calling process has already " |
| 562 | + "registered an IDisplayManagerCallback."); |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 563 | } |
| 564 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 565 | CallbackRecord record = new CallbackRecord(callingPid, callback); |
| 566 | try { |
| 567 | IBinder binder = callback.asBinder(); |
| 568 | binder.linkToDeath(record, 0); |
| 569 | } catch (RemoteException ex) { |
| 570 | // give up |
| 571 | throw new RuntimeException(ex); |
| 572 | } |
| 573 | |
| 574 | mCallbacks.put(callingPid, record); |
| 575 | } |
| 576 | } |
| 577 | |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 578 | private void onCallbackDied(CallbackRecord record) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 579 | synchronized (mSyncRoot) { |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 580 | mCallbacks.remove(record.mPid); |
| 581 | stopWifiDisplayScanLocked(record); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 582 | } |
| 583 | } |
| 584 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 585 | private void startWifiDisplayScanInternal(int callingPid) { |
| 586 | synchronized (mSyncRoot) { |
| 587 | CallbackRecord record = mCallbacks.get(callingPid); |
| 588 | if (record == null) { |
| 589 | throw new IllegalStateException("The calling process has not " |
| 590 | + "registered an IDisplayManagerCallback."); |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 591 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 592 | startWifiDisplayScanLocked(record); |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 593 | } |
| 594 | } |
| 595 | |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 596 | private void startWifiDisplayScanLocked(CallbackRecord record) { |
| 597 | if (!record.mWifiDisplayScanRequested) { |
| 598 | record.mWifiDisplayScanRequested = true; |
| 599 | if (mWifiDisplayScanRequestCount++ == 0) { |
| 600 | if (mWifiDisplayAdapter != null) { |
| 601 | mWifiDisplayAdapter.requestStartScanLocked(); |
| 602 | } |
| 603 | } |
| 604 | } |
| 605 | } |
| 606 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 607 | private void stopWifiDisplayScanInternal(int callingPid) { |
| 608 | synchronized (mSyncRoot) { |
| 609 | CallbackRecord record = mCallbacks.get(callingPid); |
| 610 | if (record == null) { |
| 611 | throw new IllegalStateException("The calling process has not " |
| 612 | + "registered an IDisplayManagerCallback."); |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 613 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 614 | stopWifiDisplayScanLocked(record); |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 615 | } |
| 616 | } |
| 617 | |
| 618 | private void stopWifiDisplayScanLocked(CallbackRecord record) { |
| 619 | if (record.mWifiDisplayScanRequested) { |
| 620 | record.mWifiDisplayScanRequested = false; |
| 621 | if (--mWifiDisplayScanRequestCount == 0) { |
| 622 | if (mWifiDisplayAdapter != null) { |
| 623 | mWifiDisplayAdapter.requestStopScanLocked(); |
| 624 | } |
| 625 | } else if (mWifiDisplayScanRequestCount < 0) { |
Dianne Hackborn | 8d05172 | 2014-10-01 14:59:58 -0700 | [diff] [blame] | 626 | Slog.wtf(TAG, "mWifiDisplayScanRequestCount became negative: " |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 627 | + mWifiDisplayScanRequestCount); |
| 628 | mWifiDisplayScanRequestCount = 0; |
| 629 | } |
| 630 | } |
| 631 | } |
| 632 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 633 | private void connectWifiDisplayInternal(String address) { |
| 634 | synchronized (mSyncRoot) { |
| 635 | if (mWifiDisplayAdapter != null) { |
| 636 | mWifiDisplayAdapter.requestConnectLocked(address); |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 637 | } |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 638 | } |
| 639 | } |
| 640 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 641 | private void pauseWifiDisplayInternal() { |
| 642 | synchronized (mSyncRoot) { |
| 643 | if (mWifiDisplayAdapter != null) { |
| 644 | mWifiDisplayAdapter.requestPauseLocked(); |
Chong Zhang | 1f3ecaa | 2013-05-03 15:55:36 -0700 | [diff] [blame] | 645 | } |
Chong Zhang | 1f3ecaa | 2013-05-03 15:55:36 -0700 | [diff] [blame] | 646 | } |
| 647 | } |
| 648 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 649 | private void resumeWifiDisplayInternal() { |
| 650 | synchronized (mSyncRoot) { |
| 651 | if (mWifiDisplayAdapter != null) { |
| 652 | mWifiDisplayAdapter.requestResumeLocked(); |
Chong Zhang | 1f3ecaa | 2013-05-03 15:55:36 -0700 | [diff] [blame] | 653 | } |
Chong Zhang | 1f3ecaa | 2013-05-03 15:55:36 -0700 | [diff] [blame] | 654 | } |
| 655 | } |
| 656 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 657 | private void disconnectWifiDisplayInternal() { |
| 658 | synchronized (mSyncRoot) { |
| 659 | if (mWifiDisplayAdapter != null) { |
| 660 | mWifiDisplayAdapter.requestDisconnectLocked(); |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 661 | } |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 662 | } |
| 663 | } |
| 664 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 665 | private void renameWifiDisplayInternal(String address, String alias) { |
| 666 | synchronized (mSyncRoot) { |
| 667 | if (mWifiDisplayAdapter != null) { |
| 668 | mWifiDisplayAdapter.requestRenameLocked(address, alias); |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 669 | } |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 670 | } |
| 671 | } |
| 672 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 673 | private void forgetWifiDisplayInternal(String address) { |
| 674 | synchronized (mSyncRoot) { |
| 675 | if (mWifiDisplayAdapter != null) { |
| 676 | mWifiDisplayAdapter.requestForgetLocked(address); |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 677 | } |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 678 | } |
| 679 | } |
| 680 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 681 | private WifiDisplayStatus getWifiDisplayStatusInternal() { |
| 682 | synchronized (mSyncRoot) { |
| 683 | if (mWifiDisplayAdapter != null) { |
| 684 | return mWifiDisplayAdapter.getWifiDisplayStatusLocked(); |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 685 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 686 | return new WifiDisplayStatus(); |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 687 | } |
| 688 | } |
| 689 | |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 690 | private void requestColorModeInternal(int displayId, int colorMode) { |
Michael Wright | 58e829f | 2015-09-15 00:13:26 +0100 | [diff] [blame] | 691 | synchronized (mSyncRoot) { |
| 692 | LogicalDisplay display = mLogicalDisplays.get(displayId); |
| 693 | if (display != null && |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 694 | display.getRequestedColorModeLocked() != colorMode) { |
| 695 | display.setRequestedColorModeLocked(colorMode); |
Michael Wright | 58e829f | 2015-09-15 00:13:26 +0100 | [diff] [blame] | 696 | scheduleTraversalLocked(false); |
| 697 | } |
| 698 | } |
| 699 | } |
| 700 | |
Bryan Mawhinney | 462e29d | 2018-03-22 15:52:41 +0000 | [diff] [blame] | 701 | private void setSaturationLevelInternal(float level) { |
| 702 | if (level < 0 || level > 1) { |
| 703 | throw new IllegalArgumentException("Saturation level must be between 0 and 1"); |
| 704 | } |
| 705 | float[] matrix = (level == 1.0f ? null : computeSaturationMatrix(level)); |
| 706 | DisplayTransformManager dtm = LocalServices.getService(DisplayTransformManager.class); |
| 707 | dtm.setColorMatrix(DisplayTransformManager.LEVEL_COLOR_MATRIX_SATURATION, matrix); |
| 708 | } |
| 709 | |
| 710 | private static float[] computeSaturationMatrix(float saturation) { |
| 711 | float desaturation = 1.0f - saturation; |
| 712 | float[] luminance = {0.231f * desaturation, 0.715f * desaturation, 0.072f * desaturation}; |
| 713 | float[] matrix = { |
| 714 | luminance[0] + saturation, luminance[0], luminance[0], 0, |
| 715 | luminance[1], luminance[1] + saturation, luminance[1], 0, |
| 716 | luminance[2], luminance[2], luminance[2] + saturation, 0, |
| 717 | 0, 0, 0, 1 |
| 718 | }; |
| 719 | return matrix; |
| 720 | } |
| 721 | |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 722 | private int createVirtualDisplayInternal(IVirtualDisplayCallback callback, |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 723 | IMediaProjection projection, int callingUid, String packageName, String name, int width, |
| 724 | int height, int densityDpi, Surface surface, int flags, String uniqueId) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 725 | synchronized (mSyncRoot) { |
| 726 | if (mVirtualDisplayAdapter == null) { |
| 727 | Slog.w(TAG, "Rejecting request to create private virtual display " |
| 728 | + "because the virtual display adapter is not available."); |
| 729 | return -1; |
Jeff Brown | 7d00aff | 2013-08-02 19:03:49 -0700 | [diff] [blame] | 730 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 731 | |
| 732 | DisplayDevice device = mVirtualDisplayAdapter.createVirtualDisplayLocked( |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 733 | callback, projection, callingUid, packageName, name, width, height, densityDpi, |
| 734 | surface, flags, uniqueId); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 735 | if (device == null) { |
| 736 | return -1; |
Jeff Brown | 7d00aff | 2013-08-02 19:03:49 -0700 | [diff] [blame] | 737 | } |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 738 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 739 | handleDisplayDeviceAddedLocked(device); |
| 740 | LogicalDisplay display = findLogicalDisplayForDeviceLocked(device); |
| 741 | if (display != null) { |
| 742 | return display.getDisplayIdLocked(); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 743 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 744 | |
| 745 | // Something weird happened and the logical display was not created. |
| 746 | Slog.w(TAG, "Rejecting request to create virtual display " |
| 747 | + "because the logical display was not created."); |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 748 | mVirtualDisplayAdapter.releaseVirtualDisplayLocked(callback.asBinder()); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 749 | handleDisplayDeviceRemovedLocked(device); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 750 | } |
| 751 | return -1; |
| 752 | } |
| 753 | |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 754 | private void resizeVirtualDisplayInternal(IBinder appToken, |
| 755 | int width, int height, int densityDpi) { |
| 756 | synchronized (mSyncRoot) { |
| 757 | if (mVirtualDisplayAdapter == null) { |
| 758 | return; |
| 759 | } |
| 760 | |
| 761 | mVirtualDisplayAdapter.resizeVirtualDisplayLocked(appToken, width, height, densityDpi); |
| 762 | } |
| 763 | } |
| 764 | |
Jeff Brown | 92207df | 2014-04-16 13:16:07 -0700 | [diff] [blame] | 765 | private void setVirtualDisplaySurfaceInternal(IBinder appToken, Surface surface) { |
| 766 | synchronized (mSyncRoot) { |
| 767 | if (mVirtualDisplayAdapter == null) { |
| 768 | return; |
| 769 | } |
| 770 | |
| 771 | mVirtualDisplayAdapter.setVirtualDisplaySurfaceLocked(appToken, surface); |
| 772 | } |
| 773 | } |
| 774 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 775 | private void releaseVirtualDisplayInternal(IBinder appToken) { |
| 776 | synchronized (mSyncRoot) { |
| 777 | if (mVirtualDisplayAdapter == null) { |
| 778 | return; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 779 | } |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 780 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 781 | DisplayDevice device = |
| 782 | mVirtualDisplayAdapter.releaseVirtualDisplayLocked(appToken); |
| 783 | if (device != null) { |
| 784 | handleDisplayDeviceRemovedLocked(device); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 785 | } |
| 786 | } |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 787 | } |
| 788 | |
Santos Cordon | c22c563 | 2017-06-21 16:03:49 -0700 | [diff] [blame] | 789 | private void registerDefaultDisplayAdapters() { |
| 790 | // Register default display adapters. |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 791 | synchronized (mSyncRoot) { |
Santos Cordon | c22c563 | 2017-06-21 16:03:49 -0700 | [diff] [blame] | 792 | // main display adapter |
Mike Lockwood | e63f6f7 | 2013-11-15 11:01:47 -0800 | [diff] [blame] | 793 | registerDisplayAdapterLocked(new LocalDisplayAdapter( |
| 794 | mSyncRoot, mContext, mHandler, mDisplayAdapterListener)); |
Santos Cordon | c22c563 | 2017-06-21 16:03:49 -0700 | [diff] [blame] | 795 | |
| 796 | // Standalone VR devices rely on a virtual display as their primary display for |
| 797 | // 2D UI. We register virtual display adapter along side the main display adapter |
| 798 | // here so that it is ready by the time the system sends the home Intent for |
| 799 | // early apps like SetupWizard/Launcher. In particular, SUW is displayed using |
| 800 | // the virtual display inside VR before any VR-specific apps even run. |
| 801 | mVirtualDisplayAdapter = mInjector.getVirtualDisplayAdapter(mSyncRoot, mContext, |
| 802 | mHandler, mDisplayAdapterListener); |
| 803 | if (mVirtualDisplayAdapter != null) { |
| 804 | registerDisplayAdapterLocked(mVirtualDisplayAdapter); |
| 805 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 806 | } |
| 807 | } |
| 808 | |
| 809 | private void registerAdditionalDisplayAdapters() { |
| 810 | synchronized (mSyncRoot) { |
| 811 | if (shouldRegisterNonEssentialDisplayAdaptersLocked()) { |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 812 | registerOverlayDisplayAdapterLocked(); |
| 813 | registerWifiDisplayAdapterLocked(); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 814 | } |
| 815 | } |
| 816 | } |
| 817 | |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 818 | private void registerOverlayDisplayAdapterLocked() { |
| 819 | registerDisplayAdapterLocked(new OverlayDisplayAdapter( |
| 820 | mSyncRoot, mContext, mHandler, mDisplayAdapterListener, mUiHandler)); |
| 821 | } |
| 822 | |
| 823 | private void registerWifiDisplayAdapterLocked() { |
| 824 | if (mContext.getResources().getBoolean( |
Jeff Brown | bbd28a2 | 2012-09-20 16:47:15 -0700 | [diff] [blame] | 825 | com.android.internal.R.bool.config_enableWifiDisplay) |
| 826 | || SystemProperties.getInt(FORCE_WIFI_DISPLAY_ENABLE, -1) == 1) { |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 827 | mWifiDisplayAdapter = new WifiDisplayAdapter( |
| 828 | mSyncRoot, mContext, mHandler, mDisplayAdapterListener, |
| 829 | mPersistentDataStore); |
| 830 | registerDisplayAdapterLocked(mWifiDisplayAdapter); |
| 831 | } |
| 832 | } |
| 833 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 834 | private boolean shouldRegisterNonEssentialDisplayAdaptersLocked() { |
| 835 | // In safe mode, we disable non-essential display adapters to give the user |
| 836 | // an opportunity to fix broken settings or other problems that might affect |
| 837 | // system stability. |
| 838 | // In only-core mode, we disable non-essential display adapters to minimize |
| 839 | // the number of dependencies that are started while in this mode and to |
| 840 | // prevent problems that might occur due to the device being encrypted. |
| 841 | return !mSafeMode && !mOnlyCore; |
| 842 | } |
| 843 | |
| 844 | private void registerDisplayAdapterLocked(DisplayAdapter adapter) { |
| 845 | mDisplayAdapters.add(adapter); |
| 846 | adapter.registerLocked(); |
| 847 | } |
| 848 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 849 | private void handleDisplayDeviceAdded(DisplayDevice device) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 850 | synchronized (mSyncRoot) { |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 851 | handleDisplayDeviceAddedLocked(device); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 852 | } |
| 853 | } |
| 854 | |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 855 | private void handleDisplayDeviceAddedLocked(DisplayDevice device) { |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 856 | DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 857 | if (mDisplayDevices.contains(device)) { |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 858 | Slog.w(TAG, "Attempted to add already added display device: " + info); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 859 | return; |
| 860 | } |
| 861 | |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 862 | Slog.i(TAG, "Display device added: " + info); |
| 863 | device.mDebugLastLoggedDeviceInfo = info; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 864 | |
| 865 | mDisplayDevices.add(device); |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 866 | LogicalDisplay display = addLogicalDisplayLocked(device); |
Jeff Brown | 0033a86 | 2014-10-08 12:06:39 -0700 | [diff] [blame] | 867 | Runnable work = updateDisplayStateLocked(device); |
| 868 | if (work != null) { |
| 869 | work.run(); |
| 870 | } |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 871 | scheduleTraversalLocked(false); |
| 872 | } |
| 873 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 874 | private void handleDisplayDeviceChanged(DisplayDevice device) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 875 | synchronized (mSyncRoot) { |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 876 | DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 877 | if (!mDisplayDevices.contains(device)) { |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 878 | Slog.w(TAG, "Attempted to change non-existent display device: " + info); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 879 | return; |
| 880 | } |
| 881 | |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 882 | int diff = device.mDebugLastLoggedDeviceInfo.diff(info); |
| 883 | if (diff == DisplayDeviceInfo.DIFF_STATE) { |
| 884 | Slog.i(TAG, "Display device changed state: \"" + info.name |
| 885 | + "\", " + Display.stateToString(info.state)); |
| 886 | } else if (diff != 0) { |
| 887 | Slog.i(TAG, "Display device changed: " + info); |
| 888 | } |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 889 | if ((diff & DisplayDeviceInfo.DIFF_COLOR_MODE) != 0) { |
| 890 | try { |
| 891 | mPersistentDataStore.setColorMode(device, info.colorMode); |
| 892 | } finally { |
| 893 | mPersistentDataStore.saveIfNeeded(); |
| 894 | } |
| 895 | } |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 896 | device.mDebugLastLoggedDeviceInfo = info; |
Jeff Brown | e87bf03 | 2012-09-20 18:30:13 -0700 | [diff] [blame] | 897 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 898 | device.applyPendingDisplayDeviceInfoChangesLocked(); |
| 899 | if (updateLogicalDisplaysLocked()) { |
Craig Mautner | 65d11b3 | 2012-10-01 13:59:52 -0700 | [diff] [blame] | 900 | scheduleTraversalLocked(false); |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 901 | } |
| 902 | } |
| 903 | } |
| 904 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 905 | private void handleDisplayDeviceRemoved(DisplayDevice device) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 906 | synchronized (mSyncRoot) { |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 907 | handleDisplayDeviceRemovedLocked(device); |
| 908 | } |
| 909 | } |
Jeff Brown | 8e5d33e | 2015-06-10 13:05:50 -0700 | [diff] [blame] | 910 | |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 911 | private void handleDisplayDeviceRemovedLocked(DisplayDevice device) { |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 912 | DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 913 | if (!mDisplayDevices.remove(device)) { |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 914 | Slog.w(TAG, "Attempted to remove non-existent display device: " + info); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 915 | return; |
| 916 | } |
| 917 | |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 918 | Slog.i(TAG, "Display device removed: " + info); |
| 919 | device.mDebugLastLoggedDeviceInfo = info; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 920 | |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 921 | updateLogicalDisplaysLocked(); |
| 922 | scheduleTraversalLocked(false); |
| 923 | } |
| 924 | |
Jeff Brown | 8e5d33e | 2015-06-10 13:05:50 -0700 | [diff] [blame] | 925 | private void applyGlobalDisplayStateLocked(List<Runnable> workQueue) { |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 926 | final int count = mDisplayDevices.size(); |
| 927 | for (int i = 0; i < count; i++) { |
| 928 | DisplayDevice device = mDisplayDevices.get(i); |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 929 | Runnable runnable = updateDisplayStateLocked(device); |
| 930 | if (runnable != null) { |
| 931 | workQueue.add(runnable); |
| 932 | } |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 933 | } |
| 934 | } |
| 935 | |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 936 | private Runnable updateDisplayStateLocked(DisplayDevice device) { |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 937 | // Blank or unblank the display immediately to match the state requested |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 938 | // by the display power controller (if known). |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 939 | DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); |
| 940 | if ((info.flags & DisplayDeviceInfo.FLAG_NEVER_BLANK) == 0) { |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 941 | return device.requestDisplayStateLocked(mGlobalDisplayState, mGlobalDisplayBrightness); |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 942 | } |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 943 | return null; |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 944 | } |
| 945 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 946 | // Adds a new logical display based on the given display device. |
| 947 | // Sends notifications if needed. |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 948 | private LogicalDisplay addLogicalDisplayLocked(DisplayDevice device) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 949 | DisplayDeviceInfo deviceInfo = device.getDisplayDeviceInfoLocked(); |
| 950 | boolean isDefault = (deviceInfo.flags |
| 951 | & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0; |
| 952 | if (isDefault && mLogicalDisplays.get(Display.DEFAULT_DISPLAY) != null) { |
| 953 | Slog.w(TAG, "Ignoring attempt to add a second default display: " + deviceInfo); |
| 954 | isDefault = false; |
| 955 | } |
| 956 | |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 957 | if (!isDefault && mSingleDisplayDemoMode) { |
| 958 | Slog.i(TAG, "Not creating a logical display for a secondary display " |
| 959 | + " because single display demo mode is enabled: " + deviceInfo); |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 960 | return null; |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 961 | } |
| 962 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 963 | final int displayId = assignDisplayIdLocked(isDefault); |
| 964 | final int layerStack = assignLayerStackLocked(displayId); |
| 965 | |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 966 | LogicalDisplay display = new LogicalDisplay(displayId, layerStack, device); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 967 | display.updateLocked(mDisplayDevices); |
| 968 | if (!display.isValidLocked()) { |
| 969 | // This should never happen currently. |
| 970 | Slog.w(TAG, "Ignoring display device because the logical display " |
| 971 | + "created from it was not considered valid: " + deviceInfo); |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 972 | return null; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 973 | } |
| 974 | |
Michael Wright | eedcbf1 | 2017-08-16 23:14:54 +0100 | [diff] [blame] | 975 | configureColorModeLocked(display, device); |
| 976 | if (isDefault) { |
| 977 | recordStableDisplayStatsIfNeededLocked(display); |
| 978 | } |
| 979 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 980 | mLogicalDisplays.put(displayId, display); |
| 981 | |
| 982 | // Wake up waitForDefaultDisplay. |
| 983 | if (isDefault) { |
| 984 | mSyncRoot.notifyAll(); |
| 985 | } |
| 986 | |
| 987 | sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_ADDED); |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 988 | return display; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 989 | } |
| 990 | |
| 991 | private int assignDisplayIdLocked(boolean isDefault) { |
| 992 | return isDefault ? Display.DEFAULT_DISPLAY : mNextNonDefaultDisplayId++; |
| 993 | } |
| 994 | |
| 995 | private int assignLayerStackLocked(int displayId) { |
| 996 | // Currently layer stacks and display ids are the same. |
| 997 | // This need not be the case. |
| 998 | return displayId; |
| 999 | } |
| 1000 | |
Michael Wright | eedcbf1 | 2017-08-16 23:14:54 +0100 | [diff] [blame] | 1001 | private void configureColorModeLocked(LogicalDisplay display, DisplayDevice device) { |
| 1002 | if (display.getPrimaryDisplayDeviceLocked() == device) { |
| 1003 | int colorMode = mPersistentDataStore.getColorMode(device); |
| 1004 | if (colorMode == Display.COLOR_MODE_INVALID) { |
| 1005 | if ((device.getDisplayDeviceInfoLocked().flags |
| 1006 | & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0) { |
| 1007 | colorMode = mDefaultDisplayDefaultColorMode; |
| 1008 | } else { |
| 1009 | colorMode = Display.COLOR_MODE_DEFAULT; |
| 1010 | } |
| 1011 | } |
| 1012 | display.setRequestedColorModeLocked(colorMode); |
| 1013 | } |
| 1014 | } |
| 1015 | |
| 1016 | // If we've never recorded stable device stats for this device before and they aren't |
| 1017 | // explicitly configured, go ahead and record the stable device stats now based on the status |
| 1018 | // of the default display at first boot. |
| 1019 | private void recordStableDisplayStatsIfNeededLocked(LogicalDisplay d) { |
| 1020 | if (mStableDisplaySize.x <= 0 && mStableDisplaySize.y <= 0) { |
| 1021 | DisplayInfo info = d.getDisplayInfoLocked(); |
| 1022 | setStableDisplaySizeLocked(info.getNaturalWidth(), info.getNaturalHeight()); |
| 1023 | } |
| 1024 | } |
| 1025 | |
| 1026 | private void setStableDisplaySizeLocked(int width, int height) { |
| 1027 | mStableDisplaySize = new Point(width, height); |
| 1028 | try { |
| 1029 | mPersistentDataStore.setStableDisplaySize(mStableDisplaySize); |
| 1030 | } finally { |
| 1031 | mPersistentDataStore.saveIfNeeded(); |
| 1032 | } |
| 1033 | } |
| 1034 | |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 1035 | private void setBrightnessConfigurationForUserInternal( |
Dan Gittik | 7a32fba | 2018-03-28 12:19:38 +0100 | [diff] [blame^] | 1036 | @Nullable BrightnessConfiguration c, @UserIdInt int userId, |
Kenny Guy | 05ce809 | 2018-01-17 13:44:20 +0000 | [diff] [blame] | 1037 | @Nullable String packageName) { |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 1038 | final int userSerial = getUserManager().getUserSerialNumber(userId); |
| 1039 | synchronized (mSyncRoot) { |
| 1040 | try { |
Kenny Guy | 05ce809 | 2018-01-17 13:44:20 +0000 | [diff] [blame] | 1041 | mPersistentDataStore.setBrightnessConfigurationForUser(c, userSerial, |
| 1042 | packageName); |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 1043 | } finally { |
| 1044 | mPersistentDataStore.saveIfNeeded(); |
| 1045 | } |
| 1046 | if (userId == mCurrentUserId) { |
| 1047 | mDisplayPowerController.setBrightnessConfiguration(c); |
| 1048 | } |
| 1049 | } |
| 1050 | } |
| 1051 | |
| 1052 | private void loadBrightnessConfiguration() { |
| 1053 | synchronized (mSyncRoot) { |
| 1054 | final int userSerial = getUserManager().getUserSerialNumber(mCurrentUserId); |
| 1055 | BrightnessConfiguration config = |
| 1056 | mPersistentDataStore.getBrightnessConfiguration(userSerial); |
| 1057 | mDisplayPowerController.setBrightnessConfiguration(config); |
| 1058 | } |
| 1059 | } |
| 1060 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1061 | // Updates all existing logical displays given the current set of display devices. |
| 1062 | // Removes invalid logical displays. |
| 1063 | // Sends notifications if needed. |
| 1064 | private boolean updateLogicalDisplaysLocked() { |
| 1065 | boolean changed = false; |
| 1066 | for (int i = mLogicalDisplays.size(); i-- > 0; ) { |
| 1067 | final int displayId = mLogicalDisplays.keyAt(i); |
| 1068 | LogicalDisplay display = mLogicalDisplays.valueAt(i); |
| 1069 | |
| 1070 | mTempDisplayInfo.copyFrom(display.getDisplayInfoLocked()); |
| 1071 | display.updateLocked(mDisplayDevices); |
| 1072 | if (!display.isValidLocked()) { |
| 1073 | mLogicalDisplays.removeAt(i); |
| 1074 | sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_REMOVED); |
| 1075 | changed = true; |
| 1076 | } else if (!mTempDisplayInfo.equals(display.getDisplayInfoLocked())) { |
| 1077 | sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED); |
| 1078 | changed = true; |
| 1079 | } |
| 1080 | } |
| 1081 | return changed; |
| 1082 | } |
| 1083 | |
Robert Carr | ae606b4 | 2018-02-15 15:36:23 -0800 | [diff] [blame] | 1084 | private void performTraversalLocked(SurfaceControl.Transaction t) { |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1085 | // Clear all viewports before configuring displays so that we can keep |
| 1086 | // track of which ones we have configured. |
| 1087 | clearViewportsLocked(); |
| 1088 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1089 | // Configure each display device. |
| 1090 | final int count = mDisplayDevices.size(); |
| 1091 | for (int i = 0; i < count; i++) { |
| 1092 | DisplayDevice device = mDisplayDevices.get(i); |
Robert Carr | ae606b4 | 2018-02-15 15:36:23 -0800 | [diff] [blame] | 1093 | configureDisplayLocked(t, device); |
| 1094 | device.performTraversalLocked(t); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1095 | } |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1096 | |
| 1097 | // Tell the input system about these new viewports. |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1098 | if (mInputManagerInternal != null) { |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1099 | mHandler.sendEmptyMessage(MSG_UPDATE_VIEWPORT); |
| 1100 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1101 | } |
| 1102 | |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 1103 | private void setDisplayPropertiesInternal(int displayId, boolean hasContent, |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 1104 | float requestedRefreshRate, int requestedModeId, boolean inTraversal) { |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 1105 | synchronized (mSyncRoot) { |
| 1106 | LogicalDisplay display = mLogicalDisplays.get(displayId); |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 1107 | if (display == null) { |
| 1108 | return; |
| 1109 | } |
| 1110 | if (display.hasContentLocked() != hasContent) { |
Jeff Brown | 33041bd | 2013-08-02 21:11:14 -0700 | [diff] [blame] | 1111 | if (DEBUG) { |
| 1112 | Slog.d(TAG, "Display " + displayId + " hasContent flag changed: " |
| 1113 | + "hasContent=" + hasContent + ", inTraversal=" + inTraversal); |
| 1114 | } |
| 1115 | |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 1116 | display.setHasContentLocked(hasContent); |
Craig Mautner | 65d11b3 | 2012-10-01 13:59:52 -0700 | [diff] [blame] | 1117 | scheduleTraversalLocked(inTraversal); |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 1118 | } |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 1119 | if (requestedModeId == 0 && requestedRefreshRate != 0) { |
| 1120 | // Scan supported modes returned by display.getInfo() to find a mode with the same |
| 1121 | // size as the default display mode but with the specified refresh rate instead. |
| 1122 | requestedModeId = display.getDisplayInfoLocked().findDefaultModeByRefreshRate( |
| 1123 | requestedRefreshRate); |
| 1124 | } |
| 1125 | if (display.getRequestedModeIdLocked() != requestedModeId) { |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 1126 | if (DEBUG) { |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 1127 | Slog.d(TAG, "Display " + displayId + " switching to mode " + requestedModeId); |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 1128 | } |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 1129 | display.setRequestedModeIdLocked(requestedModeId); |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 1130 | scheduleTraversalLocked(inTraversal); |
| 1131 | } |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 1132 | } |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1133 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1134 | |
Filip Gruszczynski | d2e8640 | 2015-02-19 13:05:03 -0800 | [diff] [blame] | 1135 | private void setDisplayOffsetsInternal(int displayId, int x, int y) { |
| 1136 | synchronized (mSyncRoot) { |
| 1137 | LogicalDisplay display = mLogicalDisplays.get(displayId); |
| 1138 | if (display == null) { |
| 1139 | return; |
| 1140 | } |
| 1141 | if (display.getDisplayOffsetXLocked() != x |
| 1142 | || display.getDisplayOffsetYLocked() != y) { |
| 1143 | if (DEBUG) { |
| 1144 | Slog.d(TAG, "Display " + displayId + " burn-in offset set to (" |
| 1145 | + x + ", " + y + ")"); |
| 1146 | } |
| 1147 | display.setDisplayOffsetsLocked(x, y); |
| 1148 | scheduleTraversalLocked(false); |
| 1149 | } |
| 1150 | } |
| 1151 | } |
| 1152 | |
Andrii Kulian | fb1bf69 | 2017-01-17 11:17:34 -0800 | [diff] [blame] | 1153 | // Updates the lists of UIDs that are present on displays. |
| 1154 | private void setDisplayAccessUIDsInternal(SparseArray<IntArray> newDisplayAccessUIDs) { |
| 1155 | synchronized (mSyncRoot) { |
| 1156 | mDisplayAccessUIDs.clear(); |
| 1157 | for (int i = newDisplayAccessUIDs.size() - 1; i >= 0; i--) { |
| 1158 | mDisplayAccessUIDs.append(newDisplayAccessUIDs.keyAt(i), |
| 1159 | newDisplayAccessUIDs.valueAt(i)); |
| 1160 | } |
| 1161 | } |
| 1162 | } |
| 1163 | |
| 1164 | // Checks if provided UID's content is present on the display and UID has access to it. |
| 1165 | private boolean isUidPresentOnDisplayInternal(int uid, int displayId) { |
| 1166 | synchronized (mSyncRoot) { |
| 1167 | final IntArray displayUIDs = mDisplayAccessUIDs.get(displayId); |
| 1168 | return displayUIDs != null && displayUIDs.indexOf(uid) != -1; |
| 1169 | } |
| 1170 | } |
| 1171 | |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1172 | private void clearViewportsLocked() { |
| 1173 | mDefaultViewport.valid = false; |
| 1174 | mExternalTouchViewport.valid = false; |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 1175 | mVirtualTouchViewports.clear(); |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 1176 | } |
| 1177 | |
Robert Carr | ae606b4 | 2018-02-15 15:36:23 -0800 | [diff] [blame] | 1178 | private void configureDisplayLocked(SurfaceControl.Transaction t, DisplayDevice device) { |
Jeff Brown | d14c8c9 | 2014-01-07 18:13:09 -0800 | [diff] [blame] | 1179 | final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); |
| 1180 | final boolean ownContent = (info.flags & DisplayDeviceInfo.FLAG_OWN_CONTENT_ONLY) != 0; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 1181 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1182 | // Find the logical display that the display device is showing. |
Jeff Brown | d14c8c9 | 2014-01-07 18:13:09 -0800 | [diff] [blame] | 1183 | // Certain displays only ever show their own content. |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 1184 | LogicalDisplay display = findLogicalDisplayForDeviceLocked(device); |
Jeff Brown | d14c8c9 | 2014-01-07 18:13:09 -0800 | [diff] [blame] | 1185 | if (!ownContent) { |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 1186 | if (display != null && !display.hasContentLocked()) { |
| 1187 | // If the display does not have any content of its own, then |
| 1188 | // automatically mirror the default logical display contents. |
| 1189 | display = null; |
| 1190 | } |
| 1191 | if (display == null) { |
| 1192 | display = mLogicalDisplays.get(Display.DEFAULT_DISPLAY); |
| 1193 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1194 | } |
| 1195 | |
| 1196 | // Apply the logical display configuration to the display device. |
| 1197 | if (display == null) { |
| 1198 | // TODO: no logical display for the device, blank it |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1199 | Slog.w(TAG, "Missing logical display to use for physical display device: " |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1200 | + device.getDisplayDeviceInfoLocked()); |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1201 | return; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1202 | } |
Robert Carr | ae606b4 | 2018-02-15 15:36:23 -0800 | [diff] [blame] | 1203 | display.configureDisplayLocked(t, device, info.state == Display.STATE_OFF); |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1204 | |
| 1205 | // Update the viewports if needed. |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1206 | if (!mDefaultViewport.valid |
| 1207 | && (info.flags & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0) { |
| 1208 | setViewportLocked(mDefaultViewport, display, device); |
| 1209 | } |
| 1210 | if (!mExternalTouchViewport.valid |
| 1211 | && info.touch == DisplayDeviceInfo.TOUCH_EXTERNAL) { |
| 1212 | setViewportLocked(mExternalTouchViewport, display, device); |
| 1213 | } |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 1214 | |
| 1215 | if (info.touch == DisplayDeviceInfo.TOUCH_VIRTUAL && !TextUtils.isEmpty(info.uniqueId)) { |
| 1216 | final DisplayViewport viewport = getVirtualTouchViewportLocked(info.uniqueId); |
| 1217 | setViewportLocked(viewport, display, device); |
| 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | /** Gets the virtual device viewport or creates it if not yet created. */ |
| 1222 | private DisplayViewport getVirtualTouchViewportLocked(@NonNull String uniqueId) { |
| 1223 | DisplayViewport viewport; |
| 1224 | final int count = mVirtualTouchViewports.size(); |
| 1225 | for (int i = 0; i < count; i++) { |
| 1226 | viewport = mVirtualTouchViewports.get(i); |
| 1227 | if (uniqueId.equals(viewport.uniqueId)) { |
| 1228 | return viewport; |
| 1229 | } |
| 1230 | } |
| 1231 | |
| 1232 | viewport = new DisplayViewport(); |
| 1233 | viewport.uniqueId = uniqueId; |
| 1234 | mVirtualTouchViewports.add(viewport); |
| 1235 | return viewport; |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1236 | } |
| 1237 | |
| 1238 | private static void setViewportLocked(DisplayViewport viewport, |
| 1239 | LogicalDisplay display, DisplayDevice device) { |
| 1240 | viewport.valid = true; |
| 1241 | viewport.displayId = display.getDisplayIdLocked(); |
| 1242 | device.populateViewportLocked(viewport); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1243 | } |
| 1244 | |
| 1245 | private LogicalDisplay findLogicalDisplayForDeviceLocked(DisplayDevice device) { |
| 1246 | final int count = mLogicalDisplays.size(); |
| 1247 | for (int i = 0; i < count; i++) { |
| 1248 | LogicalDisplay display = mLogicalDisplays.valueAt(i); |
| 1249 | if (display.getPrimaryDisplayDeviceLocked() == device) { |
| 1250 | return display; |
| 1251 | } |
| 1252 | } |
| 1253 | return null; |
| 1254 | } |
| 1255 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1256 | private void sendDisplayEventLocked(int displayId, int event) { |
| 1257 | Message msg = mHandler.obtainMessage(MSG_DELIVER_DISPLAY_EVENT, displayId, event); |
| 1258 | mHandler.sendMessage(msg); |
| 1259 | } |
| 1260 | |
Robert Carr | ae606b4 | 2018-02-15 15:36:23 -0800 | [diff] [blame] | 1261 | // Requests that performTraversals be called at a |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1262 | // later time to apply changes to surfaces and displays. |
Craig Mautner | 65d11b3 | 2012-10-01 13:59:52 -0700 | [diff] [blame] | 1263 | private void scheduleTraversalLocked(boolean inTraversal) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1264 | if (!mPendingTraversal && mWindowManagerInternal != null) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1265 | mPendingTraversal = true; |
Craig Mautner | 65d11b3 | 2012-10-01 13:59:52 -0700 | [diff] [blame] | 1266 | if (!inTraversal) { |
| 1267 | mHandler.sendEmptyMessage(MSG_REQUEST_TRAVERSAL); |
| 1268 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1269 | } |
| 1270 | } |
| 1271 | |
| 1272 | // Runs on Handler thread. |
| 1273 | // Delivers display event notifications to callbacks. |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1274 | private void deliverDisplayEvent(int displayId, int event) { |
| 1275 | if (DEBUG) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1276 | Slog.d(TAG, "Delivering display event: displayId=" |
| 1277 | + displayId + ", event=" + event); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 1278 | } |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 1279 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1280 | // Grab the lock and copy the callbacks. |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1281 | final int count; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1282 | synchronized (mSyncRoot) { |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1283 | count = mCallbacks.size(); |
| 1284 | mTempCallbacks.clear(); |
| 1285 | for (int i = 0; i < count; i++) { |
| 1286 | mTempCallbacks.add(mCallbacks.valueAt(i)); |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 1287 | } |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1288 | } |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 1289 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1290 | // After releasing the lock, send the notifications out. |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1291 | for (int i = 0; i < count; i++) { |
| 1292 | mTempCallbacks.get(i).notifyDisplayEventAsync(displayId, event); |
| 1293 | } |
| 1294 | mTempCallbacks.clear(); |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 1295 | } |
| 1296 | |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1297 | private IMediaProjectionManager getProjectionService() { |
| 1298 | if (mProjectionService == null) { |
| 1299 | IBinder b = ServiceManager.getService(Context.MEDIA_PROJECTION_SERVICE); |
| 1300 | mProjectionService = IMediaProjectionManager.Stub.asInterface(b); |
| 1301 | } |
| 1302 | return mProjectionService; |
| 1303 | } |
| 1304 | |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 1305 | private UserManager getUserManager() { |
| 1306 | return mContext.getSystemService(UserManager.class); |
| 1307 | } |
| 1308 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1309 | private void dumpInternal(PrintWriter pw) { |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1310 | pw.println("DISPLAY MANAGER (dumpsys display)"); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 1311 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1312 | synchronized (mSyncRoot) { |
Jeff Brown | 9e316a1 | 2012-10-08 19:17:06 -0700 | [diff] [blame] | 1313 | pw.println(" mOnlyCode=" + mOnlyCore); |
| 1314 | pw.println(" mSafeMode=" + mSafeMode); |
| 1315 | pw.println(" mPendingTraversal=" + mPendingTraversal); |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1316 | pw.println(" mGlobalDisplayState=" + Display.stateToString(mGlobalDisplayState)); |
Jeff Brown | 9e316a1 | 2012-10-08 19:17:06 -0700 | [diff] [blame] | 1317 | pw.println(" mNextNonDefaultDisplayId=" + mNextNonDefaultDisplayId); |
| 1318 | pw.println(" mDefaultViewport=" + mDefaultViewport); |
| 1319 | pw.println(" mExternalTouchViewport=" + mExternalTouchViewport); |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 1320 | pw.println(" mVirtualTouchViewports=" + mVirtualTouchViewports); |
Damien Bargiacchi | 4364bbf | 2016-11-01 21:44:20 -0700 | [diff] [blame] | 1321 | pw.println(" mDefaultDisplayDefaultColorMode=" + mDefaultDisplayDefaultColorMode); |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 1322 | pw.println(" mSingleDisplayDemoMode=" + mSingleDisplayDemoMode); |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 1323 | pw.println(" mWifiDisplayScanRequestCount=" + mWifiDisplayScanRequestCount); |
Michael Wright | eedcbf1 | 2017-08-16 23:14:54 +0100 | [diff] [blame] | 1324 | pw.println(" mStableDisplaySize=" + mStableDisplaySize); |
| 1325 | |
Jeff Brown | 9e316a1 | 2012-10-08 19:17:06 -0700 | [diff] [blame] | 1326 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1327 | IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " "); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1328 | ipw.increaseIndent(); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1329 | |
| 1330 | pw.println(); |
| 1331 | pw.println("Display Adapters: size=" + mDisplayAdapters.size()); |
Jeff Brown | 848c2dc | 2012-08-19 20:18:08 -0700 | [diff] [blame] | 1332 | for (DisplayAdapter adapter : mDisplayAdapters) { |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1333 | pw.println(" " + adapter.getName()); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1334 | adapter.dumpLocked(ipw); |
Jeff Brown | 848c2dc | 2012-08-19 20:18:08 -0700 | [diff] [blame] | 1335 | } |
Craig Mautner | 9de4936 | 2012-08-02 14:30:30 -0700 | [diff] [blame] | 1336 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1337 | pw.println(); |
| 1338 | pw.println("Display Devices: size=" + mDisplayDevices.size()); |
| 1339 | for (DisplayDevice device : mDisplayDevices) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1340 | pw.println(" " + device.getDisplayDeviceInfoLocked()); |
| 1341 | device.dumpLocked(ipw); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1342 | } |
| 1343 | |
| 1344 | final int logicalDisplayCount = mLogicalDisplays.size(); |
| 1345 | pw.println(); |
| 1346 | pw.println("Logical Displays: size=" + logicalDisplayCount); |
| 1347 | for (int i = 0; i < logicalDisplayCount; i++) { |
| 1348 | int displayId = mLogicalDisplays.keyAt(i); |
| 1349 | LogicalDisplay display = mLogicalDisplays.valueAt(i); |
| 1350 | pw.println(" Display " + displayId + ":"); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1351 | display.dumpLocked(ipw); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1352 | } |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 1353 | |
| 1354 | final int callbackCount = mCallbacks.size(); |
| 1355 | pw.println(); |
| 1356 | pw.println("Callbacks: size=" + callbackCount); |
| 1357 | for (int i = 0; i < callbackCount; i++) { |
| 1358 | CallbackRecord callback = mCallbacks.valueAt(i); |
| 1359 | pw.println(" " + i + ": mPid=" + callback.mPid |
| 1360 | + ", mWifiDisplayScanRequested=" + callback.mWifiDisplayScanRequested); |
| 1361 | } |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 1362 | |
| 1363 | if (mDisplayPowerController != null) { |
| 1364 | mDisplayPowerController.dump(pw); |
| 1365 | } |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 1366 | |
| 1367 | pw.println(); |
| 1368 | mPersistentDataStore.dump(pw); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1369 | } |
| 1370 | } |
| 1371 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1372 | /** |
| 1373 | * This is the object that everything in the display manager locks on. |
| 1374 | * We make it an inner class within the {@link DisplayManagerService} to so that it is |
| 1375 | * clear that the object belongs to the display manager service and that it is |
| 1376 | * a unique object with a special purpose. |
| 1377 | */ |
| 1378 | public static final class SyncRoot { |
| 1379 | } |
| 1380 | |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 1381 | @VisibleForTesting |
| 1382 | static class Injector { |
| 1383 | VirtualDisplayAdapter getVirtualDisplayAdapter(SyncRoot syncRoot, Context context, |
| 1384 | Handler handler, DisplayAdapter.Listener displayAdapterListener) { |
| 1385 | return new VirtualDisplayAdapter(syncRoot, context, handler, displayAdapterListener); |
| 1386 | } |
Santos Cordon | c22c563 | 2017-06-21 16:03:49 -0700 | [diff] [blame] | 1387 | |
| 1388 | long getDefaultDisplayDelayTimeout() { |
| 1389 | return WAIT_FOR_DEFAULT_DISPLAY_TIMEOUT; |
| 1390 | } |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 1391 | } |
| 1392 | |
Alex Sakhartchouk | 879d24f | 2017-06-20 22:01:19 -0400 | [diff] [blame] | 1393 | @VisibleForTesting |
| 1394 | DisplayDeviceInfo getDisplayDeviceInfoInternal(int displayId) { |
| 1395 | synchronized (mSyncRoot) { |
| 1396 | LogicalDisplay display = mLogicalDisplays.get(displayId); |
| 1397 | if (display != null) { |
| 1398 | DisplayDevice displayDevice = display.getPrimaryDisplayDeviceLocked(); |
| 1399 | return displayDevice.getDisplayDeviceInfoLocked(); |
| 1400 | } |
| 1401 | return null; |
| 1402 | } |
| 1403 | } |
| 1404 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1405 | private final class DisplayManagerHandler extends Handler { |
| 1406 | public DisplayManagerHandler(Looper looper) { |
| 1407 | super(looper, null, true /*async*/); |
Jeff Brown | 848c2dc | 2012-08-19 20:18:08 -0700 | [diff] [blame] | 1408 | } |
Jeff Brown | bf5740e | 2012-08-19 23:20:02 -0700 | [diff] [blame] | 1409 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1410 | @Override |
| 1411 | public void handleMessage(Message msg) { |
| 1412 | switch (msg.what) { |
Santos Cordon | c22c563 | 2017-06-21 16:03:49 -0700 | [diff] [blame] | 1413 | case MSG_REGISTER_DEFAULT_DISPLAY_ADAPTERS: |
| 1414 | registerDefaultDisplayAdapters(); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1415 | break; |
| 1416 | |
| 1417 | case MSG_REGISTER_ADDITIONAL_DISPLAY_ADAPTERS: |
| 1418 | registerAdditionalDisplayAdapters(); |
| 1419 | break; |
| 1420 | |
| 1421 | case MSG_DELIVER_DISPLAY_EVENT: |
| 1422 | deliverDisplayEvent(msg.arg1, msg.arg2); |
| 1423 | break; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1424 | |
| 1425 | case MSG_REQUEST_TRAVERSAL: |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1426 | mWindowManagerInternal.requestTraversalFromDisplayManager(); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1427 | break; |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1428 | |
| 1429 | case MSG_UPDATE_VIEWPORT: { |
| 1430 | synchronized (mSyncRoot) { |
| 1431 | mTempDefaultViewport.copyFrom(mDefaultViewport); |
| 1432 | mTempExternalTouchViewport.copyFrom(mExternalTouchViewport); |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 1433 | if (!mTempVirtualTouchViewports.equals(mVirtualTouchViewports)) { |
| 1434 | mTempVirtualTouchViewports.clear(); |
| 1435 | for (DisplayViewport d : mVirtualTouchViewports) { |
| 1436 | mTempVirtualTouchViewports.add(d.makeCopy()); |
| 1437 | } |
| 1438 | } |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1439 | } |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 1440 | mInputManagerInternal.setDisplayViewports(mTempDefaultViewport, |
| 1441 | mTempExternalTouchViewport, mTempVirtualTouchViewports); |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1442 | break; |
| 1443 | } |
Kenny Guy | 22bd044 | 2017-10-26 00:15:54 +0100 | [diff] [blame] | 1444 | |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 1445 | case MSG_LOAD_BRIGHTNESS_CONFIGURATION: |
| 1446 | loadBrightnessConfiguration(); |
| 1447 | break; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1448 | } |
| 1449 | } |
| 1450 | } |
| 1451 | |
| 1452 | private final class DisplayAdapterListener implements DisplayAdapter.Listener { |
| 1453 | @Override |
| 1454 | public void onDisplayDeviceEvent(DisplayDevice device, int event) { |
| 1455 | switch (event) { |
| 1456 | case DisplayAdapter.DISPLAY_DEVICE_EVENT_ADDED: |
| 1457 | handleDisplayDeviceAdded(device); |
| 1458 | break; |
| 1459 | |
| 1460 | case DisplayAdapter.DISPLAY_DEVICE_EVENT_CHANGED: |
| 1461 | handleDisplayDeviceChanged(device); |
| 1462 | break; |
| 1463 | |
| 1464 | case DisplayAdapter.DISPLAY_DEVICE_EVENT_REMOVED: |
| 1465 | handleDisplayDeviceRemoved(device); |
| 1466 | break; |
| 1467 | } |
| 1468 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1469 | |
| 1470 | @Override |
| 1471 | public void onTraversalRequested() { |
| 1472 | synchronized (mSyncRoot) { |
Craig Mautner | 65d11b3 | 2012-10-01 13:59:52 -0700 | [diff] [blame] | 1473 | scheduleTraversalLocked(false); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1474 | } |
| 1475 | } |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1476 | } |
| 1477 | |
| 1478 | private final class CallbackRecord implements DeathRecipient { |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 1479 | public final int mPid; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1480 | private final IDisplayManagerCallback mCallback; |
| 1481 | |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 1482 | public boolean mWifiDisplayScanRequested; |
| 1483 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1484 | public CallbackRecord(int pid, IDisplayManagerCallback callback) { |
| 1485 | mPid = pid; |
| 1486 | mCallback = callback; |
| 1487 | } |
| 1488 | |
| 1489 | @Override |
| 1490 | public void binderDied() { |
| 1491 | if (DEBUG) { |
| 1492 | Slog.d(TAG, "Display listener for pid " + mPid + " died."); |
| 1493 | } |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 1494 | onCallbackDied(this); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1495 | } |
| 1496 | |
| 1497 | public void notifyDisplayEventAsync(int displayId, int event) { |
| 1498 | try { |
| 1499 | mCallback.onDisplayEvent(displayId, event); |
| 1500 | } catch (RemoteException ex) { |
| 1501 | Slog.w(TAG, "Failed to notify process " |
| 1502 | + mPid + " that displays changed, assuming it died.", ex); |
| 1503 | binderDied(); |
| 1504 | } |
| 1505 | } |
| 1506 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1507 | |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 1508 | @VisibleForTesting |
| 1509 | final class BinderService extends IDisplayManager.Stub { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1510 | /** |
| 1511 | * Returns information about the specified logical display. |
| 1512 | * |
| 1513 | * @param displayId The logical display id. |
| 1514 | * @return The logical display info, or null if the display does not exist. The |
| 1515 | * returned object must be treated as immutable. |
| 1516 | */ |
| 1517 | @Override // Binder call |
| 1518 | public DisplayInfo getDisplayInfo(int displayId) { |
| 1519 | final int callingUid = Binder.getCallingUid(); |
| 1520 | final long token = Binder.clearCallingIdentity(); |
| 1521 | try { |
| 1522 | return getDisplayInfoInternal(displayId, callingUid); |
| 1523 | } finally { |
| 1524 | Binder.restoreCallingIdentity(token); |
| 1525 | } |
| 1526 | } |
| 1527 | |
| 1528 | /** |
| 1529 | * Returns the list of all display ids. |
| 1530 | */ |
| 1531 | @Override // Binder call |
| 1532 | public int[] getDisplayIds() { |
| 1533 | final int callingUid = Binder.getCallingUid(); |
| 1534 | final long token = Binder.clearCallingIdentity(); |
| 1535 | try { |
| 1536 | return getDisplayIdsInternal(callingUid); |
| 1537 | } finally { |
| 1538 | Binder.restoreCallingIdentity(token); |
| 1539 | } |
| 1540 | } |
| 1541 | |
Michael Wright | eedcbf1 | 2017-08-16 23:14:54 +0100 | [diff] [blame] | 1542 | /** |
| 1543 | * Returns the stable device display size, in pixels. |
| 1544 | */ |
| 1545 | @Override // Binder call |
| 1546 | public Point getStableDisplaySize() { |
| 1547 | final long token = Binder.clearCallingIdentity(); |
| 1548 | try { |
| 1549 | return getStableDisplaySizeInternal(); |
| 1550 | } finally { |
| 1551 | Binder.restoreCallingIdentity(token); |
| 1552 | } |
| 1553 | } |
| 1554 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1555 | @Override // Binder call |
| 1556 | public void registerCallback(IDisplayManagerCallback callback) { |
| 1557 | if (callback == null) { |
| 1558 | throw new IllegalArgumentException("listener must not be null"); |
| 1559 | } |
| 1560 | |
| 1561 | final int callingPid = Binder.getCallingPid(); |
| 1562 | final long token = Binder.clearCallingIdentity(); |
| 1563 | try { |
| 1564 | registerCallbackInternal(callback, callingPid); |
| 1565 | } finally { |
| 1566 | Binder.restoreCallingIdentity(token); |
| 1567 | } |
| 1568 | } |
| 1569 | |
| 1570 | @Override // Binder call |
| 1571 | public void startWifiDisplayScan() { |
| 1572 | mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY, |
| 1573 | "Permission required to start wifi display scans"); |
| 1574 | |
| 1575 | final int callingPid = Binder.getCallingPid(); |
| 1576 | final long token = Binder.clearCallingIdentity(); |
| 1577 | try { |
| 1578 | startWifiDisplayScanInternal(callingPid); |
| 1579 | } finally { |
| 1580 | Binder.restoreCallingIdentity(token); |
| 1581 | } |
| 1582 | } |
| 1583 | |
| 1584 | @Override // Binder call |
| 1585 | public void stopWifiDisplayScan() { |
| 1586 | mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY, |
| 1587 | "Permission required to stop wifi display scans"); |
| 1588 | |
| 1589 | final int callingPid = Binder.getCallingPid(); |
| 1590 | final long token = Binder.clearCallingIdentity(); |
| 1591 | try { |
| 1592 | stopWifiDisplayScanInternal(callingPid); |
| 1593 | } finally { |
| 1594 | Binder.restoreCallingIdentity(token); |
| 1595 | } |
| 1596 | } |
| 1597 | |
| 1598 | @Override // Binder call |
| 1599 | public void connectWifiDisplay(String address) { |
| 1600 | if (address == null) { |
| 1601 | throw new IllegalArgumentException("address must not be null"); |
| 1602 | } |
| 1603 | mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY, |
| 1604 | "Permission required to connect to a wifi display"); |
| 1605 | |
| 1606 | final long token = Binder.clearCallingIdentity(); |
| 1607 | try { |
| 1608 | connectWifiDisplayInternal(address); |
| 1609 | } finally { |
| 1610 | Binder.restoreCallingIdentity(token); |
| 1611 | } |
| 1612 | } |
| 1613 | |
| 1614 | @Override // Binder call |
| 1615 | public void disconnectWifiDisplay() { |
| 1616 | // This request does not require special permissions. |
| 1617 | // Any app can request disconnection from the currently active wifi display. |
| 1618 | // This exception should no longer be needed once wifi display control moves |
| 1619 | // to the media router service. |
| 1620 | |
| 1621 | final long token = Binder.clearCallingIdentity(); |
| 1622 | try { |
| 1623 | disconnectWifiDisplayInternal(); |
| 1624 | } finally { |
| 1625 | Binder.restoreCallingIdentity(token); |
| 1626 | } |
| 1627 | } |
| 1628 | |
| 1629 | @Override // Binder call |
| 1630 | public void renameWifiDisplay(String address, String alias) { |
| 1631 | if (address == null) { |
| 1632 | throw new IllegalArgumentException("address must not be null"); |
| 1633 | } |
| 1634 | mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY, |
| 1635 | "Permission required to rename to a wifi display"); |
| 1636 | |
| 1637 | final long token = Binder.clearCallingIdentity(); |
| 1638 | try { |
| 1639 | renameWifiDisplayInternal(address, alias); |
| 1640 | } finally { |
| 1641 | Binder.restoreCallingIdentity(token); |
| 1642 | } |
| 1643 | } |
| 1644 | |
| 1645 | @Override // Binder call |
| 1646 | public void forgetWifiDisplay(String address) { |
| 1647 | if (address == null) { |
| 1648 | throw new IllegalArgumentException("address must not be null"); |
| 1649 | } |
| 1650 | mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY, |
| 1651 | "Permission required to forget to a wifi display"); |
| 1652 | |
| 1653 | final long token = Binder.clearCallingIdentity(); |
| 1654 | try { |
| 1655 | forgetWifiDisplayInternal(address); |
| 1656 | } finally { |
| 1657 | Binder.restoreCallingIdentity(token); |
| 1658 | } |
| 1659 | } |
| 1660 | |
| 1661 | @Override // Binder call |
| 1662 | public void pauseWifiDisplay() { |
| 1663 | mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY, |
| 1664 | "Permission required to pause a wifi display session"); |
| 1665 | |
| 1666 | final long token = Binder.clearCallingIdentity(); |
| 1667 | try { |
| 1668 | pauseWifiDisplayInternal(); |
| 1669 | } finally { |
| 1670 | Binder.restoreCallingIdentity(token); |
| 1671 | } |
| 1672 | } |
| 1673 | |
| 1674 | @Override // Binder call |
| 1675 | public void resumeWifiDisplay() { |
| 1676 | mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY, |
| 1677 | "Permission required to resume a wifi display session"); |
| 1678 | |
| 1679 | final long token = Binder.clearCallingIdentity(); |
| 1680 | try { |
| 1681 | resumeWifiDisplayInternal(); |
| 1682 | } finally { |
| 1683 | Binder.restoreCallingIdentity(token); |
| 1684 | } |
| 1685 | } |
| 1686 | |
| 1687 | @Override // Binder call |
| 1688 | public WifiDisplayStatus getWifiDisplayStatus() { |
| 1689 | // This request does not require special permissions. |
| 1690 | // Any app can get information about available wifi displays. |
| 1691 | |
| 1692 | final long token = Binder.clearCallingIdentity(); |
| 1693 | try { |
| 1694 | return getWifiDisplayStatusInternal(); |
| 1695 | } finally { |
| 1696 | Binder.restoreCallingIdentity(token); |
| 1697 | } |
| 1698 | } |
| 1699 | |
| 1700 | @Override // Binder call |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 1701 | public void requestColorMode(int displayId, int colorMode) { |
Michael Wright | 58e829f | 2015-09-15 00:13:26 +0100 | [diff] [blame] | 1702 | mContext.enforceCallingOrSelfPermission( |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 1703 | Manifest.permission.CONFIGURE_DISPLAY_COLOR_MODE, |
| 1704 | "Permission required to change the display color mode"); |
Michael Wright | 58e829f | 2015-09-15 00:13:26 +0100 | [diff] [blame] | 1705 | final long token = Binder.clearCallingIdentity(); |
| 1706 | try { |
Michael Wright | 1c9977b | 2016-07-12 13:30:10 -0700 | [diff] [blame] | 1707 | requestColorModeInternal(displayId, colorMode); |
Michael Wright | 58e829f | 2015-09-15 00:13:26 +0100 | [diff] [blame] | 1708 | } finally { |
| 1709 | Binder.restoreCallingIdentity(token); |
| 1710 | } |
| 1711 | } |
| 1712 | |
| 1713 | @Override // Binder call |
Bryan Mawhinney | 462e29d | 2018-03-22 15:52:41 +0000 | [diff] [blame] | 1714 | public void setSaturationLevel(float level) { |
| 1715 | mContext.enforceCallingOrSelfPermission( |
| 1716 | Manifest.permission.CONTROL_DISPLAY_SATURATION, |
| 1717 | "Permission required to set display saturation level"); |
| 1718 | final long token = Binder.clearCallingIdentity(); |
| 1719 | try { |
| 1720 | setSaturationLevelInternal(level); |
| 1721 | } finally { |
| 1722 | Binder.restoreCallingIdentity(token); |
| 1723 | } |
| 1724 | } |
| 1725 | |
| 1726 | @Override // Binder call |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1727 | public int createVirtualDisplay(IVirtualDisplayCallback callback, |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1728 | IMediaProjection projection, String packageName, String name, |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 1729 | int width, int height, int densityDpi, Surface surface, int flags, |
| 1730 | String uniqueId) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1731 | final int callingUid = Binder.getCallingUid(); |
| 1732 | if (!validatePackageName(callingUid, packageName)) { |
| 1733 | throw new SecurityException("packageName must match the calling uid"); |
| 1734 | } |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1735 | if (callback == null) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1736 | throw new IllegalArgumentException("appToken must not be null"); |
| 1737 | } |
| 1738 | if (TextUtils.isEmpty(name)) { |
| 1739 | throw new IllegalArgumentException("name must be non-null and non-empty"); |
| 1740 | } |
| 1741 | if (width <= 0 || height <= 0 || densityDpi <= 0) { |
| 1742 | throw new IllegalArgumentException("width, height, and densityDpi must be " |
| 1743 | + "greater than 0"); |
| 1744 | } |
Pablo Ceballos | eb3370d | 2016-08-31 15:00:17 -0700 | [diff] [blame] | 1745 | if (surface != null && surface.isSingleBuffered()) { |
Pablo Ceballos | aff2f94 | 2016-07-29 14:49:55 -0700 | [diff] [blame] | 1746 | throw new IllegalArgumentException("Surface can't be single-buffered"); |
| 1747 | } |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1748 | |
Andrii Kulian | fc8f82b | 2017-01-26 13:17:27 -0800 | [diff] [blame] | 1749 | if ((flags & VIRTUAL_DISPLAY_FLAG_PUBLIC) != 0) { |
| 1750 | flags |= VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR; |
| 1751 | |
| 1752 | // Public displays can't be allowed to show content when locked. |
Andrii Kulian | 7211d2e | 2017-01-27 15:58:05 -0800 | [diff] [blame] | 1753 | if ((flags & VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD) != 0) { |
Andrii Kulian | fc8f82b | 2017-01-26 13:17:27 -0800 | [diff] [blame] | 1754 | throw new IllegalArgumentException( |
| 1755 | "Public display must not be marked as SHOW_WHEN_LOCKED_INSECURE"); |
| 1756 | } |
Michael Wright | 6720be4 | 2014-07-29 19:14:16 -0700 | [diff] [blame] | 1757 | } |
Andrii Kulian | fc8f82b | 2017-01-26 13:17:27 -0800 | [diff] [blame] | 1758 | if ((flags & VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY) != 0) { |
| 1759 | flags &= ~VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR; |
Michael Wright | 6720be4 | 2014-07-29 19:14:16 -0700 | [diff] [blame] | 1760 | } |
| 1761 | |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1762 | if (projection != null) { |
| 1763 | try { |
| 1764 | if (!getProjectionService().isValidMediaProjection(projection)) { |
| 1765 | throw new SecurityException("Invalid media projection"); |
| 1766 | } |
Michael Wright | 6720be4 | 2014-07-29 19:14:16 -0700 | [diff] [blame] | 1767 | flags = projection.applyVirtualDisplayFlags(flags); |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1768 | } catch (RemoteException e) { |
Michael Wright | 6720be4 | 2014-07-29 19:14:16 -0700 | [diff] [blame] | 1769 | throw new SecurityException("unable to validate media projection or flags"); |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1770 | } |
| 1771 | } |
| 1772 | |
Michael Wright | 6720be4 | 2014-07-29 19:14:16 -0700 | [diff] [blame] | 1773 | if (callingUid != Process.SYSTEM_UID && |
Andrii Kulian | fc8f82b | 2017-01-26 13:17:27 -0800 | [diff] [blame] | 1774 | (flags & VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR) != 0) { |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1775 | if (!canProjectVideo(projection)) { |
| 1776 | throw new SecurityException("Requires CAPTURE_VIDEO_OUTPUT or " |
| 1777 | + "CAPTURE_SECURE_VIDEO_OUTPUT permission, or an appropriate " |
| 1778 | + "MediaProjection token in order to create a screen sharing virtual " |
| 1779 | + "display."); |
| 1780 | } |
| 1781 | } |
Andrii Kulian | fc8f82b | 2017-01-26 13:17:27 -0800 | [diff] [blame] | 1782 | if ((flags & VIRTUAL_DISPLAY_FLAG_SECURE) != 0) { |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1783 | if (!canProjectSecureVideo(projection)) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1784 | throw new SecurityException("Requires CAPTURE_SECURE_VIDEO_OUTPUT " |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1785 | + "or an appropriate MediaProjection token to create a " |
| 1786 | + "secure virtual display."); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1787 | } |
| 1788 | } |
| 1789 | |
| 1790 | final long token = Binder.clearCallingIdentity(); |
| 1791 | try { |
Santos Cordon | ee8931e | 2017-04-05 10:31:15 -0700 | [diff] [blame] | 1792 | return createVirtualDisplayInternal(callback, projection, callingUid, packageName, |
| 1793 | name, width, height, densityDpi, surface, flags, uniqueId); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1794 | } finally { |
| 1795 | Binder.restoreCallingIdentity(token); |
| 1796 | } |
| 1797 | } |
| 1798 | |
| 1799 | @Override // Binder call |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1800 | public void resizeVirtualDisplay(IVirtualDisplayCallback callback, |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 1801 | int width, int height, int densityDpi) { |
| 1802 | final long token = Binder.clearCallingIdentity(); |
| 1803 | try { |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1804 | resizeVirtualDisplayInternal(callback.asBinder(), width, height, densityDpi); |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 1805 | } finally { |
| 1806 | Binder.restoreCallingIdentity(token); |
| 1807 | } |
| 1808 | } |
| 1809 | |
| 1810 | @Override // Binder call |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1811 | public void setVirtualDisplaySurface(IVirtualDisplayCallback callback, Surface surface) { |
Pablo Ceballos | eb3370d | 2016-08-31 15:00:17 -0700 | [diff] [blame] | 1812 | if (surface != null && surface.isSingleBuffered()) { |
| 1813 | throw new IllegalArgumentException("Surface can't be single-buffered"); |
| 1814 | } |
Jeff Brown | 92207df | 2014-04-16 13:16:07 -0700 | [diff] [blame] | 1815 | final long token = Binder.clearCallingIdentity(); |
| 1816 | try { |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1817 | setVirtualDisplaySurfaceInternal(callback.asBinder(), surface); |
Jeff Brown | 92207df | 2014-04-16 13:16:07 -0700 | [diff] [blame] | 1818 | } finally { |
| 1819 | Binder.restoreCallingIdentity(token); |
| 1820 | } |
| 1821 | } |
| 1822 | |
| 1823 | @Override // Binder call |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1824 | public void releaseVirtualDisplay(IVirtualDisplayCallback callback) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1825 | final long token = Binder.clearCallingIdentity(); |
| 1826 | try { |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1827 | releaseVirtualDisplayInternal(callback.asBinder()); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1828 | } finally { |
| 1829 | Binder.restoreCallingIdentity(token); |
| 1830 | } |
| 1831 | } |
| 1832 | |
| 1833 | @Override // Binder call |
| 1834 | public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) { |
Jeff Sharkey | fe9a53b | 2017-03-31 14:08:23 -0600 | [diff] [blame] | 1835 | if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1836 | |
| 1837 | final long token = Binder.clearCallingIdentity(); |
| 1838 | try { |
| 1839 | dumpInternal(pw); |
| 1840 | } finally { |
| 1841 | Binder.restoreCallingIdentity(token); |
| 1842 | } |
| 1843 | } |
| 1844 | |
Kenny Guy | 22bd044 | 2017-10-26 00:15:54 +0100 | [diff] [blame] | 1845 | @Override // Binder call |
Kenny Guy | 29aa30e | 2017-11-30 13:43:46 +0000 | [diff] [blame] | 1846 | public ParceledListSlice<BrightnessChangeEvent> getBrightnessEvents(String callingPackage) { |
Kenny Guy | 22bd044 | 2017-10-26 00:15:54 +0100 | [diff] [blame] | 1847 | mContext.enforceCallingOrSelfPermission( |
| 1848 | Manifest.permission.BRIGHTNESS_SLIDER_USAGE, |
| 1849 | "Permission to read brightness events."); |
Kenny Guy | 29aa30e | 2017-11-30 13:43:46 +0000 | [diff] [blame] | 1850 | |
| 1851 | final int callingUid = Binder.getCallingUid(); |
| 1852 | AppOpsManager appOpsManager = mContext.getSystemService(AppOpsManager.class); |
| 1853 | final int mode = appOpsManager.checkOp(AppOpsManager.OP_GET_USAGE_STATS, |
| 1854 | callingUid, callingPackage); |
| 1855 | final boolean hasUsageStats; |
| 1856 | if (mode == AppOpsManager.MODE_DEFAULT) { |
| 1857 | // The default behavior here is to check if PackageManager has given the app |
| 1858 | // permission. |
| 1859 | hasUsageStats = mContext.checkCallingPermission( |
| 1860 | Manifest.permission.PACKAGE_USAGE_STATS) |
| 1861 | == PackageManager.PERMISSION_GRANTED; |
| 1862 | } else { |
| 1863 | hasUsageStats = mode == AppOpsManager.MODE_ALLOWED; |
| 1864 | } |
| 1865 | |
| 1866 | final int userId = UserHandle.getUserId(callingUid); |
Kenny Guy | 22bd044 | 2017-10-26 00:15:54 +0100 | [diff] [blame] | 1867 | final long token = Binder.clearCallingIdentity(); |
| 1868 | try { |
Michael Wright | 144aac9 | 2017-12-21 18:37:41 +0000 | [diff] [blame] | 1869 | synchronized (mSyncRoot) { |
| 1870 | return mDisplayPowerController.getBrightnessEvents(userId, hasUsageStats); |
| 1871 | } |
Kenny Guy | 22bd044 | 2017-10-26 00:15:54 +0100 | [diff] [blame] | 1872 | } finally { |
| 1873 | Binder.restoreCallingIdentity(token); |
| 1874 | } |
| 1875 | } |
| 1876 | |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 1877 | @Override // Binder call |
Peeyush Agarwal | cc155dd | 2018-01-10 11:51:33 +0000 | [diff] [blame] | 1878 | public ParceledListSlice<AmbientBrightnessDayStats> getAmbientBrightnessStats() { |
| 1879 | mContext.enforceCallingOrSelfPermission( |
| 1880 | Manifest.permission.ACCESS_AMBIENT_LIGHT_STATS, |
| 1881 | "Permission required to to access ambient light stats."); |
| 1882 | final int callingUid = Binder.getCallingUid(); |
| 1883 | final int userId = UserHandle.getUserId(callingUid); |
| 1884 | final long token = Binder.clearCallingIdentity(); |
| 1885 | try { |
| 1886 | synchronized (mSyncRoot) { |
| 1887 | return mDisplayPowerController.getAmbientBrightnessStats(userId); |
| 1888 | } |
| 1889 | } finally { |
| 1890 | Binder.restoreCallingIdentity(token); |
| 1891 | } |
| 1892 | } |
| 1893 | |
| 1894 | @Override // Binder call |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 1895 | public void setBrightnessConfigurationForUser( |
Kenny Guy | 05ce809 | 2018-01-17 13:44:20 +0000 | [diff] [blame] | 1896 | BrightnessConfiguration c, @UserIdInt int userId, String packageName) { |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 1897 | mContext.enforceCallingOrSelfPermission( |
| 1898 | Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS, |
| 1899 | "Permission required to change the display's brightness configuration"); |
| 1900 | if (userId != UserHandle.getCallingUserId()) { |
| 1901 | mContext.enforceCallingOrSelfPermission( |
| 1902 | Manifest.permission.INTERACT_ACROSS_USERS, |
| 1903 | "Permission required to change the display brightness" |
| 1904 | + " configuration of another user"); |
| 1905 | } |
Kenny Guy | 05ce809 | 2018-01-17 13:44:20 +0000 | [diff] [blame] | 1906 | if (packageName != null && !validatePackageName(getCallingUid(), packageName)) { |
| 1907 | packageName = null; |
| 1908 | } |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 1909 | final long token = Binder.clearCallingIdentity(); |
| 1910 | try { |
Kenny Guy | 05ce809 | 2018-01-17 13:44:20 +0000 | [diff] [blame] | 1911 | setBrightnessConfigurationForUserInternal(c, userId, packageName); |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 1912 | } finally { |
| 1913 | Binder.restoreCallingIdentity(token); |
| 1914 | } |
| 1915 | } |
| 1916 | |
Michael Wright | d846023 | 2018-01-16 18:04:59 +0000 | [diff] [blame] | 1917 | @Override // Binder call |
Kenny Guy | 6d1009f | 2018-03-14 14:28:23 +0000 | [diff] [blame] | 1918 | public BrightnessConfiguration getBrightnessConfigurationForUser(int userId) { |
| 1919 | mContext.enforceCallingOrSelfPermission( |
| 1920 | Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS, |
| 1921 | "Permission required to read the display's brightness configuration"); |
| 1922 | if (userId != UserHandle.getCallingUserId()) { |
| 1923 | mContext.enforceCallingOrSelfPermission( |
| 1924 | Manifest.permission.INTERACT_ACROSS_USERS, |
| 1925 | "Permission required to read the display brightness" |
| 1926 | + " configuration of another user"); |
| 1927 | } |
| 1928 | final long token = Binder.clearCallingIdentity(); |
| 1929 | try { |
| 1930 | final int userSerial = getUserManager().getUserSerialNumber(userId); |
| 1931 | synchronized (mSyncRoot) { |
| 1932 | BrightnessConfiguration config = |
| 1933 | mPersistentDataStore.getBrightnessConfiguration(userSerial); |
| 1934 | if (config == null) { |
| 1935 | config = mDisplayPowerController.getDefaultBrightnessConfiguration(); |
| 1936 | } |
| 1937 | return config; |
| 1938 | } |
| 1939 | } finally { |
| 1940 | Binder.restoreCallingIdentity(token); |
| 1941 | } |
| 1942 | } |
| 1943 | |
| 1944 | @Override // Binder call |
| 1945 | public BrightnessConfiguration getDefaultBrightnessConfiguration() { |
| 1946 | mContext.enforceCallingOrSelfPermission( |
| 1947 | Manifest.permission.CONFIGURE_DISPLAY_BRIGHTNESS, |
| 1948 | "Permission required to read the display's default brightness configuration"); |
| 1949 | final long token = Binder.clearCallingIdentity(); |
| 1950 | try { |
| 1951 | synchronized (mSyncRoot) { |
| 1952 | return mDisplayPowerController.getDefaultBrightnessConfiguration(); |
| 1953 | } |
| 1954 | } finally { |
| 1955 | Binder.restoreCallingIdentity(token); |
| 1956 | } |
| 1957 | } |
| 1958 | |
| 1959 | @Override // Binder call |
Michael Wright | d846023 | 2018-01-16 18:04:59 +0000 | [diff] [blame] | 1960 | public void setTemporaryBrightness(int brightness) { |
| 1961 | mContext.enforceCallingOrSelfPermission( |
| 1962 | Manifest.permission.CONTROL_DISPLAY_BRIGHTNESS, |
| 1963 | "Permission required to set the display's brightness"); |
| 1964 | final long token = Binder.clearCallingIdentity(); |
| 1965 | try { |
| 1966 | synchronized (mSyncRoot) { |
| 1967 | mDisplayPowerController.setTemporaryBrightness(brightness); |
| 1968 | } |
| 1969 | } finally { |
| 1970 | Binder.restoreCallingIdentity(token); |
| 1971 | } |
| 1972 | } |
| 1973 | |
| 1974 | @Override // Binder call |
| 1975 | public void setTemporaryAutoBrightnessAdjustment(float adjustment) { |
| 1976 | mContext.enforceCallingOrSelfPermission( |
| 1977 | Manifest.permission.CONTROL_DISPLAY_BRIGHTNESS, |
| 1978 | "Permission required to set the display's auto brightness adjustment"); |
| 1979 | final long token = Binder.clearCallingIdentity(); |
| 1980 | try { |
| 1981 | synchronized (mSyncRoot) { |
| 1982 | mDisplayPowerController.setTemporaryAutoBrightnessAdjustment(adjustment); |
| 1983 | } |
| 1984 | } finally { |
| 1985 | Binder.restoreCallingIdentity(token); |
| 1986 | } |
| 1987 | } |
| 1988 | |
Dan Gittik | 7a32fba | 2018-03-28 12:19:38 +0100 | [diff] [blame^] | 1989 | @Override // Binder call |
| 1990 | public void onShellCommand(FileDescriptor in, FileDescriptor out, |
| 1991 | FileDescriptor err, String[] args, ShellCallback callback, |
| 1992 | ResultReceiver resultReceiver) { |
| 1993 | final long token = Binder.clearCallingIdentity(); |
| 1994 | try { |
| 1995 | DisplayManagerShellCommand command = new DisplayManagerShellCommand(this); |
| 1996 | command.exec(this, in, out, err, args, callback, resultReceiver); |
| 1997 | } finally { |
| 1998 | Binder.restoreCallingIdentity(token); |
| 1999 | } |
| 2000 | } |
| 2001 | |
| 2002 | void setBrightness(int brightness) { |
| 2003 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2004 | Settings.System.SCREEN_BRIGHTNESS, brightness, UserHandle.USER_CURRENT); |
| 2005 | } |
| 2006 | |
| 2007 | void resetBrightnessConfiguration() { |
| 2008 | setBrightnessConfigurationForUserInternal(null, mContext.getUserId(), |
| 2009 | mContext.getPackageName()); |
| 2010 | } |
| 2011 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 2012 | private boolean validatePackageName(int uid, String packageName) { |
| 2013 | if (packageName != null) { |
| 2014 | String[] packageNames = mContext.getPackageManager().getPackagesForUid(uid); |
| 2015 | if (packageNames != null) { |
| 2016 | for (String n : packageNames) { |
| 2017 | if (n.equals(packageName)) { |
| 2018 | return true; |
| 2019 | } |
| 2020 | } |
| 2021 | } |
| 2022 | } |
| 2023 | return false; |
| 2024 | } |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 2025 | |
| 2026 | private boolean canProjectVideo(IMediaProjection projection) { |
| 2027 | if (projection != null) { |
| 2028 | try { |
| 2029 | if (projection.canProjectVideo()) { |
| 2030 | return true; |
| 2031 | } |
| 2032 | } catch (RemoteException e) { |
| 2033 | Slog.e(TAG, "Unable to query projection service for permissions", e); |
| 2034 | } |
| 2035 | } |
| 2036 | if (mContext.checkCallingPermission( |
| 2037 | android.Manifest.permission.CAPTURE_VIDEO_OUTPUT) |
Michael Wright | 0ccc2b0 | 2014-07-24 18:20:41 -0700 | [diff] [blame] | 2038 | == PackageManager.PERMISSION_GRANTED) { |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 2039 | return true; |
| 2040 | } |
| 2041 | return canProjectSecureVideo(projection); |
| 2042 | } |
| 2043 | |
| 2044 | private boolean canProjectSecureVideo(IMediaProjection projection) { |
| 2045 | if (projection != null) { |
| 2046 | try { |
| 2047 | if (projection.canProjectSecureVideo()){ |
| 2048 | return true; |
| 2049 | } |
| 2050 | } catch (RemoteException e) { |
| 2051 | Slog.e(TAG, "Unable to query projection service for permissions", e); |
| 2052 | } |
| 2053 | } |
| 2054 | return mContext.checkCallingPermission( |
| 2055 | android.Manifest.permission.CAPTURE_SECURE_VIDEO_OUTPUT) |
Michael Wright | 0ccc2b0 | 2014-07-24 18:20:41 -0700 | [diff] [blame] | 2056 | == PackageManager.PERMISSION_GRANTED; |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 2057 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 2058 | } |
| 2059 | |
| 2060 | private final class LocalService extends DisplayManagerInternal { |
| 2061 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 2062 | public void initPowerManagement(final DisplayPowerCallbacks callbacks, Handler handler, |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 2063 | SensorManager sensorManager) { |
| 2064 | synchronized (mSyncRoot) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 2065 | DisplayBlanker blanker = new DisplayBlanker() { |
| 2066 | @Override |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 2067 | public void requestDisplayState(int state, int brightness) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 2068 | // The order of operations is important for legacy reasons. |
| 2069 | if (state == Display.STATE_OFF) { |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 2070 | requestGlobalDisplayStateInternal(state, brightness); |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 2071 | } |
| 2072 | |
| 2073 | callbacks.onDisplayStateChange(state); |
| 2074 | |
| 2075 | if (state != Display.STATE_OFF) { |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 2076 | requestGlobalDisplayStateInternal(state, brightness); |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 2077 | } |
| 2078 | } |
| 2079 | }; |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 2080 | mDisplayPowerController = new DisplayPowerController( |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 2081 | mContext, callbacks, handler, sensorManager, blanker); |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 2082 | } |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 2083 | |
| 2084 | mHandler.sendEmptyMessage(MSG_LOAD_BRIGHTNESS_CONFIGURATION); |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 2085 | } |
| 2086 | |
| 2087 | @Override |
| 2088 | public boolean requestPowerState(DisplayPowerRequest request, |
| 2089 | boolean waitForNegativeProximity) { |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 2090 | synchronized (mSyncRoot) { |
| 2091 | return mDisplayPowerController.requestPowerState(request, |
| 2092 | waitForNegativeProximity); |
| 2093 | } |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 2094 | } |
| 2095 | |
| 2096 | @Override |
| 2097 | public boolean isProximitySensorAvailable() { |
Michael Wright | eef0e13 | 2017-11-21 17:57:52 +0000 | [diff] [blame] | 2098 | synchronized (mSyncRoot) { |
| 2099 | return mDisplayPowerController.isProximitySensorAvailable(); |
| 2100 | } |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 2101 | } |
| 2102 | |
| 2103 | @Override |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 2104 | public DisplayInfo getDisplayInfo(int displayId) { |
| 2105 | return getDisplayInfoInternal(displayId, Process.myUid()); |
| 2106 | } |
| 2107 | |
| 2108 | @Override |
| 2109 | public void registerDisplayTransactionListener(DisplayTransactionListener listener) { |
| 2110 | if (listener == null) { |
| 2111 | throw new IllegalArgumentException("listener must not be null"); |
| 2112 | } |
| 2113 | |
| 2114 | registerDisplayTransactionListenerInternal(listener); |
| 2115 | } |
| 2116 | |
| 2117 | @Override |
| 2118 | public void unregisterDisplayTransactionListener(DisplayTransactionListener listener) { |
| 2119 | if (listener == null) { |
| 2120 | throw new IllegalArgumentException("listener must not be null"); |
| 2121 | } |
| 2122 | |
| 2123 | unregisterDisplayTransactionListenerInternal(listener); |
| 2124 | } |
| 2125 | |
| 2126 | @Override |
| 2127 | public void setDisplayInfoOverrideFromWindowManager(int displayId, DisplayInfo info) { |
| 2128 | setDisplayInfoOverrideFromWindowManagerInternal(displayId, info); |
| 2129 | } |
| 2130 | |
| 2131 | @Override |
Andrii Kulian | cd09799 | 2017-03-23 18:31:59 -0700 | [diff] [blame] | 2132 | public void getNonOverrideDisplayInfo(int displayId, DisplayInfo outInfo) { |
| 2133 | getNonOverrideDisplayInfoInternal(displayId, outInfo); |
| 2134 | } |
| 2135 | |
| 2136 | @Override |
Robert Carr | ae606b4 | 2018-02-15 15:36:23 -0800 | [diff] [blame] | 2137 | public void performTraversal(SurfaceControl.Transaction t) { |
| 2138 | performTraversalInternal(t); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 2139 | } |
| 2140 | |
| 2141 | @Override |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 2142 | public void setDisplayProperties(int displayId, boolean hasContent, |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 2143 | float requestedRefreshRate, int requestedMode, boolean inTraversal) { |
| 2144 | setDisplayPropertiesInternal(displayId, hasContent, requestedRefreshRate, |
| 2145 | requestedMode, inTraversal); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 2146 | } |
Filip Gruszczynski | d2e8640 | 2015-02-19 13:05:03 -0800 | [diff] [blame] | 2147 | |
| 2148 | @Override |
| 2149 | public void setDisplayOffsets(int displayId, int x, int y) { |
| 2150 | setDisplayOffsetsInternal(displayId, x, y); |
| 2151 | } |
Andrii Kulian | fb1bf69 | 2017-01-17 11:17:34 -0800 | [diff] [blame] | 2152 | |
| 2153 | @Override |
| 2154 | public void setDisplayAccessUIDs(SparseArray<IntArray> newDisplayAccessUIDs) { |
| 2155 | setDisplayAccessUIDsInternal(newDisplayAccessUIDs); |
| 2156 | } |
| 2157 | |
| 2158 | @Override |
| 2159 | public boolean isUidPresentOnDisplay(int uid, int displayId) { |
| 2160 | return isUidPresentOnDisplayInternal(uid, displayId); |
| 2161 | } |
Kenny Guy | cfe7b70 | 2017-11-14 21:04:58 +0000 | [diff] [blame] | 2162 | |
| 2163 | @Override |
Peeyush Agarwal | cc155dd | 2018-01-10 11:51:33 +0000 | [diff] [blame] | 2164 | public void persistBrightnessTrackerState() { |
Michael Wright | 144aac9 | 2017-12-21 18:37:41 +0000 | [diff] [blame] | 2165 | synchronized (mSyncRoot) { |
Peeyush Agarwal | cc155dd | 2018-01-10 11:51:33 +0000 | [diff] [blame] | 2166 | mDisplayPowerController.persistBrightnessTrackerState(); |
Michael Wright | 144aac9 | 2017-12-21 18:37:41 +0000 | [diff] [blame] | 2167 | } |
Kenny Guy | cfe7b70 | 2017-11-14 21:04:58 +0000 | [diff] [blame] | 2168 | } |
Adrian Roos | e1d68cd | 2018-01-17 12:54:50 +0100 | [diff] [blame] | 2169 | |
| 2170 | @Override |
| 2171 | public void onOverlayChanged() { |
| 2172 | synchronized (mSyncRoot) { |
Adrian Roos | 898ec38 | 2018-01-17 12:54:50 +0100 | [diff] [blame] | 2173 | for (int i = 0; i < mDisplayDevices.size(); i++) { |
| 2174 | mDisplayDevices.get(i).onOverlayChangedLocked(); |
Adrian Roos | e1d68cd | 2018-01-17 12:54:50 +0100 | [diff] [blame] | 2175 | } |
| 2176 | } |
| 2177 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 2178 | } |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 2179 | } |