Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server.display; |
| 18 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 19 | import com.android.internal.util.IndentingPrintWriter; |
| 20 | |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 21 | import android.Manifest; |
| 22 | import android.content.Context; |
| 23 | import android.content.pm.PackageManager; |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 24 | import android.hardware.SensorManager; |
Jeff Brown | 7d00aff | 2013-08-02 19:03:49 -0700 | [diff] [blame] | 25 | import android.hardware.display.DisplayManager; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 26 | import android.hardware.display.DisplayManagerGlobal; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 27 | import android.hardware.display.DisplayManagerInternal; |
| 28 | import android.hardware.display.DisplayViewport; |
| 29 | import android.hardware.display.DisplayManagerInternal.DisplayTransactionListener; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 30 | import android.hardware.display.IDisplayManager; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 31 | import android.hardware.display.IDisplayManagerCallback; |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 32 | import android.hardware.display.IVirtualDisplayCallback; |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 33 | import android.hardware.display.WifiDisplayStatus; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 34 | import android.hardware.input.InputManagerInternal; |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 35 | import android.media.projection.IMediaProjection; |
| 36 | import android.media.projection.IMediaProjectionManager; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 37 | import android.os.Binder; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 38 | import android.os.Handler; |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 39 | import android.os.IBinder; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 40 | import android.os.IBinder.DeathRecipient; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 41 | import android.os.Looper; |
| 42 | import android.os.Message; |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 43 | import android.os.PowerManager; |
Craig Mautner | 4504de5 | 2013-12-20 09:06:56 -0800 | [diff] [blame] | 44 | import android.os.Process; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 45 | import android.os.RemoteException; |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 46 | import android.os.ServiceManager; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 47 | import android.os.SystemClock; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 48 | import android.os.SystemProperties; |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 49 | import android.os.Trace; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 50 | import android.text.TextUtils; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 51 | import android.util.Slog; |
| 52 | import android.util.SparseArray; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 53 | import android.view.Display; |
| 54 | import android.view.DisplayInfo; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 55 | import android.view.Surface; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 56 | import android.view.WindowManagerInternal; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 57 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 58 | import com.android.server.DisplayThread; |
| 59 | import com.android.server.LocalServices; |
| 60 | import com.android.server.SystemService; |
Dianne Hackborn | 8d044e8 | 2013-04-30 17:24:15 -0700 | [diff] [blame] | 61 | import com.android.server.UiThread; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 62 | |
| 63 | import java.io.FileDescriptor; |
| 64 | import java.io.PrintWriter; |
| 65 | import java.util.ArrayList; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 66 | import java.util.Arrays; |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 67 | import java.util.List; |
Jeff Brown | 7f3994e | 2012-12-04 14:04:28 -0800 | [diff] [blame] | 68 | import java.util.concurrent.CopyOnWriteArrayList; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 69 | |
| 70 | /** |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 71 | * Manages attached displays. |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 72 | * <p> |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 73 | * The {@link DisplayManagerService} manages the global lifecycle of displays, |
| 74 | * decides how to configure logical displays based on the physical display devices currently |
| 75 | * attached, sends notifications to the system and to applications when the state |
| 76 | * changes, and so on. |
| 77 | * </p><p> |
| 78 | * The display manager service relies on a collection of {@link DisplayAdapter} components, |
| 79 | * for discovering and configuring physical display devices attached to the system. |
| 80 | * There are separate display adapters for each manner that devices are attached: |
| 81 | * one display adapter for built-in local displays, one for simulated non-functional |
| 82 | * displays when the system is headless, one for simulated overlay displays used for |
| 83 | * development, one for wifi displays, etc. |
| 84 | * </p><p> |
| 85 | * Display adapters are only weakly coupled to the display manager service. |
| 86 | * Display adapters communicate changes in display device state to the display manager |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 87 | * service asynchronously via a {@link DisplayAdapter.Listener} registered |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 88 | * by the display manager service. This separation of concerns is important for |
| 89 | * two main reasons. First, it neatly encapsulates the responsibilities of these |
| 90 | * two classes: display adapters handle individual display devices whereas |
| 91 | * the display manager service handles the global state. Second, it eliminates |
| 92 | * the potential for deadlocks resulting from asynchronous display device discovery. |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 93 | * </p> |
| 94 | * |
| 95 | * <h3>Synchronization</h3> |
| 96 | * <p> |
| 97 | * Because the display manager may be accessed by multiple threads, the synchronization |
| 98 | * story gets a little complicated. In particular, the window manager may call into |
| 99 | * the display manager while holding a surface transaction with the expectation that |
| 100 | * it can apply changes immediately. Unfortunately, that means we can't just do |
| 101 | * everything asynchronously (*grump*). |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 102 | * </p><p> |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 103 | * To make this work, all of the objects that belong to the display manager must |
| 104 | * use the same lock. We call this lock the synchronization root and it has a unique |
| 105 | * type {@link DisplayManagerService.SyncRoot}. Methods that require this lock are |
| 106 | * named with the "Locked" suffix. |
| 107 | * </p><p> |
| 108 | * Where things get tricky is that the display manager is not allowed to make |
| 109 | * any potentially reentrant calls, especially into the window manager. We generally |
| 110 | * avoid this by making all potentially reentrant out-calls asynchronous. |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 111 | * </p> |
| 112 | */ |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 113 | public final class DisplayManagerService extends SystemService { |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 114 | private static final String TAG = "DisplayManagerService"; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 115 | private static final boolean DEBUG = false; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 116 | |
Jeff Brown | bbd28a2 | 2012-09-20 16:47:15 -0700 | [diff] [blame] | 117 | // When this system property is set to 0, WFD is forcibly disabled on boot. |
| 118 | // When this system property is set to 1, WFD is forcibly enabled on boot. |
| 119 | // Otherwise WFD is enabled according to the value of config_enableWifiDisplay. |
| 120 | private static final String FORCE_WIFI_DISPLAY_ENABLE = "persist.debug.wfd.enable"; |
| 121 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 122 | private static final long WAIT_FOR_DEFAULT_DISPLAY_TIMEOUT = 10000; |
| 123 | |
| 124 | private static final int MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER = 1; |
| 125 | private static final int MSG_REGISTER_ADDITIONAL_DISPLAY_ADAPTERS = 2; |
| 126 | private static final int MSG_DELIVER_DISPLAY_EVENT = 3; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 127 | private static final int MSG_REQUEST_TRAVERSAL = 4; |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 128 | private static final int MSG_UPDATE_VIEWPORT = 5; |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 129 | |
Jeff Brown | b880d88 | 2014-02-10 19:47:07 -0800 | [diff] [blame] | 130 | private final Context mContext; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 131 | private final DisplayManagerHandler mHandler; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 132 | private final Handler mUiHandler; |
| 133 | private final DisplayAdapterListener mDisplayAdapterListener; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 134 | private WindowManagerInternal mWindowManagerInternal; |
| 135 | private InputManagerInternal mInputManagerInternal; |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 136 | private IMediaProjectionManager mProjectionService; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 137 | |
| 138 | // The synchronization root for the display manager. |
| 139 | // This lock guards most of the display manager's state. |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 140 | // NOTE: This is synchronized on while holding WindowManagerService.mWindowMap so never call |
| 141 | // into WindowManagerService methods that require mWindowMap while holding this unless you are |
| 142 | // very very sure that no deadlock can occur. |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 143 | private final SyncRoot mSyncRoot = new SyncRoot(); |
| 144 | |
| 145 | // True if in safe mode. |
| 146 | // This option may disable certain display adapters. |
| 147 | public boolean mSafeMode; |
| 148 | |
| 149 | // True if we are in a special boot mode where only core applications and |
| 150 | // services should be started. This option may disable certain display adapters. |
| 151 | public boolean mOnlyCore; |
| 152 | |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 153 | // True if the display manager service should pretend there is only one display |
| 154 | // and only tell applications about the existence of the default logical display. |
| 155 | // The display manager can still mirror content to secondary displays but applications |
| 156 | // cannot present unique content on those displays. |
| 157 | // Used for demonstration purposes only. |
| 158 | private final boolean mSingleDisplayDemoMode; |
| 159 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 160 | // All callback records indexed by calling process id. |
| 161 | public final SparseArray<CallbackRecord> mCallbacks = |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 162 | new SparseArray<CallbackRecord>(); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 163 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 164 | // List of all currently registered display adapters. |
| 165 | private final ArrayList<DisplayAdapter> mDisplayAdapters = new ArrayList<DisplayAdapter>(); |
| 166 | |
| 167 | // List of all currently connected display devices. |
| 168 | private final ArrayList<DisplayDevice> mDisplayDevices = new ArrayList<DisplayDevice>(); |
| 169 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 170 | // List of all logical displays indexed by logical display id. |
| 171 | private final SparseArray<LogicalDisplay> mLogicalDisplays = |
| 172 | new SparseArray<LogicalDisplay>(); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 173 | private int mNextNonDefaultDisplayId = Display.DEFAULT_DISPLAY + 1; |
| 174 | |
Jeff Brown | 7f3994e | 2012-12-04 14:04:28 -0800 | [diff] [blame] | 175 | // List of all display transaction listeners. |
| 176 | private final CopyOnWriteArrayList<DisplayTransactionListener> mDisplayTransactionListeners = |
| 177 | new CopyOnWriteArrayList<DisplayTransactionListener>(); |
| 178 | |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 179 | // Display power controller. |
| 180 | private DisplayPowerController mDisplayPowerController; |
| 181 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 182 | // The overall display state, independent of changes that might influence one |
| 183 | // display or another in particular. |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 184 | private int mGlobalDisplayState = Display.STATE_ON; |
| 185 | |
| 186 | // The overall display brightness. |
| 187 | // For now, this only applies to the built-in display but we may split it up eventually. |
| 188 | private int mGlobalDisplayBrightness = PowerManager.BRIGHTNESS_DEFAULT; |
Jeff Brown | 9e316a1 | 2012-10-08 19:17:06 -0700 | [diff] [blame] | 189 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 190 | // Set to true when there are pending display changes that have yet to be applied |
| 191 | // to the surface flinger state. |
| 192 | private boolean mPendingTraversal; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 193 | |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 194 | // The Wifi display adapter, or null if not registered. |
| 195 | private WifiDisplayAdapter mWifiDisplayAdapter; |
| 196 | |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 197 | // The number of active wifi display scan requests. |
| 198 | private int mWifiDisplayScanRequestCount; |
| 199 | |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 200 | // The virtual display adapter, or null if not registered. |
| 201 | private VirtualDisplayAdapter mVirtualDisplayAdapter; |
| 202 | |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 203 | // Viewports of the default display and the display that should receive touch |
| 204 | // input from an external source. Used by the input system. |
| 205 | private final DisplayViewport mDefaultViewport = new DisplayViewport(); |
| 206 | private final DisplayViewport mExternalTouchViewport = new DisplayViewport(); |
| 207 | |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 208 | // Persistent data store for all internal settings maintained by the display manager service. |
| 209 | private final PersistentDataStore mPersistentDataStore = new PersistentDataStore(); |
| 210 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 211 | // Temporary callback list, used when sending display events to applications. |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 212 | // May be used outside of the lock but only on the handler thread. |
| 213 | private final ArrayList<CallbackRecord> mTempCallbacks = new ArrayList<CallbackRecord>(); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 214 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 215 | // Temporary display info, used for comparing display configurations. |
| 216 | private final DisplayInfo mTempDisplayInfo = new DisplayInfo(); |
| 217 | |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 218 | // Temporary viewports, used when sending new viewport information to the |
| 219 | // input system. May be used outside of the lock but only on the handler thread. |
| 220 | private final DisplayViewport mTempDefaultViewport = new DisplayViewport(); |
| 221 | private final DisplayViewport mTempExternalTouchViewport = new DisplayViewport(); |
| 222 | |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 223 | // Temporary list of deferred work to perform when setting the display state. |
| 224 | // Only used by requestDisplayState. The field is self-synchronized and only |
| 225 | // intended for use inside of the requestGlobalDisplayStateInternal function. |
| 226 | private final ArrayList<Runnable> mTempDisplayStateWorkQueue = new ArrayList<Runnable>(); |
| 227 | |
Jeff Brown | b880d88 | 2014-02-10 19:47:07 -0800 | [diff] [blame] | 228 | public DisplayManagerService(Context context) { |
| 229 | super(context); |
| 230 | mContext = context; |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 231 | mHandler = new DisplayManagerHandler(DisplayThread.get().getLooper()); |
Dianne Hackborn | 8d044e8 | 2013-04-30 17:24:15 -0700 | [diff] [blame] | 232 | mUiHandler = UiThread.getHandler(); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 233 | mDisplayAdapterListener = new DisplayAdapterListener(); |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 234 | mSingleDisplayDemoMode = SystemProperties.getBoolean("persist.demo.singledisplay", false); |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 235 | |
| 236 | PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
| 237 | mGlobalDisplayBrightness = pm.getDefaultScreenBrightnessSetting(); |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 240 | @Override |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 241 | public void onStart() { |
| 242 | mHandler.sendEmptyMessage(MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER); |
| 243 | |
| 244 | publishBinderService(Context.DISPLAY_SERVICE, new BinderService(), |
| 245 | true /*allowIsolated*/); |
| 246 | publishLocalService(DisplayManagerInternal.class, new LocalService()); |
| 247 | } |
| 248 | |
| 249 | @Override |
| 250 | public void onBootPhase(int phase) { |
| 251 | if (phase == PHASE_WAIT_FOR_DEFAULT_DISPLAY) { |
| 252 | synchronized (mSyncRoot) { |
| 253 | long timeout = SystemClock.uptimeMillis() + WAIT_FOR_DEFAULT_DISPLAY_TIMEOUT; |
| 254 | while (mLogicalDisplays.get(Display.DEFAULT_DISPLAY) == null) { |
| 255 | long delay = timeout - SystemClock.uptimeMillis(); |
| 256 | if (delay <= 0) { |
| 257 | throw new RuntimeException("Timeout waiting for default display " |
| 258 | + "to be initialized."); |
| 259 | } |
| 260 | if (DEBUG) { |
| 261 | Slog.d(TAG, "waitForDefaultDisplay: waiting, timeout=" + delay); |
| 262 | } |
| 263 | try { |
| 264 | mSyncRoot.wait(delay); |
| 265 | } catch (InterruptedException ex) { |
| 266 | } |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 267 | } |
| 268 | } |
| 269 | } |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 270 | } |
| 271 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 272 | // TODO: Use dependencies or a boot phase |
| 273 | public void windowManagerAndInputReady() { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 274 | synchronized (mSyncRoot) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 275 | mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); |
| 276 | mInputManagerInternal = LocalServices.getService(InputManagerInternal.class); |
Craig Mautner | 65d11b3 | 2012-10-01 13:59:52 -0700 | [diff] [blame] | 277 | scheduleTraversalLocked(false); |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 278 | } |
| 279 | } |
| 280 | |
| 281 | /** |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 282 | * Called when the system is ready to go. |
| 283 | */ |
| 284 | public void systemReady(boolean safeMode, boolean onlyCore) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 285 | synchronized (mSyncRoot) { |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 286 | mSafeMode = safeMode; |
| 287 | mOnlyCore = onlyCore; |
| 288 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 289 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 290 | mHandler.sendEmptyMessage(MSG_REGISTER_ADDITIONAL_DISPLAY_ADAPTERS); |
| 291 | } |
| 292 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 293 | private void registerDisplayTransactionListenerInternal( |
| 294 | DisplayTransactionListener listener) { |
Jeff Brown | 7f3994e | 2012-12-04 14:04:28 -0800 | [diff] [blame] | 295 | // List is self-synchronized copy-on-write. |
| 296 | mDisplayTransactionListeners.add(listener); |
| 297 | } |
| 298 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 299 | private void unregisterDisplayTransactionListenerInternal( |
| 300 | DisplayTransactionListener listener) { |
Jeff Brown | 7f3994e | 2012-12-04 14:04:28 -0800 | [diff] [blame] | 301 | // List is self-synchronized copy-on-write. |
| 302 | mDisplayTransactionListeners.remove(listener); |
| 303 | } |
| 304 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 305 | private void setDisplayInfoOverrideFromWindowManagerInternal( |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 306 | int displayId, DisplayInfo info) { |
| 307 | synchronized (mSyncRoot) { |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 308 | LogicalDisplay display = mLogicalDisplays.get(displayId); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 309 | if (display != null) { |
Jeff Brown | ef981a4 | 2013-08-07 14:13:37 -0700 | [diff] [blame] | 310 | if (display.setDisplayInfoOverrideFromWindowManagerLocked(info)) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 311 | sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED); |
Craig Mautner | 65d11b3 | 2012-10-01 13:59:52 -0700 | [diff] [blame] | 312 | scheduleTraversalLocked(false); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 313 | } |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 314 | } |
| 315 | } |
| 316 | } |
| 317 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 318 | private void performTraversalInTransactionFromWindowManagerInternal() { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 319 | synchronized (mSyncRoot) { |
| 320 | if (!mPendingTraversal) { |
| 321 | return; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 322 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 323 | mPendingTraversal = false; |
| 324 | |
| 325 | performTraversalInTransactionLocked(); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 326 | } |
Jeff Brown | 7f3994e | 2012-12-04 14:04:28 -0800 | [diff] [blame] | 327 | |
| 328 | // List is self-synchronized copy-on-write. |
| 329 | for (DisplayTransactionListener listener : mDisplayTransactionListeners) { |
| 330 | listener.onDisplayTransaction(); |
| 331 | } |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 332 | } |
| 333 | |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 334 | private void requestGlobalDisplayStateInternal(int state, int brightness) { |
| 335 | if (state == Display.STATE_UNKNOWN) { |
| 336 | state = Display.STATE_ON; |
| 337 | } |
| 338 | if (state == Display.STATE_OFF) { |
| 339 | brightness = PowerManager.BRIGHTNESS_OFF; |
| 340 | } else if (brightness < 0) { |
| 341 | brightness = PowerManager.BRIGHTNESS_DEFAULT; |
| 342 | } else if (brightness > PowerManager.BRIGHTNESS_ON) { |
| 343 | brightness = PowerManager.BRIGHTNESS_ON; |
| 344 | } |
| 345 | |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 346 | synchronized (mTempDisplayStateWorkQueue) { |
| 347 | try { |
| 348 | // Update the display state within the lock. |
Jeff Brown | 8e5d33e | 2015-06-10 13:05:50 -0700 | [diff] [blame] | 349 | // Note that we do not need to schedule traversals here although it |
| 350 | // may happen as a side-effect of displays changing state. |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 351 | synchronized (mSyncRoot) { |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 352 | if (mGlobalDisplayState == state |
| 353 | && mGlobalDisplayBrightness == brightness) { |
| 354 | return; // no change |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 355 | } |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 356 | |
| 357 | Trace.traceBegin(Trace.TRACE_TAG_POWER, "requestGlobalDisplayState(" |
| 358 | + Display.stateToString(state) |
| 359 | + ", brightness=" + brightness + ")"); |
| 360 | mGlobalDisplayState = state; |
| 361 | mGlobalDisplayBrightness = brightness; |
Jeff Brown | 8e5d33e | 2015-06-10 13:05:50 -0700 | [diff] [blame] | 362 | applyGlobalDisplayStateLocked(mTempDisplayStateWorkQueue); |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | // Setting the display power state can take hundreds of milliseconds |
| 366 | // to complete so we defer the most expensive part of the work until |
| 367 | // after we have exited the critical section to avoid blocking other |
| 368 | // threads for a long time. |
| 369 | for (int i = 0; i < mTempDisplayStateWorkQueue.size(); i++) { |
| 370 | mTempDisplayStateWorkQueue.get(i).run(); |
| 371 | } |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 372 | Trace.traceEnd(Trace.TRACE_TAG_POWER); |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 373 | } finally { |
| 374 | mTempDisplayStateWorkQueue.clear(); |
Jeff Brown | 9e316a1 | 2012-10-08 19:17:06 -0700 | [diff] [blame] | 375 | } |
| 376 | } |
| 377 | } |
| 378 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 379 | private DisplayInfo getDisplayInfoInternal(int displayId, int callingUid) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 380 | synchronized (mSyncRoot) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 381 | LogicalDisplay display = mLogicalDisplays.get(displayId); |
| 382 | if (display != null) { |
| 383 | DisplayInfo info = display.getDisplayInfoLocked(); |
| 384 | if (info.hasAccess(callingUid)) { |
| 385 | return info; |
| 386 | } |
| 387 | } |
| 388 | return null; |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | private int[] getDisplayIdsInternal(int callingUid) { |
| 393 | synchronized (mSyncRoot) { |
| 394 | final int count = mLogicalDisplays.size(); |
| 395 | int[] displayIds = new int[count]; |
| 396 | int n = 0; |
| 397 | for (int i = 0; i < count; i++) { |
| 398 | LogicalDisplay display = mLogicalDisplays.valueAt(i); |
| 399 | DisplayInfo info = display.getDisplayInfoLocked(); |
| 400 | if (info.hasAccess(callingUid)) { |
| 401 | displayIds[n++] = mLogicalDisplays.keyAt(i); |
| 402 | } |
| 403 | } |
| 404 | if (n != count) { |
| 405 | displayIds = Arrays.copyOfRange(displayIds, 0, n); |
| 406 | } |
| 407 | return displayIds; |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | private void registerCallbackInternal(IDisplayManagerCallback callback, int callingPid) { |
| 412 | synchronized (mSyncRoot) { |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 413 | if (mCallbacks.get(callingPid) != null) { |
| 414 | throw new SecurityException("The calling process has already " |
| 415 | + "registered an IDisplayManagerCallback."); |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 416 | } |
| 417 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 418 | CallbackRecord record = new CallbackRecord(callingPid, callback); |
| 419 | try { |
| 420 | IBinder binder = callback.asBinder(); |
| 421 | binder.linkToDeath(record, 0); |
| 422 | } catch (RemoteException ex) { |
| 423 | // give up |
| 424 | throw new RuntimeException(ex); |
| 425 | } |
| 426 | |
| 427 | mCallbacks.put(callingPid, record); |
| 428 | } |
| 429 | } |
| 430 | |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 431 | private void onCallbackDied(CallbackRecord record) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 432 | synchronized (mSyncRoot) { |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 433 | mCallbacks.remove(record.mPid); |
| 434 | stopWifiDisplayScanLocked(record); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 435 | } |
| 436 | } |
| 437 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 438 | private void startWifiDisplayScanInternal(int callingPid) { |
| 439 | synchronized (mSyncRoot) { |
| 440 | CallbackRecord record = mCallbacks.get(callingPid); |
| 441 | if (record == null) { |
| 442 | throw new IllegalStateException("The calling process has not " |
| 443 | + "registered an IDisplayManagerCallback."); |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 444 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 445 | startWifiDisplayScanLocked(record); |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 446 | } |
| 447 | } |
| 448 | |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 449 | private void startWifiDisplayScanLocked(CallbackRecord record) { |
| 450 | if (!record.mWifiDisplayScanRequested) { |
| 451 | record.mWifiDisplayScanRequested = true; |
| 452 | if (mWifiDisplayScanRequestCount++ == 0) { |
| 453 | if (mWifiDisplayAdapter != null) { |
| 454 | mWifiDisplayAdapter.requestStartScanLocked(); |
| 455 | } |
| 456 | } |
| 457 | } |
| 458 | } |
| 459 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 460 | private void stopWifiDisplayScanInternal(int callingPid) { |
| 461 | synchronized (mSyncRoot) { |
| 462 | CallbackRecord record = mCallbacks.get(callingPid); |
| 463 | if (record == null) { |
| 464 | throw new IllegalStateException("The calling process has not " |
| 465 | + "registered an IDisplayManagerCallback."); |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 466 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 467 | stopWifiDisplayScanLocked(record); |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 468 | } |
| 469 | } |
| 470 | |
| 471 | private void stopWifiDisplayScanLocked(CallbackRecord record) { |
| 472 | if (record.mWifiDisplayScanRequested) { |
| 473 | record.mWifiDisplayScanRequested = false; |
| 474 | if (--mWifiDisplayScanRequestCount == 0) { |
| 475 | if (mWifiDisplayAdapter != null) { |
| 476 | mWifiDisplayAdapter.requestStopScanLocked(); |
| 477 | } |
| 478 | } else if (mWifiDisplayScanRequestCount < 0) { |
Dianne Hackborn | 8d05172 | 2014-10-01 14:59:58 -0700 | [diff] [blame] | 479 | Slog.wtf(TAG, "mWifiDisplayScanRequestCount became negative: " |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 480 | + mWifiDisplayScanRequestCount); |
| 481 | mWifiDisplayScanRequestCount = 0; |
| 482 | } |
| 483 | } |
| 484 | } |
| 485 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 486 | private void connectWifiDisplayInternal(String address) { |
| 487 | synchronized (mSyncRoot) { |
| 488 | if (mWifiDisplayAdapter != null) { |
| 489 | mWifiDisplayAdapter.requestConnectLocked(address); |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 490 | } |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 491 | } |
| 492 | } |
| 493 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 494 | private void pauseWifiDisplayInternal() { |
| 495 | synchronized (mSyncRoot) { |
| 496 | if (mWifiDisplayAdapter != null) { |
| 497 | mWifiDisplayAdapter.requestPauseLocked(); |
Chong Zhang | 1f3ecaa | 2013-05-03 15:55:36 -0700 | [diff] [blame] | 498 | } |
Chong Zhang | 1f3ecaa | 2013-05-03 15:55:36 -0700 | [diff] [blame] | 499 | } |
| 500 | } |
| 501 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 502 | private void resumeWifiDisplayInternal() { |
| 503 | synchronized (mSyncRoot) { |
| 504 | if (mWifiDisplayAdapter != null) { |
| 505 | mWifiDisplayAdapter.requestResumeLocked(); |
Chong Zhang | 1f3ecaa | 2013-05-03 15:55:36 -0700 | [diff] [blame] | 506 | } |
Chong Zhang | 1f3ecaa | 2013-05-03 15:55:36 -0700 | [diff] [blame] | 507 | } |
| 508 | } |
| 509 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 510 | private void disconnectWifiDisplayInternal() { |
| 511 | synchronized (mSyncRoot) { |
| 512 | if (mWifiDisplayAdapter != null) { |
| 513 | mWifiDisplayAdapter.requestDisconnectLocked(); |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 514 | } |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 515 | } |
| 516 | } |
| 517 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 518 | private void renameWifiDisplayInternal(String address, String alias) { |
| 519 | synchronized (mSyncRoot) { |
| 520 | if (mWifiDisplayAdapter != null) { |
| 521 | mWifiDisplayAdapter.requestRenameLocked(address, alias); |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 522 | } |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 523 | } |
| 524 | } |
| 525 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 526 | private void forgetWifiDisplayInternal(String address) { |
| 527 | synchronized (mSyncRoot) { |
| 528 | if (mWifiDisplayAdapter != null) { |
| 529 | mWifiDisplayAdapter.requestForgetLocked(address); |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 530 | } |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 531 | } |
| 532 | } |
| 533 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 534 | private WifiDisplayStatus getWifiDisplayStatusInternal() { |
| 535 | synchronized (mSyncRoot) { |
| 536 | if (mWifiDisplayAdapter != null) { |
| 537 | return mWifiDisplayAdapter.getWifiDisplayStatusLocked(); |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 538 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 539 | return new WifiDisplayStatus(); |
Jeff Brown | e08ae38 | 2012-09-07 20:36:36 -0700 | [diff] [blame] | 540 | } |
| 541 | } |
| 542 | |
Michael Wright | 58e829f | 2015-09-15 00:13:26 +0100 | [diff] [blame^] | 543 | private void requestColorTransformInternal(int displayId, int colorTransformId) { |
| 544 | synchronized (mSyncRoot) { |
| 545 | LogicalDisplay display = mLogicalDisplays.get(displayId); |
| 546 | if (display != null && |
| 547 | display.getRequestedColorTransformIdLocked() != colorTransformId) { |
| 548 | display.setRequestedColorTransformIdLocked(colorTransformId); |
| 549 | scheduleTraversalLocked(false); |
| 550 | } |
| 551 | } |
| 552 | } |
| 553 | |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 554 | private int createVirtualDisplayInternal(IVirtualDisplayCallback callback, |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 555 | IMediaProjection projection, int callingUid, String packageName, |
Jeff Brown | 7d00aff | 2013-08-02 19:03:49 -0700 | [diff] [blame] | 556 | String name, int width, int height, int densityDpi, Surface surface, int flags) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 557 | synchronized (mSyncRoot) { |
| 558 | if (mVirtualDisplayAdapter == null) { |
| 559 | Slog.w(TAG, "Rejecting request to create private virtual display " |
| 560 | + "because the virtual display adapter is not available."); |
| 561 | return -1; |
Jeff Brown | 7d00aff | 2013-08-02 19:03:49 -0700 | [diff] [blame] | 562 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 563 | |
| 564 | DisplayDevice device = mVirtualDisplayAdapter.createVirtualDisplayLocked( |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 565 | callback, projection, callingUid, packageName, |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 566 | name, width, height, densityDpi, surface, flags); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 567 | if (device == null) { |
| 568 | return -1; |
Jeff Brown | 7d00aff | 2013-08-02 19:03:49 -0700 | [diff] [blame] | 569 | } |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 570 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 571 | handleDisplayDeviceAddedLocked(device); |
| 572 | LogicalDisplay display = findLogicalDisplayForDeviceLocked(device); |
| 573 | if (display != null) { |
| 574 | return display.getDisplayIdLocked(); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 575 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 576 | |
| 577 | // Something weird happened and the logical display was not created. |
| 578 | Slog.w(TAG, "Rejecting request to create virtual display " |
| 579 | + "because the logical display was not created."); |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 580 | mVirtualDisplayAdapter.releaseVirtualDisplayLocked(callback.asBinder()); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 581 | handleDisplayDeviceRemovedLocked(device); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 582 | } |
| 583 | return -1; |
| 584 | } |
| 585 | |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 586 | private void resizeVirtualDisplayInternal(IBinder appToken, |
| 587 | int width, int height, int densityDpi) { |
| 588 | synchronized (mSyncRoot) { |
| 589 | if (mVirtualDisplayAdapter == null) { |
| 590 | return; |
| 591 | } |
| 592 | |
| 593 | mVirtualDisplayAdapter.resizeVirtualDisplayLocked(appToken, width, height, densityDpi); |
| 594 | } |
| 595 | } |
| 596 | |
Jeff Brown | 92207df | 2014-04-16 13:16:07 -0700 | [diff] [blame] | 597 | private void setVirtualDisplaySurfaceInternal(IBinder appToken, Surface surface) { |
| 598 | synchronized (mSyncRoot) { |
| 599 | if (mVirtualDisplayAdapter == null) { |
| 600 | return; |
| 601 | } |
| 602 | |
| 603 | mVirtualDisplayAdapter.setVirtualDisplaySurfaceLocked(appToken, surface); |
| 604 | } |
| 605 | } |
| 606 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 607 | private void releaseVirtualDisplayInternal(IBinder appToken) { |
| 608 | synchronized (mSyncRoot) { |
| 609 | if (mVirtualDisplayAdapter == null) { |
| 610 | return; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 611 | } |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 612 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 613 | DisplayDevice device = |
| 614 | mVirtualDisplayAdapter.releaseVirtualDisplayLocked(appToken); |
| 615 | if (device != null) { |
| 616 | handleDisplayDeviceRemovedLocked(device); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 617 | } |
| 618 | } |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 619 | } |
| 620 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 621 | private void registerDefaultDisplayAdapter() { |
| 622 | // Register default display adapter. |
| 623 | synchronized (mSyncRoot) { |
Mike Lockwood | e63f6f7 | 2013-11-15 11:01:47 -0800 | [diff] [blame] | 624 | registerDisplayAdapterLocked(new LocalDisplayAdapter( |
| 625 | mSyncRoot, mContext, mHandler, mDisplayAdapterListener)); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 626 | } |
| 627 | } |
| 628 | |
| 629 | private void registerAdditionalDisplayAdapters() { |
| 630 | synchronized (mSyncRoot) { |
| 631 | if (shouldRegisterNonEssentialDisplayAdaptersLocked()) { |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 632 | registerOverlayDisplayAdapterLocked(); |
| 633 | registerWifiDisplayAdapterLocked(); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 634 | registerVirtualDisplayAdapterLocked(); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 635 | } |
| 636 | } |
| 637 | } |
| 638 | |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 639 | private void registerOverlayDisplayAdapterLocked() { |
| 640 | registerDisplayAdapterLocked(new OverlayDisplayAdapter( |
| 641 | mSyncRoot, mContext, mHandler, mDisplayAdapterListener, mUiHandler)); |
| 642 | } |
| 643 | |
| 644 | private void registerWifiDisplayAdapterLocked() { |
| 645 | if (mContext.getResources().getBoolean( |
Jeff Brown | bbd28a2 | 2012-09-20 16:47:15 -0700 | [diff] [blame] | 646 | com.android.internal.R.bool.config_enableWifiDisplay) |
| 647 | || SystemProperties.getInt(FORCE_WIFI_DISPLAY_ENABLE, -1) == 1) { |
Jeff Brown | 89d5546 | 2012-09-19 11:33:42 -0700 | [diff] [blame] | 648 | mWifiDisplayAdapter = new WifiDisplayAdapter( |
| 649 | mSyncRoot, mContext, mHandler, mDisplayAdapterListener, |
| 650 | mPersistentDataStore); |
| 651 | registerDisplayAdapterLocked(mWifiDisplayAdapter); |
| 652 | } |
| 653 | } |
| 654 | |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 655 | private void registerVirtualDisplayAdapterLocked() { |
| 656 | mVirtualDisplayAdapter = new VirtualDisplayAdapter( |
| 657 | mSyncRoot, mContext, mHandler, mDisplayAdapterListener); |
| 658 | registerDisplayAdapterLocked(mVirtualDisplayAdapter); |
| 659 | } |
| 660 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 661 | private boolean shouldRegisterNonEssentialDisplayAdaptersLocked() { |
| 662 | // In safe mode, we disable non-essential display adapters to give the user |
| 663 | // an opportunity to fix broken settings or other problems that might affect |
| 664 | // system stability. |
| 665 | // In only-core mode, we disable non-essential display adapters to minimize |
| 666 | // the number of dependencies that are started while in this mode and to |
| 667 | // prevent problems that might occur due to the device being encrypted. |
| 668 | return !mSafeMode && !mOnlyCore; |
| 669 | } |
| 670 | |
| 671 | private void registerDisplayAdapterLocked(DisplayAdapter adapter) { |
| 672 | mDisplayAdapters.add(adapter); |
| 673 | adapter.registerLocked(); |
| 674 | } |
| 675 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 676 | private void handleDisplayDeviceAdded(DisplayDevice device) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 677 | synchronized (mSyncRoot) { |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 678 | handleDisplayDeviceAddedLocked(device); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 679 | } |
| 680 | } |
| 681 | |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 682 | private void handleDisplayDeviceAddedLocked(DisplayDevice device) { |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 683 | DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 684 | if (mDisplayDevices.contains(device)) { |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 685 | Slog.w(TAG, "Attempted to add already added display device: " + info); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 686 | return; |
| 687 | } |
| 688 | |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 689 | Slog.i(TAG, "Display device added: " + info); |
| 690 | device.mDebugLastLoggedDeviceInfo = info; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 691 | |
| 692 | mDisplayDevices.add(device); |
| 693 | addLogicalDisplayLocked(device); |
Jeff Brown | 0033a86 | 2014-10-08 12:06:39 -0700 | [diff] [blame] | 694 | Runnable work = updateDisplayStateLocked(device); |
| 695 | if (work != null) { |
| 696 | work.run(); |
| 697 | } |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 698 | scheduleTraversalLocked(false); |
| 699 | } |
| 700 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 701 | private void handleDisplayDeviceChanged(DisplayDevice device) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 702 | synchronized (mSyncRoot) { |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 703 | DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 704 | if (!mDisplayDevices.contains(device)) { |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 705 | Slog.w(TAG, "Attempted to change non-existent display device: " + info); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 706 | return; |
| 707 | } |
| 708 | |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 709 | int diff = device.mDebugLastLoggedDeviceInfo.diff(info); |
| 710 | if (diff == DisplayDeviceInfo.DIFF_STATE) { |
| 711 | Slog.i(TAG, "Display device changed state: \"" + info.name |
| 712 | + "\", " + Display.stateToString(info.state)); |
| 713 | } else if (diff != 0) { |
| 714 | Slog.i(TAG, "Display device changed: " + info); |
| 715 | } |
| 716 | device.mDebugLastLoggedDeviceInfo = info; |
Jeff Brown | e87bf03 | 2012-09-20 18:30:13 -0700 | [diff] [blame] | 717 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 718 | device.applyPendingDisplayDeviceInfoChangesLocked(); |
| 719 | if (updateLogicalDisplaysLocked()) { |
Craig Mautner | 65d11b3 | 2012-10-01 13:59:52 -0700 | [diff] [blame] | 720 | scheduleTraversalLocked(false); |
Jeff Brown | 64a55af | 2012-08-26 02:47:39 -0700 | [diff] [blame] | 721 | } |
| 722 | } |
| 723 | } |
| 724 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 725 | private void handleDisplayDeviceRemoved(DisplayDevice device) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 726 | synchronized (mSyncRoot) { |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 727 | handleDisplayDeviceRemovedLocked(device); |
| 728 | } |
| 729 | } |
Jeff Brown | 8e5d33e | 2015-06-10 13:05:50 -0700 | [diff] [blame] | 730 | |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 731 | private void handleDisplayDeviceRemovedLocked(DisplayDevice device) { |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 732 | DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 733 | if (!mDisplayDevices.remove(device)) { |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 734 | Slog.w(TAG, "Attempted to remove non-existent display device: " + info); |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 735 | return; |
| 736 | } |
| 737 | |
Jeff Brown | 10acf6d | 2015-04-14 14:20:47 -0700 | [diff] [blame] | 738 | Slog.i(TAG, "Display device removed: " + info); |
| 739 | device.mDebugLastLoggedDeviceInfo = info; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 740 | |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 741 | updateLogicalDisplaysLocked(); |
| 742 | scheduleTraversalLocked(false); |
| 743 | } |
| 744 | |
Jeff Brown | 8e5d33e | 2015-06-10 13:05:50 -0700 | [diff] [blame] | 745 | private void applyGlobalDisplayStateLocked(List<Runnable> workQueue) { |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 746 | final int count = mDisplayDevices.size(); |
| 747 | for (int i = 0; i < count; i++) { |
| 748 | DisplayDevice device = mDisplayDevices.get(i); |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 749 | Runnable runnable = updateDisplayStateLocked(device); |
| 750 | if (runnable != null) { |
| 751 | workQueue.add(runnable); |
| 752 | } |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 753 | } |
| 754 | } |
| 755 | |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 756 | private Runnable updateDisplayStateLocked(DisplayDevice device) { |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 757 | // Blank or unblank the display immediately to match the state requested |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 758 | // by the display power controller (if known). |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 759 | DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); |
| 760 | if ((info.flags & DisplayDeviceInfo.FLAG_NEVER_BLANK) == 0) { |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 761 | return device.requestDisplayStateLocked(mGlobalDisplayState, mGlobalDisplayBrightness); |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 762 | } |
Jeff Brown | e75926d | 2014-09-18 15:24:49 -0700 | [diff] [blame] | 763 | return null; |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 764 | } |
| 765 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 766 | // Adds a new logical display based on the given display device. |
| 767 | // Sends notifications if needed. |
| 768 | private void addLogicalDisplayLocked(DisplayDevice device) { |
| 769 | DisplayDeviceInfo deviceInfo = device.getDisplayDeviceInfoLocked(); |
| 770 | boolean isDefault = (deviceInfo.flags |
| 771 | & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0; |
| 772 | if (isDefault && mLogicalDisplays.get(Display.DEFAULT_DISPLAY) != null) { |
| 773 | Slog.w(TAG, "Ignoring attempt to add a second default display: " + deviceInfo); |
| 774 | isDefault = false; |
| 775 | } |
| 776 | |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 777 | if (!isDefault && mSingleDisplayDemoMode) { |
| 778 | Slog.i(TAG, "Not creating a logical display for a secondary display " |
| 779 | + " because single display demo mode is enabled: " + deviceInfo); |
| 780 | return; |
| 781 | } |
| 782 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 783 | final int displayId = assignDisplayIdLocked(isDefault); |
| 784 | final int layerStack = assignLayerStackLocked(displayId); |
| 785 | |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 786 | LogicalDisplay display = new LogicalDisplay(displayId, layerStack, device); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 787 | display.updateLocked(mDisplayDevices); |
| 788 | if (!display.isValidLocked()) { |
| 789 | // This should never happen currently. |
| 790 | Slog.w(TAG, "Ignoring display device because the logical display " |
| 791 | + "created from it was not considered valid: " + deviceInfo); |
| 792 | return; |
| 793 | } |
| 794 | |
| 795 | mLogicalDisplays.put(displayId, display); |
| 796 | |
| 797 | // Wake up waitForDefaultDisplay. |
| 798 | if (isDefault) { |
| 799 | mSyncRoot.notifyAll(); |
| 800 | } |
| 801 | |
| 802 | sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_ADDED); |
| 803 | } |
| 804 | |
| 805 | private int assignDisplayIdLocked(boolean isDefault) { |
| 806 | return isDefault ? Display.DEFAULT_DISPLAY : mNextNonDefaultDisplayId++; |
| 807 | } |
| 808 | |
| 809 | private int assignLayerStackLocked(int displayId) { |
| 810 | // Currently layer stacks and display ids are the same. |
| 811 | // This need not be the case. |
| 812 | return displayId; |
| 813 | } |
| 814 | |
| 815 | // Updates all existing logical displays given the current set of display devices. |
| 816 | // Removes invalid logical displays. |
| 817 | // Sends notifications if needed. |
| 818 | private boolean updateLogicalDisplaysLocked() { |
| 819 | boolean changed = false; |
| 820 | for (int i = mLogicalDisplays.size(); i-- > 0; ) { |
| 821 | final int displayId = mLogicalDisplays.keyAt(i); |
| 822 | LogicalDisplay display = mLogicalDisplays.valueAt(i); |
| 823 | |
| 824 | mTempDisplayInfo.copyFrom(display.getDisplayInfoLocked()); |
| 825 | display.updateLocked(mDisplayDevices); |
| 826 | if (!display.isValidLocked()) { |
| 827 | mLogicalDisplays.removeAt(i); |
| 828 | sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_REMOVED); |
| 829 | changed = true; |
| 830 | } else if (!mTempDisplayInfo.equals(display.getDisplayInfoLocked())) { |
| 831 | sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED); |
| 832 | changed = true; |
| 833 | } |
| 834 | } |
| 835 | return changed; |
| 836 | } |
| 837 | |
| 838 | private void performTraversalInTransactionLocked() { |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 839 | // Clear all viewports before configuring displays so that we can keep |
| 840 | // track of which ones we have configured. |
| 841 | clearViewportsLocked(); |
| 842 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 843 | // Configure each display device. |
| 844 | final int count = mDisplayDevices.size(); |
| 845 | for (int i = 0; i < count; i++) { |
| 846 | DisplayDevice device = mDisplayDevices.get(i); |
| 847 | configureDisplayInTransactionLocked(device); |
| 848 | device.performTraversalInTransactionLocked(); |
| 849 | } |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 850 | |
| 851 | // Tell the input system about these new viewports. |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 852 | if (mInputManagerInternal != null) { |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 853 | mHandler.sendEmptyMessage(MSG_UPDATE_VIEWPORT); |
| 854 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 855 | } |
| 856 | |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 857 | private void setDisplayPropertiesInternal(int displayId, boolean hasContent, |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 858 | float requestedRefreshRate, int requestedModeId, boolean inTraversal) { |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 859 | synchronized (mSyncRoot) { |
| 860 | LogicalDisplay display = mLogicalDisplays.get(displayId); |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 861 | if (display == null) { |
| 862 | return; |
| 863 | } |
| 864 | if (display.hasContentLocked() != hasContent) { |
Jeff Brown | 33041bd | 2013-08-02 21:11:14 -0700 | [diff] [blame] | 865 | if (DEBUG) { |
| 866 | Slog.d(TAG, "Display " + displayId + " hasContent flag changed: " |
| 867 | + "hasContent=" + hasContent + ", inTraversal=" + inTraversal); |
| 868 | } |
| 869 | |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 870 | display.setHasContentLocked(hasContent); |
Craig Mautner | 65d11b3 | 2012-10-01 13:59:52 -0700 | [diff] [blame] | 871 | scheduleTraversalLocked(inTraversal); |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 872 | } |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 873 | if (requestedModeId == 0 && requestedRefreshRate != 0) { |
| 874 | // Scan supported modes returned by display.getInfo() to find a mode with the same |
| 875 | // size as the default display mode but with the specified refresh rate instead. |
| 876 | requestedModeId = display.getDisplayInfoLocked().findDefaultModeByRefreshRate( |
| 877 | requestedRefreshRate); |
| 878 | } |
| 879 | if (display.getRequestedModeIdLocked() != requestedModeId) { |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 880 | if (DEBUG) { |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 881 | Slog.d(TAG, "Display " + displayId + " switching to mode " + requestedModeId); |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 882 | } |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 883 | display.setRequestedModeIdLocked(requestedModeId); |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 884 | scheduleTraversalLocked(inTraversal); |
| 885 | } |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 886 | } |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 887 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 888 | |
Filip Gruszczynski | d2e8640 | 2015-02-19 13:05:03 -0800 | [diff] [blame] | 889 | private void setDisplayOffsetsInternal(int displayId, int x, int y) { |
| 890 | synchronized (mSyncRoot) { |
| 891 | LogicalDisplay display = mLogicalDisplays.get(displayId); |
| 892 | if (display == null) { |
| 893 | return; |
| 894 | } |
| 895 | if (display.getDisplayOffsetXLocked() != x |
| 896 | || display.getDisplayOffsetYLocked() != y) { |
| 897 | if (DEBUG) { |
| 898 | Slog.d(TAG, "Display " + displayId + " burn-in offset set to (" |
| 899 | + x + ", " + y + ")"); |
| 900 | } |
| 901 | display.setDisplayOffsetsLocked(x, y); |
| 902 | scheduleTraversalLocked(false); |
| 903 | } |
| 904 | } |
| 905 | } |
| 906 | |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 907 | private void clearViewportsLocked() { |
| 908 | mDefaultViewport.valid = false; |
| 909 | mExternalTouchViewport.valid = false; |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | private void configureDisplayInTransactionLocked(DisplayDevice device) { |
Jeff Brown | d14c8c9 | 2014-01-07 18:13:09 -0800 | [diff] [blame] | 913 | final DisplayDeviceInfo info = device.getDisplayDeviceInfoLocked(); |
| 914 | final boolean ownContent = (info.flags & DisplayDeviceInfo.FLAG_OWN_CONTENT_ONLY) != 0; |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 915 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 916 | // Find the logical display that the display device is showing. |
Jeff Brown | d14c8c9 | 2014-01-07 18:13:09 -0800 | [diff] [blame] | 917 | // Certain displays only ever show their own content. |
Craig Mautner | 722285e | 2012-09-07 13:55:58 -0700 | [diff] [blame] | 918 | LogicalDisplay display = findLogicalDisplayForDeviceLocked(device); |
Jeff Brown | d14c8c9 | 2014-01-07 18:13:09 -0800 | [diff] [blame] | 919 | if (!ownContent) { |
Jeff Brown | a506a6e | 2013-06-04 00:02:38 -0700 | [diff] [blame] | 920 | if (display != null && !display.hasContentLocked()) { |
| 921 | // If the display does not have any content of its own, then |
| 922 | // automatically mirror the default logical display contents. |
| 923 | display = null; |
| 924 | } |
| 925 | if (display == null) { |
| 926 | display = mLogicalDisplays.get(Display.DEFAULT_DISPLAY); |
| 927 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 928 | } |
| 929 | |
| 930 | // Apply the logical display configuration to the display device. |
| 931 | if (display == null) { |
| 932 | // TODO: no logical display for the device, blank it |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 933 | Slog.w(TAG, "Missing logical display to use for physical display device: " |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 934 | + device.getDisplayDeviceInfoLocked()); |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 935 | return; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 936 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 937 | display.configureDisplayInTransactionLocked(device, info.state == Display.STATE_OFF); |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 938 | |
| 939 | // Update the viewports if needed. |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 940 | if (!mDefaultViewport.valid |
| 941 | && (info.flags & DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY) != 0) { |
| 942 | setViewportLocked(mDefaultViewport, display, device); |
| 943 | } |
| 944 | if (!mExternalTouchViewport.valid |
| 945 | && info.touch == DisplayDeviceInfo.TOUCH_EXTERNAL) { |
| 946 | setViewportLocked(mExternalTouchViewport, display, device); |
| 947 | } |
| 948 | } |
| 949 | |
| 950 | private static void setViewportLocked(DisplayViewport viewport, |
| 951 | LogicalDisplay display, DisplayDevice device) { |
| 952 | viewport.valid = true; |
| 953 | viewport.displayId = display.getDisplayIdLocked(); |
| 954 | device.populateViewportLocked(viewport); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 955 | } |
| 956 | |
| 957 | private LogicalDisplay findLogicalDisplayForDeviceLocked(DisplayDevice device) { |
| 958 | final int count = mLogicalDisplays.size(); |
| 959 | for (int i = 0; i < count; i++) { |
| 960 | LogicalDisplay display = mLogicalDisplays.valueAt(i); |
| 961 | if (display.getPrimaryDisplayDeviceLocked() == device) { |
| 962 | return display; |
| 963 | } |
| 964 | } |
| 965 | return null; |
| 966 | } |
| 967 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 968 | private void sendDisplayEventLocked(int displayId, int event) { |
| 969 | Message msg = mHandler.obtainMessage(MSG_DELIVER_DISPLAY_EVENT, displayId, event); |
| 970 | mHandler.sendMessage(msg); |
| 971 | } |
| 972 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 973 | // Requests that performTraversalsInTransactionFromWindowManager be called at a |
| 974 | // later time to apply changes to surfaces and displays. |
Craig Mautner | 65d11b3 | 2012-10-01 13:59:52 -0700 | [diff] [blame] | 975 | private void scheduleTraversalLocked(boolean inTraversal) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 976 | if (!mPendingTraversal && mWindowManagerInternal != null) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 977 | mPendingTraversal = true; |
Craig Mautner | 65d11b3 | 2012-10-01 13:59:52 -0700 | [diff] [blame] | 978 | if (!inTraversal) { |
| 979 | mHandler.sendEmptyMessage(MSG_REQUEST_TRAVERSAL); |
| 980 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 981 | } |
| 982 | } |
| 983 | |
| 984 | // Runs on Handler thread. |
| 985 | // Delivers display event notifications to callbacks. |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 986 | private void deliverDisplayEvent(int displayId, int event) { |
| 987 | if (DEBUG) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 988 | Slog.d(TAG, "Delivering display event: displayId=" |
| 989 | + displayId + ", event=" + event); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 990 | } |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 991 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 992 | // Grab the lock and copy the callbacks. |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 993 | final int count; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 994 | synchronized (mSyncRoot) { |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 995 | count = mCallbacks.size(); |
| 996 | mTempCallbacks.clear(); |
| 997 | for (int i = 0; i < count; i++) { |
| 998 | mTempCallbacks.add(mCallbacks.valueAt(i)); |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 999 | } |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1000 | } |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 1001 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1002 | // After releasing the lock, send the notifications out. |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1003 | for (int i = 0; i < count; i++) { |
| 1004 | mTempCallbacks.get(i).notifyDisplayEventAsync(displayId, event); |
| 1005 | } |
| 1006 | mTempCallbacks.clear(); |
Craig Mautner | 4f67ba6 | 2012-08-02 11:23:00 -0700 | [diff] [blame] | 1007 | } |
| 1008 | |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1009 | private IMediaProjectionManager getProjectionService() { |
| 1010 | if (mProjectionService == null) { |
| 1011 | IBinder b = ServiceManager.getService(Context.MEDIA_PROJECTION_SERVICE); |
| 1012 | mProjectionService = IMediaProjectionManager.Stub.asInterface(b); |
| 1013 | } |
| 1014 | return mProjectionService; |
| 1015 | } |
| 1016 | |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1017 | private void dumpInternal(PrintWriter pw) { |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1018 | pw.println("DISPLAY MANAGER (dumpsys display)"); |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 1019 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1020 | synchronized (mSyncRoot) { |
Jeff Brown | 9e316a1 | 2012-10-08 19:17:06 -0700 | [diff] [blame] | 1021 | pw.println(" mOnlyCode=" + mOnlyCore); |
| 1022 | pw.println(" mSafeMode=" + mSafeMode); |
| 1023 | pw.println(" mPendingTraversal=" + mPendingTraversal); |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1024 | pw.println(" mGlobalDisplayState=" + Display.stateToString(mGlobalDisplayState)); |
Jeff Brown | 9e316a1 | 2012-10-08 19:17:06 -0700 | [diff] [blame] | 1025 | pw.println(" mNextNonDefaultDisplayId=" + mNextNonDefaultDisplayId); |
| 1026 | pw.println(" mDefaultViewport=" + mDefaultViewport); |
| 1027 | pw.println(" mExternalTouchViewport=" + mExternalTouchViewport); |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 1028 | pw.println(" mSingleDisplayDemoMode=" + mSingleDisplayDemoMode); |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 1029 | pw.println(" mWifiDisplayScanRequestCount=" + mWifiDisplayScanRequestCount); |
Jeff Brown | 9e316a1 | 2012-10-08 19:17:06 -0700 | [diff] [blame] | 1030 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1031 | IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " "); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1032 | ipw.increaseIndent(); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1033 | |
| 1034 | pw.println(); |
| 1035 | pw.println("Display Adapters: size=" + mDisplayAdapters.size()); |
Jeff Brown | 848c2dc | 2012-08-19 20:18:08 -0700 | [diff] [blame] | 1036 | for (DisplayAdapter adapter : mDisplayAdapters) { |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1037 | pw.println(" " + adapter.getName()); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1038 | adapter.dumpLocked(ipw); |
Jeff Brown | 848c2dc | 2012-08-19 20:18:08 -0700 | [diff] [blame] | 1039 | } |
Craig Mautner | 9de4936 | 2012-08-02 14:30:30 -0700 | [diff] [blame] | 1040 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1041 | pw.println(); |
| 1042 | pw.println("Display Devices: size=" + mDisplayDevices.size()); |
| 1043 | for (DisplayDevice device : mDisplayDevices) { |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1044 | pw.println(" " + device.getDisplayDeviceInfoLocked()); |
| 1045 | device.dumpLocked(ipw); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1046 | } |
| 1047 | |
| 1048 | final int logicalDisplayCount = mLogicalDisplays.size(); |
| 1049 | pw.println(); |
| 1050 | pw.println("Logical Displays: size=" + logicalDisplayCount); |
| 1051 | for (int i = 0; i < logicalDisplayCount; i++) { |
| 1052 | int displayId = mLogicalDisplays.keyAt(i); |
| 1053 | LogicalDisplay display = mLogicalDisplays.valueAt(i); |
| 1054 | pw.println(" Display " + displayId + ":"); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1055 | display.dumpLocked(ipw); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1056 | } |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 1057 | |
| 1058 | final int callbackCount = mCallbacks.size(); |
| 1059 | pw.println(); |
| 1060 | pw.println("Callbacks: size=" + callbackCount); |
| 1061 | for (int i = 0; i < callbackCount; i++) { |
| 1062 | CallbackRecord callback = mCallbacks.valueAt(i); |
| 1063 | pw.println(" " + i + ": mPid=" + callback.mPid |
| 1064 | + ", mWifiDisplayScanRequested=" + callback.mWifiDisplayScanRequested); |
| 1065 | } |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 1066 | |
| 1067 | if (mDisplayPowerController != null) { |
| 1068 | mDisplayPowerController.dump(pw); |
| 1069 | } |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1070 | } |
| 1071 | } |
| 1072 | |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1073 | /** |
| 1074 | * This is the object that everything in the display manager locks on. |
| 1075 | * We make it an inner class within the {@link DisplayManagerService} to so that it is |
| 1076 | * clear that the object belongs to the display manager service and that it is |
| 1077 | * a unique object with a special purpose. |
| 1078 | */ |
| 1079 | public static final class SyncRoot { |
| 1080 | } |
| 1081 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1082 | private final class DisplayManagerHandler extends Handler { |
| 1083 | public DisplayManagerHandler(Looper looper) { |
| 1084 | super(looper, null, true /*async*/); |
Jeff Brown | 848c2dc | 2012-08-19 20:18:08 -0700 | [diff] [blame] | 1085 | } |
Jeff Brown | bf5740e | 2012-08-19 23:20:02 -0700 | [diff] [blame] | 1086 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1087 | @Override |
| 1088 | public void handleMessage(Message msg) { |
| 1089 | switch (msg.what) { |
| 1090 | case MSG_REGISTER_DEFAULT_DISPLAY_ADAPTER: |
| 1091 | registerDefaultDisplayAdapter(); |
| 1092 | break; |
| 1093 | |
| 1094 | case MSG_REGISTER_ADDITIONAL_DISPLAY_ADAPTERS: |
| 1095 | registerAdditionalDisplayAdapters(); |
| 1096 | break; |
| 1097 | |
| 1098 | case MSG_DELIVER_DISPLAY_EVENT: |
| 1099 | deliverDisplayEvent(msg.arg1, msg.arg2); |
| 1100 | break; |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1101 | |
| 1102 | case MSG_REQUEST_TRAVERSAL: |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1103 | mWindowManagerInternal.requestTraversalFromDisplayManager(); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1104 | break; |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1105 | |
| 1106 | case MSG_UPDATE_VIEWPORT: { |
| 1107 | synchronized (mSyncRoot) { |
| 1108 | mTempDefaultViewport.copyFrom(mDefaultViewport); |
| 1109 | mTempExternalTouchViewport.copyFrom(mExternalTouchViewport); |
| 1110 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1111 | mInputManagerInternal.setDisplayViewports( |
Jeff Brown | d728bf5 | 2012-09-08 18:05:28 -0700 | [diff] [blame] | 1112 | mTempDefaultViewport, mTempExternalTouchViewport); |
| 1113 | break; |
| 1114 | } |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1115 | } |
| 1116 | } |
| 1117 | } |
| 1118 | |
| 1119 | private final class DisplayAdapterListener implements DisplayAdapter.Listener { |
| 1120 | @Override |
| 1121 | public void onDisplayDeviceEvent(DisplayDevice device, int event) { |
| 1122 | switch (event) { |
| 1123 | case DisplayAdapter.DISPLAY_DEVICE_EVENT_ADDED: |
| 1124 | handleDisplayDeviceAdded(device); |
| 1125 | break; |
| 1126 | |
| 1127 | case DisplayAdapter.DISPLAY_DEVICE_EVENT_CHANGED: |
| 1128 | handleDisplayDeviceChanged(device); |
| 1129 | break; |
| 1130 | |
| 1131 | case DisplayAdapter.DISPLAY_DEVICE_EVENT_REMOVED: |
| 1132 | handleDisplayDeviceRemoved(device); |
| 1133 | break; |
| 1134 | } |
| 1135 | } |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1136 | |
| 1137 | @Override |
| 1138 | public void onTraversalRequested() { |
| 1139 | synchronized (mSyncRoot) { |
Craig Mautner | 65d11b3 | 2012-10-01 13:59:52 -0700 | [diff] [blame] | 1140 | scheduleTraversalLocked(false); |
Jeff Brown | 4ed8fe7 | 2012-08-30 18:18:29 -0700 | [diff] [blame] | 1141 | } |
| 1142 | } |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1143 | } |
| 1144 | |
| 1145 | private final class CallbackRecord implements DeathRecipient { |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 1146 | public final int mPid; |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1147 | private final IDisplayManagerCallback mCallback; |
| 1148 | |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 1149 | public boolean mWifiDisplayScanRequested; |
| 1150 | |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1151 | public CallbackRecord(int pid, IDisplayManagerCallback callback) { |
| 1152 | mPid = pid; |
| 1153 | mCallback = callback; |
| 1154 | } |
| 1155 | |
| 1156 | @Override |
| 1157 | public void binderDied() { |
| 1158 | if (DEBUG) { |
| 1159 | Slog.d(TAG, "Display listener for pid " + mPid + " died."); |
| 1160 | } |
Jeff Brown | ce468a3 | 2013-11-21 16:42:03 -0800 | [diff] [blame] | 1161 | onCallbackDied(this); |
Jeff Brown | bd6e150 | 2012-08-28 03:27:37 -0700 | [diff] [blame] | 1162 | } |
| 1163 | |
| 1164 | public void notifyDisplayEventAsync(int displayId, int event) { |
| 1165 | try { |
| 1166 | mCallback.onDisplayEvent(displayId, event); |
| 1167 | } catch (RemoteException ex) { |
| 1168 | Slog.w(TAG, "Failed to notify process " |
| 1169 | + mPid + " that displays changed, assuming it died.", ex); |
| 1170 | binderDied(); |
| 1171 | } |
| 1172 | } |
| 1173 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1174 | |
| 1175 | private final class BinderService extends IDisplayManager.Stub { |
| 1176 | /** |
| 1177 | * Returns information about the specified logical display. |
| 1178 | * |
| 1179 | * @param displayId The logical display id. |
| 1180 | * @return The logical display info, or null if the display does not exist. The |
| 1181 | * returned object must be treated as immutable. |
| 1182 | */ |
| 1183 | @Override // Binder call |
| 1184 | public DisplayInfo getDisplayInfo(int displayId) { |
| 1185 | final int callingUid = Binder.getCallingUid(); |
| 1186 | final long token = Binder.clearCallingIdentity(); |
| 1187 | try { |
| 1188 | return getDisplayInfoInternal(displayId, callingUid); |
| 1189 | } finally { |
| 1190 | Binder.restoreCallingIdentity(token); |
| 1191 | } |
| 1192 | } |
| 1193 | |
| 1194 | /** |
| 1195 | * Returns the list of all display ids. |
| 1196 | */ |
| 1197 | @Override // Binder call |
| 1198 | public int[] getDisplayIds() { |
| 1199 | final int callingUid = Binder.getCallingUid(); |
| 1200 | final long token = Binder.clearCallingIdentity(); |
| 1201 | try { |
| 1202 | return getDisplayIdsInternal(callingUid); |
| 1203 | } finally { |
| 1204 | Binder.restoreCallingIdentity(token); |
| 1205 | } |
| 1206 | } |
| 1207 | |
| 1208 | @Override // Binder call |
| 1209 | public void registerCallback(IDisplayManagerCallback callback) { |
| 1210 | if (callback == null) { |
| 1211 | throw new IllegalArgumentException("listener must not be null"); |
| 1212 | } |
| 1213 | |
| 1214 | final int callingPid = Binder.getCallingPid(); |
| 1215 | final long token = Binder.clearCallingIdentity(); |
| 1216 | try { |
| 1217 | registerCallbackInternal(callback, callingPid); |
| 1218 | } finally { |
| 1219 | Binder.restoreCallingIdentity(token); |
| 1220 | } |
| 1221 | } |
| 1222 | |
| 1223 | @Override // Binder call |
| 1224 | public void startWifiDisplayScan() { |
| 1225 | mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY, |
| 1226 | "Permission required to start wifi display scans"); |
| 1227 | |
| 1228 | final int callingPid = Binder.getCallingPid(); |
| 1229 | final long token = Binder.clearCallingIdentity(); |
| 1230 | try { |
| 1231 | startWifiDisplayScanInternal(callingPid); |
| 1232 | } finally { |
| 1233 | Binder.restoreCallingIdentity(token); |
| 1234 | } |
| 1235 | } |
| 1236 | |
| 1237 | @Override // Binder call |
| 1238 | public void stopWifiDisplayScan() { |
| 1239 | mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY, |
| 1240 | "Permission required to stop wifi display scans"); |
| 1241 | |
| 1242 | final int callingPid = Binder.getCallingPid(); |
| 1243 | final long token = Binder.clearCallingIdentity(); |
| 1244 | try { |
| 1245 | stopWifiDisplayScanInternal(callingPid); |
| 1246 | } finally { |
| 1247 | Binder.restoreCallingIdentity(token); |
| 1248 | } |
| 1249 | } |
| 1250 | |
| 1251 | @Override // Binder call |
| 1252 | public void connectWifiDisplay(String address) { |
| 1253 | if (address == null) { |
| 1254 | throw new IllegalArgumentException("address must not be null"); |
| 1255 | } |
| 1256 | mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY, |
| 1257 | "Permission required to connect to a wifi display"); |
| 1258 | |
| 1259 | final long token = Binder.clearCallingIdentity(); |
| 1260 | try { |
| 1261 | connectWifiDisplayInternal(address); |
| 1262 | } finally { |
| 1263 | Binder.restoreCallingIdentity(token); |
| 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | @Override // Binder call |
| 1268 | public void disconnectWifiDisplay() { |
| 1269 | // This request does not require special permissions. |
| 1270 | // Any app can request disconnection from the currently active wifi display. |
| 1271 | // This exception should no longer be needed once wifi display control moves |
| 1272 | // to the media router service. |
| 1273 | |
| 1274 | final long token = Binder.clearCallingIdentity(); |
| 1275 | try { |
| 1276 | disconnectWifiDisplayInternal(); |
| 1277 | } finally { |
| 1278 | Binder.restoreCallingIdentity(token); |
| 1279 | } |
| 1280 | } |
| 1281 | |
| 1282 | @Override // Binder call |
| 1283 | public void renameWifiDisplay(String address, String alias) { |
| 1284 | if (address == null) { |
| 1285 | throw new IllegalArgumentException("address must not be null"); |
| 1286 | } |
| 1287 | mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY, |
| 1288 | "Permission required to rename to a wifi display"); |
| 1289 | |
| 1290 | final long token = Binder.clearCallingIdentity(); |
| 1291 | try { |
| 1292 | renameWifiDisplayInternal(address, alias); |
| 1293 | } finally { |
| 1294 | Binder.restoreCallingIdentity(token); |
| 1295 | } |
| 1296 | } |
| 1297 | |
| 1298 | @Override // Binder call |
| 1299 | public void forgetWifiDisplay(String address) { |
| 1300 | if (address == null) { |
| 1301 | throw new IllegalArgumentException("address must not be null"); |
| 1302 | } |
| 1303 | mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY, |
| 1304 | "Permission required to forget to a wifi display"); |
| 1305 | |
| 1306 | final long token = Binder.clearCallingIdentity(); |
| 1307 | try { |
| 1308 | forgetWifiDisplayInternal(address); |
| 1309 | } finally { |
| 1310 | Binder.restoreCallingIdentity(token); |
| 1311 | } |
| 1312 | } |
| 1313 | |
| 1314 | @Override // Binder call |
| 1315 | public void pauseWifiDisplay() { |
| 1316 | mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY, |
| 1317 | "Permission required to pause a wifi display session"); |
| 1318 | |
| 1319 | final long token = Binder.clearCallingIdentity(); |
| 1320 | try { |
| 1321 | pauseWifiDisplayInternal(); |
| 1322 | } finally { |
| 1323 | Binder.restoreCallingIdentity(token); |
| 1324 | } |
| 1325 | } |
| 1326 | |
| 1327 | @Override // Binder call |
| 1328 | public void resumeWifiDisplay() { |
| 1329 | mContext.enforceCallingOrSelfPermission(Manifest.permission.CONFIGURE_WIFI_DISPLAY, |
| 1330 | "Permission required to resume a wifi display session"); |
| 1331 | |
| 1332 | final long token = Binder.clearCallingIdentity(); |
| 1333 | try { |
| 1334 | resumeWifiDisplayInternal(); |
| 1335 | } finally { |
| 1336 | Binder.restoreCallingIdentity(token); |
| 1337 | } |
| 1338 | } |
| 1339 | |
| 1340 | @Override // Binder call |
| 1341 | public WifiDisplayStatus getWifiDisplayStatus() { |
| 1342 | // This request does not require special permissions. |
| 1343 | // Any app can get information about available wifi displays. |
| 1344 | |
| 1345 | final long token = Binder.clearCallingIdentity(); |
| 1346 | try { |
| 1347 | return getWifiDisplayStatusInternal(); |
| 1348 | } finally { |
| 1349 | Binder.restoreCallingIdentity(token); |
| 1350 | } |
| 1351 | } |
| 1352 | |
| 1353 | @Override // Binder call |
Michael Wright | 58e829f | 2015-09-15 00:13:26 +0100 | [diff] [blame^] | 1354 | public void requestColorTransform(int displayId, int colorTransformId) { |
| 1355 | mContext.enforceCallingOrSelfPermission( |
| 1356 | Manifest.permission.CONFIGURE_DISPLAY_COLOR_TRANSFORM, |
| 1357 | "Permission required to change the display color transform"); |
| 1358 | final long token = Binder.clearCallingIdentity(); |
| 1359 | try { |
| 1360 | requestColorTransformInternal(displayId, colorTransformId); |
| 1361 | } finally { |
| 1362 | Binder.restoreCallingIdentity(token); |
| 1363 | } |
| 1364 | } |
| 1365 | |
| 1366 | @Override // Binder call |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1367 | public int createVirtualDisplay(IVirtualDisplayCallback callback, |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1368 | IMediaProjection projection, String packageName, String name, |
| 1369 | int width, int height, int densityDpi, Surface surface, int flags) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1370 | final int callingUid = Binder.getCallingUid(); |
| 1371 | if (!validatePackageName(callingUid, packageName)) { |
| 1372 | throw new SecurityException("packageName must match the calling uid"); |
| 1373 | } |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1374 | if (callback == null) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1375 | throw new IllegalArgumentException("appToken must not be null"); |
| 1376 | } |
| 1377 | if (TextUtils.isEmpty(name)) { |
| 1378 | throw new IllegalArgumentException("name must be non-null and non-empty"); |
| 1379 | } |
| 1380 | if (width <= 0 || height <= 0 || densityDpi <= 0) { |
| 1381 | throw new IllegalArgumentException("width, height, and densityDpi must be " |
| 1382 | + "greater than 0"); |
| 1383 | } |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1384 | |
Michael Wright | 6720be4 | 2014-07-29 19:14:16 -0700 | [diff] [blame] | 1385 | if ((flags & DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC) != 0) { |
| 1386 | flags |= DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR; |
| 1387 | } |
| 1388 | if ((flags & DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY) != 0) { |
| 1389 | flags &= ~DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR; |
| 1390 | } |
| 1391 | |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1392 | if (projection != null) { |
| 1393 | try { |
| 1394 | if (!getProjectionService().isValidMediaProjection(projection)) { |
| 1395 | throw new SecurityException("Invalid media projection"); |
| 1396 | } |
Michael Wright | 6720be4 | 2014-07-29 19:14:16 -0700 | [diff] [blame] | 1397 | flags = projection.applyVirtualDisplayFlags(flags); |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1398 | } catch (RemoteException e) { |
Michael Wright | 6720be4 | 2014-07-29 19:14:16 -0700 | [diff] [blame] | 1399 | throw new SecurityException("unable to validate media projection or flags"); |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1400 | } |
| 1401 | } |
| 1402 | |
Michael Wright | 6720be4 | 2014-07-29 19:14:16 -0700 | [diff] [blame] | 1403 | if (callingUid != Process.SYSTEM_UID && |
| 1404 | (flags & DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR) != 0) { |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1405 | if (!canProjectVideo(projection)) { |
| 1406 | throw new SecurityException("Requires CAPTURE_VIDEO_OUTPUT or " |
| 1407 | + "CAPTURE_SECURE_VIDEO_OUTPUT permission, or an appropriate " |
| 1408 | + "MediaProjection token in order to create a screen sharing virtual " |
| 1409 | + "display."); |
| 1410 | } |
| 1411 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1412 | if ((flags & DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE) != 0) { |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1413 | if (!canProjectSecureVideo(projection)) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1414 | throw new SecurityException("Requires CAPTURE_SECURE_VIDEO_OUTPUT " |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1415 | + "or an appropriate MediaProjection token to create a " |
| 1416 | + "secure virtual display."); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1417 | } |
| 1418 | } |
| 1419 | |
| 1420 | final long token = Binder.clearCallingIdentity(); |
| 1421 | try { |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1422 | return createVirtualDisplayInternal(callback, projection, callingUid, |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1423 | packageName, name, width, height, densityDpi, surface, flags); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1424 | } finally { |
| 1425 | Binder.restoreCallingIdentity(token); |
| 1426 | } |
| 1427 | } |
| 1428 | |
| 1429 | @Override // Binder call |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1430 | public void resizeVirtualDisplay(IVirtualDisplayCallback callback, |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 1431 | int width, int height, int densityDpi) { |
| 1432 | final long token = Binder.clearCallingIdentity(); |
| 1433 | try { |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1434 | resizeVirtualDisplayInternal(callback.asBinder(), width, height, densityDpi); |
Michael Wright | 01e840f | 2014-06-26 16:03:25 -0700 | [diff] [blame] | 1435 | } finally { |
| 1436 | Binder.restoreCallingIdentity(token); |
| 1437 | } |
| 1438 | } |
| 1439 | |
| 1440 | @Override // Binder call |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1441 | public void setVirtualDisplaySurface(IVirtualDisplayCallback callback, Surface surface) { |
Jeff Brown | 92207df | 2014-04-16 13:16:07 -0700 | [diff] [blame] | 1442 | final long token = Binder.clearCallingIdentity(); |
| 1443 | try { |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1444 | setVirtualDisplaySurfaceInternal(callback.asBinder(), surface); |
Jeff Brown | 92207df | 2014-04-16 13:16:07 -0700 | [diff] [blame] | 1445 | } finally { |
| 1446 | Binder.restoreCallingIdentity(token); |
| 1447 | } |
| 1448 | } |
| 1449 | |
| 1450 | @Override // Binder call |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1451 | public void releaseVirtualDisplay(IVirtualDisplayCallback callback) { |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1452 | final long token = Binder.clearCallingIdentity(); |
| 1453 | try { |
Michael Wright | 75ee9fc | 2014-09-01 19:55:22 -0700 | [diff] [blame] | 1454 | releaseVirtualDisplayInternal(callback.asBinder()); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1455 | } finally { |
| 1456 | Binder.restoreCallingIdentity(token); |
| 1457 | } |
| 1458 | } |
| 1459 | |
| 1460 | @Override // Binder call |
| 1461 | public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) { |
| 1462 | if (mContext == null |
| 1463 | || mContext.checkCallingOrSelfPermission(Manifest.permission.DUMP) |
| 1464 | != PackageManager.PERMISSION_GRANTED) { |
| 1465 | pw.println("Permission Denial: can't dump DisplayManager from from pid=" |
| 1466 | + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()); |
| 1467 | return; |
| 1468 | } |
| 1469 | |
| 1470 | final long token = Binder.clearCallingIdentity(); |
| 1471 | try { |
| 1472 | dumpInternal(pw); |
| 1473 | } finally { |
| 1474 | Binder.restoreCallingIdentity(token); |
| 1475 | } |
| 1476 | } |
| 1477 | |
| 1478 | private boolean validatePackageName(int uid, String packageName) { |
| 1479 | if (packageName != null) { |
| 1480 | String[] packageNames = mContext.getPackageManager().getPackagesForUid(uid); |
| 1481 | if (packageNames != null) { |
| 1482 | for (String n : packageNames) { |
| 1483 | if (n.equals(packageName)) { |
| 1484 | return true; |
| 1485 | } |
| 1486 | } |
| 1487 | } |
| 1488 | } |
| 1489 | return false; |
| 1490 | } |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1491 | |
| 1492 | private boolean canProjectVideo(IMediaProjection projection) { |
| 1493 | if (projection != null) { |
| 1494 | try { |
| 1495 | if (projection.canProjectVideo()) { |
| 1496 | return true; |
| 1497 | } |
| 1498 | } catch (RemoteException e) { |
| 1499 | Slog.e(TAG, "Unable to query projection service for permissions", e); |
| 1500 | } |
| 1501 | } |
| 1502 | if (mContext.checkCallingPermission( |
| 1503 | android.Manifest.permission.CAPTURE_VIDEO_OUTPUT) |
Michael Wright | 0ccc2b0 | 2014-07-24 18:20:41 -0700 | [diff] [blame] | 1504 | == PackageManager.PERMISSION_GRANTED) { |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1505 | return true; |
| 1506 | } |
| 1507 | return canProjectSecureVideo(projection); |
| 1508 | } |
| 1509 | |
| 1510 | private boolean canProjectSecureVideo(IMediaProjection projection) { |
| 1511 | if (projection != null) { |
| 1512 | try { |
| 1513 | if (projection.canProjectSecureVideo()){ |
| 1514 | return true; |
| 1515 | } |
| 1516 | } catch (RemoteException e) { |
| 1517 | Slog.e(TAG, "Unable to query projection service for permissions", e); |
| 1518 | } |
| 1519 | } |
| 1520 | return mContext.checkCallingPermission( |
| 1521 | android.Manifest.permission.CAPTURE_SECURE_VIDEO_OUTPUT) |
Michael Wright | 0ccc2b0 | 2014-07-24 18:20:41 -0700 | [diff] [blame] | 1522 | == PackageManager.PERMISSION_GRANTED; |
Michael Wright | c39d47a | 2014-07-08 18:07:36 -0700 | [diff] [blame] | 1523 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1524 | } |
| 1525 | |
| 1526 | private final class LocalService extends DisplayManagerInternal { |
| 1527 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1528 | public void initPowerManagement(final DisplayPowerCallbacks callbacks, Handler handler, |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 1529 | SensorManager sensorManager) { |
| 1530 | synchronized (mSyncRoot) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1531 | DisplayBlanker blanker = new DisplayBlanker() { |
| 1532 | @Override |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 1533 | public void requestDisplayState(int state, int brightness) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1534 | // The order of operations is important for legacy reasons. |
| 1535 | if (state == Display.STATE_OFF) { |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 1536 | requestGlobalDisplayStateInternal(state, brightness); |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1537 | } |
| 1538 | |
| 1539 | callbacks.onDisplayStateChange(state); |
| 1540 | |
| 1541 | if (state != Display.STATE_OFF) { |
Jeff Brown | 5d6443b | 2015-04-10 20:15:01 -0700 | [diff] [blame] | 1542 | requestGlobalDisplayStateInternal(state, brightness); |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1543 | } |
| 1544 | } |
| 1545 | }; |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 1546 | mDisplayPowerController = new DisplayPowerController( |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1547 | mContext, callbacks, handler, sensorManager, blanker); |
Jeff Brown | ad9ef19 | 2014-04-08 17:26:30 -0700 | [diff] [blame] | 1548 | } |
| 1549 | } |
| 1550 | |
| 1551 | @Override |
| 1552 | public boolean requestPowerState(DisplayPowerRequest request, |
| 1553 | boolean waitForNegativeProximity) { |
| 1554 | return mDisplayPowerController.requestPowerState(request, |
| 1555 | waitForNegativeProximity); |
| 1556 | } |
| 1557 | |
| 1558 | @Override |
| 1559 | public boolean isProximitySensorAvailable() { |
| 1560 | return mDisplayPowerController.isProximitySensorAvailable(); |
| 1561 | } |
| 1562 | |
| 1563 | @Override |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1564 | public DisplayInfo getDisplayInfo(int displayId) { |
| 1565 | return getDisplayInfoInternal(displayId, Process.myUid()); |
| 1566 | } |
| 1567 | |
| 1568 | @Override |
| 1569 | public void registerDisplayTransactionListener(DisplayTransactionListener listener) { |
| 1570 | if (listener == null) { |
| 1571 | throw new IllegalArgumentException("listener must not be null"); |
| 1572 | } |
| 1573 | |
| 1574 | registerDisplayTransactionListenerInternal(listener); |
| 1575 | } |
| 1576 | |
| 1577 | @Override |
| 1578 | public void unregisterDisplayTransactionListener(DisplayTransactionListener listener) { |
| 1579 | if (listener == null) { |
| 1580 | throw new IllegalArgumentException("listener must not be null"); |
| 1581 | } |
| 1582 | |
| 1583 | unregisterDisplayTransactionListenerInternal(listener); |
| 1584 | } |
| 1585 | |
| 1586 | @Override |
| 1587 | public void setDisplayInfoOverrideFromWindowManager(int displayId, DisplayInfo info) { |
| 1588 | setDisplayInfoOverrideFromWindowManagerInternal(displayId, info); |
| 1589 | } |
| 1590 | |
| 1591 | @Override |
| 1592 | public void performTraversalInTransactionFromWindowManager() { |
| 1593 | performTraversalInTransactionFromWindowManagerInternal(); |
| 1594 | } |
| 1595 | |
| 1596 | @Override |
Michael Wright | 3f145a2 | 2014-07-22 19:46:03 -0700 | [diff] [blame] | 1597 | public void setDisplayProperties(int displayId, boolean hasContent, |
P.Y. Laligand | b3b9eb3 | 2015-05-11 15:02:07 -0700 | [diff] [blame] | 1598 | float requestedRefreshRate, int requestedMode, boolean inTraversal) { |
| 1599 | setDisplayPropertiesInternal(displayId, hasContent, requestedRefreshRate, |
| 1600 | requestedMode, inTraversal); |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1601 | } |
Filip Gruszczynski | d2e8640 | 2015-02-19 13:05:03 -0800 | [diff] [blame] | 1602 | |
| 1603 | @Override |
| 1604 | public void setDisplayOffsets(int displayId, int x, int y) { |
| 1605 | setDisplayOffsetsInternal(displayId, x, y); |
| 1606 | } |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 1607 | } |
Jeff Brown | fa25bf5 | 2012-07-23 19:26:30 -0700 | [diff] [blame] | 1608 | } |