blob: d83676b58552fe87514efffac99036d7e567b2e5 [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 Sharkeyfe9a53b2017-03-31 14:08:23 -060026import com.android.internal.util.DumpUtils;
Jeff Brownbd6e1502012-08-28 03:27:37 -070027import com.android.internal.util.IndentingPrintWriter;
28
Jeff Brownfa25bf52012-07-23 19:26:30 -070029import android.Manifest;
30import android.content.Context;
31import android.content.pm.PackageManager;
Jeff Brownad9ef192014-04-08 17:26:30 -070032import android.hardware.SensorManager;
Jeff Brownbd6e1502012-08-28 03:27:37 -070033import android.hardware.display.DisplayManagerGlobal;
Jeff Brown4ccb8232014-01-16 22:16:42 -080034import android.hardware.display.DisplayManagerInternal;
35import android.hardware.display.DisplayViewport;
36import android.hardware.display.DisplayManagerInternal.DisplayTransactionListener;
Jeff Brownfa25bf52012-07-23 19:26:30 -070037import android.hardware.display.IDisplayManager;
Jeff Brownbd6e1502012-08-28 03:27:37 -070038import android.hardware.display.IDisplayManagerCallback;
Michael Wright75ee9fc2014-09-01 19:55:22 -070039import android.hardware.display.IVirtualDisplayCallback;
Jeff Browne08ae382012-09-07 20:36:36 -070040import android.hardware.display.WifiDisplayStatus;
Jeff Brown4ccb8232014-01-16 22:16:42 -080041import android.hardware.input.InputManagerInternal;
Michael Wrightc39d47a2014-07-08 18:07:36 -070042import android.media.projection.IMediaProjection;
43import android.media.projection.IMediaProjectionManager;
Jeff Brownfa25bf52012-07-23 19:26:30 -070044import android.os.Binder;
Jeff Brownbd6e1502012-08-28 03:27:37 -070045import android.os.Handler;
Jeff Brown64a55af2012-08-26 02:47:39 -070046import android.os.IBinder;
Jeff Brown4ccb8232014-01-16 22:16:42 -080047import android.os.IBinder.DeathRecipient;
Jeff Brownbd6e1502012-08-28 03:27:37 -070048import android.os.Looper;
49import android.os.Message;
Jeff Brown5d6443b2015-04-10 20:15:01 -070050import android.os.PowerManager;
Craig Mautner4504de52013-12-20 09:06:56 -080051import android.os.Process;
Jeff Brownbd6e1502012-08-28 03:27:37 -070052import android.os.RemoteException;
Michael Wrightc39d47a2014-07-08 18:07:36 -070053import android.os.ServiceManager;
Jeff Brownbd6e1502012-08-28 03:27:37 -070054import android.os.SystemClock;
Jeff Brownfa25bf52012-07-23 19:26:30 -070055import android.os.SystemProperties;
Jeff Brown5d6443b2015-04-10 20:15:01 -070056import android.os.Trace;
Jeff Browna506a6e2013-06-04 00:02:38 -070057import android.text.TextUtils;
Andrii Kulianfb1bf692017-01-17 11:17:34 -080058import android.util.IntArray;
Jeff Brownbd6e1502012-08-28 03:27:37 -070059import android.util.Slog;
60import android.util.SparseArray;
Jeff Brownfa25bf52012-07-23 19:26:30 -070061import android.view.Display;
62import android.view.DisplayInfo;
Jeff Browna506a6e2013-06-04 00:02:38 -070063import android.view.Surface;
Jeff Brown4ccb8232014-01-16 22:16:42 -080064import android.view.WindowManagerInternal;
Jeff Browna506a6e2013-06-04 00:02:38 -070065
Jeff Brown4ccb8232014-01-16 22:16:42 -080066import com.android.server.DisplayThread;
67import com.android.server.LocalServices;
68import com.android.server.SystemService;
Dianne Hackborn8d044e82013-04-30 17:24:15 -070069import com.android.server.UiThread;
Jeff Brownfa25bf52012-07-23 19:26:30 -070070
71import java.io.FileDescriptor;
72import java.io.PrintWriter;
73import java.util.ArrayList;
Jeff Browna506a6e2013-06-04 00:02:38 -070074import java.util.Arrays;
Jeff Browne75926d2014-09-18 15:24:49 -070075import java.util.List;
Jeff Brown7f3994e2012-12-04 14:04:28 -080076import java.util.concurrent.CopyOnWriteArrayList;
Jeff Brownfa25bf52012-07-23 19:26:30 -070077
78/**
Jeff Brownbd6e1502012-08-28 03:27:37 -070079 * Manages attached displays.
Jeff Brownfa25bf52012-07-23 19:26:30 -070080 * <p>
Jeff Brownbd6e1502012-08-28 03:27:37 -070081 * The {@link DisplayManagerService} manages the global lifecycle of displays,
82 * decides how to configure logical displays based on the physical display devices currently
83 * attached, sends notifications to the system and to applications when the state
84 * changes, and so on.
85 * </p><p>
86 * The display manager service relies on a collection of {@link DisplayAdapter} components,
87 * for discovering and configuring physical display devices attached to the system.
88 * There are separate display adapters for each manner that devices are attached:
89 * one display adapter for built-in local displays, one for simulated non-functional
90 * displays when the system is headless, one for simulated overlay displays used for
91 * development, one for wifi displays, etc.
92 * </p><p>
93 * Display adapters are only weakly coupled to the display manager service.
94 * Display adapters communicate changes in display device state to the display manager
Craig Mautner722285e2012-09-07 13:55:58 -070095 * service asynchronously via a {@link DisplayAdapter.Listener} registered
Jeff Brownbd6e1502012-08-28 03:27:37 -070096 * by the display manager service. This separation of concerns is important for
97 * two main reasons. First, it neatly encapsulates the responsibilities of these
98 * two classes: display adapters handle individual display devices whereas
99 * the display manager service handles the global state. Second, it eliminates
100 * the potential for deadlocks resulting from asynchronous display device discovery.
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700101 * </p>
102 *
103 * <h3>Synchronization</h3>
104 * <p>
105 * Because the display manager may be accessed by multiple threads, the synchronization
106 * story gets a little complicated. In particular, the window manager may call into
107 * the display manager while holding a surface transaction with the expectation that
108 * it can apply changes immediately. Unfortunately, that means we can't just do
109 * everything asynchronously (*grump*).
Jeff Brownbd6e1502012-08-28 03:27:37 -0700110 * </p><p>
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700111 * To make this work, all of the objects that belong to the display manager must
112 * use the same lock. We call this lock the synchronization root and it has a unique
113 * type {@link DisplayManagerService.SyncRoot}. Methods that require this lock are
114 * named with the "Locked" suffix.
115 * </p><p>
116 * Where things get tricky is that the display manager is not allowed to make
117 * any potentially reentrant calls, especially into the window manager. We generally
118 * avoid this by making all potentially reentrant out-calls asynchronous.
Jeff Brownfa25bf52012-07-23 19:26:30 -0700119 * </p>
120 */
Jeff Brown4ccb8232014-01-16 22:16:42 -0800121public final class DisplayManagerService extends SystemService {
Jeff Brownfa25bf52012-07-23 19:26:30 -0700122 private static final String TAG = "DisplayManagerService";
Jeff Brownbd6e1502012-08-28 03:27:37 -0700123 private static final boolean DEBUG = false;
Jeff Brownfa25bf52012-07-23 19:26:30 -0700124
Jeff Brownbbd28a22012-09-20 16:47:15 -0700125 // When this system property is set to 0, WFD is forcibly disabled on boot.
126 // When this system property is set to 1, WFD is forcibly enabled on boot.
127 // Otherwise WFD is enabled according to the value of config_enableWifiDisplay.
128 private static final String FORCE_WIFI_DISPLAY_ENABLE = "persist.debug.wfd.enable";
129
Jeff Brownbd6e1502012-08-28 03:27:37 -0700130 private static final long WAIT_FOR_DEFAULT_DISPLAY_TIMEOUT = 10000;
131
132 private static final int MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER = 1;
133 private static final int MSG_REGISTER_ADDITIONAL_DISPLAY_ADAPTERS = 2;
134 private static final int MSG_DELIVER_DISPLAY_EVENT = 3;
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700135 private static final int MSG_REQUEST_TRAVERSAL = 4;
Jeff Brownd728bf52012-09-08 18:05:28 -0700136 private static final int MSG_UPDATE_VIEWPORT = 5;
Jeff Brownfa25bf52012-07-23 19:26:30 -0700137
Jeff Brownb880d882014-02-10 19:47:07 -0800138 private final Context mContext;
Jeff Brownbd6e1502012-08-28 03:27:37 -0700139 private final DisplayManagerHandler mHandler;
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700140 private final Handler mUiHandler;
141 private final DisplayAdapterListener mDisplayAdapterListener;
Jeff Brown4ccb8232014-01-16 22:16:42 -0800142 private WindowManagerInternal mWindowManagerInternal;
143 private InputManagerInternal mInputManagerInternal;
Michael Wrightc39d47a2014-07-08 18:07:36 -0700144 private IMediaProjectionManager mProjectionService;
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700145
146 // The synchronization root for the display manager.
147 // This lock guards most of the display manager's state.
Craig Mautner0bf6ec92012-12-18 08:33:27 -0800148 // NOTE: This is synchronized on while holding WindowManagerService.mWindowMap so never call
149 // into WindowManagerService methods that require mWindowMap while holding this unless you are
150 // very very sure that no deadlock can occur.
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700151 private final SyncRoot mSyncRoot = new SyncRoot();
152
153 // True if in safe mode.
154 // This option may disable certain display adapters.
155 public boolean mSafeMode;
156
157 // True if we are in a special boot mode where only core applications and
158 // services should be started. This option may disable certain display adapters.
159 public boolean mOnlyCore;
160
Jeff Brown27f1d672012-10-17 18:32:34 -0700161 // True if the display manager service should pretend there is only one display
162 // and only tell applications about the existence of the default logical display.
163 // The display manager can still mirror content to secondary displays but applications
164 // cannot present unique content on those displays.
165 // Used for demonstration purposes only.
166 private final boolean mSingleDisplayDemoMode;
167
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700168 // All callback records indexed by calling process id.
169 public final SparseArray<CallbackRecord> mCallbacks =
Jeff Brownbd6e1502012-08-28 03:27:37 -0700170 new SparseArray<CallbackRecord>();
Jeff Brownfa25bf52012-07-23 19:26:30 -0700171
Jeff Brownbd6e1502012-08-28 03:27:37 -0700172 // List of all currently registered display adapters.
173 private final ArrayList<DisplayAdapter> mDisplayAdapters = new ArrayList<DisplayAdapter>();
174
175 // List of all currently connected display devices.
176 private final ArrayList<DisplayDevice> mDisplayDevices = new ArrayList<DisplayDevice>();
177
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700178 // List of all logical displays indexed by logical display id.
179 private final SparseArray<LogicalDisplay> mLogicalDisplays =
180 new SparseArray<LogicalDisplay>();
Jeff Brownbd6e1502012-08-28 03:27:37 -0700181 private int mNextNonDefaultDisplayId = Display.DEFAULT_DISPLAY + 1;
182
Jeff Brown7f3994e2012-12-04 14:04:28 -0800183 // List of all display transaction listeners.
184 private final CopyOnWriteArrayList<DisplayTransactionListener> mDisplayTransactionListeners =
185 new CopyOnWriteArrayList<DisplayTransactionListener>();
186
Jeff Brownad9ef192014-04-08 17:26:30 -0700187 // Display power controller.
188 private DisplayPowerController mDisplayPowerController;
189
Jeff Brown037c33e2014-04-09 00:31:55 -0700190 // The overall display state, independent of changes that might influence one
191 // display or another in particular.
Jeff Brown5d6443b2015-04-10 20:15:01 -0700192 private int mGlobalDisplayState = Display.STATE_ON;
193
194 // The overall display brightness.
195 // For now, this only applies to the built-in display but we may split it up eventually.
196 private int mGlobalDisplayBrightness = PowerManager.BRIGHTNESS_DEFAULT;
Jeff Brown9e316a12012-10-08 19:17:06 -0700197
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700198 // Set to true when there are pending display changes that have yet to be applied
199 // to the surface flinger state.
200 private boolean mPendingTraversal;
Jeff Brownbd6e1502012-08-28 03:27:37 -0700201
Jeff Browne08ae382012-09-07 20:36:36 -0700202 // The Wifi display adapter, or null if not registered.
203 private WifiDisplayAdapter mWifiDisplayAdapter;
204
Jeff Brownce468a32013-11-21 16:42:03 -0800205 // The number of active wifi display scan requests.
206 private int mWifiDisplayScanRequestCount;
207
Jeff Browna506a6e2013-06-04 00:02:38 -0700208 // The virtual display adapter, or null if not registered.
209 private VirtualDisplayAdapter mVirtualDisplayAdapter;
210
Jeff Brownd728bf52012-09-08 18:05:28 -0700211 // Viewports of the default display and the display that should receive touch
212 // input from an external source. Used by the input system.
213 private final DisplayViewport mDefaultViewport = new DisplayViewport();
214 private final DisplayViewport mExternalTouchViewport = new DisplayViewport();
215
Jeff Brown89d55462012-09-19 11:33:42 -0700216 // Persistent data store for all internal settings maintained by the display manager service.
217 private final PersistentDataStore mPersistentDataStore = new PersistentDataStore();
218
Jeff Brownbd6e1502012-08-28 03:27:37 -0700219 // Temporary callback list, used when sending display events to applications.
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700220 // May be used outside of the lock but only on the handler thread.
221 private final ArrayList<CallbackRecord> mTempCallbacks = new ArrayList<CallbackRecord>();
Jeff Brownbd6e1502012-08-28 03:27:37 -0700222
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700223 // Temporary display info, used for comparing display configurations.
224 private final DisplayInfo mTempDisplayInfo = new DisplayInfo();
225
Jeff Brownd728bf52012-09-08 18:05:28 -0700226 // Temporary viewports, used when sending new viewport information to the
227 // input system. May be used outside of the lock but only on the handler thread.
228 private final DisplayViewport mTempDefaultViewport = new DisplayViewport();
229 private final DisplayViewport mTempExternalTouchViewport = new DisplayViewport();
230
Damien Bargiacchi4364bbf2016-11-01 21:44:20 -0700231 // The default color mode for default displays. Overrides the usual
232 // Display.Display.COLOR_MODE_DEFAULT for displays with the
233 // DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY flag set.
234 private final int mDefaultDisplayDefaultColorMode;
235
Jeff Browne75926d2014-09-18 15:24:49 -0700236 // Temporary list of deferred work to perform when setting the display state.
237 // Only used by requestDisplayState. The field is self-synchronized and only
238 // intended for use inside of the requestGlobalDisplayStateInternal function.
239 private final ArrayList<Runnable> mTempDisplayStateWorkQueue = new ArrayList<Runnable>();
240
Andrii Kulianfb1bf692017-01-17 11:17:34 -0800241 // Lists of UIDs that are present on the displays. Maps displayId -> array of UIDs.
242 private final SparseArray<IntArray> mDisplayAccessUIDs = new SparseArray<>();
243
Jeff Brownb880d882014-02-10 19:47:07 -0800244 public DisplayManagerService(Context context) {
245 super(context);
246 mContext = context;
Jeff Brown4ccb8232014-01-16 22:16:42 -0800247 mHandler = new DisplayManagerHandler(DisplayThread.get().getLooper());
Dianne Hackborn8d044e82013-04-30 17:24:15 -0700248 mUiHandler = UiThread.getHandler();
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700249 mDisplayAdapterListener = new DisplayAdapterListener();
Jeff Brown27f1d672012-10-17 18:32:34 -0700250 mSingleDisplayDemoMode = SystemProperties.getBoolean("persist.demo.singledisplay", false);
Damien Bargiacchi4364bbf2016-11-01 21:44:20 -0700251 mDefaultDisplayDefaultColorMode = mContext.getResources().getInteger(
252 com.android.internal.R.integer.config_defaultDisplayDefaultColorMode);
Jeff Brown5d6443b2015-04-10 20:15:01 -0700253
254 PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
255 mGlobalDisplayBrightness = pm.getDefaultScreenBrightnessSetting();
Joel Fernandes2d314e12017-04-04 16:32:15 -0700256
257 }
258
259 public void setupSchedulerPolicies() {
260 /*
261 * android.display is critical to user experience and we should
262 * make sure it is not in the default foregroup groups, add it to
263 * top-app to make sure it uses all the cores and scheduling
264 * settings for top-app when it runs.
265 */
266 Process.setThreadGroupAndCpuset(DisplayThread.get().getThreadId(), Process.THREAD_GROUP_TOP_APP);
Craig Mautner4f67ba62012-08-02 11:23:00 -0700267 }
268
Jeff Brown4ccb8232014-01-16 22:16:42 -0800269 @Override
Jeff Brown4ccb8232014-01-16 22:16:42 -0800270 public void onStart() {
Michael Wright1c9977b2016-07-12 13:30:10 -0700271 // We need to pre-load the persistent data store so it's ready before the default display
272 // adapter is up so that we have it's configuration. We could load it lazily, but since
273 // we're going to have to read it in eventually we may as well do it here rather than after
274 // we've waited for the diplay to register itself with us.
275 mPersistentDataStore.loadIfNeeded();
Jeff Brown4ccb8232014-01-16 22:16:42 -0800276 mHandler.sendEmptyMessage(MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER);
277
278 publishBinderService(Context.DISPLAY_SERVICE, new BinderService(),
279 true /*allowIsolated*/);
280 publishLocalService(DisplayManagerInternal.class, new LocalService());
Justin Klaassen22eb1992016-07-11 20:52:23 -0700281 publishLocalService(DisplayTransformManager.class, new DisplayTransformManager());
Jeff Brown4ccb8232014-01-16 22:16:42 -0800282 }
283
284 @Override
285 public void onBootPhase(int phase) {
286 if (phase == PHASE_WAIT_FOR_DEFAULT_DISPLAY) {
287 synchronized (mSyncRoot) {
288 long timeout = SystemClock.uptimeMillis() + WAIT_FOR_DEFAULT_DISPLAY_TIMEOUT;
289 while (mLogicalDisplays.get(Display.DEFAULT_DISPLAY) == null) {
290 long delay = timeout - SystemClock.uptimeMillis();
291 if (delay <= 0) {
292 throw new RuntimeException("Timeout waiting for default display "
293 + "to be initialized.");
294 }
295 if (DEBUG) {
296 Slog.d(TAG, "waitForDefaultDisplay: waiting, timeout=" + delay);
297 }
298 try {
299 mSyncRoot.wait(delay);
300 } catch (InterruptedException ex) {
301 }
Jeff Brownbd6e1502012-08-28 03:27:37 -0700302 }
303 }
304 }
Jeff Brownbd6e1502012-08-28 03:27:37 -0700305 }
306
Jeff Brown4ccb8232014-01-16 22:16:42 -0800307 // TODO: Use dependencies or a boot phase
308 public void windowManagerAndInputReady() {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700309 synchronized (mSyncRoot) {
Jeff Brown4ccb8232014-01-16 22:16:42 -0800310 mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
311 mInputManagerInternal = LocalServices.getService(InputManagerInternal.class);
Craig Mautner65d11b32012-10-01 13:59:52 -0700312 scheduleTraversalLocked(false);
Jeff Brownd728bf52012-09-08 18:05:28 -0700313 }
314 }
315
316 /**
Jeff Brownbd6e1502012-08-28 03:27:37 -0700317 * Called when the system is ready to go.
318 */
319 public void systemReady(boolean safeMode, boolean onlyCore) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700320 synchronized (mSyncRoot) {
Jeff Brownbd6e1502012-08-28 03:27:37 -0700321 mSafeMode = safeMode;
322 mOnlyCore = onlyCore;
323 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700324
Jeff Brownbd6e1502012-08-28 03:27:37 -0700325 mHandler.sendEmptyMessage(MSG_REGISTER_ADDITIONAL_DISPLAY_ADAPTERS);
326 }
327
Jeff Brown4ccb8232014-01-16 22:16:42 -0800328 private void registerDisplayTransactionListenerInternal(
329 DisplayTransactionListener listener) {
Jeff Brown7f3994e2012-12-04 14:04:28 -0800330 // List is self-synchronized copy-on-write.
331 mDisplayTransactionListeners.add(listener);
332 }
333
Jeff Brown4ccb8232014-01-16 22:16:42 -0800334 private void unregisterDisplayTransactionListenerInternal(
335 DisplayTransactionListener listener) {
Jeff Brown7f3994e2012-12-04 14:04:28 -0800336 // List is self-synchronized copy-on-write.
337 mDisplayTransactionListeners.remove(listener);
338 }
339
Jeff Brown4ccb8232014-01-16 22:16:42 -0800340 private void setDisplayInfoOverrideFromWindowManagerInternal(
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700341 int displayId, DisplayInfo info) {
342 synchronized (mSyncRoot) {
Jeff Brownbd6e1502012-08-28 03:27:37 -0700343 LogicalDisplay display = mLogicalDisplays.get(displayId);
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700344 if (display != null) {
Jeff Brownef981a42013-08-07 14:13:37 -0700345 if (display.setDisplayInfoOverrideFromWindowManagerLocked(info)) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700346 sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED);
Craig Mautner65d11b32012-10-01 13:59:52 -0700347 scheduleTraversalLocked(false);
Jeff Brownbd6e1502012-08-28 03:27:37 -0700348 }
Jeff Brownbd6e1502012-08-28 03:27:37 -0700349 }
350 }
351 }
352
Andrii Kuliancd097992017-03-23 18:31:59 -0700353 /**
354 * @see DisplayManagerInternal#getNonOverrideDisplayInfo(int, DisplayInfo)
355 */
356 private void getNonOverrideDisplayInfoInternal(int displayId, DisplayInfo outInfo) {
357 synchronized (mSyncRoot) {
358 final LogicalDisplay display = mLogicalDisplays.get(displayId);
359 if (display != null) {
360 display.getNonOverrideDisplayInfoLocked(outInfo);
361 }
362 }
363 }
364
Jeff Brown4ccb8232014-01-16 22:16:42 -0800365 private void performTraversalInTransactionFromWindowManagerInternal() {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700366 synchronized (mSyncRoot) {
367 if (!mPendingTraversal) {
368 return;
Jeff Brownbd6e1502012-08-28 03:27:37 -0700369 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700370 mPendingTraversal = false;
371
372 performTraversalInTransactionLocked();
Jeff Brownbd6e1502012-08-28 03:27:37 -0700373 }
Jeff Brown7f3994e2012-12-04 14:04:28 -0800374
375 // List is self-synchronized copy-on-write.
376 for (DisplayTransactionListener listener : mDisplayTransactionListeners) {
377 listener.onDisplayTransaction();
378 }
Jeff Brownbd6e1502012-08-28 03:27:37 -0700379 }
380
Jeff Brown5d6443b2015-04-10 20:15:01 -0700381 private void requestGlobalDisplayStateInternal(int state, int brightness) {
382 if (state == Display.STATE_UNKNOWN) {
383 state = Display.STATE_ON;
384 }
385 if (state == Display.STATE_OFF) {
386 brightness = PowerManager.BRIGHTNESS_OFF;
387 } else if (brightness < 0) {
388 brightness = PowerManager.BRIGHTNESS_DEFAULT;
389 } else if (brightness > PowerManager.BRIGHTNESS_ON) {
390 brightness = PowerManager.BRIGHTNESS_ON;
391 }
392
Jeff Browne75926d2014-09-18 15:24:49 -0700393 synchronized (mTempDisplayStateWorkQueue) {
394 try {
395 // Update the display state within the lock.
Jeff Brown8e5d33e2015-06-10 13:05:50 -0700396 // Note that we do not need to schedule traversals here although it
397 // may happen as a side-effect of displays changing state.
Jeff Browne75926d2014-09-18 15:24:49 -0700398 synchronized (mSyncRoot) {
Jeff Brown5d6443b2015-04-10 20:15:01 -0700399 if (mGlobalDisplayState == state
400 && mGlobalDisplayBrightness == brightness) {
401 return; // no change
Jeff Browne75926d2014-09-18 15:24:49 -0700402 }
Jeff Brown5d6443b2015-04-10 20:15:01 -0700403
404 Trace.traceBegin(Trace.TRACE_TAG_POWER, "requestGlobalDisplayState("
405 + Display.stateToString(state)
406 + ", brightness=" + brightness + ")");
407 mGlobalDisplayState = state;
408 mGlobalDisplayBrightness = brightness;
Jeff Brown8e5d33e2015-06-10 13:05:50 -0700409 applyGlobalDisplayStateLocked(mTempDisplayStateWorkQueue);
Jeff Browne75926d2014-09-18 15:24:49 -0700410 }
411
412 // Setting the display power state can take hundreds of milliseconds
413 // to complete so we defer the most expensive part of the work until
414 // after we have exited the critical section to avoid blocking other
415 // threads for a long time.
416 for (int i = 0; i < mTempDisplayStateWorkQueue.size(); i++) {
417 mTempDisplayStateWorkQueue.get(i).run();
418 }
Jeff Brown5d6443b2015-04-10 20:15:01 -0700419 Trace.traceEnd(Trace.TRACE_TAG_POWER);
Jeff Browne75926d2014-09-18 15:24:49 -0700420 } finally {
421 mTempDisplayStateWorkQueue.clear();
Jeff Brown9e316a12012-10-08 19:17:06 -0700422 }
423 }
424 }
425
Jeff Brown4ccb8232014-01-16 22:16:42 -0800426 private DisplayInfo getDisplayInfoInternal(int displayId, int callingUid) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700427 synchronized (mSyncRoot) {
Jeff Brown4ccb8232014-01-16 22:16:42 -0800428 LogicalDisplay display = mLogicalDisplays.get(displayId);
429 if (display != null) {
430 DisplayInfo info = display.getDisplayInfoLocked();
Andrii Kulianfb1bf692017-01-17 11:17:34 -0800431 if (info.hasAccess(callingUid)
432 || isUidPresentOnDisplayInternal(callingUid, displayId)) {
Jeff Brown4ccb8232014-01-16 22:16:42 -0800433 return info;
434 }
435 }
436 return null;
437 }
438 }
439
440 private int[] getDisplayIdsInternal(int callingUid) {
441 synchronized (mSyncRoot) {
442 final int count = mLogicalDisplays.size();
443 int[] displayIds = new int[count];
444 int n = 0;
445 for (int i = 0; i < count; i++) {
446 LogicalDisplay display = mLogicalDisplays.valueAt(i);
447 DisplayInfo info = display.getDisplayInfoLocked();
448 if (info.hasAccess(callingUid)) {
449 displayIds[n++] = mLogicalDisplays.keyAt(i);
450 }
451 }
452 if (n != count) {
453 displayIds = Arrays.copyOfRange(displayIds, 0, n);
454 }
455 return displayIds;
456 }
457 }
458
459 private void registerCallbackInternal(IDisplayManagerCallback callback, int callingPid) {
460 synchronized (mSyncRoot) {
Jeff Brownbd6e1502012-08-28 03:27:37 -0700461 if (mCallbacks.get(callingPid) != null) {
462 throw new SecurityException("The calling process has already "
463 + "registered an IDisplayManagerCallback.");
Jeff Brown64a55af2012-08-26 02:47:39 -0700464 }
465
Jeff Brownbd6e1502012-08-28 03:27:37 -0700466 CallbackRecord record = new CallbackRecord(callingPid, callback);
467 try {
468 IBinder binder = callback.asBinder();
469 binder.linkToDeath(record, 0);
470 } catch (RemoteException ex) {
471 // give up
472 throw new RuntimeException(ex);
473 }
474
475 mCallbacks.put(callingPid, record);
476 }
477 }
478
Jeff Brownce468a32013-11-21 16:42:03 -0800479 private void onCallbackDied(CallbackRecord record) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700480 synchronized (mSyncRoot) {
Jeff Brownce468a32013-11-21 16:42:03 -0800481 mCallbacks.remove(record.mPid);
482 stopWifiDisplayScanLocked(record);
Jeff Brownbd6e1502012-08-28 03:27:37 -0700483 }
484 }
485
Jeff Brown4ccb8232014-01-16 22:16:42 -0800486 private void startWifiDisplayScanInternal(int callingPid) {
487 synchronized (mSyncRoot) {
488 CallbackRecord record = mCallbacks.get(callingPid);
489 if (record == null) {
490 throw new IllegalStateException("The calling process has not "
491 + "registered an IDisplayManagerCallback.");
Jeff Browne08ae382012-09-07 20:36:36 -0700492 }
Jeff Brown4ccb8232014-01-16 22:16:42 -0800493 startWifiDisplayScanLocked(record);
Jeff Browne08ae382012-09-07 20:36:36 -0700494 }
495 }
496
Jeff Brownce468a32013-11-21 16:42:03 -0800497 private void startWifiDisplayScanLocked(CallbackRecord record) {
498 if (!record.mWifiDisplayScanRequested) {
499 record.mWifiDisplayScanRequested = true;
500 if (mWifiDisplayScanRequestCount++ == 0) {
501 if (mWifiDisplayAdapter != null) {
502 mWifiDisplayAdapter.requestStartScanLocked();
503 }
504 }
505 }
506 }
507
Jeff Brown4ccb8232014-01-16 22:16:42 -0800508 private void stopWifiDisplayScanInternal(int callingPid) {
509 synchronized (mSyncRoot) {
510 CallbackRecord record = mCallbacks.get(callingPid);
511 if (record == null) {
512 throw new IllegalStateException("The calling process has not "
513 + "registered an IDisplayManagerCallback.");
Jeff Brownce468a32013-11-21 16:42:03 -0800514 }
Jeff Brown4ccb8232014-01-16 22:16:42 -0800515 stopWifiDisplayScanLocked(record);
Jeff Brownce468a32013-11-21 16:42:03 -0800516 }
517 }
518
519 private void stopWifiDisplayScanLocked(CallbackRecord record) {
520 if (record.mWifiDisplayScanRequested) {
521 record.mWifiDisplayScanRequested = false;
522 if (--mWifiDisplayScanRequestCount == 0) {
523 if (mWifiDisplayAdapter != null) {
524 mWifiDisplayAdapter.requestStopScanLocked();
525 }
526 } else if (mWifiDisplayScanRequestCount < 0) {
Dianne Hackborn8d051722014-10-01 14:59:58 -0700527 Slog.wtf(TAG, "mWifiDisplayScanRequestCount became negative: "
Jeff Brownce468a32013-11-21 16:42:03 -0800528 + mWifiDisplayScanRequestCount);
529 mWifiDisplayScanRequestCount = 0;
530 }
531 }
532 }
533
Jeff Brown4ccb8232014-01-16 22:16:42 -0800534 private void connectWifiDisplayInternal(String address) {
535 synchronized (mSyncRoot) {
536 if (mWifiDisplayAdapter != null) {
537 mWifiDisplayAdapter.requestConnectLocked(address);
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 pauseWifiDisplayInternal() {
543 synchronized (mSyncRoot) {
544 if (mWifiDisplayAdapter != null) {
545 mWifiDisplayAdapter.requestPauseLocked();
Chong Zhang1f3ecaa2013-05-03 15:55:36 -0700546 }
Chong Zhang1f3ecaa2013-05-03 15:55:36 -0700547 }
548 }
549
Jeff Brown4ccb8232014-01-16 22:16:42 -0800550 private void resumeWifiDisplayInternal() {
551 synchronized (mSyncRoot) {
552 if (mWifiDisplayAdapter != null) {
553 mWifiDisplayAdapter.requestResumeLocked();
Chong Zhang1f3ecaa2013-05-03 15:55:36 -0700554 }
Chong Zhang1f3ecaa2013-05-03 15:55:36 -0700555 }
556 }
557
Jeff Brown4ccb8232014-01-16 22:16:42 -0800558 private void disconnectWifiDisplayInternal() {
559 synchronized (mSyncRoot) {
560 if (mWifiDisplayAdapter != null) {
561 mWifiDisplayAdapter.requestDisconnectLocked();
Jeff Browne08ae382012-09-07 20:36:36 -0700562 }
Jeff Browne08ae382012-09-07 20:36:36 -0700563 }
564 }
565
Jeff Brown4ccb8232014-01-16 22:16:42 -0800566 private void renameWifiDisplayInternal(String address, String alias) {
567 synchronized (mSyncRoot) {
568 if (mWifiDisplayAdapter != null) {
569 mWifiDisplayAdapter.requestRenameLocked(address, alias);
Jeff Brown89d55462012-09-19 11:33:42 -0700570 }
Jeff Brown89d55462012-09-19 11:33:42 -0700571 }
572 }
573
Jeff Brown4ccb8232014-01-16 22:16:42 -0800574 private void forgetWifiDisplayInternal(String address) {
575 synchronized (mSyncRoot) {
576 if (mWifiDisplayAdapter != null) {
577 mWifiDisplayAdapter.requestForgetLocked(address);
Jeff Brown89d55462012-09-19 11:33:42 -0700578 }
Jeff Brown89d55462012-09-19 11:33:42 -0700579 }
580 }
581
Jeff Brown4ccb8232014-01-16 22:16:42 -0800582 private WifiDisplayStatus getWifiDisplayStatusInternal() {
583 synchronized (mSyncRoot) {
584 if (mWifiDisplayAdapter != null) {
585 return mWifiDisplayAdapter.getWifiDisplayStatusLocked();
Jeff Browne08ae382012-09-07 20:36:36 -0700586 }
Jeff Brown4ccb8232014-01-16 22:16:42 -0800587 return new WifiDisplayStatus();
Jeff Browne08ae382012-09-07 20:36:36 -0700588 }
589 }
590
Michael Wright1c9977b2016-07-12 13:30:10 -0700591 private void requestColorModeInternal(int displayId, int colorMode) {
Michael Wright58e829f2015-09-15 00:13:26 +0100592 synchronized (mSyncRoot) {
593 LogicalDisplay display = mLogicalDisplays.get(displayId);
594 if (display != null &&
Michael Wright1c9977b2016-07-12 13:30:10 -0700595 display.getRequestedColorModeLocked() != colorMode) {
596 display.setRequestedColorModeLocked(colorMode);
Michael Wright58e829f2015-09-15 00:13:26 +0100597 scheduleTraversalLocked(false);
598 }
599 }
600 }
601
Michael Wright75ee9fc2014-09-01 19:55:22 -0700602 private int createVirtualDisplayInternal(IVirtualDisplayCallback callback,
Michael Wrightc39d47a2014-07-08 18:07:36 -0700603 IMediaProjection projection, int callingUid, String packageName,
Jeff Brown7d00aff2013-08-02 19:03:49 -0700604 String name, int width, int height, int densityDpi, Surface surface, int flags) {
Jeff Brown4ccb8232014-01-16 22:16:42 -0800605 synchronized (mSyncRoot) {
606 if (mVirtualDisplayAdapter == null) {
607 Slog.w(TAG, "Rejecting request to create private virtual display "
608 + "because the virtual display adapter is not available.");
609 return -1;
Jeff Brown7d00aff2013-08-02 19:03:49 -0700610 }
Jeff Brown4ccb8232014-01-16 22:16:42 -0800611
612 DisplayDevice device = mVirtualDisplayAdapter.createVirtualDisplayLocked(
Michael Wright75ee9fc2014-09-01 19:55:22 -0700613 callback, projection, callingUid, packageName,
Michael Wrightc39d47a2014-07-08 18:07:36 -0700614 name, width, height, densityDpi, surface, flags);
Jeff Brown4ccb8232014-01-16 22:16:42 -0800615 if (device == null) {
616 return -1;
Jeff Brown7d00aff2013-08-02 19:03:49 -0700617 }
Jeff Browna506a6e2013-06-04 00:02:38 -0700618
Jeff Brown4ccb8232014-01-16 22:16:42 -0800619 handleDisplayDeviceAddedLocked(device);
620 LogicalDisplay display = findLogicalDisplayForDeviceLocked(device);
621 if (display != null) {
622 return display.getDisplayIdLocked();
Jeff Browna506a6e2013-06-04 00:02:38 -0700623 }
Jeff Brown4ccb8232014-01-16 22:16:42 -0800624
625 // Something weird happened and the logical display was not created.
626 Slog.w(TAG, "Rejecting request to create virtual display "
627 + "because the logical display was not created.");
Michael Wright75ee9fc2014-09-01 19:55:22 -0700628 mVirtualDisplayAdapter.releaseVirtualDisplayLocked(callback.asBinder());
Jeff Brown4ccb8232014-01-16 22:16:42 -0800629 handleDisplayDeviceRemovedLocked(device);
Jeff Browna506a6e2013-06-04 00:02:38 -0700630 }
631 return -1;
632 }
633
Michael Wright01e840f2014-06-26 16:03:25 -0700634 private void resizeVirtualDisplayInternal(IBinder appToken,
635 int width, int height, int densityDpi) {
636 synchronized (mSyncRoot) {
637 if (mVirtualDisplayAdapter == null) {
638 return;
639 }
640
641 mVirtualDisplayAdapter.resizeVirtualDisplayLocked(appToken, width, height, densityDpi);
642 }
643 }
644
Jeff Brown92207df2014-04-16 13:16:07 -0700645 private void setVirtualDisplaySurfaceInternal(IBinder appToken, Surface surface) {
646 synchronized (mSyncRoot) {
647 if (mVirtualDisplayAdapter == null) {
648 return;
649 }
650
651 mVirtualDisplayAdapter.setVirtualDisplaySurfaceLocked(appToken, surface);
652 }
653 }
654
Jeff Brown4ccb8232014-01-16 22:16:42 -0800655 private void releaseVirtualDisplayInternal(IBinder appToken) {
656 synchronized (mSyncRoot) {
657 if (mVirtualDisplayAdapter == null) {
658 return;
Jeff Browna506a6e2013-06-04 00:02:38 -0700659 }
Jeff Browna506a6e2013-06-04 00:02:38 -0700660
Jeff Brown4ccb8232014-01-16 22:16:42 -0800661 DisplayDevice device =
662 mVirtualDisplayAdapter.releaseVirtualDisplayLocked(appToken);
663 if (device != null) {
664 handleDisplayDeviceRemovedLocked(device);
Jeff Browna506a6e2013-06-04 00:02:38 -0700665 }
666 }
Jeff Browna506a6e2013-06-04 00:02:38 -0700667 }
668
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700669 private void registerDefaultDisplayAdapter() {
670 // Register default display adapter.
671 synchronized (mSyncRoot) {
Mike Lockwoode63f6f72013-11-15 11:01:47 -0800672 registerDisplayAdapterLocked(new LocalDisplayAdapter(
673 mSyncRoot, mContext, mHandler, mDisplayAdapterListener));
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700674 }
675 }
676
677 private void registerAdditionalDisplayAdapters() {
678 synchronized (mSyncRoot) {
679 if (shouldRegisterNonEssentialDisplayAdaptersLocked()) {
Jeff Brown89d55462012-09-19 11:33:42 -0700680 registerOverlayDisplayAdapterLocked();
681 registerWifiDisplayAdapterLocked();
Jeff Browna506a6e2013-06-04 00:02:38 -0700682 registerVirtualDisplayAdapterLocked();
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700683 }
684 }
685 }
686
Jeff Brown89d55462012-09-19 11:33:42 -0700687 private void registerOverlayDisplayAdapterLocked() {
688 registerDisplayAdapterLocked(new OverlayDisplayAdapter(
689 mSyncRoot, mContext, mHandler, mDisplayAdapterListener, mUiHandler));
690 }
691
692 private void registerWifiDisplayAdapterLocked() {
693 if (mContext.getResources().getBoolean(
Jeff Brownbbd28a22012-09-20 16:47:15 -0700694 com.android.internal.R.bool.config_enableWifiDisplay)
695 || SystemProperties.getInt(FORCE_WIFI_DISPLAY_ENABLE, -1) == 1) {
Jeff Brown89d55462012-09-19 11:33:42 -0700696 mWifiDisplayAdapter = new WifiDisplayAdapter(
697 mSyncRoot, mContext, mHandler, mDisplayAdapterListener,
698 mPersistentDataStore);
699 registerDisplayAdapterLocked(mWifiDisplayAdapter);
700 }
701 }
702
Jeff Browna506a6e2013-06-04 00:02:38 -0700703 private void registerVirtualDisplayAdapterLocked() {
704 mVirtualDisplayAdapter = new VirtualDisplayAdapter(
705 mSyncRoot, mContext, mHandler, mDisplayAdapterListener);
706 registerDisplayAdapterLocked(mVirtualDisplayAdapter);
707 }
708
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700709 private boolean shouldRegisterNonEssentialDisplayAdaptersLocked() {
710 // In safe mode, we disable non-essential display adapters to give the user
711 // an opportunity to fix broken settings or other problems that might affect
712 // system stability.
713 // In only-core mode, we disable non-essential display adapters to minimize
714 // the number of dependencies that are started while in this mode and to
715 // prevent problems that might occur due to the device being encrypted.
716 return !mSafeMode && !mOnlyCore;
717 }
718
719 private void registerDisplayAdapterLocked(DisplayAdapter adapter) {
720 mDisplayAdapters.add(adapter);
721 adapter.registerLocked();
722 }
723
Jeff Brownbd6e1502012-08-28 03:27:37 -0700724 private void handleDisplayDeviceAdded(DisplayDevice device) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700725 synchronized (mSyncRoot) {
Jeff Browna506a6e2013-06-04 00:02:38 -0700726 handleDisplayDeviceAddedLocked(device);
Jeff Brownbd6e1502012-08-28 03:27:37 -0700727 }
728 }
729
Jeff Browna506a6e2013-06-04 00:02:38 -0700730 private void handleDisplayDeviceAddedLocked(DisplayDevice device) {
Jeff Brown10acf6d2015-04-14 14:20:47 -0700731 DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
Jeff Browna506a6e2013-06-04 00:02:38 -0700732 if (mDisplayDevices.contains(device)) {
Jeff Brown10acf6d2015-04-14 14:20:47 -0700733 Slog.w(TAG, "Attempted to add already added display device: " + info);
Jeff Browna506a6e2013-06-04 00:02:38 -0700734 return;
735 }
736
Jeff Brown10acf6d2015-04-14 14:20:47 -0700737 Slog.i(TAG, "Display device added: " + info);
738 device.mDebugLastLoggedDeviceInfo = info;
Jeff Browna506a6e2013-06-04 00:02:38 -0700739
740 mDisplayDevices.add(device);
Michael Wright1c9977b2016-07-12 13:30:10 -0700741 LogicalDisplay display = addLogicalDisplayLocked(device);
Jeff Brown0033a862014-10-08 12:06:39 -0700742 Runnable work = updateDisplayStateLocked(device);
743 if (work != null) {
744 work.run();
745 }
Michael Wright1c9977b2016-07-12 13:30:10 -0700746 if (display != null && display.getPrimaryDisplayDeviceLocked() == device) {
747 int colorMode = mPersistentDataStore.getColorMode(device);
Damien Bargiacchi4364bbf2016-11-01 21:44:20 -0700748 if (colorMode == Display.COLOR_MODE_INVALID) {
749 if ((device.getDisplayDeviceInfoLocked().flags
750 & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0) {
751 colorMode = mDefaultDisplayDefaultColorMode;
752 } else {
753 colorMode = Display.COLOR_MODE_DEFAULT;
754 }
755 }
Michael Wright1c9977b2016-07-12 13:30:10 -0700756 display.setRequestedColorModeLocked(colorMode);
757 }
Jeff Browna506a6e2013-06-04 00:02:38 -0700758 scheduleTraversalLocked(false);
759 }
760
Jeff Brownbd6e1502012-08-28 03:27:37 -0700761 private void handleDisplayDeviceChanged(DisplayDevice device) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700762 synchronized (mSyncRoot) {
Jeff Brown10acf6d2015-04-14 14:20:47 -0700763 DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
Jeff Brownbd6e1502012-08-28 03:27:37 -0700764 if (!mDisplayDevices.contains(device)) {
Jeff Brown10acf6d2015-04-14 14:20:47 -0700765 Slog.w(TAG, "Attempted to change non-existent display device: " + info);
Jeff Brownbd6e1502012-08-28 03:27:37 -0700766 return;
767 }
768
Jeff Brown10acf6d2015-04-14 14:20:47 -0700769 int diff = device.mDebugLastLoggedDeviceInfo.diff(info);
770 if (diff == DisplayDeviceInfo.DIFF_STATE) {
771 Slog.i(TAG, "Display device changed state: \"" + info.name
772 + "\", " + Display.stateToString(info.state));
773 } else if (diff != 0) {
774 Slog.i(TAG, "Display device changed: " + info);
775 }
Michael Wright1c9977b2016-07-12 13:30:10 -0700776 if ((diff & DisplayDeviceInfo.DIFF_COLOR_MODE) != 0) {
777 try {
778 mPersistentDataStore.setColorMode(device, info.colorMode);
779 } finally {
780 mPersistentDataStore.saveIfNeeded();
781 }
782 }
Jeff Brown10acf6d2015-04-14 14:20:47 -0700783 device.mDebugLastLoggedDeviceInfo = info;
Jeff Browne87bf032012-09-20 18:30:13 -0700784
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700785 device.applyPendingDisplayDeviceInfoChangesLocked();
786 if (updateLogicalDisplaysLocked()) {
Craig Mautner65d11b32012-10-01 13:59:52 -0700787 scheduleTraversalLocked(false);
Jeff Brown64a55af2012-08-26 02:47:39 -0700788 }
789 }
790 }
791
Jeff Brownbd6e1502012-08-28 03:27:37 -0700792 private void handleDisplayDeviceRemoved(DisplayDevice device) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700793 synchronized (mSyncRoot) {
Jeff Browna506a6e2013-06-04 00:02:38 -0700794 handleDisplayDeviceRemovedLocked(device);
795 }
796 }
Jeff Brown8e5d33e2015-06-10 13:05:50 -0700797
Jeff Browna506a6e2013-06-04 00:02:38 -0700798 private void handleDisplayDeviceRemovedLocked(DisplayDevice device) {
Jeff Brown10acf6d2015-04-14 14:20:47 -0700799 DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
Jeff Browna506a6e2013-06-04 00:02:38 -0700800 if (!mDisplayDevices.remove(device)) {
Jeff Brown10acf6d2015-04-14 14:20:47 -0700801 Slog.w(TAG, "Attempted to remove non-existent display device: " + info);
Jeff Browna506a6e2013-06-04 00:02:38 -0700802 return;
803 }
804
Jeff Brown10acf6d2015-04-14 14:20:47 -0700805 Slog.i(TAG, "Display device removed: " + info);
806 device.mDebugLastLoggedDeviceInfo = info;
Jeff Browna506a6e2013-06-04 00:02:38 -0700807
Jeff Browna506a6e2013-06-04 00:02:38 -0700808 updateLogicalDisplaysLocked();
809 scheduleTraversalLocked(false);
810 }
811
Jeff Brown8e5d33e2015-06-10 13:05:50 -0700812 private void applyGlobalDisplayStateLocked(List<Runnable> workQueue) {
Jeff Browna506a6e2013-06-04 00:02:38 -0700813 final int count = mDisplayDevices.size();
814 for (int i = 0; i < count; i++) {
815 DisplayDevice device = mDisplayDevices.get(i);
Jeff Browne75926d2014-09-18 15:24:49 -0700816 Runnable runnable = updateDisplayStateLocked(device);
817 if (runnable != null) {
818 workQueue.add(runnable);
819 }
Jeff Browna506a6e2013-06-04 00:02:38 -0700820 }
821 }
822
Jeff Browne75926d2014-09-18 15:24:49 -0700823 private Runnable updateDisplayStateLocked(DisplayDevice device) {
Jeff Browna506a6e2013-06-04 00:02:38 -0700824 // Blank or unblank the display immediately to match the state requested
Jeff Brown037c33e2014-04-09 00:31:55 -0700825 // by the display power controller (if known).
Jeff Browna506a6e2013-06-04 00:02:38 -0700826 DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
827 if ((info.flags & DisplayDeviceInfo.FLAG_NEVER_BLANK) == 0) {
Jeff Brown5d6443b2015-04-10 20:15:01 -0700828 return device.requestDisplayStateLocked(mGlobalDisplayState, mGlobalDisplayBrightness);
Craig Mautner4f67ba62012-08-02 11:23:00 -0700829 }
Jeff Browne75926d2014-09-18 15:24:49 -0700830 return null;
Craig Mautner4f67ba62012-08-02 11:23:00 -0700831 }
832
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700833 // Adds a new logical display based on the given display device.
834 // Sends notifications if needed.
Michael Wright1c9977b2016-07-12 13:30:10 -0700835 private LogicalDisplay addLogicalDisplayLocked(DisplayDevice device) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700836 DisplayDeviceInfo deviceInfo = device.getDisplayDeviceInfoLocked();
837 boolean isDefault = (deviceInfo.flags
838 & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0;
839 if (isDefault && mLogicalDisplays.get(Display.DEFAULT_DISPLAY) != null) {
840 Slog.w(TAG, "Ignoring attempt to add a second default display: " + deviceInfo);
841 isDefault = false;
842 }
843
Jeff Brown27f1d672012-10-17 18:32:34 -0700844 if (!isDefault && mSingleDisplayDemoMode) {
845 Slog.i(TAG, "Not creating a logical display for a secondary display "
846 + " because single display demo mode is enabled: " + deviceInfo);
Michael Wright1c9977b2016-07-12 13:30:10 -0700847 return null;
Jeff Brown27f1d672012-10-17 18:32:34 -0700848 }
849
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700850 final int displayId = assignDisplayIdLocked(isDefault);
851 final int layerStack = assignLayerStackLocked(displayId);
852
Jeff Brownd728bf52012-09-08 18:05:28 -0700853 LogicalDisplay display = new LogicalDisplay(displayId, layerStack, device);
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700854 display.updateLocked(mDisplayDevices);
855 if (!display.isValidLocked()) {
856 // This should never happen currently.
857 Slog.w(TAG, "Ignoring display device because the logical display "
858 + "created from it was not considered valid: " + deviceInfo);
Michael Wright1c9977b2016-07-12 13:30:10 -0700859 return null;
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700860 }
861
862 mLogicalDisplays.put(displayId, display);
863
864 // Wake up waitForDefaultDisplay.
865 if (isDefault) {
866 mSyncRoot.notifyAll();
867 }
868
869 sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_ADDED);
Michael Wright1c9977b2016-07-12 13:30:10 -0700870 return display;
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700871 }
872
873 private int assignDisplayIdLocked(boolean isDefault) {
874 return isDefault ? Display.DEFAULT_DISPLAY : mNextNonDefaultDisplayId++;
875 }
876
877 private int assignLayerStackLocked(int displayId) {
878 // Currently layer stacks and display ids are the same.
879 // This need not be the case.
880 return displayId;
881 }
882
883 // Updates all existing logical displays given the current set of display devices.
884 // Removes invalid logical displays.
885 // Sends notifications if needed.
886 private boolean updateLogicalDisplaysLocked() {
887 boolean changed = false;
888 for (int i = mLogicalDisplays.size(); i-- > 0; ) {
889 final int displayId = mLogicalDisplays.keyAt(i);
890 LogicalDisplay display = mLogicalDisplays.valueAt(i);
891
892 mTempDisplayInfo.copyFrom(display.getDisplayInfoLocked());
893 display.updateLocked(mDisplayDevices);
894 if (!display.isValidLocked()) {
895 mLogicalDisplays.removeAt(i);
896 sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_REMOVED);
897 changed = true;
898 } else if (!mTempDisplayInfo.equals(display.getDisplayInfoLocked())) {
899 sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED);
900 changed = true;
901 }
902 }
903 return changed;
904 }
905
906 private void performTraversalInTransactionLocked() {
Jeff Brownd728bf52012-09-08 18:05:28 -0700907 // Clear all viewports before configuring displays so that we can keep
908 // track of which ones we have configured.
909 clearViewportsLocked();
910
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700911 // Configure each display device.
912 final int count = mDisplayDevices.size();
913 for (int i = 0; i < count; i++) {
914 DisplayDevice device = mDisplayDevices.get(i);
915 configureDisplayInTransactionLocked(device);
916 device.performTraversalInTransactionLocked();
917 }
Jeff Brownd728bf52012-09-08 18:05:28 -0700918
919 // Tell the input system about these new viewports.
Jeff Brown4ccb8232014-01-16 22:16:42 -0800920 if (mInputManagerInternal != null) {
Jeff Brownd728bf52012-09-08 18:05:28 -0700921 mHandler.sendEmptyMessage(MSG_UPDATE_VIEWPORT);
922 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700923 }
924
Michael Wright3f145a22014-07-22 19:46:03 -0700925 private void setDisplayPropertiesInternal(int displayId, boolean hasContent,
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700926 float requestedRefreshRate, int requestedModeId, boolean inTraversal) {
Craig Mautner722285e2012-09-07 13:55:58 -0700927 synchronized (mSyncRoot) {
928 LogicalDisplay display = mLogicalDisplays.get(displayId);
Michael Wright3f145a22014-07-22 19:46:03 -0700929 if (display == null) {
930 return;
931 }
932 if (display.hasContentLocked() != hasContent) {
Jeff Brown33041bd2013-08-02 21:11:14 -0700933 if (DEBUG) {
934 Slog.d(TAG, "Display " + displayId + " hasContent flag changed: "
935 + "hasContent=" + hasContent + ", inTraversal=" + inTraversal);
936 }
937
Craig Mautner722285e2012-09-07 13:55:58 -0700938 display.setHasContentLocked(hasContent);
Craig Mautner65d11b32012-10-01 13:59:52 -0700939 scheduleTraversalLocked(inTraversal);
Craig Mautner722285e2012-09-07 13:55:58 -0700940 }
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700941 if (requestedModeId == 0 && requestedRefreshRate != 0) {
942 // Scan supported modes returned by display.getInfo() to find a mode with the same
943 // size as the default display mode but with the specified refresh rate instead.
944 requestedModeId = display.getDisplayInfoLocked().findDefaultModeByRefreshRate(
945 requestedRefreshRate);
946 }
947 if (display.getRequestedModeIdLocked() != requestedModeId) {
Michael Wright3f145a22014-07-22 19:46:03 -0700948 if (DEBUG) {
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700949 Slog.d(TAG, "Display " + displayId + " switching to mode " + requestedModeId);
Michael Wright3f145a22014-07-22 19:46:03 -0700950 }
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -0700951 display.setRequestedModeIdLocked(requestedModeId);
Michael Wright3f145a22014-07-22 19:46:03 -0700952 scheduleTraversalLocked(inTraversal);
953 }
Craig Mautner722285e2012-09-07 13:55:58 -0700954 }
Jeff Brownd728bf52012-09-08 18:05:28 -0700955 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -0700956
Filip Gruszczynskid2e86402015-02-19 13:05:03 -0800957 private void setDisplayOffsetsInternal(int displayId, int x, int y) {
958 synchronized (mSyncRoot) {
959 LogicalDisplay display = mLogicalDisplays.get(displayId);
960 if (display == null) {
961 return;
962 }
963 if (display.getDisplayOffsetXLocked() != x
964 || display.getDisplayOffsetYLocked() != y) {
965 if (DEBUG) {
966 Slog.d(TAG, "Display " + displayId + " burn-in offset set to ("
967 + x + ", " + y + ")");
968 }
969 display.setDisplayOffsetsLocked(x, y);
970 scheduleTraversalLocked(false);
971 }
972 }
973 }
974
Andrii Kulianfb1bf692017-01-17 11:17:34 -0800975 // Updates the lists of UIDs that are present on displays.
976 private void setDisplayAccessUIDsInternal(SparseArray<IntArray> newDisplayAccessUIDs) {
977 synchronized (mSyncRoot) {
978 mDisplayAccessUIDs.clear();
979 for (int i = newDisplayAccessUIDs.size() - 1; i >= 0; i--) {
980 mDisplayAccessUIDs.append(newDisplayAccessUIDs.keyAt(i),
981 newDisplayAccessUIDs.valueAt(i));
982 }
983 }
984 }
985
986 // Checks if provided UID's content is present on the display and UID has access to it.
987 private boolean isUidPresentOnDisplayInternal(int uid, int displayId) {
988 synchronized (mSyncRoot) {
989 final IntArray displayUIDs = mDisplayAccessUIDs.get(displayId);
990 return displayUIDs != null && displayUIDs.indexOf(uid) != -1;
991 }
992 }
993
Jeff Brownd728bf52012-09-08 18:05:28 -0700994 private void clearViewportsLocked() {
995 mDefaultViewport.valid = false;
996 mExternalTouchViewport.valid = false;
Craig Mautner722285e2012-09-07 13:55:58 -0700997 }
998
999 private void configureDisplayInTransactionLocked(DisplayDevice device) {
Jeff Brownd14c8c92014-01-07 18:13:09 -08001000 final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked();
1001 final boolean ownContent = (info.flags & DisplayDeviceInfo.FLAG_OWN_CONTENT_ONLY) != 0;
Jeff Browna506a6e2013-06-04 00:02:38 -07001002
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001003 // Find the logical display that the display device is showing.
Jeff Brownd14c8c92014-01-07 18:13:09 -08001004 // Certain displays only ever show their own content.
Craig Mautner722285e2012-09-07 13:55:58 -07001005 LogicalDisplay display = findLogicalDisplayForDeviceLocked(device);
Jeff Brownd14c8c92014-01-07 18:13:09 -08001006 if (!ownContent) {
Jeff Browna506a6e2013-06-04 00:02:38 -07001007 if (display != null && !display.hasContentLocked()) {
1008 // If the display does not have any content of its own, then
1009 // automatically mirror the default logical display contents.
1010 display = null;
1011 }
1012 if (display == null) {
1013 display = mLogicalDisplays.get(Display.DEFAULT_DISPLAY);
1014 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001015 }
1016
1017 // Apply the logical display configuration to the display device.
1018 if (display == null) {
1019 // TODO: no logical display for the device, blank it
Jeff Brownd728bf52012-09-08 18:05:28 -07001020 Slog.w(TAG, "Missing logical display to use for physical display device: "
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001021 + device.getDisplayDeviceInfoLocked());
Jeff Brownd728bf52012-09-08 18:05:28 -07001022 return;
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001023 }
Jeff Brown037c33e2014-04-09 00:31:55 -07001024 display.configureDisplayInTransactionLocked(device, info.state == Display.STATE_OFF);
Jeff Brownd728bf52012-09-08 18:05:28 -07001025
1026 // Update the viewports if needed.
Jeff Brownd728bf52012-09-08 18:05:28 -07001027 if (!mDefaultViewport.valid
1028 && (info.flags & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0) {
1029 setViewportLocked(mDefaultViewport, display, device);
1030 }
1031 if (!mExternalTouchViewport.valid
1032 && info.touch == DisplayDeviceInfo.TOUCH_EXTERNAL) {
1033 setViewportLocked(mExternalTouchViewport, display, device);
1034 }
1035 }
1036
1037 private static void setViewportLocked(DisplayViewport viewport,
1038 LogicalDisplay display, DisplayDevice device) {
1039 viewport.valid = true;
1040 viewport.displayId = display.getDisplayIdLocked();
1041 device.populateViewportLocked(viewport);
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001042 }
1043
1044 private LogicalDisplay findLogicalDisplayForDeviceLocked(DisplayDevice device) {
1045 final int count = mLogicalDisplays.size();
1046 for (int i = 0; i < count; i++) {
1047 LogicalDisplay display = mLogicalDisplays.valueAt(i);
1048 if (display.getPrimaryDisplayDeviceLocked() == device) {
1049 return display;
1050 }
1051 }
1052 return null;
1053 }
1054
Jeff Brownbd6e1502012-08-28 03:27:37 -07001055 private void sendDisplayEventLocked(int displayId, int event) {
1056 Message msg = mHandler.obtainMessage(MSG_DELIVER_DISPLAY_EVENT, displayId, event);
1057 mHandler.sendMessage(msg);
1058 }
1059
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001060 // Requests that performTraversalsInTransactionFromWindowManager be called at a
1061 // later time to apply changes to surfaces and displays.
Craig Mautner65d11b32012-10-01 13:59:52 -07001062 private void scheduleTraversalLocked(boolean inTraversal) {
Jeff Brown4ccb8232014-01-16 22:16:42 -08001063 if (!mPendingTraversal && mWindowManagerInternal != null) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001064 mPendingTraversal = true;
Craig Mautner65d11b32012-10-01 13:59:52 -07001065 if (!inTraversal) {
1066 mHandler.sendEmptyMessage(MSG_REQUEST_TRAVERSAL);
1067 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001068 }
1069 }
1070
1071 // Runs on Handler thread.
1072 // Delivers display event notifications to callbacks.
Jeff Brownbd6e1502012-08-28 03:27:37 -07001073 private void deliverDisplayEvent(int displayId, int event) {
1074 if (DEBUG) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001075 Slog.d(TAG, "Delivering display event: displayId="
1076 + displayId + ", event=" + event);
Jeff Brownfa25bf52012-07-23 19:26:30 -07001077 }
Jeff Brownfa25bf52012-07-23 19:26:30 -07001078
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001079 // Grab the lock and copy the callbacks.
Jeff Brownbd6e1502012-08-28 03:27:37 -07001080 final int count;
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001081 synchronized (mSyncRoot) {
Jeff Brownbd6e1502012-08-28 03:27:37 -07001082 count = mCallbacks.size();
1083 mTempCallbacks.clear();
1084 for (int i = 0; i < count; i++) {
1085 mTempCallbacks.add(mCallbacks.valueAt(i));
Craig Mautner4f67ba62012-08-02 11:23:00 -07001086 }
Jeff Brownbd6e1502012-08-28 03:27:37 -07001087 }
Craig Mautner4f67ba62012-08-02 11:23:00 -07001088
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001089 // After releasing the lock, send the notifications out.
Jeff Brownbd6e1502012-08-28 03:27:37 -07001090 for (int i = 0; i < count; i++) {
1091 mTempCallbacks.get(i).notifyDisplayEventAsync(displayId, event);
1092 }
1093 mTempCallbacks.clear();
Craig Mautner4f67ba62012-08-02 11:23:00 -07001094 }
1095
Michael Wrightc39d47a2014-07-08 18:07:36 -07001096 private IMediaProjectionManager getProjectionService() {
1097 if (mProjectionService == null) {
1098 IBinder b = ServiceManager.getService(Context.MEDIA_PROJECTION_SERVICE);
1099 mProjectionService = IMediaProjectionManager.Stub.asInterface(b);
1100 }
1101 return mProjectionService;
1102 }
1103
Jeff Brown4ccb8232014-01-16 22:16:42 -08001104 private void dumpInternal(PrintWriter pw) {
Jeff Brownbd6e1502012-08-28 03:27:37 -07001105 pw.println("DISPLAY MANAGER (dumpsys display)");
Jeff Brownfa25bf52012-07-23 19:26:30 -07001106
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001107 synchronized (mSyncRoot) {
Jeff Brown9e316a12012-10-08 19:17:06 -07001108 pw.println(" mOnlyCode=" + mOnlyCore);
1109 pw.println(" mSafeMode=" + mSafeMode);
1110 pw.println(" mPendingTraversal=" + mPendingTraversal);
Jeff Brown037c33e2014-04-09 00:31:55 -07001111 pw.println(" mGlobalDisplayState=" + Display.stateToString(mGlobalDisplayState));
Jeff Brown9e316a12012-10-08 19:17:06 -07001112 pw.println(" mNextNonDefaultDisplayId=" + mNextNonDefaultDisplayId);
1113 pw.println(" mDefaultViewport=" + mDefaultViewport);
1114 pw.println(" mExternalTouchViewport=" + mExternalTouchViewport);
Damien Bargiacchi4364bbf2016-11-01 21:44:20 -07001115 pw.println(" mDefaultDisplayDefaultColorMode=" + mDefaultDisplayDefaultColorMode);
Jeff Brown27f1d672012-10-17 18:32:34 -07001116 pw.println(" mSingleDisplayDemoMode=" + mSingleDisplayDemoMode);
Jeff Brownce468a32013-11-21 16:42:03 -08001117 pw.println(" mWifiDisplayScanRequestCount=" + mWifiDisplayScanRequestCount);
Jeff Brown9e316a12012-10-08 19:17:06 -07001118
Jeff Brownbd6e1502012-08-28 03:27:37 -07001119 IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ");
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001120 ipw.increaseIndent();
Jeff Brownbd6e1502012-08-28 03:27:37 -07001121
1122 pw.println();
1123 pw.println("Display Adapters: size=" + mDisplayAdapters.size());
Jeff Brown848c2dc2012-08-19 20:18:08 -07001124 for (DisplayAdapter adapter : mDisplayAdapters) {
Jeff Brownbd6e1502012-08-28 03:27:37 -07001125 pw.println(" " + adapter.getName());
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001126 adapter.dumpLocked(ipw);
Jeff Brown848c2dc2012-08-19 20:18:08 -07001127 }
Craig Mautner9de49362012-08-02 14:30:30 -07001128
Jeff Brownbd6e1502012-08-28 03:27:37 -07001129 pw.println();
1130 pw.println("Display Devices: size=" + mDisplayDevices.size());
1131 for (DisplayDevice device : mDisplayDevices) {
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001132 pw.println(" " + device.getDisplayDeviceInfoLocked());
1133 device.dumpLocked(ipw);
Jeff Brownbd6e1502012-08-28 03:27:37 -07001134 }
1135
1136 final int logicalDisplayCount = mLogicalDisplays.size();
1137 pw.println();
1138 pw.println("Logical Displays: size=" + logicalDisplayCount);
1139 for (int i = 0; i < logicalDisplayCount; i++) {
1140 int displayId = mLogicalDisplays.keyAt(i);
1141 LogicalDisplay display = mLogicalDisplays.valueAt(i);
1142 pw.println(" Display " + displayId + ":");
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001143 display.dumpLocked(ipw);
Jeff Brownbd6e1502012-08-28 03:27:37 -07001144 }
Jeff Brownce468a32013-11-21 16:42:03 -08001145
1146 final int callbackCount = mCallbacks.size();
1147 pw.println();
1148 pw.println("Callbacks: size=" + callbackCount);
1149 for (int i = 0; i < callbackCount; i++) {
1150 CallbackRecord callback = mCallbacks.valueAt(i);
1151 pw.println(" " + i + ": mPid=" + callback.mPid
1152 + ", mWifiDisplayScanRequested=" + callback.mWifiDisplayScanRequested);
1153 }
Jeff Brownad9ef192014-04-08 17:26:30 -07001154
1155 if (mDisplayPowerController != null) {
1156 mDisplayPowerController.dump(pw);
1157 }
Michael Wright1c9977b2016-07-12 13:30:10 -07001158
1159 pw.println();
1160 mPersistentDataStore.dump(pw);
Jeff Brownbd6e1502012-08-28 03:27:37 -07001161 }
1162 }
1163
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001164 /**
1165 * This is the object that everything in the display manager locks on.
1166 * We make it an inner class within the {@link DisplayManagerService} to so that it is
1167 * clear that the object belongs to the display manager service and that it is
1168 * a unique object with a special purpose.
1169 */
1170 public static final class SyncRoot {
1171 }
1172
Jeff Brownbd6e1502012-08-28 03:27:37 -07001173 private final class DisplayManagerHandler extends Handler {
1174 public DisplayManagerHandler(Looper looper) {
1175 super(looper, null, true /*async*/);
Jeff Brown848c2dc2012-08-19 20:18:08 -07001176 }
Jeff Brownbf5740e2012-08-19 23:20:02 -07001177
Jeff Brownbd6e1502012-08-28 03:27:37 -07001178 @Override
1179 public void handleMessage(Message msg) {
1180 switch (msg.what) {
1181 case MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER:
1182 registerDefaultDisplayAdapter();
1183 break;
1184
1185 case MSG_REGISTER_ADDITIONAL_DISPLAY_ADAPTERS:
1186 registerAdditionalDisplayAdapters();
1187 break;
1188
1189 case MSG_DELIVER_DISPLAY_EVENT:
1190 deliverDisplayEvent(msg.arg1, msg.arg2);
1191 break;
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001192
1193 case MSG_REQUEST_TRAVERSAL:
Jeff Brown4ccb8232014-01-16 22:16:42 -08001194 mWindowManagerInternal.requestTraversalFromDisplayManager();
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001195 break;
Jeff Brownd728bf52012-09-08 18:05:28 -07001196
1197 case MSG_UPDATE_VIEWPORT: {
1198 synchronized (mSyncRoot) {
1199 mTempDefaultViewport.copyFrom(mDefaultViewport);
1200 mTempExternalTouchViewport.copyFrom(mExternalTouchViewport);
1201 }
Jeff Brown4ccb8232014-01-16 22:16:42 -08001202 mInputManagerInternal.setDisplayViewports(
Jeff Brownd728bf52012-09-08 18:05:28 -07001203 mTempDefaultViewport, mTempExternalTouchViewport);
1204 break;
1205 }
Jeff Brownbd6e1502012-08-28 03:27:37 -07001206 }
1207 }
1208 }
1209
1210 private final class DisplayAdapterListener implements DisplayAdapter.Listener {
1211 @Override
1212 public void onDisplayDeviceEvent(DisplayDevice device, int event) {
1213 switch (event) {
1214 case DisplayAdapter.DISPLAY_DEVICE_EVENT_ADDED:
1215 handleDisplayDeviceAdded(device);
1216 break;
1217
1218 case DisplayAdapter.DISPLAY_DEVICE_EVENT_CHANGED:
1219 handleDisplayDeviceChanged(device);
1220 break;
1221
1222 case DisplayAdapter.DISPLAY_DEVICE_EVENT_REMOVED:
1223 handleDisplayDeviceRemoved(device);
1224 break;
1225 }
1226 }
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001227
1228 @Override
1229 public void onTraversalRequested() {
1230 synchronized (mSyncRoot) {
Craig Mautner65d11b32012-10-01 13:59:52 -07001231 scheduleTraversalLocked(false);
Jeff Brown4ed8fe72012-08-30 18:18:29 -07001232 }
1233 }
Jeff Brownbd6e1502012-08-28 03:27:37 -07001234 }
1235
1236 private final class CallbackRecord implements DeathRecipient {
Jeff Brownce468a32013-11-21 16:42:03 -08001237 public final int mPid;
Jeff Brownbd6e1502012-08-28 03:27:37 -07001238 private final IDisplayManagerCallback mCallback;
1239
Jeff Brownce468a32013-11-21 16:42:03 -08001240 public boolean mWifiDisplayScanRequested;
1241
Jeff Brownbd6e1502012-08-28 03:27:37 -07001242 public CallbackRecord(int pid, IDisplayManagerCallback callback) {
1243 mPid = pid;
1244 mCallback = callback;
1245 }
1246
1247 @Override
1248 public void binderDied() {
1249 if (DEBUG) {
1250 Slog.d(TAG, "Display listener for pid " + mPid + " died.");
1251 }
Jeff Brownce468a32013-11-21 16:42:03 -08001252 onCallbackDied(this);
Jeff Brownbd6e1502012-08-28 03:27:37 -07001253 }
1254
1255 public void notifyDisplayEventAsync(int displayId, int event) {
1256 try {
1257 mCallback.onDisplayEvent(displayId, event);
1258 } catch (RemoteException ex) {
1259 Slog.w(TAG, "Failed to notify process "
1260 + mPid + " that displays changed, assuming it died.", ex);
1261 binderDied();
1262 }
1263 }
1264 }
Jeff Brown4ccb8232014-01-16 22:16:42 -08001265
1266 private final class BinderService extends IDisplayManager.Stub {
1267 /**
1268 * Returns information about the specified logical display.
1269 *
1270 * @param displayId The logical display id.
1271 * @return The logical display info, or null if the display does not exist. The
1272 * returned object must be treated as immutable.
1273 */
1274 @Override // Binder call
1275 public DisplayInfo getDisplayInfo(int displayId) {
1276 final int callingUid = Binder.getCallingUid();
1277 final long token = Binder.clearCallingIdentity();
1278 try {
1279 return getDisplayInfoInternal(displayId, callingUid);
1280 } finally {
1281 Binder.restoreCallingIdentity(token);
1282 }
1283 }
1284
1285 /**
1286 * Returns the list of all display ids.
1287 */
1288 @Override // Binder call
1289 public int[] getDisplayIds() {
1290 final int callingUid = Binder.getCallingUid();
1291 final long token = Binder.clearCallingIdentity();
1292 try {
1293 return getDisplayIdsInternal(callingUid);
1294 } finally {
1295 Binder.restoreCallingIdentity(token);
1296 }
1297 }
1298
1299 @Override // Binder call
1300 public void registerCallback(IDisplayManagerCallback callback) {
1301 if (callback == null) {
1302 throw new IllegalArgumentException("listener must not be null");
1303 }
1304
1305 final int callingPid = Binder.getCallingPid();
1306 final long token = Binder.clearCallingIdentity();
1307 try {
1308 registerCallbackInternal(callback, callingPid);
1309 } finally {
1310 Binder.restoreCallingIdentity(token);
1311 }
1312 }
1313
1314 @Override // Binder call
1315 public void startWifiDisplayScan() {
1316 mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY,
1317 "Permission required to start wifi display scans");
1318
1319 final int callingPid = Binder.getCallingPid();
1320 final long token = Binder.clearCallingIdentity();
1321 try {
1322 startWifiDisplayScanInternal(callingPid);
1323 } finally {
1324 Binder.restoreCallingIdentity(token);
1325 }
1326 }
1327
1328 @Override // Binder call
1329 public void stopWifiDisplayScan() {
1330 mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY,
1331 "Permission required to stop wifi display scans");
1332
1333 final int callingPid = Binder.getCallingPid();
1334 final long token = Binder.clearCallingIdentity();
1335 try {
1336 stopWifiDisplayScanInternal(callingPid);
1337 } finally {
1338 Binder.restoreCallingIdentity(token);
1339 }
1340 }
1341
1342 @Override // Binder call
1343 public void connectWifiDisplay(String address) {
1344 if (address == null) {
1345 throw new IllegalArgumentException("address must not be null");
1346 }
1347 mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY,
1348 "Permission required to connect to a wifi display");
1349
1350 final long token = Binder.clearCallingIdentity();
1351 try {
1352 connectWifiDisplayInternal(address);
1353 } finally {
1354 Binder.restoreCallingIdentity(token);
1355 }
1356 }
1357
1358 @Override // Binder call
1359 public void disconnectWifiDisplay() {
1360 // This request does not require special permissions.
1361 // Any app can request disconnection from the currently active wifi display.
1362 // This exception should no longer be needed once wifi display control moves
1363 // to the media router service.
1364
1365 final long token = Binder.clearCallingIdentity();
1366 try {
1367 disconnectWifiDisplayInternal();
1368 } finally {
1369 Binder.restoreCallingIdentity(token);
1370 }
1371 }
1372
1373 @Override // Binder call
1374 public void renameWifiDisplay(String address, String alias) {
1375 if (address == null) {
1376 throw new IllegalArgumentException("address must not be null");
1377 }
1378 mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY,
1379 "Permission required to rename to a wifi display");
1380
1381 final long token = Binder.clearCallingIdentity();
1382 try {
1383 renameWifiDisplayInternal(address, alias);
1384 } finally {
1385 Binder.restoreCallingIdentity(token);
1386 }
1387 }
1388
1389 @Override // Binder call
1390 public void forgetWifiDisplay(String address) {
1391 if (address == null) {
1392 throw new IllegalArgumentException("address must not be null");
1393 }
1394 mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY,
1395 "Permission required to forget to a wifi display");
1396
1397 final long token = Binder.clearCallingIdentity();
1398 try {
1399 forgetWifiDisplayInternal(address);
1400 } finally {
1401 Binder.restoreCallingIdentity(token);
1402 }
1403 }
1404
1405 @Override // Binder call
1406 public void pauseWifiDisplay() {
1407 mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY,
1408 "Permission required to pause a wifi display session");
1409
1410 final long token = Binder.clearCallingIdentity();
1411 try {
1412 pauseWifiDisplayInternal();
1413 } finally {
1414 Binder.restoreCallingIdentity(token);
1415 }
1416 }
1417
1418 @Override // Binder call
1419 public void resumeWifiDisplay() {
1420 mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY,
1421 "Permission required to resume a wifi display session");
1422
1423 final long token = Binder.clearCallingIdentity();
1424 try {
1425 resumeWifiDisplayInternal();
1426 } finally {
1427 Binder.restoreCallingIdentity(token);
1428 }
1429 }
1430
1431 @Override // Binder call
1432 public WifiDisplayStatus getWifiDisplayStatus() {
1433 // This request does not require special permissions.
1434 // Any app can get information about available wifi displays.
1435
1436 final long token = Binder.clearCallingIdentity();
1437 try {
1438 return getWifiDisplayStatusInternal();
1439 } finally {
1440 Binder.restoreCallingIdentity(token);
1441 }
1442 }
1443
1444 @Override // Binder call
Michael Wright1c9977b2016-07-12 13:30:10 -07001445 public void requestColorMode(int displayId, int colorMode) {
Michael Wright58e829f2015-09-15 00:13:26 +01001446 mContext.enforceCallingOrSelfPermission(
Michael Wright1c9977b2016-07-12 13:30:10 -07001447 Manifest.permission.CONFIGURE_DISPLAY_COLOR_MODE,
1448 "Permission required to change the display color mode");
Michael Wright58e829f2015-09-15 00:13:26 +01001449 final long token = Binder.clearCallingIdentity();
1450 try {
Michael Wright1c9977b2016-07-12 13:30:10 -07001451 requestColorModeInternal(displayId, colorMode);
Michael Wright58e829f2015-09-15 00:13:26 +01001452 } finally {
1453 Binder.restoreCallingIdentity(token);
1454 }
1455 }
1456
1457 @Override // Binder call
Michael Wright75ee9fc2014-09-01 19:55:22 -07001458 public int createVirtualDisplay(IVirtualDisplayCallback callback,
Michael Wrightc39d47a2014-07-08 18:07:36 -07001459 IMediaProjection projection, String packageName, String name,
1460 int width, int height, int densityDpi, Surface surface, int flags) {
Jeff Brown4ccb8232014-01-16 22:16:42 -08001461 final int callingUid = Binder.getCallingUid();
1462 if (!validatePackageName(callingUid, packageName)) {
1463 throw new SecurityException("packageName must match the calling uid");
1464 }
Michael Wright75ee9fc2014-09-01 19:55:22 -07001465 if (callback == null) {
Jeff Brown4ccb8232014-01-16 22:16:42 -08001466 throw new IllegalArgumentException("appToken must not be null");
1467 }
1468 if (TextUtils.isEmpty(name)) {
1469 throw new IllegalArgumentException("name must be non-null and non-empty");
1470 }
1471 if (width <= 0 || height <= 0 || densityDpi <= 0) {
1472 throw new IllegalArgumentException("width, height, and densityDpi must be "
1473 + "greater than 0");
1474 }
Pablo Ceballoseb3370d2016-08-31 15:00:17 -07001475 if (surface != null && surface.isSingleBuffered()) {
Pablo Ceballosaff2f942016-07-29 14:49:55 -07001476 throw new IllegalArgumentException("Surface can't be single-buffered");
1477 }
Michael Wrightc39d47a2014-07-08 18:07:36 -07001478
Andrii Kulianfc8f82b2017-01-26 13:17:27 -08001479 if ((flags & VIRTUAL_DISPLAY_FLAG_PUBLIC) != 0) {
1480 flags |= VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;
1481
1482 // Public displays can't be allowed to show content when locked.
Andrii Kulian7211d2e2017-01-27 15:58:05 -08001483 if ((flags & VIRTUAL_DISPLAY_FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD) != 0) {
Andrii Kulianfc8f82b2017-01-26 13:17:27 -08001484 throw new IllegalArgumentException(
1485 "Public display must not be marked as SHOW_WHEN_LOCKED_INSECURE");
1486 }
Michael Wright6720be42014-07-29 19:14:16 -07001487 }
Andrii Kulianfc8f82b2017-01-26 13:17:27 -08001488 if ((flags & VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY) != 0) {
1489 flags &= ~VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;
Michael Wright6720be42014-07-29 19:14:16 -07001490 }
1491
Michael Wrightc39d47a2014-07-08 18:07:36 -07001492 if (projection != null) {
1493 try {
1494 if (!getProjectionService().isValidMediaProjection(projection)) {
1495 throw new SecurityException("Invalid media projection");
1496 }
Michael Wright6720be42014-07-29 19:14:16 -07001497 flags = projection.applyVirtualDisplayFlags(flags);
Michael Wrightc39d47a2014-07-08 18:07:36 -07001498 } catch (RemoteException e) {
Michael Wright6720be42014-07-29 19:14:16 -07001499 throw new SecurityException("unable to validate media projection or flags");
Michael Wrightc39d47a2014-07-08 18:07:36 -07001500 }
1501 }
1502
Michael Wright6720be42014-07-29 19:14:16 -07001503 if (callingUid != Process.SYSTEM_UID &&
Andrii Kulianfc8f82b2017-01-26 13:17:27 -08001504 (flags & VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR) != 0) {
Michael Wrightc39d47a2014-07-08 18:07:36 -07001505 if (!canProjectVideo(projection)) {
1506 throw new SecurityException("Requires CAPTURE_VIDEO_OUTPUT or "
1507 + "CAPTURE_SECURE_VIDEO_OUTPUT permission, or an appropriate "
1508 + "MediaProjection token in order to create a screen sharing virtual "
1509 + "display.");
1510 }
1511 }
Andrii Kulianfc8f82b2017-01-26 13:17:27 -08001512 if ((flags & VIRTUAL_DISPLAY_FLAG_SECURE) != 0) {
Michael Wrightc39d47a2014-07-08 18:07:36 -07001513 if (!canProjectSecureVideo(projection)) {
Jeff Brown4ccb8232014-01-16 22:16:42 -08001514 throw new SecurityException("Requires CAPTURE_SECURE_VIDEO_OUTPUT "
Michael Wrightc39d47a2014-07-08 18:07:36 -07001515 + "or an appropriate MediaProjection token to create a "
1516 + "secure virtual display.");
Jeff Brown4ccb8232014-01-16 22:16:42 -08001517 }
1518 }
1519
1520 final long token = Binder.clearCallingIdentity();
1521 try {
Michael Wright75ee9fc2014-09-01 19:55:22 -07001522 return createVirtualDisplayInternal(callback, projection, callingUid,
Michael Wrightc39d47a2014-07-08 18:07:36 -07001523 packageName, name, width, height, densityDpi, surface, flags);
Jeff Brown4ccb8232014-01-16 22:16:42 -08001524 } finally {
1525 Binder.restoreCallingIdentity(token);
1526 }
1527 }
1528
1529 @Override // Binder call
Michael Wright75ee9fc2014-09-01 19:55:22 -07001530 public void resizeVirtualDisplay(IVirtualDisplayCallback callback,
Michael Wright01e840f2014-06-26 16:03:25 -07001531 int width, int height, int densityDpi) {
1532 final long token = Binder.clearCallingIdentity();
1533 try {
Michael Wright75ee9fc2014-09-01 19:55:22 -07001534 resizeVirtualDisplayInternal(callback.asBinder(), width, height, densityDpi);
Michael Wright01e840f2014-06-26 16:03:25 -07001535 } finally {
1536 Binder.restoreCallingIdentity(token);
1537 }
1538 }
1539
1540 @Override // Binder call
Michael Wright75ee9fc2014-09-01 19:55:22 -07001541 public void setVirtualDisplaySurface(IVirtualDisplayCallback callback, Surface surface) {
Pablo Ceballoseb3370d2016-08-31 15:00:17 -07001542 if (surface != null && surface.isSingleBuffered()) {
1543 throw new IllegalArgumentException("Surface can't be single-buffered");
1544 }
Jeff Brown92207df2014-04-16 13:16:07 -07001545 final long token = Binder.clearCallingIdentity();
1546 try {
Michael Wright75ee9fc2014-09-01 19:55:22 -07001547 setVirtualDisplaySurfaceInternal(callback.asBinder(), surface);
Jeff Brown92207df2014-04-16 13:16:07 -07001548 } finally {
1549 Binder.restoreCallingIdentity(token);
1550 }
1551 }
1552
1553 @Override // Binder call
Michael Wright75ee9fc2014-09-01 19:55:22 -07001554 public void releaseVirtualDisplay(IVirtualDisplayCallback callback) {
Jeff Brown4ccb8232014-01-16 22:16:42 -08001555 final long token = Binder.clearCallingIdentity();
1556 try {
Michael Wright75ee9fc2014-09-01 19:55:22 -07001557 releaseVirtualDisplayInternal(callback.asBinder());
Jeff Brown4ccb8232014-01-16 22:16:42 -08001558 } finally {
1559 Binder.restoreCallingIdentity(token);
1560 }
1561 }
1562
1563 @Override // Binder call
1564 public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) {
Jeff Sharkeyfe9a53b2017-03-31 14:08:23 -06001565 if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
Jeff Brown4ccb8232014-01-16 22:16:42 -08001566
1567 final long token = Binder.clearCallingIdentity();
1568 try {
1569 dumpInternal(pw);
1570 } finally {
1571 Binder.restoreCallingIdentity(token);
1572 }
1573 }
1574
1575 private boolean validatePackageName(int uid, String packageName) {
1576 if (packageName != null) {
1577 String[] packageNames = mContext.getPackageManager().getPackagesForUid(uid);
1578 if (packageNames != null) {
1579 for (String n : packageNames) {
1580 if (n.equals(packageName)) {
1581 return true;
1582 }
1583 }
1584 }
1585 }
1586 return false;
1587 }
Michael Wrightc39d47a2014-07-08 18:07:36 -07001588
1589 private boolean canProjectVideo(IMediaProjection projection) {
1590 if (projection != null) {
1591 try {
1592 if (projection.canProjectVideo()) {
1593 return true;
1594 }
1595 } catch (RemoteException e) {
1596 Slog.e(TAG, "Unable to query projection service for permissions", e);
1597 }
1598 }
1599 if (mContext.checkCallingPermission(
1600 android.Manifest.permission.CAPTURE_VIDEO_OUTPUT)
Michael Wright0ccc2b02014-07-24 18:20:41 -07001601 == PackageManager.PERMISSION_GRANTED) {
Michael Wrightc39d47a2014-07-08 18:07:36 -07001602 return true;
1603 }
1604 return canProjectSecureVideo(projection);
1605 }
1606
1607 private boolean canProjectSecureVideo(IMediaProjection projection) {
1608 if (projection != null) {
1609 try {
1610 if (projection.canProjectSecureVideo()){
1611 return true;
1612 }
1613 } catch (RemoteException e) {
1614 Slog.e(TAG, "Unable to query projection service for permissions", e);
1615 }
1616 }
1617 return mContext.checkCallingPermission(
1618 android.Manifest.permission.CAPTURE_SECURE_VIDEO_OUTPUT)
Michael Wright0ccc2b02014-07-24 18:20:41 -07001619 == PackageManager.PERMISSION_GRANTED;
Michael Wrightc39d47a2014-07-08 18:07:36 -07001620 }
Jeff Brown4ccb8232014-01-16 22:16:42 -08001621 }
1622
1623 private final class LocalService extends DisplayManagerInternal {
1624 @Override
Jeff Brown037c33e2014-04-09 00:31:55 -07001625 public void initPowerManagement(final DisplayPowerCallbacks callbacks, Handler handler,
Jeff Brownad9ef192014-04-08 17:26:30 -07001626 SensorManager sensorManager) {
1627 synchronized (mSyncRoot) {
Jeff Brown037c33e2014-04-09 00:31:55 -07001628 DisplayBlanker blanker = new DisplayBlanker() {
1629 @Override
Jeff Brown5d6443b2015-04-10 20:15:01 -07001630 public void requestDisplayState(int state, int brightness) {
Jeff Brown037c33e2014-04-09 00:31:55 -07001631 // The order of operations is important for legacy reasons.
1632 if (state == Display.STATE_OFF) {
Jeff Brown5d6443b2015-04-10 20:15:01 -07001633 requestGlobalDisplayStateInternal(state, brightness);
Jeff Brown037c33e2014-04-09 00:31:55 -07001634 }
1635
1636 callbacks.onDisplayStateChange(state);
1637
1638 if (state != Display.STATE_OFF) {
Jeff Brown5d6443b2015-04-10 20:15:01 -07001639 requestGlobalDisplayStateInternal(state, brightness);
Jeff Brown037c33e2014-04-09 00:31:55 -07001640 }
1641 }
1642 };
Jeff Brownad9ef192014-04-08 17:26:30 -07001643 mDisplayPowerController = new DisplayPowerController(
Jeff Brown037c33e2014-04-09 00:31:55 -07001644 mContext, callbacks, handler, sensorManager, blanker);
Jeff Brownad9ef192014-04-08 17:26:30 -07001645 }
1646 }
1647
1648 @Override
1649 public boolean requestPowerState(DisplayPowerRequest request,
1650 boolean waitForNegativeProximity) {
1651 return mDisplayPowerController.requestPowerState(request,
1652 waitForNegativeProximity);
1653 }
1654
1655 @Override
1656 public boolean isProximitySensorAvailable() {
1657 return mDisplayPowerController.isProximitySensorAvailable();
1658 }
1659
1660 @Override
Jeff Brown4ccb8232014-01-16 22:16:42 -08001661 public DisplayInfo getDisplayInfo(int displayId) {
1662 return getDisplayInfoInternal(displayId, Process.myUid());
1663 }
1664
1665 @Override
1666 public void registerDisplayTransactionListener(DisplayTransactionListener listener) {
1667 if (listener == null) {
1668 throw new IllegalArgumentException("listener must not be null");
1669 }
1670
1671 registerDisplayTransactionListenerInternal(listener);
1672 }
1673
1674 @Override
1675 public void unregisterDisplayTransactionListener(DisplayTransactionListener listener) {
1676 if (listener == null) {
1677 throw new IllegalArgumentException("listener must not be null");
1678 }
1679
1680 unregisterDisplayTransactionListenerInternal(listener);
1681 }
1682
1683 @Override
1684 public void setDisplayInfoOverrideFromWindowManager(int displayId, DisplayInfo info) {
1685 setDisplayInfoOverrideFromWindowManagerInternal(displayId, info);
1686 }
1687
1688 @Override
Andrii Kuliancd097992017-03-23 18:31:59 -07001689 public void getNonOverrideDisplayInfo(int displayId, DisplayInfo outInfo) {
1690 getNonOverrideDisplayInfoInternal(displayId, outInfo);
1691 }
1692
1693 @Override
Jeff Brown4ccb8232014-01-16 22:16:42 -08001694 public void performTraversalInTransactionFromWindowManager() {
1695 performTraversalInTransactionFromWindowManagerInternal();
1696 }
1697
1698 @Override
Michael Wright3f145a22014-07-22 19:46:03 -07001699 public void setDisplayProperties(int displayId, boolean hasContent,
P.Y. Laligandb3b9eb32015-05-11 15:02:07 -07001700 float requestedRefreshRate, int requestedMode, boolean inTraversal) {
1701 setDisplayPropertiesInternal(displayId, hasContent, requestedRefreshRate,
1702 requestedMode, inTraversal);
Jeff Brown4ccb8232014-01-16 22:16:42 -08001703 }
Filip Gruszczynskid2e86402015-02-19 13:05:03 -08001704
1705 @Override
1706 public void setDisplayOffsets(int displayId, int x, int y) {
1707 setDisplayOffsetsInternal(displayId, x, y);
1708 }
Andrii Kulianfb1bf692017-01-17 11:17:34 -08001709
1710 @Override
1711 public void setDisplayAccessUIDs(SparseArray<IntArray> newDisplayAccessUIDs) {
1712 setDisplayAccessUIDsInternal(newDisplayAccessUIDs);
1713 }
1714
1715 @Override
1716 public boolean isUidPresentOnDisplay(int uid, int displayId) {
1717 return isUidPresentOnDisplayInternal(uid, displayId);
1718 }
Jeff Brown4ccb8232014-01-16 22:16:42 -08001719 }
Jeff Brownfa25bf52012-07-23 19:26:30 -07001720}