Merge "Revert "Do not send updates for disabled displays."" into tm-dev
This commit is contained in:
@@ -559,21 +559,18 @@ public final class DisplayManager {
|
|||||||
* @see #DISPLAY_CATEGORY_PRESENTATION
|
* @see #DISPLAY_CATEGORY_PRESENTATION
|
||||||
*/
|
*/
|
||||||
public Display[] getDisplays(String category) {
|
public Display[] getDisplays(String category) {
|
||||||
boolean includeDisabledDisplays = (category != null
|
final int[] displayIds = mGlobal.getDisplayIds();
|
||||||
&& category.equals(DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED));
|
|
||||||
final int[] displayIds = mGlobal.getDisplayIds(includeDisabledDisplays);
|
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
try {
|
try {
|
||||||
if (category != null && category.equals(DISPLAY_CATEGORY_PRESENTATION)) {
|
if (category == null
|
||||||
|
|| DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED.equals(category)) {
|
||||||
|
addAllDisplaysLocked(mTempDisplays, displayIds);
|
||||||
|
} else if (category.equals(DISPLAY_CATEGORY_PRESENTATION)) {
|
||||||
addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_WIFI);
|
addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_WIFI);
|
||||||
addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_EXTERNAL);
|
addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_EXTERNAL);
|
||||||
addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_OVERLAY);
|
addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_OVERLAY);
|
||||||
addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_VIRTUAL);
|
addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_VIRTUAL);
|
||||||
addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_INTERNAL);
|
addPresentationDisplaysLocked(mTempDisplays, displayIds, Display.TYPE_INTERNAL);
|
||||||
} else if ((category == null
|
|
||||||
|| DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED.equals(category))) {
|
|
||||||
// All displays requested.
|
|
||||||
addAllDisplaysLocked(mTempDisplays, displayIds);
|
|
||||||
}
|
}
|
||||||
return mTempDisplays.toArray(new Display[mTempDisplays.size()]);
|
return mTempDisplays.toArray(new Display[mTempDisplays.size()]);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -206,16 +206,6 @@ public final class DisplayManagerGlobal {
|
|||||||
*/
|
*/
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public int[] getDisplayIds() {
|
public int[] getDisplayIds() {
|
||||||
return getDisplayIds(/* includeDisabledDisplays= */ false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all valid logical display ids and invalid ones if specified.
|
|
||||||
*
|
|
||||||
* @return An array containing all display ids.
|
|
||||||
*/
|
|
||||||
@UnsupportedAppUsage
|
|
||||||
public int[] getDisplayIds(boolean includeDisabledDisplays) {
|
|
||||||
try {
|
try {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (USE_CACHE) {
|
if (USE_CACHE) {
|
||||||
@@ -224,8 +214,7 @@ public final class DisplayManagerGlobal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] displayIds =
|
int[] displayIds = mDm.getDisplayIds();
|
||||||
mDm.getDisplayIds(includeDisabledDisplays);
|
|
||||||
if (USE_CACHE) {
|
if (USE_CACHE) {
|
||||||
mDisplayIdCache = displayIds;
|
mDisplayIdCache = displayIds;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import android.view.Surface;
|
|||||||
interface IDisplayManager {
|
interface IDisplayManager {
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
DisplayInfo getDisplayInfo(int displayId);
|
DisplayInfo getDisplayInfo(int displayId);
|
||||||
int[] getDisplayIds(boolean includeDisabled);
|
int[] getDisplayIds();
|
||||||
|
|
||||||
boolean isUidPresentOnDisplay(int uid, int displayId);
|
boolean isUidPresentOnDisplay(int uid, int displayId);
|
||||||
|
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ public final class DisplayManagerService extends SystemService {
|
|||||||
mUiHandler = UiThread.getHandler();
|
mUiHandler = UiThread.getHandler();
|
||||||
mDisplayDeviceRepo = new DisplayDeviceRepository(mSyncRoot, mPersistentDataStore);
|
mDisplayDeviceRepo = new DisplayDeviceRepository(mSyncRoot, mPersistentDataStore);
|
||||||
mLogicalDisplayMapper = new LogicalDisplayMapper(mContext, mDisplayDeviceRepo,
|
mLogicalDisplayMapper = new LogicalDisplayMapper(mContext, mDisplayDeviceRepo,
|
||||||
new LogicalDisplayListener(), mSyncRoot, mHandler, new DeviceStateToLayoutMap());
|
new LogicalDisplayListener(), mSyncRoot, mHandler);
|
||||||
mDisplayModeDirector = new DisplayModeDirector(context, mHandler);
|
mDisplayModeDirector = new DisplayModeDirector(context, mHandler);
|
||||||
mBrightnessSynchronizer = new BrightnessSynchronizer(mContext);
|
mBrightnessSynchronizer = new BrightnessSynchronizer(mContext);
|
||||||
Resources resources = mContext.getResources();
|
Resources resources = mContext.getResources();
|
||||||
@@ -945,8 +945,7 @@ public final class DisplayManagerService extends SystemService {
|
|||||||
|
|
||||||
private DisplayInfo getDisplayInfoInternal(int displayId, int callingUid) {
|
private DisplayInfo getDisplayInfoInternal(int displayId, int callingUid) {
|
||||||
synchronized (mSyncRoot) {
|
synchronized (mSyncRoot) {
|
||||||
final LogicalDisplay display = mLogicalDisplayMapper.getDisplayLocked(displayId,
|
final LogicalDisplay display = mLogicalDisplayMapper.getDisplayLocked(displayId);
|
||||||
/* includeDisabledDisplays= */ true);
|
|
||||||
if (display != null) {
|
if (display != null) {
|
||||||
final DisplayInfo info =
|
final DisplayInfo info =
|
||||||
getDisplayInfoForFrameRateOverride(display.getFrameRateOverrides(),
|
getDisplayInfoForFrameRateOverride(display.getFrameRateOverrides(),
|
||||||
@@ -2129,19 +2128,17 @@ public final class DisplayManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void resetBrightnessConfigurations() {
|
void resetBrightnessConfigurations() {
|
||||||
synchronized (mSyncRoot) {
|
|
||||||
mPersistentDataStore.setBrightnessConfigurationForUser(null, mContext.getUserId(),
|
mPersistentDataStore.setBrightnessConfigurationForUser(null, mContext.getUserId(),
|
||||||
mContext.getPackageName());
|
mContext.getPackageName());
|
||||||
mLogicalDisplayMapper.forEachLocked((logicalDisplay -> {
|
mLogicalDisplayMapper.forEachLocked((logicalDisplay -> {
|
||||||
if (logicalDisplay.getDisplayInfoLocked().type != Display.TYPE_INTERNAL) {
|
if (logicalDisplay.getDisplayInfoLocked().type != Display.TYPE_INTERNAL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String uniqueId = logicalDisplay.getPrimaryDisplayDeviceLocked().getUniqueId();
|
final String uniqueId = logicalDisplay.getPrimaryDisplayDeviceLocked().getUniqueId();
|
||||||
setBrightnessConfigurationForDisplayInternal(null, uniqueId, mContext.getUserId(),
|
setBrightnessConfigurationForDisplayInternal(null, uniqueId, mContext.getUserId(),
|
||||||
mContext.getPackageName());
|
mContext.getPackageName());
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void setAutoBrightnessLoggingEnabled(boolean enabled) {
|
void setAutoBrightnessLoggingEnabled(boolean enabled) {
|
||||||
synchronized (mSyncRoot) {
|
synchronized (mSyncRoot) {
|
||||||
@@ -2817,16 +2814,15 @@ public final class DisplayManagerService extends SystemService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of all enabled display ids, and disabled ones if specified.
|
* Returns the list of all display ids.
|
||||||
*/
|
*/
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public int[] getDisplayIds(boolean includeDisabledDisplays) {
|
public int[] getDisplayIds() {
|
||||||
final int callingUid = Binder.getCallingUid();
|
final int callingUid = Binder.getCallingUid();
|
||||||
final long token = Binder.clearCallingIdentity();
|
final long token = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
synchronized (mSyncRoot) {
|
synchronized (mSyncRoot) {
|
||||||
return mLogicalDisplayMapper.getDisplayIdsLocked(callingUid,
|
return mLogicalDisplayMapper.getDisplayIdsLocked(callingUid);
|
||||||
includeDisabledDisplays);
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(token);
|
Binder.restoreCallingIdentity(token);
|
||||||
|
|||||||
@@ -79,12 +79,8 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
private static final int MSG_TRANSITION_TO_PENDING_DEVICE_STATE = 1;
|
private static final int MSG_TRANSITION_TO_PENDING_DEVICE_STATE = 1;
|
||||||
|
|
||||||
private static final int UPDATE_STATE_NEW = 0;
|
private static final int UPDATE_STATE_NEW = 0;
|
||||||
private static final int UPDATE_STATE_UPDATED = 1;
|
private static final int UPDATE_STATE_TRANSITION = 1;
|
||||||
private static final int UPDATE_STATE_DISABLED = 2;
|
private static final int UPDATE_STATE_UPDATED = 2;
|
||||||
|
|
||||||
private static final int UPDATE_STATE_MASK = 0x3;
|
|
||||||
|
|
||||||
private static final int UPDATE_STATE_FLAG_TRANSITION = 0x100;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Temporary display info, used for comparing display configurations.
|
* Temporary display info, used for comparing display configurations.
|
||||||
@@ -170,7 +166,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
|
|
||||||
LogicalDisplayMapper(@NonNull Context context, @NonNull DisplayDeviceRepository repo,
|
LogicalDisplayMapper(@NonNull Context context, @NonNull DisplayDeviceRepository repo,
|
||||||
@NonNull Listener listener, @NonNull DisplayManagerService.SyncRoot syncRoot,
|
@NonNull Listener listener, @NonNull DisplayManagerService.SyncRoot syncRoot,
|
||||||
@NonNull Handler handler, @NonNull DeviceStateToLayoutMap deviceStateToLayoutMap) {
|
@NonNull Handler handler) {
|
||||||
mSyncRoot = syncRoot;
|
mSyncRoot = syncRoot;
|
||||||
mPowerManager = context.getSystemService(PowerManager.class);
|
mPowerManager = context.getSystemService(PowerManager.class);
|
||||||
mInteractive = mPowerManager.isInteractive();
|
mInteractive = mPowerManager.isInteractive();
|
||||||
@@ -185,7 +181,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
mDeviceStatesOnWhichToSleep = toSparseBooleanArray(context.getResources().getIntArray(
|
mDeviceStatesOnWhichToSleep = toSparseBooleanArray(context.getResources().getIntArray(
|
||||||
com.android.internal.R.array.config_deviceStatesOnWhichToSleep));
|
com.android.internal.R.array.config_deviceStatesOnWhichToSleep));
|
||||||
mDisplayDeviceRepo.addListener(this);
|
mDisplayDeviceRepo.addListener(this);
|
||||||
mDeviceStateToLayoutMap = deviceStateToLayoutMap;
|
mDeviceStateToLayoutMap = new DeviceStateToLayoutMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -222,29 +218,10 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LogicalDisplay getDisplayLocked(int displayId) {
|
public LogicalDisplay getDisplayLocked(int displayId) {
|
||||||
return getDisplayLocked(displayId, /* includeDisabled= */ false);
|
return mLogicalDisplays.get(displayId);
|
||||||
}
|
|
||||||
|
|
||||||
LogicalDisplay getDisplayLocked(int displayId, boolean includeDisabled) {
|
|
||||||
LogicalDisplay display = mLogicalDisplays.get(displayId);
|
|
||||||
if (display != null && (display.isEnabled() || includeDisabled)) {
|
|
||||||
return display;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LogicalDisplay getDisplayLocked(DisplayDevice device) {
|
public LogicalDisplay getDisplayLocked(DisplayDevice device) {
|
||||||
return getDisplayLocked(device, /* includeDisabled= */ false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loops through the existing list of displays and returns one that is associated with the
|
|
||||||
* specified display device.
|
|
||||||
*
|
|
||||||
* @param device The display device that should be associated with the LogicalDisplay.
|
|
||||||
* @param includeDisabled True if this method should return disabled displays as well.
|
|
||||||
*/
|
|
||||||
private LogicalDisplay getDisplayLocked(DisplayDevice device, boolean includeDisabled) {
|
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -252,32 +229,18 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
final LogicalDisplay display = mLogicalDisplays.valueAt(i);
|
final LogicalDisplay display = mLogicalDisplays.valueAt(i);
|
||||||
if (display.getPrimaryDisplayDeviceLocked() == device) {
|
if (display.getPrimaryDisplayDeviceLocked() == device) {
|
||||||
if (display.isEnabled() || includeDisabled) {
|
|
||||||
return display;
|
return display;
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns display Ids, defaults to enabled only.
|
|
||||||
public int[] getDisplayIdsLocked(int callingUid) {
|
public int[] getDisplayIdsLocked(int callingUid) {
|
||||||
return getDisplayIdsLocked(callingUid, /* includeDisabledDisplays= */ false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns display Ids, specified whether enabled only, or all displays.
|
|
||||||
public int[] getDisplayIdsLocked(int callingUid, boolean includeDisabledDisplays) {
|
|
||||||
final int count = mLogicalDisplays.size();
|
final int count = mLogicalDisplays.size();
|
||||||
int[] displayIds = new int[count];
|
int[] displayIds = new int[count];
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
LogicalDisplay display = mLogicalDisplays.valueAt(i);
|
LogicalDisplay display = mLogicalDisplays.valueAt(i);
|
||||||
if (!includeDisabledDisplays && !display.isEnabled()) {
|
|
||||||
continue; // Ignore disabled displays.
|
|
||||||
}
|
|
||||||
|
|
||||||
DisplayInfo info = display.getDisplayInfoLocked();
|
DisplayInfo info = display.getDisplayInfoLocked();
|
||||||
if (info.hasAccess(callingUid)) {
|
if (info.hasAccess(callingUid)) {
|
||||||
displayIds[n++] = mLogicalDisplays.keyAt(i);
|
displayIds[n++] = mLogicalDisplays.keyAt(i);
|
||||||
@@ -292,10 +255,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
public void forEachLocked(Consumer<LogicalDisplay> consumer) {
|
public void forEachLocked(Consumer<LogicalDisplay> consumer) {
|
||||||
final int count = mLogicalDisplays.size();
|
final int count = mLogicalDisplays.size();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
LogicalDisplay display = mLogicalDisplays.valueAt(i);
|
consumer.accept(mLogicalDisplays.valueAt(i));
|
||||||
if (display.isEnabled()) {
|
|
||||||
consumer.accept(display);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,8 +316,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
|
|
||||||
// Find or create the LogicalDisplay to map the DisplayDevice to.
|
// Find or create the LogicalDisplay to map the DisplayDevice to.
|
||||||
final int logicalDisplayId = displayLayout.getLogicalDisplayId();
|
final int logicalDisplayId = displayLayout.getLogicalDisplayId();
|
||||||
final LogicalDisplay logicalDisplay =
|
final LogicalDisplay logicalDisplay = getDisplayLocked(logicalDisplayId);
|
||||||
getDisplayLocked(logicalDisplayId, /* includeDisabled= */ true);
|
|
||||||
if (logicalDisplay == null) {
|
if (logicalDisplay == null) {
|
||||||
Slog.w(TAG, "The logical display (" + address + "), is not available"
|
Slog.w(TAG, "The logical display (" + address + "), is not available"
|
||||||
+ " for the display state " + deviceState);
|
+ " for the display state " + deviceState);
|
||||||
@@ -493,7 +452,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the device should be put to sleep or not.
|
* Returns if the device should be put to sleep or not.
|
||||||
*
|
*
|
||||||
* Includes a check to verify that the device state that we are moving to, {@code pendingState},
|
* Includes a check to verify that the device state that we are moving to, {@code pendingState},
|
||||||
* is the same as the physical state of the device, {@code baseState}. Different values for
|
* is the same as the physical state of the device, {@code baseState}. Different values for
|
||||||
@@ -639,12 +598,9 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
display.getNonOverrideDisplayInfoLocked(mTempNonOverrideDisplayInfo);
|
display.getNonOverrideDisplayInfoLocked(mTempNonOverrideDisplayInfo);
|
||||||
|
|
||||||
display.updateLocked(mDisplayDeviceRepo);
|
display.updateLocked(mDisplayDeviceRepo);
|
||||||
DisplayInfo newDisplayInfo = display.getDisplayInfoLocked();
|
final DisplayInfo newDisplayInfo = display.getDisplayInfoLocked();
|
||||||
|
final int updateState = mUpdatedLogicalDisplays.get(displayId, UPDATE_STATE_NEW);
|
||||||
final int storedState = mUpdatedLogicalDisplays.get(displayId, UPDATE_STATE_NEW);
|
final boolean wasPreviouslyUpdated = updateState != UPDATE_STATE_NEW;
|
||||||
final int updateState = storedState & UPDATE_STATE_MASK;
|
|
||||||
final boolean isTransitioning = (storedState & UPDATE_STATE_FLAG_TRANSITION) != 0;
|
|
||||||
final boolean wasPreviouslyUpdated = updateState == UPDATE_STATE_UPDATED;
|
|
||||||
|
|
||||||
// The display is no longer valid and needs to be removed.
|
// The display is no longer valid and needs to be removed.
|
||||||
if (!display.isValidLocked()) {
|
if (!display.isValidLocked()) {
|
||||||
@@ -668,35 +624,6 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// The display has been newly disabled, we report this as a removed display but
|
|
||||||
// don't actually remove it from our internal list in LogicalDisplayMapper. The reason
|
|
||||||
// is that LogicalDisplayMapper assumes and relies on the fact that every DisplayDevice
|
|
||||||
// has a LogicalDisplay wrapper, but certain displays that are unusable (like the inner
|
|
||||||
// display on a folded foldable device) are not available for use by the system and
|
|
||||||
// we keep them hidden. To do this, we mark those LogicalDisplays as "disabled".
|
|
||||||
// Also, if the display is in TRANSITION but was previously reported as disabled
|
|
||||||
// then keep it unreported.
|
|
||||||
} else if (!display.isEnabled()
|
|
||||||
|| (display.getPhase() == LogicalDisplay.DISPLAY_PHASE_LAYOUT_TRANSITION
|
|
||||||
&& updateState == UPDATE_STATE_DISABLED)) {
|
|
||||||
mUpdatedLogicalDisplays.put(displayId, UPDATE_STATE_DISABLED);
|
|
||||||
|
|
||||||
// If we never told anyone about this display, nothing to do
|
|
||||||
if (!wasPreviouslyUpdated) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove from group
|
|
||||||
final DisplayGroup displayGroup = getDisplayGroupLocked(
|
|
||||||
getDisplayGroupIdFromDisplayIdLocked(displayId));
|
|
||||||
if (displayGroup != null) {
|
|
||||||
displayGroup.removeDisplayLocked(display);
|
|
||||||
}
|
|
||||||
|
|
||||||
Slog.i(TAG, "Removing (disabled) display: " + displayId);
|
|
||||||
mLogicalDisplaysToUpdate.put(displayId, LOGICAL_DISPLAY_EVENT_REMOVED);
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// The display is new.
|
// The display is new.
|
||||||
} else if (!wasPreviouslyUpdated) {
|
} else if (!wasPreviouslyUpdated) {
|
||||||
Slog.i(TAG, "Adding new display: " + displayId + ": " + newDisplayInfo);
|
Slog.i(TAG, "Adding new display: " + displayId + ": " + newDisplayInfo);
|
||||||
@@ -716,7 +643,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
mLogicalDisplaysToUpdate.put(displayId, LOGICAL_DISPLAY_EVENT_CHANGED);
|
mLogicalDisplaysToUpdate.put(displayId, LOGICAL_DISPLAY_EVENT_CHANGED);
|
||||||
|
|
||||||
// The display is involved in a display layout transition
|
// The display is involved in a display layout transition
|
||||||
} else if (isTransitioning) {
|
} else if (updateState == UPDATE_STATE_TRANSITION) {
|
||||||
mLogicalDisplaysToUpdate.put(displayId,
|
mLogicalDisplaysToUpdate.put(displayId,
|
||||||
LOGICAL_DISPLAY_EVENT_DEVICE_STATE_TRANSITION);
|
LOGICAL_DISPLAY_EVENT_DEVICE_STATE_TRANSITION);
|
||||||
|
|
||||||
@@ -790,7 +717,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final int id = mLogicalDisplaysToUpdate.keyAt(i);
|
final int id = mLogicalDisplaysToUpdate.keyAt(i);
|
||||||
final LogicalDisplay display = getDisplayLocked(id, /* includeDisabled= */ true);
|
final LogicalDisplay display = getDisplayLocked(id);
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
final DisplayDevice device = display.getPrimaryDisplayDeviceLocked();
|
final DisplayDevice device = display.getPrimaryDisplayDeviceLocked();
|
||||||
final String uniqueId = device == null ? "null" : device.getUniqueId();
|
final String uniqueId = device == null ? "null" : device.getUniqueId();
|
||||||
@@ -798,7 +725,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
+ " with device=" + uniqueId);
|
+ " with device=" + uniqueId);
|
||||||
}
|
}
|
||||||
mListener.onLogicalDisplayEventLocked(display, msg);
|
mListener.onLogicalDisplayEventLocked(display, msg);
|
||||||
if (msg == LOGICAL_DISPLAY_EVENT_REMOVED && !display.isValidLocked()) {
|
if (msg == LOGICAL_DISPLAY_EVENT_REMOVED) {
|
||||||
// We wait until we sent the EVENT_REMOVED event before actually removing the
|
// We wait until we sent the EVENT_REMOVED event before actually removing the
|
||||||
// display.
|
// display.
|
||||||
mLogicalDisplays.delete(id);
|
mLogicalDisplays.delete(id);
|
||||||
@@ -918,8 +845,7 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
if (isTransitioning) {
|
if (isTransitioning) {
|
||||||
setDisplayPhase(logicalDisplay, phase);
|
setDisplayPhase(logicalDisplay, phase);
|
||||||
if (phase == LogicalDisplay.DISPLAY_PHASE_LAYOUT_TRANSITION) {
|
if (phase == LogicalDisplay.DISPLAY_PHASE_LAYOUT_TRANSITION) {
|
||||||
int oldState = mUpdatedLogicalDisplays.get(displayId, UPDATE_STATE_NEW);
|
mUpdatedLogicalDisplays.put(displayId, UPDATE_STATE_TRANSITION);
|
||||||
mUpdatedLogicalDisplays.put(displayId, oldState | UPDATE_STATE_FLAG_TRANSITION);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -953,15 +879,14 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
// Now that we have a display-device, we need a LogicalDisplay to map it to. Find the
|
// Now that we have a display-device, we need a LogicalDisplay to map it to. Find the
|
||||||
// right one, if it doesn't exist, create a new one.
|
// right one, if it doesn't exist, create a new one.
|
||||||
final int logicalDisplayId = displayLayout.getLogicalDisplayId();
|
final int logicalDisplayId = displayLayout.getLogicalDisplayId();
|
||||||
LogicalDisplay newDisplay =
|
LogicalDisplay newDisplay = getDisplayLocked(logicalDisplayId);
|
||||||
getDisplayLocked(logicalDisplayId, /* includeDisabled= */ true);
|
|
||||||
if (newDisplay == null) {
|
if (newDisplay == null) {
|
||||||
newDisplay = createNewLogicalDisplayLocked(
|
newDisplay = createNewLogicalDisplayLocked(
|
||||||
/* displayDevice= */ null, logicalDisplayId);
|
null /*displayDevice*/, logicalDisplayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now swap the underlying display devices between the old display and the new display
|
// Now swap the underlying display devices between the old display and the new display
|
||||||
final LogicalDisplay oldDisplay = getDisplayLocked(device, /* includeDisabled= */ true);
|
final LogicalDisplay oldDisplay = getDisplayLocked(device);
|
||||||
if (newDisplay != oldDisplay) {
|
if (newDisplay != oldDisplay) {
|
||||||
newDisplay.swapDisplaysLocked(oldDisplay);
|
newDisplay.swapDisplaysLocked(oldDisplay);
|
||||||
}
|
}
|
||||||
@@ -978,14 +903,13 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
|
|||||||
* Creates a new logical display for the specified device and display Id and adds it to the list
|
* Creates a new logical display for the specified device and display Id and adds it to the list
|
||||||
* of logical displays.
|
* of logical displays.
|
||||||
*
|
*
|
||||||
* @param displayDevice The displayDevice to associate with the LogicalDisplay.
|
* @param device The device to associate with the LogicalDisplay.
|
||||||
* @param displayId The display ID to give the new display. If invalid, a new ID is assigned.
|
* @param displayId The display ID to give the new display. If invalid, a new ID is assigned.
|
||||||
* @return The new logical display if created, null otherwise.
|
* @return The new logical display if created, null otherwise.
|
||||||
*/
|
*/
|
||||||
private LogicalDisplay createNewLogicalDisplayLocked(DisplayDevice displayDevice,
|
private LogicalDisplay createNewLogicalDisplayLocked(DisplayDevice device, int displayId) {
|
||||||
int displayId) {
|
|
||||||
final int layerStack = assignLayerStackLocked(displayId);
|
final int layerStack = assignLayerStackLocked(displayId);
|
||||||
final LogicalDisplay display = new LogicalDisplay(displayId, layerStack, displayDevice);
|
final LogicalDisplay display = new LogicalDisplay(displayId, layerStack, device);
|
||||||
display.updateLocked(mDisplayDeviceRepo);
|
display.updateLocked(mDisplayDeviceRepo);
|
||||||
mLogicalDisplays.put(displayId, display);
|
mLogicalDisplays.put(displayId, display);
|
||||||
setDisplayPhase(display, LogicalDisplay.DISPLAY_PHASE_ENABLED);
|
setDisplayPhase(display, LogicalDisplay.DISPLAY_PHASE_ENABLED);
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ public class DisplayManagerServiceTest {
|
|||||||
|
|
||||||
when(mMockAppToken.asBinder()).thenReturn(mMockAppToken);
|
when(mMockAppToken.asBinder()).thenReturn(mMockAppToken);
|
||||||
|
|
||||||
final int[] displayIds = bs.getDisplayIds(/* includeDisabled= */ false);
|
final int displayIds[] = bs.getDisplayIds();
|
||||||
final int size = displayIds.length;
|
final int size = displayIds.length;
|
||||||
assertTrue(size > 0);
|
assertTrue(size > 0);
|
||||||
|
|
||||||
@@ -297,10 +297,8 @@ public class DisplayManagerServiceTest {
|
|||||||
);
|
);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
DisplayInfo info = bs.getDisplayInfo(displayIds[i]);
|
DisplayInfo info = bs.getDisplayInfo(displayIds[i]);
|
||||||
if (info != null) {
|
|
||||||
assertTrue(expectedDisplayTypeToViewPortTypeMapping.keySet().contains(info.type));
|
assertTrue(expectedDisplayTypeToViewPortTypeMapping.keySet().contains(info.type));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
displayManager.performTraversalInternal(mock(SurfaceControl.Transaction.class));
|
displayManager.performTraversalInternal(mock(SurfaceControl.Transaction.class));
|
||||||
|
|
||||||
@@ -1176,8 +1174,7 @@ public class DisplayManagerServiceTest {
|
|||||||
DisplayManagerService.BinderService displayManagerBinderService,
|
DisplayManagerService.BinderService displayManagerBinderService,
|
||||||
FakeDisplayDevice displayDevice) {
|
FakeDisplayDevice displayDevice) {
|
||||||
|
|
||||||
final int[] displayIds = displayManagerBinderService.getDisplayIds(
|
final int[] displayIds = displayManagerBinderService.getDisplayIds();
|
||||||
/* includeDisabled= */ false);
|
|
||||||
assertTrue(displayIds.length > 0);
|
assertTrue(displayIds.length > 0);
|
||||||
int displayId = Display.INVALID_DISPLAY;
|
int displayId = Display.INVALID_DISPLAY;
|
||||||
for (int i = 0; i < displayIds.length; i++) {
|
for (int i = 0; i < displayIds.length; i++) {
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import static org.junit.Assert.assertNotEquals;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.clearInvocations;
|
import static org.mockito.Mockito.clearInvocations;
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -54,8 +53,6 @@ import android.view.DisplayInfo;
|
|||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import com.android.server.display.layout.Layout;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -82,7 +79,6 @@ public class LogicalDisplayMapperTest {
|
|||||||
private TestLooper mLooper;
|
private TestLooper mLooper;
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private PowerManager mPowerManager;
|
private PowerManager mPowerManager;
|
||||||
private DeviceStateToLayoutMap mDeviceStateToLayoutMapSpy;
|
|
||||||
|
|
||||||
@Mock LogicalDisplayMapper.Listener mListenerMock;
|
@Mock LogicalDisplayMapper.Listener mListenerMock;
|
||||||
@Mock Context mContextMock;
|
@Mock Context mContextMock;
|
||||||
@@ -137,11 +133,8 @@ public class LogicalDisplayMapperTest {
|
|||||||
|
|
||||||
mLooper = new TestLooper();
|
mLooper = new TestLooper();
|
||||||
mHandler = new Handler(mLooper.getLooper());
|
mHandler = new Handler(mLooper.getLooper());
|
||||||
|
|
||||||
mDeviceStateToLayoutMapSpy = spy(new DeviceStateToLayoutMap());
|
|
||||||
mLogicalDisplayMapper = new LogicalDisplayMapper(mContextMock, mDisplayDeviceRepo,
|
mLogicalDisplayMapper = new LogicalDisplayMapper(mContextMock, mDisplayDeviceRepo,
|
||||||
mListenerMock, new DisplayManagerService.SyncRoot(), mHandler,
|
mListenerMock, new DisplayManagerService.SyncRoot(), mHandler);
|
||||||
mDeviceStateToLayoutMapSpy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -420,86 +413,6 @@ public class LogicalDisplayMapperTest {
|
|||||||
/* isBootCompleted= */true));
|
/* isBootCompleted= */true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testEnabledAndDisabledDisplays() {
|
|
||||||
DisplayAddress displayAddressOne = new TestUtils.TestDisplayAddress();
|
|
||||||
DisplayAddress displayAddressTwo = new TestUtils.TestDisplayAddress();
|
|
||||||
DisplayAddress displayAddressThree = new TestUtils.TestDisplayAddress();
|
|
||||||
|
|
||||||
TestDisplayDevice device1 = createDisplayDevice(displayAddressOne, Display.TYPE_INTERNAL,
|
|
||||||
600, 800,
|
|
||||||
DisplayDeviceInfo.FLAG_ALLOWED_TO_BE_DEFAULT_DISPLAY);
|
|
||||||
TestDisplayDevice device2 = createDisplayDevice(displayAddressTwo, Display.TYPE_INTERNAL,
|
|
||||||
200, 800,
|
|
||||||
DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP);
|
|
||||||
TestDisplayDevice device3 = createDisplayDevice(displayAddressThree, Display.TYPE_INTERNAL,
|
|
||||||
600, 900, DisplayDeviceInfo.FLAG_OWN_DISPLAY_GROUP);
|
|
||||||
|
|
||||||
Layout threeDevicesEnabledLayout = new Layout();
|
|
||||||
threeDevicesEnabledLayout.createDisplayLocked(
|
|
||||||
displayAddressOne,
|
|
||||||
/* isDefault= */ true,
|
|
||||||
/* isEnabled= */ true);
|
|
||||||
|
|
||||||
threeDevicesEnabledLayout.createDisplayLocked(
|
|
||||||
displayAddressTwo,
|
|
||||||
/* isDefault= */ false,
|
|
||||||
/* isEnabled= */ true);
|
|
||||||
threeDevicesEnabledLayout.createDisplayLocked(
|
|
||||||
displayAddressThree,
|
|
||||||
/* isDefault= */ false,
|
|
||||||
/* isEnabled= */ true);
|
|
||||||
|
|
||||||
when(mDeviceStateToLayoutMapSpy.get(DeviceStateToLayoutMap.STATE_DEFAULT))
|
|
||||||
.thenReturn(threeDevicesEnabledLayout);
|
|
||||||
|
|
||||||
LogicalDisplay display1 = add(device1);
|
|
||||||
LogicalDisplay display2 = add(device2);
|
|
||||||
LogicalDisplay display3 = add(device3);
|
|
||||||
|
|
||||||
// ensure 3 displays are returned
|
|
||||||
int [] ids = mLogicalDisplayMapper.getDisplayIdsLocked(Process.SYSTEM_UID);
|
|
||||||
assertEquals(3, ids.length);
|
|
||||||
Arrays.sort(ids);
|
|
||||||
assertEquals(DEFAULT_DISPLAY, ids[0]);
|
|
||||||
|
|
||||||
Layout oneDeviceEnabledLayout = new Layout();
|
|
||||||
oneDeviceEnabledLayout.createDisplayLocked(
|
|
||||||
display1.getDisplayInfoLocked().address,
|
|
||||||
/* isDefault= */ true,
|
|
||||||
/* isEnabled= */ true);
|
|
||||||
oneDeviceEnabledLayout.createDisplayLocked(
|
|
||||||
display2.getDisplayInfoLocked().address,
|
|
||||||
/* isDefault= */ false,
|
|
||||||
/* isEnabled= */ false);
|
|
||||||
oneDeviceEnabledLayout.createDisplayLocked(
|
|
||||||
display3.getDisplayInfoLocked().address,
|
|
||||||
/* isDefault= */ false,
|
|
||||||
/* isEnabled= */ false);
|
|
||||||
|
|
||||||
when(mDeviceStateToLayoutMapSpy.get(0)).thenReturn(oneDeviceEnabledLayout);
|
|
||||||
when(mDeviceStateToLayoutMapSpy.get(1)).thenReturn(threeDevicesEnabledLayout);
|
|
||||||
|
|
||||||
mLogicalDisplayMapper
|
|
||||||
.setDeviceStateLocked(0, false);
|
|
||||||
mDisplayDeviceRepo.onDisplayDeviceEvent(device3, DISPLAY_DEVICE_EVENT_CHANGED);
|
|
||||||
final int[] allDisplayIds = mLogicalDisplayMapper.getDisplayIdsLocked(
|
|
||||||
Process.SYSTEM_UID, false);
|
|
||||||
mLooper.dispatchAll();
|
|
||||||
|
|
||||||
// ensure only one display is returned
|
|
||||||
assertEquals(1, allDisplayIds.length);
|
|
||||||
|
|
||||||
mLogicalDisplayMapper
|
|
||||||
.setDeviceStateLocked(1, false);
|
|
||||||
mDisplayDeviceRepo.onDisplayDeviceEvent(device3, DISPLAY_DEVICE_EVENT_CHANGED);
|
|
||||||
final int[] threeDisplaysEnabled = mLogicalDisplayMapper.getDisplayIdsLocked(
|
|
||||||
Process.SYSTEM_UID, false);
|
|
||||||
mLooper.dispatchAll();
|
|
||||||
|
|
||||||
// ensure all three displays are returned
|
|
||||||
assertEquals(3, threeDisplaysEnabled.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////
|
/////////////////
|
||||||
// Helper Methods
|
// Helper Methods
|
||||||
/////////////////
|
/////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user