/** * Overrides the display information of a particular logical display. This is used by the window * manager to control the size and characteristics of the default display. It is expected to apply * the requested change to the display information synchronously so that applications will * immediately observe the new state. * * @param displayId The logical display id. * @param info The new data to be stored. */ public void setDisplayInfoOverrideFromWindowManager(int displayId, DisplayInfo info) { synchronized (mSyncRoot) { LogicalDisplay display = mLogicalDisplays.get(displayId); if (display != null) { mTempDisplayInfo.copyFrom(display.getDisplayInfoLocked()); display.setDisplayInfoOverrideFromWindowManagerLocked(info); if (!mTempDisplayInfo.equals(display.getDisplayInfoLocked())) { sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED); scheduleTraversalLocked(false); } } } }
// Updates all existing logical displays given the current set of display devices. // Removes invalid logical displays. // Sends notifications if needed. private boolean updateLogicalDisplaysLocked() { boolean changed = false; for (int i = mLogicalDisplays.size(); i-- > 0; ) { final int displayId = mLogicalDisplays.keyAt(i); LogicalDisplay display = mLogicalDisplays.valueAt(i); mTempDisplayInfo.copyFrom(display.getDisplayInfoLocked()); display.updateLocked(mDisplayDevices); if (!display.isValidLocked()) { mLogicalDisplays.removeAt(i); sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_REMOVED); changed = true; } else if (!mTempDisplayInfo.equals(display.getDisplayInfoLocked())) { sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED); changed = true; } } return changed; }
/** * Returns information about the specified logical display. * * @param displayId The logical display id. * @return The logical display info, or null if the display does not exist. The returned object * must be treated as immutable. */ @Override // Binder call public DisplayInfo getDisplayInfo(int displayId) { synchronized (mSyncRoot) { LogicalDisplay display = mLogicalDisplays.get(displayId); if (display != null) { return display.getDisplayInfoLocked(); } return null; } }
private DisplayInfo getDisplayInfoInternal(int displayId, int callingUid) { synchronized (mSyncRoot) { LogicalDisplay display = mLogicalDisplays.get(displayId); if (display != null) { DisplayInfo info = display.getDisplayInfoLocked(); if (info.hasAccess(callingUid)) { return info; } } return null; } }
private int[] getDisplayIdsInternal(int callingUid) { synchronized (mSyncRoot) { final int count = mLogicalDisplays.size(); int[] displayIds = new int[count]; int n = 0; for (int i = 0; i < count; i++) { LogicalDisplay display = mLogicalDisplays.valueAt(i); DisplayInfo info = display.getDisplayInfoLocked(); if (info.hasAccess(callingUid)) { displayIds[n++] = mLogicalDisplays.keyAt(i); } } if (n != count) { displayIds = Arrays.copyOfRange(displayIds, 0, n); } return displayIds; } }