blob: fd89b970071424b63ecb4f34033d7bd274bf87a9 [file] [log] [blame]
Jeff Brownfa25bf52012-07-23 19:26:30 -07001/*
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
17package com.android.server.display;
18
Andrii Kulianfc8f82b2017-01-26 13:17:27 -080019import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;
20import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY;
21import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC;
22import static android.hardware.display.DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE;
23import static android.hardware.display.DisplayManager
Andrii Kulian7211d2e2017-01-27 15:58:05 -080024 .VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD;
Andrii Kulianfc8f82b2017-01-26 13:17:27 -080025
Jeff Brownbd6e1502012-08-28 03:27:37 -070026import com.android.internal.util.IndentingPrintWriter;
27
Jeff Brownfa25bf52012-07-23 19:26:30 -070028import android.Manifest;
29import android.content.Context;
30import android.content.pm.PackageManager;
Jeff Brownad9ef192014-04-08 17:26:30 -070031import android.hardware.SensorManager;
Jeff Brownbd6e1502012-08-28 03:27:37 -070032import android.hardware.display.DisplayManagerGlobal;
Jeff Brown4ccb8232014-01-16 22:16:42 -080033import android.hardware.display.DisplayManagerInternal;
34import android.hardware.display.DisplayViewport;
35import android.hardware.display.DisplayManagerInternal.DisplayTransactionListener;
Jeff Brownfa25bf52012-07-23 19:26:30 -070036import android.hardware.display.IDisplayManager;
Jeff Brownbd6e1502012-08-28 03:27:37 -070037import android.hardware.display.IDisplayManagerCallback;
Michael Wright75ee9fc2014-09-01 19:55:22 -070038import android.hardware.display.IVirtualDisplayCallback;
Jeff Browne08ae382012-09-07 20:36:36 -070039import android.hardware.display.WifiDisplayStatus;
Jeff Brown4ccb8232014-01-16 22:16:42 -080040import android.hardware.input.InputManagerInternal;
Michael Wrightc39d47a2014-07-08 18:07:36 -070041import android.media.projection.IMediaProjection;
42import android.media.projection.IMediaProjectionManager;
Jeff Brownfa25bf52012-07-23 19:26:30 -070043import android.os.Binder;
Jeff Brownbd6e1502012-08-28 03:27:37 -070044import android.os.Handler;
Jeff Brown64a55af2012-08-26 02:47:39 -070045import android.os.IBinder;
Jeff Brown4ccb8232014-01-16 22:16:42 -080046import android.os.IBinder.DeathRecipient;
Jeff Brownbd6e1502012-08-28 03:27:37 -070047import android.os.Looper;
48import android.os.Message;
Jeff Brown5d6443b2015-04-10 20:15:01 -070049import android.os.PowerManager;
Craig Mautner4504de52013-12-20 09:06:56 -080050import android.os.Process;
Jeff Brownbd6e1502012-08-28 03:27:37 -070051import android.os.RemoteException;
Michael Wrightc39d47a2014-07-08 18:07:36 -070052import android.os.ServiceManager;
Jeff Brownbd6e1502012-08-28 03:27:37 -070053import android.os.SystemClock;
Jeff Brownfa25bf52012-07-23 19:26:30 -070054import android.os.SystemProperties;
Jeff Brown5d6443b2015-04-10 20:15:01 -070055import android.os.Trace;
Jeff Browna506a6e2013-06-04 00:02:38 -070056import android.text.TextUtils;
Andrii Kulianfb1bf692017-01-17 11:17:34 -080057import android.util.IntArray;
Jeff Brownbd6e1502012-08-28 03:27:37 -070058import android.util.Slog;
59import android.util.SparseArray;
Jeff Brownfa25bf52012-07-23 19:26:30 -070060import android.view.Display;
61import android.view.DisplayInfo;
Jeff Browna506a6e2013-06-04 00:02:38 -070062import android.view.Surface;
Jeff Brown4ccb8232014-01-16 22:16:42 -080063import android.view.WindowManagerInternal;
Jeff Browna506a6e2013-06-04 00:02:38 -070064
Jeff Brown4ccb8232014-01-16 22:16:42 -080065import com.android.server.DisplayThread;
66import com.android.server.LocalServices;
67import com.android.server.SystemService;
Dianne Hackborn8d044e82013-04-30 17:24:15 -070068import com.android.server.UiThread;
Jeff Brownfa25bf52012-07-23 19:26:30 -070069
70import java.io.FileDescriptor;
71import java.io.PrintWriter;
72import java.util.ArrayList;
Jeff Browna506a6e2013-06-04 00:02:38 -070073import java.util.Arrays;
Jeff Browne75926d2014-09-18 15:24:49 -070074import java.util.List;
Jeff Brown7f3994e2012-12-04 14:04:28 -080075import java.util.concurrent.CopyOnWriteArrayList;
Jeff Brownfa25bf52012-07-23 19:26:30 -070076
77/**
Jeff Brownbd6e1502012-08-28 03:27:37 -070078 * Manages attached displays.
Jeff Brownfa25bf52012-07-23 19:26:30 -070079 * <p>
Jeff Brownbd6e1502012-08-28 03:27:37 -070080 * The {@link DisplayManagerService} manages the global lifecycle of displays,
81 * decides how to configure logical displays based on the physical display devices currently
82 * attached, sends notifications to the system and to applications when the state
83 * changes, and so on.
84 * </p><p>
85 * The display manager service relies on a collection of {@link DisplayAdapter} components,
86 * for discovering and configuring physical display devices attached to the system.
87 * There are separate display adapters for each manner that devices are attached:
88 * one display adapter for built-in local displays, one for simulated non-functional
89 * displays when the system is headless, one for simulated overlay displays used for
90 * development, one for wifi displays, etc.
91 * </p><p>
92 * Display adapters are only weakly coupled to the display manager service.
93 * Display adapters communicate changes in display device state to the display manager
Craig Mautner722285e2012-09-07 13:55:58 -070094 * service asynchronously via a {@link DisplayAdapter.Listener} registered
Jeff Brownbd6e1502012-08-28 03:27:37 -070095 * by the display manager service. This separation of concerns is important for
96 * two main reasons. First, it neatly encapsulates the responsibilities of these
97 * two classes: display adapters handle individual display devices whereas
98 * the display manager service handles the global state. Second, it eliminates
99 * the potential for deadlocks resulting from asynchronous display device discovery.
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700100 * </p>
101 *
102 * <h3>Synchronization</h3>
103 * <p>
104 * Because the display manager may be accessed by multiple threads, the synchronization
105 * story gets a little complicated. In particular, the window manager may call into
106 * the display manager while holding a surface transaction with the expectation that
107 * it can apply changes immediately. Unfortunately, that means we can't just do
108 * everything asynchronously (*grump*).
Jeff Brownbd6e1502012-08-28 03:27:37 -0700109 * </p><p>
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700110 * To make this work, all of the objects that belong to the display manager must
111 * use the same lock. We call this lock the synchronization root and it has a unique
112 * type {@link DisplayManagerService.SyncRoot}. Methods that require this lock are
113 * named with the "Locked" suffix.
114 * </p><p>
115 * Where things get tricky is that the display manager is not allowed to make
116 * any potentially reentrant calls, especially into the window manager. We generally
117 * avoid this by making all potentially reentrant out-calls asynchronous.
Jeff Brownfa25bf52012-07-23 19:26:30 -0700118 * </p>
119 */
Jeff Brown4ccb8232014-01-16 22:16:42 -0800120public final class DisplayManagerService extends SystemService {
Jeff Brownfa25bf52012-07-23 19:26:30 -0700121 private static final String TAG = "DisplayManagerService";
Jeff Brownbd6e1502012-08-28 03:27:37 -0700122 private static final boolean DEBUG = false;
Jeff Brownfa25bf52012-07-23 19:26:30 -0700123
Jeff Brownbbd28a22012-09-20 16:47:15 -0700124 // When this system property is set to 0, WFD is forcibly disabled on boot.
125 // When this system property is set to 1, WFD is forcibly enabled on boot.
126 // Otherwise WFD is enabled according to the value of config_enableWifiDisplay.
127 private static final String FORCE_WIFI_DISPLAY_ENABLE = "persist.debug.wfd.enable";
128
Jeff Brownbd6e1502012-08-28 03:27:37 -0700129 private static final long WAIT_FOR_DEFAULT_DISPLAY_TIMEOUT = 10000;
130
131 private static final int MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER = 1;
132 private static final int MSG_REGISTER_ADDITIONAL_DISPLAY_ADAPTERS = 2;
133 private static final int MSG_DELIVER_DISPLAY_EVENT = 3;
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700134 private static final int MSG_REQUEST_TRAVERSAL = 4;
Jeff Brownd728bf52012-09-08 18:05:28 -0700135 private static final int MSG_UPDATE_VIEWPORT = 5;
Jeff Brownfa25bf52012-07-23 19:26:30 -0700136
Jeff Brownb880d882014-02-10 19:47:07 -0800137 private final Context mContext;
Jeff Brownbd6e1502012-08-28 03:27:37 -0700138 private final DisplayManagerHandler mHandler;
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700139 private final Handler mUiHandler;
140 private final DisplayAdapterListener mDisplayAdapterListener;
Jeff Brown4ccb8232014-01-16 22:16:42 -0800141 private WindowManagerInternal mWindowManagerInternal;
142 private InputManagerInternal mInputManagerInternal;
Michael Wrightc39d47a2014-07-08 18:07:36 -0700143 private IMediaProjectionManager mProjectionService;
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700144
145 // The synchronization root for the display manager.
146 // This lock guards most of the display manager's state.
Craig Mautner0bf6ec92012-12-18 08:33:27 -0800147 // NOTE: This is synchronized on while holding WindowManagerService.mWindowMap so never call
148 // into WindowManagerService methods that require mWindowMap while holding this unless you are
149 // very very sure that no deadlock can occur.
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700150 private final SyncRoot mSyncRoot = new SyncRoot();
151
152 // True if in safe mode.
153 // This option may disable certain display adapters.
154 public boolean mSafeMode;
155
156 // True if we are in a special boot mode where only core applications and
157 // services should be started. This option may disable certain display adapters.
158 public boolean mOnlyCore;
159
Jeff Brown27f1d672012-10-17 18:32:34 -0700160 // True if the display manager service should pretend there is only one display
161 // and only tell applications about the existence of the default logical display.
162 // The display manager can still mirror content to secondary displays but applications
163 // cannot present unique content on those displays.
164 // Used for demonstration purposes only.
165 private final boolean mSingleDisplayDemoMode;
166
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700167 // All callback records indexed by calling process id.
168 public final SparseArray<CallbackRecord> mCallbacks =
Jeff Brownbd6e1502012-08-28 03:27:37 -0700169 new SparseArray<CallbackRecord>();
Jeff Brownfa25bf52012-07-23 19:26:30 -0700170
Jeff Brownbd6e1502012-08-28 03:27:37 -0700171 // List of all currently registered display adapters.
172 private final ArrayList<DisplayAdapter> mDisplayAdapters = new ArrayList<DisplayAdapter>();
173
174 // List of all currently connected display devices.
175 private final ArrayList<DisplayDevice> mDisplayDevices = new ArrayList<DisplayDevice>();
176
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700177 // List of all logical displays indexed by logical display id.
178 private final SparseArray<LogicalDisplay> mLogicalDisplays =
179 new SparseArray<LogicalDisplay>();
Jeff Brownbd6e1502012-08-28 03:27:37 -0700180 private int mNextNonDefaultDisplayId = Display.DEFAULT_DISPLAY + 1;
181
Jeff Brown7f3994e2012-12-04 14:04:28 -0800182 // List of all display transaction listeners.
183 private final CopyOnWriteArrayList<DisplayTransactionListener> mDisplayTransactionListeners =
184 new CopyOnWriteArrayList<DisplayTransactionListener>();
185
Jeff Brownad9ef192014-04-08 17:26:30 -0700186 // Display power controller.
187 private DisplayPowerController mDisplayPowerController;
188
Jeff Brown037c33e2014-04-09 00:31:55 -0700189 // The overall display state, independent of changes that might influence one
190 // display or another in particular.
Jeff Brown5d6443b2015-04-10 20:15:01 -0700191 private int mGlobalDisplayState = Display.STATE_ON;
192
193 // The overall display brightness.
194 // For now, this only applies to the built-in display but we may split it up eventually.
195 private int mGlobalDisplayBrightness = PowerManager.BRIGHTNESS_DEFAULT;
Jeff Brown9e316a12012-10-08 19:17:06 -0700196
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700197 // Set to true when there are pending display changes that have yet to be applied
198 // to the surface flinger state.
199 private boolean mPendingTraversal;
Jeff Brownbd6e1502012-08-28 03:27:37 -0700200
Jeff Browne08ae382012-09-07 20:36:36 -0700201 // The Wifi display adapter, or null if not registered.
202 private WifiDisplayAdapter mWifiDisplayAdapter;
203
Jeff Brownce468a32013-11-21 16:42:03 -0800204 // The number of active wifi display scan requests.
205 private int mWifiDisplayScanRequestCount;
206
Jeff Browna506a6e2013-06-04 00:02:38 -0700207 // The virtual display adapter, or null if not registered.
208 private VirtualDisplayAdapter mVirtualDisplayAdapter;
209
Jeff Brownd728bf52012-09-08 18:05:28 -0700210 // Viewports of the default display and the display that should receive touch
211 // input from an external source. Used by the input system.
212 private final DisplayViewport mDefaultViewport = new DisplayViewport();
213 private final DisplayViewport mExternalTouchViewport = new DisplayViewport();
214
Jeff Brown89d55462012-09-19 11:33:42 -0700215 // Persistent data store for all internal settings maintained by the display manager service.
216 private final PersistentDataStore mPersistentDataStore = new PersistentDataStore();
217
Jeff Brownbd6e1502012-08-28 03:27:37 -0700218 // Temporary callback list, used when sending display events to applications.
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700219 // May be used outside of the lock but only on the handler thread.
220 private final ArrayList<CallbackRecord> mTempCallbacks = new ArrayList<CallbackRecord>();
Jeff Brownbd6e1502012-08-28 03:27:37 -0700221
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700222 // Temporary display info, used for comparing display configurations.
223 private final DisplayInfo mTempDisplayInfo = new DisplayInfo();
224
Jeff Brownd728bf52012-09-08 18:05:28 -0700225 // Temporary viewports, used when sending new viewport information to the
226 // input system. May be used outside of the lock but only on the handler thread.
227 private final DisplayViewport mTempDefaultViewport = new DisplayViewport();
228 private final DisplayViewport mTempExternalTouchViewport = new DisplayViewport();
229
Damien Bargiacchi4364bbf2016-11-01 21:44:20 -0700230 // The default color mode for default displays. Overrides the usual
231 // Display.Display.COLOR_MODE_DEFAULT for displays with the
232 // DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY flag set.
233 private final int mDefaultDisplayDefaultColorMode;
234
Jeff Browne75926d2014-09-18 15:24:49 -0700235 // Temporary list of deferred work to perform when setting the display state.
236 // Only used by requestDisplayState. The field is self-synchronized and only
237 // intended for use inside of the requestGlobalDisplayStateInternal function.
238 private final ArrayList<Runnable> mTempDisplayStateWorkQueue = new ArrayList<Runnable>();
239
Andrii Kulianfb1bf692017-01-17 11:17:34 -0800240 // Lists of UIDs that are present on the displays. Maps displayId -> array of UIDs.
241 private final SparseArray<IntArray> mDisplayAccessUIDs = new SparseArray<>();
242
Jeff Brownb880d882014-02-10 19:47:07 -0800243 public DisplayManagerService(Context context) {
244 super(context);
245 mContext = context;
Jeff Brown4ccb8232014-01-16 22:16:42 -0800246 mHandler = new DisplayManagerHandler(DisplayThread.get().getLooper());
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700247 mUiHandler = UiThread.getHandler();
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700248 mDisplayAdapterListener = new DisplayAdapterListener();
Jeff Brown27f1d672012-10-17 18:32:34 -0700249 mSingleDisplayDemoMode = SystemProperties.getBoolean("persist.demo.singledisplay", false);
Damien Bargiacchi4364bbf2016-11-01 21:44:20 -0700250 mDefaultDisplayDefaultColorMode = mContext.getResources().getInteger(
251 com.android.internal.R.integer.config_defaultDisplayDefaultColorMode);
Jeff Brown5d6443b2015-04-10 20:15:01 -0700252
253 PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
254 mGlobalDisplayBrightness = pm.getDefaultScreenBrightnessSetting();
Craig Mautner4f67ba62012-08-02 11:23:00 -0700255 }
256
Jeff Brown4ccb8232014-01-16 22:16:42 -0800257 @Override
Jeff Brown4ccb8232014-01-16 22:16:42 -0800258 public void onStart() {
Michael Wright1c9977b2016-07-12 13:30:10 -0700259 // We need to pre-load the persistent data store so it's ready before the default display
260 // adapter is up so that we have it's configuration. We could load it lazily, but since
261 // we're going to have to read it in eventually we may as well do it here rather than after
262 // we've waited for the diplay to register itself with us.
263 mPersistentDataStore.loadIfNeeded();
Jeff Brown4ccb8232014-01-16 22:16:42 -0800264 mHandler.sendEmptyMessage(MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER);
265
266 publishBinderService(Context.DISPLAY_SERVICE, new BinderService(),
267 true /*allowIsolated*/);
268 publishLocalService(DisplayManagerInternal.class, new LocalService());
Justin Klaassen22eb1992016-07-11 20:52:23 -0700269 publishLocalService(DisplayTransformManager.class, new DisplayTransformManager());
Jeff Brown4ccb8232014-01-16 22:16:42 -0800270 }
271
272 @Override
273 public void onBootPhase(int phase) {
274 if (phase == PHASE_WAIT_FOR_DEFAULT_DISPLAY) {
275 synchronized (mSyncRoot) {
276 long timeout = SystemClock.uptimeMillis() + WAIT_FOR_DEFAULT_DISPLAY_TIMEOUT;
277 while (mLogicalDisplays.get(Display.DEFAULT_DISPLAY) == null) {
278 long delay = timeout - SystemClock.uptimeMillis();
279 if (delay <= 0) {
280 throw new RuntimeException("Timeout waiting for default display "
281 + "to be initialized.");
282 }
283 if (DEBUG) {
284 Slog.d(TAG, "waitForDefaultDisplay: waiting, timeout=" + delay);
285 }
286 try {
287 mSyncRoot.wait(delay);
288 } catch (InterruptedException ex) {
289 }
Jeff Brownbd6e1502012-08-28 03:27:37 -0700290 }
291 }
292 }
Jeff Brownbd6e1502012-08-28 03:27:37 -0700293 }
294
Jeff Brown4ccb8232014-01-16 22:16:42 -0800295 // TODO: Use dependencies or a boot phase
296 public void windowManagerAndInputReady() {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700297 synchronized (mSyncRoot) {
Jeff Brown4ccb8232014-01-16 22:16:42 -0800298 mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
299 mInputManagerInternal = LocalServices.getService(InputManagerInternal.class);
Craig Mautner65d11b32012-10-01 13:59:52 -0700300 scheduleTraversalLocked(false);
Jeff Brownd728bf52012-09-08 18:05:28 -0700301 }
302 }
303
304 /**
Jeff Brownbd6e1502012-08-28 03:27:37 -0700305 * Called when the system is ready to go.
306 */
307 public void systemReady(boolean safeMode, boolean onlyCore) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700308 synchronized (mSyncRoot) {
Jeff Brownbd6e1502012-08-28 03:27:37 -0700309 mSafeMode = safeMode;
310 mOnlyCore = onlyCore;
311 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700312
Jeff Brownbd6e1502012-08-28 03:27:37 -0700313 mHandler.sendEmptyMessage(MSG_REGISTER_ADDITIONAL_DISPLAY_ADAPTERS);
314 }
315
Jeff Brown4ccb8232014-01-16 22:16:42 -0800316 private void registerDisplayTransactionListenerInternal(
317 DisplayTransactionListener listener) {
Jeff Brown7f3994e2012-12-04 14:04:28 -0800318 // List is self-synchronized copy-on-write.
319 mDisplayTransactionListeners.add(listener);
320 }
321
Jeff Brown4ccb8232014-01-16 22:16:42 -0800322 private void unregisterDisplayTransactionListenerInternal(
323 DisplayTransactionListener listener) {
Jeff Brown7f3994e2012-12-04 14:04:28 -0800324 // List is self-synchronized copy-on-write.
325 mDisplayTransactionListeners.remove(listener);
326 }
327
Jeff Brown4ccb8232014-01-16 22:16:42 -0800328 private void setDisplayInfoOverrideFromWindowManagerInternal(
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700329 int displayId, DisplayInfo info) {
330 synchronized (mSyncRoot) {
Jeff Brownbd6e1502012-08-28 03:27:37 -0700331 LogicalDisplay display = mLogicalDisplays.get(displayId);
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700332 if (display != null) {
Jeff Brownef981a42013-08-07 14:13:37 -0700333 if (display.setDisplayInfoOverrideFromWindowManagerLocked(info)) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700334 sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED);
Craig Mautner65d11b32012-10-01 13:59:52 -0700335 scheduleTraversalLocked(false);
Jeff Brownbd6e1502012-08-28 03:27:37 -0700336 }
Jeff Brownbd6e1502012-08-28 03:27:37 -0700337 }
338 }
339 }
340
Jeff Brown4ccb8232014-01-16 22:16:42 -0800341 private void performTraversalInTransactionFromWindowManagerInternal() {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700342 synchronized (mSyncRoot) {
343 if (!mPendingTraversal) {
344 return;
Jeff Brownbd6e1502012-08-28 03:27:37 -0700345 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700346 mPendingTraversal = false;
347
348 performTraversalInTransactionLocked();
Jeff Brownbd6e1502012-08-28 03:27:37 -0700349 }
Jeff Brown7f3994e2012-12-04 14:04:28 -0800350
351 // List is self-synchronized copy-on-write.
352 for (DisplayTransactionListener listener : mDisplayTransactionListeners) {
353 listener.onDisplayTransaction();
354 }
Jeff Brownbd6e1502012-08-28 03:27:37 -0700355 }
356
Jeff Brown5d6443b2015-04-10 20:15:01 -0700357 private void requestGlobalDisplayStateInternal(int state, int brightness) {
358 if (state == Display.STATE_UNKNOWN) {
359 state = Display.STATE_ON;
360 }
361 if (state == Display.STATE_OFF) {
362 brightness = PowerManager.BRIGHTNESS_OFF;
363 } else if (brightness < 0) {
364 brightness = PowerManager.BRIGHTNESS_DEFAULT;
365 } else if (brightness > PowerManager.BRIGHTNESS_ON) {
366 brightness = PowerManager.BRIGHTNESS_ON;
367 }
368
Jeff Browne75926d2014-09-18 15:24:49 -0700369 synchronized (mTempDisplayStateWorkQueue) {
370 try {
371 // Update the display state within the lock.
Jeff Brown8e5d33e2015-06-10 13:05:50 -0700372 // Note that we do not need to schedule traversals here although it
373 // may happen as a side-effect of displays changing state.
Jeff Browne75926d2014-09-18 15:24:49 -0700374 synchronized (mSyncRoot) {
Jeff Brown5d6443b2015-04-10 20:15:01 -0700375 if (mGlobalDisplayState == state
376 && mGlobalDisplayBrightness == brightness) {
377 return; // no change
Jeff Browne75926d2014-09-18 15:24:49 -0700378 }
Jeff Brown5d6443b2015-04-10 20:15:01 -0700379
380 Trace.traceBegin(Trace.TRACE_TAG_POWER, "requestGlobalDisplayState("
381 + Display.stateToString(state)
382 + ", brightness=" + brightness + ")");
383 mGlobalDisplayState = state;
384 mGlobalDisplayBrightness = brightness;
Jeff Brown8e5d33e2015-06-10 13:05:50 -0700385 applyGlobalDisplayStateLocked(mTempDisplayStateWorkQueue);
Jeff Browne75926d2014-09-18 15:24:49 -0700386 }
387
388 // Setting the display power state can take hundreds of milliseconds
389 // to complete so we defer the most expensive part of the work until
390 // after we have exited the critical section to avoid blocking other
391 // threads for a long time.
392 for (int i = 0; i < mTempDisplayStateWorkQueue.size(); i++) {
393 mTempDisplayStateWorkQueue.get(i).run();
394 }
Jeff Brown5d6443b2015-04-10 20:15:01 -0700395 Trace.traceEnd(Trace.TRACE_TAG_POWER);
Jeff Browne75926d2014-09-18 15:24:49 -0700396 } finally {
397 mTempDisplayStateWorkQueue.clear();
Jeff Brown9e316a12012-10-08 19:17:06 -0700398 }
399 }
400 }
401
Jeff Brown4ccb8232014-01-16 22:16:42 -0800402 private DisplayInfo getDisplayInfoInternal(int displayId, int callingUid) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700403 synchronized (mSyncRoot) {
Jeff Brown4ccb8232014-01-16 22:16:42 -0800404 LogicalDisplay display = mLogicalDisplays.get(displayId);
405 if (display != null) {
406 DisplayInfo info = display.getDisplayInfoLocked();
Andrii Kulianfb1bf692017-01-17 11:17:34 -0800407 if (info.hasAccess(callingUid)
408 || isUidPresentOnDisplayInternal(callingUid, displayId)) {
Jeff Brown4ccb8232014-01-16 22:16:42 -0800409 return info;
410 }
411 }
412 return null;
413 }
414 }
415
416 private int[] getDisplayIdsInternal(int callingUid) {
417 synchronized (mSyncRoot) {
418 final int count = mLogicalDisplays.size();
419 int[] displayIds = new int[count];
420 int n = 0;
421 for (int i = 0; i < count; i++) {
422 LogicalDisplay display = mLogicalDisplays.valueAt(i);
423 DisplayInfo info = display.getDisplayInfoLocked();
424 if (info.hasAccess(callingUid)) {
425 displayIds[n++] = mLogicalDisplays.keyAt(i);
426 }
427 }
428 if (n != count) {
429 displayIds = Arrays.copyOfRange(displayIds, 0, n);
430 }
431 return displayIds;
432 }
433 }
434
435 private void registerCallbackInternal(IDisplayManagerCallback callback, int callingPid) {
436 synchronized (mSyncRoot) {
Jeff Brownbd6e1502012-08-28 03:27:37 -0700437 if (mCallbacks.get(callingPid) != null) {
438 throw new SecurityException("The calling process has already "
439 + "registered an IDisplayManagerCallback.");
Jeff Brown64a55af2012-08-26 02:47:39 -0700440 }
441
Jeff Brownbd6e1502012-08-28 03:27:37 -0700442 CallbackRecord record = new CallbackRecord(callingPid, callback);
443 try {
444 IBinder binder = callback.asBinder();
445 binder.linkToDeath(record, 0);
446 } catch (RemoteException ex) {
447 // give up
448 throw new RuntimeException(ex);
449 }
450
451 mCallbacks.put(callingPid, record);
452 }
453 }
454
Jeff Brownce468a32013-11-21 16:42:03 -0800455 private void onCallbackDied(CallbackRecord record) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700456 synchronized (mSyncRoot) {
Jeff Brownce468a32013-11-21 16:42:03 -0800457 mCallbacks.remove(record.mPid);
458 stopWifiDisplayScanLocked(record);
Jeff Brownbd6e1502012-08-28 03:27:37 -0700459 }
460 }
461
Jeff Brown4ccb8232014-01-16 22:16:42 -0800462 private void startWifiDisplayScanInternal(int callingPid) {
463 synchronized (mSyncRoot) {
464 CallbackRecord record = mCallbacks.get(callingPid);
465 if (record == null) {
466 throw new IllegalStateException("The calling process has not "
467 + "registered an IDisplayManagerCallback.");
Jeff Browne08ae382012-09-07 20:36:36 -0700468 }
Jeff Brown4ccb8232014-01-16 22:16:42 -0800469 startWifiDisplayScanLocked(record);
Jeff Browne08ae382012-09-07 20:36:36 -0700470 }
471 }
472
Jeff Brownce468a32013-11-21 16:42:03 -0800473 private void startWifiDisplayScanLocked(CallbackRecord record) {
474 if (!record.mWifiDisplayScanRequested) {
475 record.mWifiDisplayScanRequested = true;
476 if (mWifiDisplayScanRequestCount++ == 0) {
477 if (mWifiDisplayAdapter != null) {
478 mWifiDisplayAdapter.requestStartScanLocked();
479 }
480 }
481 }
482 }
483
Jeff Brown4ccb8232014-01-16 22:16:42 -0800484 private void stopWifiDisplayScanInternal(int callingPid) {
485 synchronized (mSyncRoot) {
486 CallbackRecord record = mCallbacks.get(callingPid);
487 if (record == null) {
488 throw new IllegalStateException("The calling process has not "
489 + "registered an IDisplayManagerCallback.");
Jeff Brownce468a32013-11-21 16:42:03 -0800490 }
Jeff Brown4ccb8232014-01-16 22:16:42 -0800491 stopWifiDisplayScanLocked(record);
Jeff Brownce468a32013-11-21 16:42:03 -0800492 }
493 }
494
495 private void stopWifiDisplayScanLocked(CallbackRecord record) {
496 if (record.mWifiDisplayScanRequested) {
497 record.mWifiDisplayScanRequested = false;
498 if (--mWifiDisplayScanRequestCount == 0) {
499 if (mWifiDisplayAdapter != null) {
500 mWifiDisplayAdapter.requestStopScanLocked();
501 }
502 } else if (mWifiDisplayScanRequestCount < 0) {
Dianne Hackborn8d051722014-10-01 14:59:58 -0700503 Slog.wtf(TAG, "mWifiDisplayScanRequestCount became negative: "
Jeff Brownce468a32013-11-21 16:42:03 -0800504 + mWifiDisplayScanRequestCount);
505 mWifiDisplayScanRequestCount = 0;
506 }
507 }
508 }
509
Jeff Brown4ccb8232014-01-16 22:16:42 -0800510 private void connectWifiDisplayInternal(String address) {
511 synchronized (mSyncRoot) {
512 if (mWifiDisplayAdapter != null) {
513 mWifiDisplayAdapter.requestConnectLocked(address);
Jeff Browne08ae382012-09-07 20:36:36 -0700514 }
Jeff Browne08ae382012-09-07 20:36:36 -0700515 }
516 }
517
Jeff Brown4ccb8232014-01-16 22:16:42 -0800518 private void pauseWifiDisplayInternal() {
519 synchronized (mSyncRoot) {
520 if (mWifiDisplayAdapter != null) {
521 mWifiDisplayAdapter.requestPauseLocked();
Chong Zhang1f3ecaa2013-05-03 15:55:36 -0700522 }
Chong Zhang1f3ecaa2013-05-03 15:55:36 -0700523 }
524 }
525
Jeff Brown4ccb8232014-01-16 22:16:42 -0800526 private void resumeWifiDisplayInternal() {
527 synchronized (mSyncRoot) {
528 if (mWifiDisplayAdapter != null) {
529 mWifiDisplayAdapter.requestResumeLocked();
Chong Zhang1f3ecaa2013-05-03 15:55:36 -0700530 }
Chong Zhang1f3ecaa2013-05-03 15:55:36 -0700531 }
532 }
533
Jeff Brown4ccb8232014-01-16 22:16:42 -0800534 private void disconnectWifiDisplayInternal() {
535 synchronized (mSyncRoot) {
536 if (mWifiDisplayAdapter != null) {
537 mWifiDisplayAdapter.requestDisconnectLocked();
Jeff Browne08ae382012-09-07 20:36:36 -0700538 }
Jeff Browne08ae382012-09-07 20:36:36 -0700539 }
540 }
541
Jeff Brown4ccb8232014-01-16 22:16:42 -0800542 private void renameWifiDisplayInternal(String address, String alias) {
543 synchronized (mSyncRoot) {
544 if (mWifiDisplayAdapter != null) {
545 mWifiDisplayAdapter.requestRenameLocked(address, alias);
Jeff Brown89d55462012-09-19 11:33:42 -0700546 }
Jeff Brown89d55462012-09-19 11:33:42 -0700547 }
548 }
549
Jeff Brown4ccb8232014-01-16 22:16:42 -0800550 private void forgetWifiDisplayInternal(String address) {
551 synchronized (mSyncRoot) {
552 if (mWifiDisplayAdapter != null) {
553 mWifiDisplayAdapter.requestForgetLocked(address);
Jeff Brown89d55462012-09-19 11:33:42 -0700554 }
Jeff Brown89d55462012-09-19 11:33:42 -0700555 }
556 }
557
Jeff Brown4ccb8232014-01-16 22:16:42 -0800558 private WifiDisplayStatus getWifiDisplayStatusInternal() {
559 synchronized (mSyncRoot) {
560 if (mWifiDisplayAdapter != null) {
561 return mWifiDisplayAdapter.getWifiDisplayStatusLocked();
Jeff Browne08ae382012-09-07 20:36:36 -0700562 }
Jeff Brown4ccb8232014-01-16 22:16:42 -0800563 return new WifiDisplayStatus();
Jeff Browne08ae382012-09-07 20:36:36 -0700564 }
565 }
566
Michael Wright1c9977b2016-07-12 13:30:10 -0700567 private void requestColorModeInternal(int displayId, int colorMode) {
Michael Wright58e829f2015-09-15 00:13:26 +0100568 synchronized (mSyncRoot) {
569 LogicalDisplay display = mLogicalDisplays.get(displayId);
570 if (display != null &&
Michael Wright1c9977b2016-07-12 13:30:10 -0700571 display.getRequestedColorModeLocked() != colorMode) {
572 display.setRequestedColorModeLocked(colorMode);
Michael Wright58e829f2015-09-15 00:13:26 +0100573 scheduleTraversalLocked(false);
574 }
575 }
576 }
577
Michael Wright75ee9fc2014-09-01 19:55:22 -0700578 private int createVirtualDisplayInternal(IVirtualDisplayCallback callback,
Michael Wrightc39d47a2014-07-08 18:07:36 -0700579 IMediaProjection projection, int callingUid, String packageName,
Jeff Brown7d00aff2013-08-02 19:03:49 -0700580 String name, int width, int height, int densityDpi, Surface surface, int flags) {
Jeff Brown4ccb8232014-01-16 22:16:42 -0800581 synchronized (mSyncRoot) {
582 if (mVirtualDisplayAdapter == null) {
583 Slog.w(TAG, "Rejecting request to create private virtual display "
584 + "because the virtual display adapter is not available.");
585 return -1;
Jeff Brown7d00aff2013-08-02 19:03:49 -0700586 }
Jeff Brown4ccb8232014-01-16 22:16:42 -0800587
588 DisplayDevice device = mVirtualDisplayAdapter.createVirtualDisplayLocked(
Michael Wright75ee9fc2014-09-01 19:55:22 -0700589 callback, projection, callingUid, packageName,
Michael Wrightc39d47a2014-07-08 18:07:36 -0700590 name, width, height, densityDpi, surface, flags);
Jeff Brown4ccb8232014-01-16 22:16:42 -0800591 if (device == null) {
592 return -1;
Jeff Brown7d00aff2013-08-02 19:03:49 -0700593 }
Jeff Browna506a6e2013-06-04 00:02:38 -0700594
Jeff Brown4ccb8232014-01-16 22:16:42 -0800595 handleDisplayDeviceAddedLocked(device);
596 LogicalDisplay display = findLogicalDisplayForDeviceLocked(device);
597 if (display != null) {
598 return display.getDisplayIdLocked();
Jeff Browna506a6e2013-06-04 00:02:38 -0700599 }
Jeff Brown4ccb8232014-01-16 22:16:42 -0800600
601 // Something weird happened and the logical display was not created.
602 Slog.w(TAG, "Rejecting request to create virtual display "
603 + "because the logical display was not created.");
Michael Wright75ee9fc2014-09-01 19:55:22 -0700604 mVirtualDisplayAdapter.releaseVirtualDisplayLocked(callback.asBinder());
Jeff Brown4ccb8232014-01-16 22:16:42 -0800605 handleDisplayDeviceRemovedLocked(device);
Jeff Browna506a6e2013-06-04 00:02:38 -0700606 }
607 return -1;
608 }
609
Michael Wright01e840f2014-06-26 16:03:25 -0700610 private void resizeVirtualDisplayInternal(IBinder appToken,
611 int width, int height, int densityDpi) {
612 synchronized (mSyncRoot) {
613 if (mVirtualDisplayAdapter == null) {
614 return;
615 }
616
617 mVirtualDisplayAdapter.resizeVirtualDisplayLocked(appToken, width, height, densityDpi);
618 }
619 }
620
Jeff Brown92207df2014-04-16 13:16:07 -0700621 private void setVirtualDisplaySurfaceInternal(IBinder appToken, Surface surface) {
622 synchronized (mSyncRoot) {
623 if (mVirtualDisplayAdapter == null) {
624 return;
625 }
626
627 mVirtualDisplayAdapter.setVirtualDisplaySurfaceLocked(appToken, surface);
628 }
629 }
630
Jeff Brown4ccb8232014-01-16 22:16:42 -0800631 private void releaseVirtualDisplayInternal(IBinder appToken) {
632 synchronized (mSyncRoot) {
633 if (mVirtualDisplayAdapter == null) {
634 return;
Jeff Browna506a6e2013-06-04 00:02:38 -0700635 }
Jeff Browna506a6e2013-06-04 00:02:38 -0700636
Jeff Brown4ccb8232014-01-16 22:16:42 -0800637 DisplayDevice device =
638 mVirtualDisplayAdapter.releaseVirtualDisplayLocked(appToken);
639 if (device != null) {
640 handleDisplayDeviceRemovedLocked(device);
Jeff Browna506a6e2013-06-04 00:02:38 -0700641 }
642 }
Jeff Browna506a6e2013-06-04 00:02:38 -0700643 }
644
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700645 private void registerDefaultDisplayAdapter() {
646 // Register default display adapter.
647 synchronized (mSyncRoot) {
Mike Lockwoode63f6f72013-11-15 11:01:47 -0800648 registerDisplayAdapterLocked(new LocalDisplayAdapter(
649 mSyncRoot, mContext, mHandler, mDisplayAdapterListener));
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700650 }
651 }
652
653 private void registerAdditionalDisplayAdapters() {
654 synchronized (mSyncRoot) {
655 if (shouldRegisterNonEssentialDisplayAdaptersLocked()) {
Jeff Brown89d55462012-09-19 11:33:42 -0700656 registerOverlayDisplayAdapterLocked();
657 registerWifiDisplayAdapterLocked();
Jeff Browna506a6e2013-06-04 00:02:38 -0700658 registerVirtualDisplayAdapterLocked();
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700659 }
660 }
661 }
662
Jeff Brown89d55462012-09-19 11:33:42 -0700663 private void registerOverlayDisplayAdapterLocked() {
664 registerDisplayAdapterLocked(new OverlayDisplayAdapter(
665 mSyncRoot, mContext, mHandler, mDisplayAdapterListener, mUiHandler));
666 }
667
668 private void registerWifiDisplayAdapterLocked() {
669 if (mContext.getResources().getBoolean(
Jeff Brownbbd28a22012-09-20 16:47:15 -0700670 com.android.internal.R.bool.config_enableWifiDisplay)
671 || SystemProperties.getInt(FORCE_WIFI_DISPLAY_ENABLE, -1) == 1) {
Jeff Brown89d55462012-09-19 11:33:42 -0700672 mWifiDisplayAdapter = new WifiDisplayAdapter(
673 mSyncRoot, mContext, mHandler, mDisplayAdapterListener,
674 mPersistentDataStore);
675 registerDisplayAdapterLocked(mWifiDisplayAdapter);
676 }
677 }
678
Jeff Browna506a6e2013-06-04 00:02:38 -0700679 private void registerVirtualDisplayAdapterLocked() {
680 mVirtualDisplayAdapter = new VirtualDisplayAdapter(
681 mSyncRoot, mContext, mHandler, mDisplayAdapterListener);
682 registerDisplayAdapterLocked(mVirtualDisplayAdapter);
683 }
684
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700685 private boolean shouldRegisterNonEssentialDisplayAdaptersLocked() {
686 // In safe mode, we disable non-essential display adapters to give the user
687 // an opportunity to fix broken settings or other problems that might affect
688 // system stability.
689 // In only-core mode, we disable non-essential display adapters to minimize
690 // the number of dependencies that are started while in this mode and to
691 // prevent problems that might occur due to the device being encrypted.
692 return !mSafeMode && !mOnlyCore;
693 }
694
695 private void registerDisplayAdapterLocked(DisplayAdapter adapter) {
696 mDisplayAdapters.add(adapter);
697 adapter.registerLocked();
698 }
699
Jeff Brownbd6e1502012-08-28 03:27:37 -0700700 private void handleDisplayDeviceAdded(DisplayDevice device) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700701 synchronized (mSyncRoot) {
Jeff Browna506a6e2013-06-04 00:02:38 -0700702 handleDisplayDeviceAddedLocked(device);
Jeff Brownbd6e1502012-08-28 03:27:37 -0700703 }
704 }
705
Jeff Browna506a6e2013-06-04 00:02:38 -0700706 private void handleDisplayDeviceAddedLocked(DisplayDevice device) {
Jeff Brown10acf6d2015-04-14 14:20:47 -0700707 DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
Jeff Browna506a6e2013-06-04 00:02:38 -0700708 if (mDisplayDevices.contains(device)) {
Jeff Brown10acf6d2015-04-14 14:20:47 -0700709 Slog.w(TAG, "Attempted to add already added display device: " + info);
Jeff Browna506a6e2013-06-04 00:02:38 -0700710 return;
711 }
712
Jeff Brown10acf6d2015-04-14 14:20:47 -0700713 Slog.i(TAG, "Display device added: " + info);
714 device.mDebugLastLoggedDeviceInfo = info;
Jeff Browna506a6e2013-06-04 00:02:38 -0700715
716 mDisplayDevices.add(device);
Michael Wright1c9977b2016-07-12 13:30:10 -0700717 LogicalDisplay display = addLogicalDisplayLocked(device);
Jeff Brown0033a862014-10-08 12:06:39 -0700718 Runnable work = updateDisplayStateLocked(device);
719 if (work != null) {
720 work.run();
721 }
Michael Wright1c9977b2016-07-12 13:30:10 -0700722 if (display != null && display.getPrimaryDisplayDeviceLocked() == device) {
723 int colorMode = mPersistentDataStore.getColorMode(device);
Damien Bargiacchi4364bbf2016-11-01 21:44:20 -0700724 if (colorMode == Display.COLOR_MODE_INVALID) {
725 if ((device.getDisplayDeviceInfoLocked().flags
726 & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0) {
727 colorMode = mDefaultDisplayDefaultColorMode;
728 } else {
729 colorMode = Display.COLOR_MODE_DEFAULT;
730 }
731 }
Michael Wright1c9977b2016-07-12 13:30:10 -0700732 display.setRequestedColorModeLocked(colorMode);
733 }
Jeff Browna506a6e2013-06-04 00:02:38 -0700734 scheduleTraversalLocked(false);
735 }
736
Jeff Brownbd6e1502012-08-28 03:27:37 -0700737 private void handleDisplayDeviceChanged(DisplayDevice device) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700738 synchronized (mSyncRoot) {
Jeff Brown10acf6d2015-04-14 14:20:47 -0700739 DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
Jeff Brownbd6e1502012-08-28 03:27:37 -0700740 if (!mDisplayDevices.contains(device)) {
Jeff Brown10acf6d2015-04-14 14:20:47 -0700741 Slog.w(TAG, "Attempted to change non-existent display device: " + info);
Jeff Brownbd6e1502012-08-28 03:27:37 -0700742 return;
743 }
744
Jeff Brown10acf6d2015-04-14 14:20:47 -0700745 int diff = device.mDebugLastLoggedDeviceInfo.diff(info);
746 if (diff == DisplayDeviceInfo.DIFF_STATE) {
747 Slog.i(TAG, "Display device changed state: \"" + info.name
748 + "\", " + Display.stateToString(info.state));
749 } else if (diff != 0) {
750 Slog.i(TAG, "Display device changed: " + info);
751 }
Michael Wright1c9977b2016-07-12 13:30:10 -0700752 if ((diff & DisplayDeviceInfo.DIFF_COLOR_MODE) != 0) {
753 try {
754 mPersistentDataStore.setColorMode(device, info.colorMode);
755 } finally {
756 mPersistentDataStore.saveIfNeeded();
757 }
758 }
Jeff Brown10acf6d2015-04-14 14:20:47 -0700759 device.mDebugLastLoggedDeviceInfo = info;
Jeff Browne87bf032012-09-20 18:30:13 -0700760
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700761 device.applyPendingDisplayDeviceInfoChangesLocked();
762 if (updateLogicalDisplaysLocked()) {
Craig Mautner65d11b32012-10-01 13:59:52 -0700763 scheduleTraversalLocked(false);
Jeff Brown64a55af2012-08-26 02:47:39 -0700764 }
765 }
766 }
767
Jeff Brownbd6e1502012-08-28 03:27:37 -0700768 private void handleDisplayDeviceRemoved(DisplayDevice device) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700769 synchronized (mSyncRoot) {
Jeff Browna506a6e2013-06-04 00:02:38 -0700770 handleDisplayDeviceRemovedLocked(device);
771 }
772 }
Jeff Brown8e5d33e2015-06-10 13:05:50 -0700773
Jeff Browna506a6e2013-06-04 00:02:38 -0700774 private void handleDisplayDeviceRemovedLocked(DisplayDevice device) {
Jeff Brown10acf6d2015-04-14 14:20:47 -0700775 DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
Jeff Browna506a6e2013-06-04 00:02:38 -0700776 if (!mDisplayDevices.remove(device)) {
Jeff Brown10acf6d2015-04-14 14:20:47 -0700777 Slog.w(TAG, "Attempted to remove non-existent display device: " + info);
Jeff Browna506a6e2013-06-04 00:02:38 -0700778 return;
779 }
780
Jeff Brown10acf6d2015-04-14 14:20:47 -0700781 Slog.i(TAG, "Display device removed: " + info);
782 device.mDebugLastLoggedDeviceInfo = info;
Jeff Browna506a6e2013-06-04 00:02:38 -0700783
Jeff Browna506a6e2013-06-04 00:02:38 -0700784 updateLogicalDisplaysLocked();
785 scheduleTraversalLocked(false);
786 }
787
Jeff Brown8e5d33e2015-06-10 13:05:50 -0700788 private void applyGlobalDisplayStateLocked(List<Runnable> workQueue) {
Jeff Browna506a6e2013-06-04 00:02:38 -0700789 final int count = mDisplayDevices.size();
790 for (int i = 0; i < count; i++) {
791 DisplayDevice device = mDisplayDevices.get(i);
Jeff Browne75926d2014-09-18 15:24:49 -0700792 Runnable runnable = updateDisplayStateLocked(device);
793 if (runnable != null) {
794 workQueue.add(runnable);
795 }
Jeff Browna506a6e2013-06-04 00:02:38 -0700796 }
797 }
798
Jeff Browne75926d2014-09-18 15:24:49 -0700799 private Runnable updateDisplayStateLocked(DisplayDevice device) {
Jeff Browna506a6e2013-06-04 00:02:38 -0700800 // Blank or unblank the display immediately to match the state requested
Jeff Brown037c33e2014-04-09 00:31:55 -0700801 // by the display power controller (if known).
Jeff Browna506a6e2013-06-04 00:02:38 -0700802 DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
803 if ((info.flags & DisplayDeviceInfo.FLAG_NEVER_BLANK) == 0) {
Jeff Brown5d6443b2015-04-10 20:15:01 -0700804 return device.requestDisplayStateLocked(mGlobalDisplayState, mGlobalDisplayBrightness);
Craig Mautner4f67ba62012-08-02 11:23:00 -0700805 }
Jeff Browne75926d2014-09-18 15:24:49 -0700806 return null;
Craig Mautner4f67ba62012-08-02 11:23:00 -0700807 }
808
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700809 // Adds a new logical display based on the given display device.
810 // Sends notifications if needed.
Michael Wright1c9977b2016-07-12 13:30:10 -0700811 private LogicalDisplay addLogicalDisplayLocked(DisplayDevice device) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700812 DisplayDeviceInfo deviceInfo = device.getDisplayDeviceInfoLocked();
813 boolean isDefault = (deviceInfo.flags
814 & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0;
815 if (isDefault && mLogicalDisplays.get(Display.DEFAULT_DISPLAY) != null) {
816 Slog.w(TAG, "Ignoring attempt to add a second default display: " + deviceInfo);
817 isDefault = false;
818 }
819
Jeff Brown27f1d672012-10-17 18:32:34 -0700820 if (!isDefault && mSingleDisplayDemoMode) {
821 Slog.i(TAG, "Not creating a logical display for a secondary display "
822 + " because single display demo mode is enabled: " + deviceInfo);
Michael Wright1c9977b2016-07-12 13:30:10 -0700823 return null;
Jeff Brown27f1d672012-10-17 18:32:34 -0700824 }
825
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700826 final int displayId = assignDisplayIdLocked(isDefault);
827 final int layerStack = assignLayerStackLocked(displayId);
828
Jeff Brownd728bf52012-09-08 18:05:28 -0700829 LogicalDisplay display = new LogicalDisplay(displayId, layerStack, device);
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700830 display.updateLocked(mDisplayDevices);
831 if (!display.isValidLocked()) {
832 // This should never happen currently.
833 Slog.w(TAG, "Ignoring display device because the logical display "
834 + "created from it was not considered valid: " + deviceInfo);
Michael Wright1c9977b2016-07-12 13:30:10 -0700835 return null;
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700836 }
837
838 mLogicalDisplays.put(displayId, display);
839
840 // Wake up waitForDefaultDisplay.
841 if (isDefault) {
842 mSyncRoot.notifyAll();
843 }
844
845 sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_ADDED);
Michael Wright1c9977b2016-07-12 13:30:10 -0700846 return display;
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700847 }
848
849 private int assignDisplayIdLocked(boolean isDefault) {
850 return isDefault ? Display.DEFAULT_DISPLAY : mNextNonDefaultDisplayId++;
851 }
852
853 private int assignLayerStackLocked(int displayId) {
854 // Currently layer stacks and display ids are the same.
855 // This need not be the case.
856 return displayId;
857 }
858
859 // Updates all existing logical displays given the current set of display devices.
860 // Removes invalid logical displays.
861 // Sends notifications if needed.
862 private boolean updateLogicalDisplaysLocked() {
863 boolean changed = false;
864 for (int i = mLogicalDisplays.size(); i-- > 0; ) {
865 final int displayId = mLogicalDisplays.keyAt(i);
866 LogicalDisplay display = mLogicalDisplays.valueAt(i);
867
868 mTempDisplayInfo.copyFrom(display.getDisplayInfoLocked());
869 display.updateLocked(mDisplayDevices);
870 if (!display.isValidLocked()) {
871 mLogicalDisplays.removeAt(i);
872 sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_REMOVED);
873 changed = true;
874 } else if (!mTempDisplayInfo.equals(display.getDisplayInfoLocked())) {
875 sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED);
876 changed = true;
877 }
878 }
879 return changed;
880 }
881
882 private void performTraversalInTransactionLocked() {
Jeff Brownd728bf52012-09-08 18:05:28 -0700883 // Clear all viewports before configuring displays so that we can keep
884 // track of which ones we have configured.
885 clearViewportsLocked();
886
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700887 // Configure each display device.
888 final int count = mDisplayDevices.size();
889 for (int i = 0; i < count; i++) {
890 DisplayDevice device = mDisplayDevices.get(i);
891 configureDisplayInTransactionLocked(device);
892 device.performTraversalInTransactionLocked();
893 }
Jeff Brownd728bf52012-09-08 18:05:28 -0700894
895 // Tell the input system about these new viewports.
Jeff Brown4ccb8232014-01-16 22:16:42 -0800896 if (mInputManagerInternal != null) {
Jeff Brownd728bf52012-09-08 18:05:28 -0700897 mHandler.sendEmptyMessage(MSG_UPDATE_VIEWPORT);
898 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700899 }
900
Michael Wright3f145a22014-07-22 19:46:03 -0700901 private void setDisplayPropertiesInternal(int displayId, boolean hasContent,
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700902 float requestedRefreshRate, int requestedModeId, boolean inTraversal) {
Craig Mautner722285e2012-09-07 13:55:58 -0700903 synchronized (mSyncRoot) {
904 LogicalDisplay display = mLogicalDisplays.get(displayId);
Michael Wright3f145a22014-07-22 19:46:03 -0700905 if (display == null) {
906 return;
907 }
908 if (display.hasContentLocked() != hasContent) {
Jeff Brown33041bd2013-08-02 21:11:14 -0700909 if (DEBUG) {
910 Slog.d(TAG, "Display " + displayId + " hasContent flag changed: "
911 + "hasContent=" + hasContent + ", inTraversal=" + inTraversal);
912 }
913
Craig Mautner722285e2012-09-07 13:55:58 -0700914 display.setHasContentLocked(hasContent);
Craig Mautner65d11b32012-10-01 13:59:52 -0700915 scheduleTraversalLocked(inTraversal);
Craig Mautner722285e2012-09-07 13:55:58 -0700916 }
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700917 if (requestedModeId == 0 && requestedRefreshRate != 0) {
918 // Scan supported modes returned by display.getInfo() to find a mode with the same
919 // size as the default display mode but with the specified refresh rate instead.
920 requestedModeId = display.getDisplayInfoLocked().findDefaultModeByRefreshRate(
921 requestedRefreshRate);
922 }
923 if (display.getRequestedModeIdLocked() != requestedModeId) {
Michael Wright3f145a22014-07-22 19:46:03 -0700924 if (DEBUG) {
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700925 Slog.d(TAG, "Display " + displayId + " switching to mode " + requestedModeId);
Michael Wright3f145a22014-07-22 19:46:03 -0700926 }
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700927 display.setRequestedModeIdLocked(requestedModeId);
Michael Wright3f145a22014-07-22 19:46:03 -0700928 scheduleTraversalLocked(inTraversal);
929 }
Craig Mautner722285e2012-09-07 13:55:58 -0700930 }
Jeff Brownd728bf52012-09-08 18:05:28 -0700931 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700932
Filip Gruszczynskid2e86402015-02-19 13:05:03 -0800933 private void setDisplayOffsetsInternal(int displayId, int x, int y) {
934 synchronized (mSyncRoot) {
935 LogicalDisplay display = mLogicalDisplays.get(displayId);
936 if (display == null) {
937 return;
938 }
939 if (display.getDisplayOffsetXLocked() != x
940 || display.getDisplayOffsetYLocked() != y) {
941 if (DEBUG) {
942 Slog.d(TAG, "Display " + displayId + " burn-in offset set to ("
943 + x + ", " + y + ")");
944 }
945 display.setDisplayOffsetsLocked(x, y);
946 scheduleTraversalLocked(false);
947 }
948 }
949 }
950
Andrii Kulianfb1bf692017-01-17 11:17:34 -0800951 // Updates the lists of UIDs that are present on displays.
952 private void setDisplayAccessUIDsInternal(SparseArray<IntArray> newDisplayAccessUIDs) {
953 synchronized (mSyncRoot) {
954 mDisplayAccessUIDs.clear();
955 for (int i = newDisplayAccessUIDs.size() - 1; i >= 0; i--) {
956 mDisplayAccessUIDs.append(newDisplayAccessUIDs.keyAt(i),
957 newDisplayAccessUIDs.valueAt(i));
958 }
959 }
960 }
961
962 // Checks if provided UID's content is present on the display and UID has access to it.
963 private boolean isUidPresentOnDisplayInternal(int uid, int displayId) {
964 synchronized (mSyncRoot) {
965 final IntArray displayUIDs = mDisplayAccessUIDs.get(displayId);
966 return displayUIDs != null && displayUIDs.indexOf(uid) != -1;
967 }
968 }
969
Jeff Brownd728bf52012-09-08 18:05:28 -0700970 private void clearViewportsLocked() {
971 mDefaultViewport.valid = false;
972 mExternalTouchViewport.valid = false;
Craig Mautner722285e2012-09-07 13:55:58 -0700973 }
974
975 private void configureDisplayInTransactionLocked(DisplayDevice device) {
Jeff Brownd14c8c92014-01-07 18:13:09 -0800976 final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
977 final boolean ownContent = (info.flags & DisplayDeviceInfo.FLAG_OWN_CONTENT_ONLY) != 0;
Jeff Browna506a6e2013-06-04 00:02:38 -0700978
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700979 // Find the logical display that the display device is showing.
Jeff Brownd14c8c92014-01-07 18:13:09 -0800980 // Certain displays only ever show their own content.
Craig Mautner722285e2012-09-07 13:55:58 -0700981 LogicalDisplay display = findLogicalDisplayForDeviceLocked(device);
Jeff Brownd14c8c92014-01-07 18:13:09 -0800982 if (!ownContent) {
Jeff Browna506a6e2013-06-04 00:02:38 -0700983 if (display != null && !display.hasContentLocked()) {
984 // If the display does not have any content of its own, then
985 // automatically mirror the default logical display contents.
986 display = null;
987 }
988 if (display == null) {
989 display = mLogicalDisplays.get(Display.DEFAULT_DISPLAY);
990 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700991 }
992
993 // Apply the logical display configuration to the display device.
994 if (display == null) {
995 // TODO: no logical display for the device, blank it
Jeff Brownd728bf52012-09-08 18:05:28 -0700996 Slog.w(TAG, "Missing logical display to use for physical display device: "
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700997 + device.getDisplayDeviceInfoLocked());
Jeff Brownd728bf52012-09-08 18:05:28 -0700998 return;
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700999 }
Jeff Brown037c33e2014-04-09 00:31:55 -07001000 display.configureDisplayInTransactionLocked(device, info.state == Display.STATE_OFF);
Jeff Brownd728bf52012-09-08 18:05:28 -07001001
1002 // Update the viewports if needed.
Jeff Brownd728bf52012-09-08 18:05:28 -07001003 if (!mDefaultViewport.valid
1004 && (info.flags & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0) {
1005 setViewportLocked(mDefaultViewport, display, device);
1006 }
1007 if (!mExternalTouchViewport.valid
1008 && info.touch == DisplayDeviceInfo.TOUCH_EXTERNAL) {
1009 setViewportLocked(mExternalTouchViewport, display, device);
1010 }
1011 }
1012
1013 private static void setViewportLocked(DisplayViewport viewport,
1014 LogicalDisplay display, DisplayDevice device) {
1015 viewport.valid = true;
1016 viewport.displayId = display.getDisplayIdLocked();
1017 device.populateViewportLocked(viewport);
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001018 }
1019
1020 private LogicalDisplay findLogicalDisplayForDeviceLocked(DisplayDevice device) {
1021 final int count = mLogicalDisplays.size();
1022 for (int i = 0; i < count; i++) {
1023 LogicalDisplay display = mLogicalDisplays.valueAt(i);
1024 if (display.getPrimaryDisplayDeviceLocked() == device) {
1025 return display;
1026 }
1027 }
1028 return null;
1029 }
1030
Jeff Brownbd6e1502012-08-28 03:27:37 -07001031 private void sendDisplayEventLocked(int displayId, int event) {
1032 Message msg = mHandler.obtainMessage(MSG_DELIVER_DISPLAY_EVENT, displayId, event);
1033 mHandler.sendMessage(msg);
1034 }
1035
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001036 // Requests that performTraversalsInTransactionFromWindowManager be called at a
1037 // later time to apply changes to surfaces and displays.
Craig Mautner65d11b32012-10-01 13:59:52 -07001038 private void scheduleTraversalLocked(boolean inTraversal) {
Jeff Brown4ccb8232014-01-16 22:16:42 -08001039 if (!mPendingTraversal && mWindowManagerInternal != null) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001040 mPendingTraversal = true;
Craig Mautner65d11b32012-10-01 13:59:52 -07001041 if (!inTraversal) {
1042 mHandler.sendEmptyMessage(MSG_REQUEST_TRAVERSAL);
1043 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001044 }
1045 }
1046
1047 // Runs on Handler thread.
1048 // Delivers display event notifications to callbacks.
Jeff Brownbd6e1502012-08-28 03:27:37 -07001049 private void deliverDisplayEvent(int displayId, int event) {
1050 if (DEBUG) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001051 Slog.d(TAG, "Delivering display event: displayId="
1052 + displayId + ", event=" + event);
Jeff Brownfa25bf52012-07-23 19:26:30 -07001053 }
Jeff Brownfa25bf52012-07-23 19:26:30 -07001054
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001055 // Grab the lock and copy the callbacks.
Jeff Brownbd6e1502012-08-28 03:27:37 -07001056 final int count;
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001057 synchronized (mSyncRoot) {
Jeff Brownbd6e1502012-08-28 03:27:37 -07001058 count = mCallbacks.size();
1059 mTempCallbacks.clear();
1060 for (int i = 0; i < count; i++) {
1061 mTempCallbacks.add(mCallbacks.valueAt(i));
Craig Mautner4f67ba62012-08-02 11:23:00 -07001062 }
Jeff Brownbd6e1502012-08-28 03:27:37 -07001063 }
Craig Mautner4f67ba62012-08-02 11:23:00 -07001064
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001065 // After releasing the lock, send the notifications out.
Jeff Brownbd6e1502012-08-28 03:27:37 -07001066 for (int i = 0; i < count; i++) {
1067 mTempCallbacks.get(i).notifyDisplayEventAsync(displayId, event);
1068 }
1069 mTempCallbacks.clear();
Craig Mautner4f67ba62012-08-02 11:23:00 -07001070 }
1071
Michael Wrightc39d47a2014-07-08 18:07:36 -07001072 private IMediaProjectionManager getProjectionService() {
1073 if (mProjectionService == null) {
1074 IBinder b = ServiceManager.getService(Context.MEDIA_PROJECTION_SERVICE);
1075 mProjectionService = IMediaProjectionManager.Stub.asInterface(b);
1076 }
1077 return mProjectionService;
1078 }
1079
Jeff Brown4ccb8232014-01-16 22:16:42 -08001080 private void dumpInternal(PrintWriter pw) {
Jeff Brownbd6e1502012-08-28 03:27:37 -07001081 pw.println("DISPLAY MANAGER (dumpsys display)");
Jeff Brownfa25bf52012-07-23 19:26:30 -07001082
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001083 synchronized (mSyncRoot) {
Jeff Brown9e316a12012-10-08 19:17:06 -07001084 pw.println(" mOnlyCode=" + mOnlyCore);
1085 pw.println(" mSafeMode=" + mSafeMode);
1086 pw.println(" mPendingTraversal=" + mPendingTraversal);
Jeff Brown037c33e2014-04-09 00:31:55 -07001087 pw.println(" mGlobalDisplayState=" + Display.stateToString(mGlobalDisplayState));
Jeff Brown9e316a12012-10-08 19:17:06 -07001088 pw.println(" mNextNonDefaultDisplayId=" + mNextNonDefaultDisplayId);
1089 pw.println(" mDefaultViewport=" + mDefaultViewport);
1090 pw.println(" mExternalTouchViewport=" + mExternalTouchViewport);
Damien Bargiacchi4364bbf2016-11-01 21:44:20 -07001091 pw.println(" mDefaultDisplayDefaultColorMode=" + mDefaultDisplayDefaultColorMode);
Jeff Brown27f1d672012-10-17 18:32:34 -07001092 pw.println(" mSingleDisplayDemoMode=" + mSingleDisplayDemoMode);
Jeff Brownce468a32013-11-21 16:42:03 -08001093 pw.println(" mWifiDisplayScanRequestCount=" + mWifiDisplayScanRequestCount);
Jeff Brown9e316a12012-10-08 19:17:06 -07001094
Jeff Brownbd6e1502012-08-28 03:27:37 -07001095 IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ");
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001096 ipw.increaseIndent();
Jeff Brownbd6e1502012-08-28 03:27:37 -07001097
1098 pw.println();
1099 pw.println("Display Adapters: size=" + mDisplayAdapters.size());
Jeff Brown848c2dc2012-08-19 20:18:08 -07001100 for (DisplayAdapter adapter : mDisplayAdapters) {
Jeff Brownbd6e1502012-08-28 03:27:37 -07001101 pw.println(" " + adapter.getName());
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001102 adapter.dumpLocked(ipw);
Jeff Brown848c2dc2012-08-19 20:18:08 -07001103 }
Craig Mautner9de49362012-08-02 14:30:30 -07001104
Jeff Brownbd6e1502012-08-28 03:27:37 -07001105 pw.println();
1106 pw.println("Display Devices: size=" + mDisplayDevices.size());
1107 for (DisplayDevice device : mDisplayDevices) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001108 pw.println(" " + device.getDisplayDeviceInfoLocked());
1109 device.dumpLocked(ipw);
Jeff Brownbd6e1502012-08-28 03:27:37 -07001110 }
1111
1112 final int logicalDisplayCount = mLogicalDisplays.size();
1113 pw.println();
1114 pw.println("Logical Displays: size=" + logicalDisplayCount);
1115 for (int i = 0; i < logicalDisplayCount; i++) {
1116 int displayId = mLogicalDisplays.keyAt(i);
1117 LogicalDisplay display = mLogicalDisplays.valueAt(i);
1118 pw.println(" Display " + displayId + ":");
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001119 display.dumpLocked(ipw);
Jeff Brownbd6e1502012-08-28 03:27:37 -07001120 }
Jeff Brownce468a32013-11-21 16:42:03 -08001121
1122 final int callbackCount = mCallbacks.size();
1123 pw.println();
1124 pw.println("Callbacks: size=" + callbackCount);
1125 for (int i = 0; i < callbackCount; i++) {
1126 CallbackRecord callback = mCallbacks.valueAt(i);
1127 pw.println(" " + i + ": mPid=" + callback.mPid
1128 + ", mWifiDisplayScanRequested=" + callback.mWifiDisplayScanRequested);
1129 }
Jeff Brownad9ef192014-04-08 17:26:30 -07001130
1131 if (mDisplayPowerController != null) {
1132 mDisplayPowerController.dump(pw);
1133 }
Michael Wright1c9977b2016-07-12 13:30:10 -07001134
1135 pw.println();
1136 mPersistentDataStore.dump(pw);
Jeff Brownbd6e1502012-08-28 03:27:37 -07001137 }
1138 }
1139
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001140 /**
1141 * This is the object that everything in the display manager locks on.
1142 * We make it an inner class within the {@link DisplayManagerService} to so that it is
1143 * clear that the object belongs to the display manager service and that it is
1144 * a unique object with a special purpose.
1145 */
1146 public static final class SyncRoot {
1147 }
1148
Jeff Brownbd6e1502012-08-28 03:27:37 -07001149 private final class DisplayManagerHandler extends Handler {
1150 public DisplayManagerHandler(Looper looper) {
1151 super(looper, null, true /*async*/);
Jeff Brown848c2dc2012-08-19 20:18:08 -07001152 }
Jeff Brownbf5740e2012-08-19 23:20:02 -07001153
Jeff Brownbd6e1502012-08-28 03:27:37 -07001154 @Override
1155 public void handleMessage(Message msg) {
1156 switch (msg.what) {
1157 case MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER:
1158 registerDefaultDisplayAdapter();
1159 break;
1160
1161 case MSG_REGISTER_ADDITIONAL_DISPLAY_ADAPTERS:
1162 registerAdditionalDisplayAdapters();
1163 break;
1164
1165 case MSG_DELIVER_DISPLAY_EVENT:
1166 deliverDisplayEvent(msg.arg1, msg.arg2);
1167 break;
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001168
1169 case MSG_REQUEST_TRAVERSAL:
Jeff Brown4ccb8232014-01-16 22:16:42 -08001170 mWindowManagerInternal.requestTraversalFromDisplayManager();
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001171 break;
Jeff Brownd728bf52012-09-08 18:05:28 -07001172
1173 case MSG_UPDATE_VIEWPORT: {
1174 synchronized (mSyncRoot) {
1175 mTempDefaultViewport.copyFrom(mDefaultViewport);
1176 mTempExternalTouchViewport.copyFrom(mExternalTouchViewport);
1177 }
Jeff Brown4ccb8232014-01-16 22:16:42 -08001178 mInputManagerInternal.setDisplayViewports(
Jeff Brownd728bf52012-09-08 18:05:28 -07001179 mTempDefaultViewport, mTempExternalTouchViewport);
1180 break;
1181 }
Jeff Brownbd6e1502012-08-28 03:27:37 -07001182 }
1183 }
1184 }
1185
1186 private final class DisplayAdapterListener implements DisplayAdapter.Listener {
1187 @Override
1188 public void onDisplayDeviceEvent(DisplayDevice device, int event) {
1189 switch (event) {
1190 case DisplayAdapter.DISPLAY_DEVICE_EVENT_ADDED:
1191 handleDisplayDeviceAdded(device);
1192 break;
1193
1194 case DisplayAdapter.DISPLAY_DEVICE_EVENT_CHANGED:
1195 handleDisplayDeviceChanged(device);
1196 break;
1197
1198 case DisplayAdapter.DISPLAY_DEVICE_EVENT_REMOVED:
1199 handleDisplayDeviceRemoved(device);
1200 break;
1201 }
1202 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001203
1204 @Override
1205 public void onTraversalRequested() {
1206 synchronized (mSyncRoot) {
Craig Mautner65d11b32012-10-01 13:59:52 -07001207 scheduleTraversalLocked(false);
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001208 }
1209 }
Jeff Brownbd6e1502012-08-28 03:27:37 -07001210 }
1211
1212 private final class CallbackRecord implements DeathRecipient {
Jeff Brownce468a32013-11-21 16:42:03 -08001213 public final int mPid;
Jeff Brownbd6e1502012-08-28 03:27:37 -07001214 private final IDisplayManagerCallback mCallback;
1215
Jeff Brownce468a32013-11-21 16:42:03 -08001216 public boolean mWifiDisplayScanRequested;
1217
Jeff Brownbd6e1502012-08-28 03:27:37 -07001218 public CallbackRecord(int pid, IDisplayManagerCallback callback) {
1219 mPid = pid;
1220 mCallback = callback;
1221 }
1222
1223 @Override
1224 public void binderDied() {
1225 if (DEBUG) {
1226 Slog.d(TAG, "Display listener for pid " + mPid + " died.");
1227 }
Jeff Brownce468a32013-11-21 16:42:03 -08001228 onCallbackDied(this);
Jeff Brownbd6e1502012-08-28 03:27:37 -07001229 }
1230
1231 public void notifyDisplayEventAsync(int displayId, int event) {
1232 try {
1233 mCallback.onDisplayEvent(displayId, event);
1234 } catch (RemoteException ex) {
1235 Slog.w(TAG, "Failed to notify process "
1236 + mPid + " that displays changed, assuming it died.", ex);
1237 binderDied();
1238 }
1239 }
1240 }
Jeff Brown4ccb8232014-01-16 22:16:42 -08001241
1242 private final class BinderService extends IDisplayManager.Stub {
1243 /**
1244 * Returns information about the specified logical display.
1245 *
1246 * @param displayId The logical display id.
1247 * @return The logical display info, or null if the display does not exist. The
1248 * returned object must be treated as immutable.
1249 */
1250 @Override // Binder call
1251 public DisplayInfo getDisplayInfo(int displayId) {
1252 final int callingUid = Binder.getCallingUid();
1253 final long token = Binder.clearCallingIdentity();
1254 try {
1255 return getDisplayInfoInternal(displayId, callingUid);
1256 } finally {
1257 Binder.restoreCallingIdentity(token);
1258 }
1259 }
1260
1261 /**
1262 * Returns the list of all display ids.
1263 */
1264 @Override // Binder call
1265 public int[] getDisplayIds() {
1266 final int callingUid = Binder.getCallingUid();
1267 final long token = Binder.clearCallingIdentity();
1268 try {
1269 return getDisplayIdsInternal(callingUid);
1270 } finally {
1271 Binder.restoreCallingIdentity(token);
1272 }
1273 }
1274
1275 @Override // Binder call
1276 public void registerCallback(IDisplayManagerCallback callback) {
1277 if (callback == null) {
1278 throw new IllegalArgumentException("listener must not be null");
1279 }
1280
1281 final int callingPid = Binder.getCallingPid();
1282 final long token = Binder.clearCallingIdentity();
1283 try {
1284 registerCallbackInternal(callback, callingPid);
1285 } finally {
1286 Binder.restoreCallingIdentity(token);
1287 }
1288 }
1289
1290 @Override // Binder call
1291 public void startWifiDisplayScan() {
1292 mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY,
1293 "Permission required to start wifi display scans");
1294
1295 final int callingPid = Binder.getCallingPid();
1296 final long token = Binder.clearCallingIdentity();
1297 try {
1298 startWifiDisplayScanInternal(callingPid);
1299 } finally {
1300 Binder.restoreCallingIdentity(token);
1301 }
1302 }
1303
1304 @Override // Binder call
1305 public void stopWifiDisplayScan() {
1306 mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY,
1307 "Permission required to stop wifi display scans");
1308
1309 final int callingPid = Binder.getCallingPid();
1310 final long token = Binder.clearCallingIdentity();
1311 try {
1312 stopWifiDisplayScanInternal(callingPid);
1313 } finally {
1314 Binder.restoreCallingIdentity(token);
1315 }
1316 }
1317
1318 @Override // Binder call
1319 public void connectWifiDisplay(String address) {
1320 if (address == null) {
1321 throw new IllegalArgumentException("address must not be null");
1322 }
1323 mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY,
1324 "Permission required to connect to a wifi display");
1325
1326 final long token = Binder.clearCallingIdentity();
1327 try {
1328 connectWifiDisplayInternal(address);
1329 } finally {
1330 Binder.restoreCallingIdentity(token);
1331 }
1332 }
1333
1334 @Override // Binder call
1335 public void disconnectWifiDisplay() {
1336 // This request does not require special permissions.
1337 // Any app can request disconnection from the currently active wifi display.
1338 // This exception should no longer be needed once wifi display control moves
1339 // to the media router service.
1340
1341 final long token = Binder.clearCallingIdentity();
1342 try {
1343 disconnectWifiDisplayInternal();
1344 } finally {
1345 Binder.restoreCallingIdentity(token);
1346 }
1347 }
1348
1349 @Override // Binder call
1350 public void renameWifiDisplay(String address, String alias) {
1351 if (address == null) {
1352 throw new IllegalArgumentException("address must not be null");
1353 }
1354 mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY,
1355 "Permission required to rename to a wifi display");
1356
1357 final long token = Binder.clearCallingIdentity();
1358 try {
1359 renameWifiDisplayInternal(address, alias);
1360 } finally {
1361 Binder.restoreCallingIdentity(token);
1362 }
1363 }
1364
1365 @Override // Binder call
1366 public void forgetWifiDisplay(String address) {
1367 if (address == null) {
1368 throw new IllegalArgumentException("address must not be null");
1369 }
1370 mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY,
1371 "Permission required to forget to a wifi display");
1372
1373 final long token = Binder.clearCallingIdentity();
1374 try {
1375 forgetWifiDisplayInternal(address);
1376 } finally {
1377 Binder.restoreCallingIdentity(token);
1378 }
1379 }
1380
1381 @Override // Binder call
1382 public void pauseWifiDisplay() {
1383 mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY,
1384 "Permission required to pause a wifi display session");
1385
1386 final long token = Binder.clearCallingIdentity();
1387 try {
1388 pauseWifiDisplayInternal();
1389 } finally {
1390 Binder.restoreCallingIdentity(token);
1391 }
1392 }
1393
1394 @Override // Binder call
1395 public void resumeWifiDisplay() {
1396 mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY,
1397 "Permission required to resume a wifi display session");
1398
1399 final long token = Binder.clearCallingIdentity();
1400 try {
1401 resumeWifiDisplayInternal();
1402 } finally {
1403 Binder.restoreCallingIdentity(token);
1404 }
1405 }
1406
1407 @Override // Binder call
1408 public WifiDisplayStatus getWifiDisplayStatus() {
1409 // This request does not require special permissions.
1410 // Any app can get information about available wifi displays.
1411
1412 final long token = Binder.clearCallingIdentity();
1413 try {
1414 return getWifiDisplayStatusInternal();
1415 } finally {
1416 Binder.restoreCallingIdentity(token);
1417 }
1418 }
1419
1420 @Override // Binder call
Michael Wright1c9977b2016-07-12 13:30:10 -07001421 public void requestColorMode(int displayId, int colorMode) {
Michael Wright58e829f2015-09-15 00:13:26 +01001422 mContext.enforceCallingOrSelfPermission(
Michael Wright1c9977b2016-07-12 13:30:10 -07001423 Manifest.permission.CONFIGURE_DISPLAY_COLOR_MODE,
1424 "Permission required to change the display color mode");
Michael Wright58e829f2015-09-15 00:13:26 +01001425 final long token = Binder.clearCallingIdentity();
1426 try {
Michael Wright1c9977b2016-07-12 13:30:10 -07001427 requestColorModeInternal(displayId, colorMode);
Michael Wright58e829f2015-09-15 00:13:26 +01001428 } finally {
1429 Binder.restoreCallingIdentity(token);
1430 }
1431 }
1432
1433 @Override // Binder call
Michael Wright75ee9fc2014-09-01 19:55:22 -07001434 public int createVirtualDisplay(IVirtualDisplayCallback callback,
Michael Wrightc39d47a2014-07-08 18:07:36 -07001435 IMediaProjection projection, String packageName, String name,
1436 int width, int height, int densityDpi, Surface surface, int flags) {
Jeff Brown4ccb8232014-01-16 22:16:42 -08001437 final int callingUid = Binder.getCallingUid();
1438 if (!validatePackageName(callingUid, packageName)) {
1439 throw new SecurityException("packageName must match the calling uid");
1440 }
Michael Wright75ee9fc2014-09-01 19:55:22 -07001441 if (callback == null) {
Jeff Brown4ccb8232014-01-16 22:16:42 -08001442 throw new IllegalArgumentException("appToken must not be null");
1443 }
1444 if (TextUtils.isEmpty(name)) {
1445 throw new IllegalArgumentException("name must be non-null and non-empty");
1446 }
1447 if (width <= 0 || height <= 0 || densityDpi <= 0) {
1448 throw new IllegalArgumentException("width, height, and densityDpi must be "
1449 + "greater than 0");
1450 }
Pablo Ceballoseb3370d2016-08-31 15:00:17 -07001451 if (surface != null && surface.isSingleBuffered()) {
Pablo Ceballosaff2f942016-07-29 14:49:55 -07001452 throw new IllegalArgumentException("Surface can't be single-buffered");
1453 }
Michael Wrightc39d47a2014-07-08 18:07:36 -07001454
Andrii Kulianfc8f82b2017-01-26 13:17:27 -08001455 if ((flags & VIRTUAL_DISPLAY_FLAG_PUBLIC) != 0) {
1456 flags |= VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;
1457
1458 // Public displays can't be allowed to show content when locked.
Andrii Kulian7211d2e2017-01-27 15:58:05 -08001459 if ((flags & VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD) != 0) {
Andrii Kulianfc8f82b2017-01-26 13:17:27 -08001460 throw new IllegalArgumentException(
1461 "Public display must not be marked as SHOW_WHEN_LOCKED_INSECURE");
1462 }
Michael Wright6720be42014-07-29 19:14:16 -07001463 }
Andrii Kulianfc8f82b2017-01-26 13:17:27 -08001464 if ((flags & VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY) != 0) {
1465 flags &= ~VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;
Michael Wright6720be42014-07-29 19:14:16 -07001466 }
1467
Michael Wrightc39d47a2014-07-08 18:07:36 -07001468 if (projection != null) {
1469 try {
1470 if (!getProjectionService().isValidMediaProjection(projection)) {
1471 throw new SecurityException("Invalid media projection");
1472 }
Michael Wright6720be42014-07-29 19:14:16 -07001473 flags = projection.applyVirtualDisplayFlags(flags);
Michael Wrightc39d47a2014-07-08 18:07:36 -07001474 } catch (RemoteException e) {
Michael Wright6720be42014-07-29 19:14:16 -07001475 throw new SecurityException("unable to validate media projection or flags");
Michael Wrightc39d47a2014-07-08 18:07:36 -07001476 }
1477 }
1478
Michael Wright6720be42014-07-29 19:14:16 -07001479 if (callingUid != Process.SYSTEM_UID &&
Andrii Kulianfc8f82b2017-01-26 13:17:27 -08001480 (flags & VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR) != 0) {
Michael Wrightc39d47a2014-07-08 18:07:36 -07001481 if (!canProjectVideo(projection)) {
1482 throw new SecurityException("Requires CAPTURE_VIDEO_OUTPUT or "
1483 + "CAPTURE_SECURE_VIDEO_OUTPUT permission, or an appropriate "
1484 + "MediaProjection token in order to create a screen sharing virtual "
1485 + "display.");
1486 }
1487 }
Andrii Kulianfc8f82b2017-01-26 13:17:27 -08001488 if ((flags & VIRTUAL_DISPLAY_FLAG_SECURE) != 0) {
Michael Wrightc39d47a2014-07-08 18:07:36 -07001489 if (!canProjectSecureVideo(projection)) {
Jeff Brown4ccb8232014-01-16 22:16:42 -08001490 throw new SecurityException("Requires CAPTURE_SECURE_VIDEO_OUTPUT "
Michael Wrightc39d47a2014-07-08 18:07:36 -07001491 + "or an appropriate MediaProjection token to create a "
1492 + "secure virtual display.");
Jeff Brown4ccb8232014-01-16 22:16:42 -08001493 }
1494 }
1495
1496 final long token = Binder.clearCallingIdentity();
1497 try {
Michael Wright75ee9fc2014-09-01 19:55:22 -07001498 return createVirtualDisplayInternal(callback, projection, callingUid,
Michael Wrightc39d47a2014-07-08 18:07:36 -07001499 packageName, name, width, height, densityDpi, surface, flags);
Jeff Brown4ccb8232014-01-16 22:16:42 -08001500 } finally {
1501 Binder.restoreCallingIdentity(token);
1502 }
1503 }
1504
1505 @Override // Binder call
Michael Wright75ee9fc2014-09-01 19:55:22 -07001506 public void resizeVirtualDisplay(IVirtualDisplayCallback callback,
Michael Wright01e840f2014-06-26 16:03:25 -07001507 int width, int height, int densityDpi) {
1508 final long token = Binder.clearCallingIdentity();
1509 try {
Michael Wright75ee9fc2014-09-01 19:55:22 -07001510 resizeVirtualDisplayInternal(callback.asBinder(), width, height, densityDpi);
Michael Wright01e840f2014-06-26 16:03:25 -07001511 } finally {
1512 Binder.restoreCallingIdentity(token);
1513 }
1514 }
1515
1516 @Override // Binder call
Michael Wright75ee9fc2014-09-01 19:55:22 -07001517 public void setVirtualDisplaySurface(IVirtualDisplayCallback callback, Surface surface) {
Pablo Ceballoseb3370d2016-08-31 15:00:17 -07001518 if (surface != null && surface.isSingleBuffered()) {
1519 throw new IllegalArgumentException("Surface can't be single-buffered");
1520 }
Jeff Brown92207df2014-04-16 13:16:07 -07001521 final long token = Binder.clearCallingIdentity();
1522 try {
Michael Wright75ee9fc2014-09-01 19:55:22 -07001523 setVirtualDisplaySurfaceInternal(callback.asBinder(), surface);
Jeff Brown92207df2014-04-16 13:16:07 -07001524 } finally {
1525 Binder.restoreCallingIdentity(token);
1526 }
1527 }
1528
1529 @Override // Binder call
Michael Wright75ee9fc2014-09-01 19:55:22 -07001530 public void releaseVirtualDisplay(IVirtualDisplayCallback callback) {
Jeff Brown4ccb8232014-01-16 22:16:42 -08001531 final long token = Binder.clearCallingIdentity();
1532 try {
Michael Wright75ee9fc2014-09-01 19:55:22 -07001533 releaseVirtualDisplayInternal(callback.asBinder());
Jeff Brown4ccb8232014-01-16 22:16:42 -08001534 } finally {
1535 Binder.restoreCallingIdentity(token);
1536 }
1537 }
1538
1539 @Override // Binder call
1540 public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) {
1541 if (mContext == null
1542 || mContext.checkCallingOrSelfPermission(Manifest.permission.DUMP)
1543 != PackageManager.PERMISSION_GRANTED) {
1544 pw.println("Permission Denial: can't dump DisplayManager from from pid="
1545 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
1546 return;
1547 }
1548
1549 final long token = Binder.clearCallingIdentity();
1550 try {
1551 dumpInternal(pw);
1552 } finally {
1553 Binder.restoreCallingIdentity(token);
1554 }
1555 }
1556
1557 private boolean validatePackageName(int uid, String packageName) {
1558 if (packageName != null) {
1559 String[] packageNames = mContext.getPackageManager().getPackagesForUid(uid);
1560 if (packageNames != null) {
1561 for (String n : packageNames) {
1562 if (n.equals(packageName)) {
1563 return true;
1564 }
1565 }
1566 }
1567 }
1568 return false;
1569 }
Michael Wrightc39d47a2014-07-08 18:07:36 -07001570
1571 private boolean canProjectVideo(IMediaProjection projection) {
1572 if (projection != null) {
1573 try {
1574 if (projection.canProjectVideo()) {
1575 return true;
1576 }
1577 } catch (RemoteException e) {
1578 Slog.e(TAG, "Unable to query projection service for permissions", e);
1579 }
1580 }
1581 if (mContext.checkCallingPermission(
1582 android.Manifest.permission.CAPTURE_VIDEO_OUTPUT)
Michael Wright0ccc2b02014-07-24 18:20:41 -07001583 == PackageManager.PERMISSION_GRANTED) {
Michael Wrightc39d47a2014-07-08 18:07:36 -07001584 return true;
1585 }
1586 return canProjectSecureVideo(projection);
1587 }
1588
1589 private boolean canProjectSecureVideo(IMediaProjection projection) {
1590 if (projection != null) {
1591 try {
1592 if (projection.canProjectSecureVideo()){
1593 return true;
1594 }
1595 } catch (RemoteException e) {
1596 Slog.e(TAG, "Unable to query projection service for permissions", e);
1597 }
1598 }
1599 return mContext.checkCallingPermission(
1600 android.Manifest.permission.CAPTURE_SECURE_VIDEO_OUTPUT)
Michael Wright0ccc2b02014-07-24 18:20:41 -07001601 == PackageManager.PERMISSION_GRANTED;
Michael Wrightc39d47a2014-07-08 18:07:36 -07001602 }
Jeff Brown4ccb8232014-01-16 22:16:42 -08001603 }
1604
1605 private final class LocalService extends DisplayManagerInternal {
1606 @Override
Jeff Brown037c33e2014-04-09 00:31:55 -07001607 public void initPowerManagement(final DisplayPowerCallbacks callbacks, Handler handler,
Jeff Brownad9ef192014-04-08 17:26:30 -07001608 SensorManager sensorManager) {
1609 synchronized (mSyncRoot) {
Jeff Brown037c33e2014-04-09 00:31:55 -07001610 DisplayBlanker blanker = new DisplayBlanker() {
1611 @Override
Jeff Brown5d6443b2015-04-10 20:15:01 -07001612 public void requestDisplayState(int state, int brightness) {
Jeff Brown037c33e2014-04-09 00:31:55 -07001613 // The order of operations is important for legacy reasons.
1614 if (state == Display.STATE_OFF) {
Jeff Brown5d6443b2015-04-10 20:15:01 -07001615 requestGlobalDisplayStateInternal(state, brightness);
Jeff Brown037c33e2014-04-09 00:31:55 -07001616 }
1617
1618 callbacks.onDisplayStateChange(state);
1619
1620 if (state != Display.STATE_OFF) {
Jeff Brown5d6443b2015-04-10 20:15:01 -07001621 requestGlobalDisplayStateInternal(state, brightness);
Jeff Brown037c33e2014-04-09 00:31:55 -07001622 }
1623 }
1624 };
Jeff Brownad9ef192014-04-08 17:26:30 -07001625 mDisplayPowerController = new DisplayPowerController(
Jeff Brown037c33e2014-04-09 00:31:55 -07001626 mContext, callbacks, handler, sensorManager, blanker);
Jeff Brownad9ef192014-04-08 17:26:30 -07001627 }
1628 }
1629
1630 @Override
1631 public boolean requestPowerState(DisplayPowerRequest request,
1632 boolean waitForNegativeProximity) {
1633 return mDisplayPowerController.requestPowerState(request,
1634 waitForNegativeProximity);
1635 }
1636
1637 @Override
1638 public boolean isProximitySensorAvailable() {
1639 return mDisplayPowerController.isProximitySensorAvailable();
1640 }
1641
1642 @Override
Jeff Brown4ccb8232014-01-16 22:16:42 -08001643 public DisplayInfo getDisplayInfo(int displayId) {
1644 return getDisplayInfoInternal(displayId, Process.myUid());
1645 }
1646
1647 @Override
1648 public void registerDisplayTransactionListener(DisplayTransactionListener listener) {
1649 if (listener == null) {
1650 throw new IllegalArgumentException("listener must not be null");
1651 }
1652
1653 registerDisplayTransactionListenerInternal(listener);
1654 }
1655
1656 @Override
1657 public void unregisterDisplayTransactionListener(DisplayTransactionListener listener) {
1658 if (listener == null) {
1659 throw new IllegalArgumentException("listener must not be null");
1660 }
1661
1662 unregisterDisplayTransactionListenerInternal(listener);
1663 }
1664
1665 @Override
1666 public void setDisplayInfoOverrideFromWindowManager(int displayId, DisplayInfo info) {
1667 setDisplayInfoOverrideFromWindowManagerInternal(displayId, info);
1668 }
1669
1670 @Override
1671 public void performTraversalInTransactionFromWindowManager() {
1672 performTraversalInTransactionFromWindowManagerInternal();
1673 }
1674
1675 @Override
Michael Wright3f145a22014-07-22 19:46:03 -07001676 public void setDisplayProperties(int displayId, boolean hasContent,
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -07001677 float requestedRefreshRate, int requestedMode, boolean inTraversal) {
1678 setDisplayPropertiesInternal(displayId, hasContent, requestedRefreshRate,
1679 requestedMode, inTraversal);
Jeff Brown4ccb8232014-01-16 22:16:42 -08001680 }
Filip Gruszczynskid2e86402015-02-19 13:05:03 -08001681
1682 @Override
1683 public void setDisplayOffsets(int displayId, int x, int y) {
1684 setDisplayOffsetsInternal(displayId, x, y);
1685 }
Andrii Kulianfb1bf692017-01-17 11:17:34 -08001686
1687 @Override
1688 public void setDisplayAccessUIDs(SparseArray<IntArray> newDisplayAccessUIDs) {
1689 setDisplayAccessUIDsInternal(newDisplayAccessUIDs);
1690 }
1691
1692 @Override
1693 public boolean isUidPresentOnDisplay(int uid, int displayId) {
1694 return isUidPresentOnDisplayInternal(uid, displayId);
1695 }
Jeff Brown4ccb8232014-01-16 22:16:42 -08001696 }
Jeff Brownfa25bf52012-07-23 19:26:30 -07001697}