Merge "Prevent displays that are disabled from receiving input" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
3ca7a5ab25
@@ -522,10 +522,12 @@ final class LogicalDisplay {
|
|||||||
// Set the layer stack.
|
// Set the layer stack.
|
||||||
device.setLayerStackLocked(t, isBlanked ? BLANK_LAYER_STACK : mLayerStack);
|
device.setLayerStackLocked(t, isBlanked ? BLANK_LAYER_STACK : mLayerStack);
|
||||||
// Also inform whether the device is the same one sent to inputflinger for its layerstack.
|
// Also inform whether the device is the same one sent to inputflinger for its layerstack.
|
||||||
|
// Prevent displays that are disabled from receiving input.
|
||||||
// TODO(b/188914255): Remove once input can dispatch against device vs layerstack.
|
// TODO(b/188914255): Remove once input can dispatch against device vs layerstack.
|
||||||
device.setDisplayFlagsLocked(t,
|
device.setDisplayFlagsLocked(t,
|
||||||
device.getDisplayDeviceInfoLocked().touch != TOUCH_NONE
|
(isEnabled() && device.getDisplayDeviceInfoLocked().touch != TOUCH_NONE)
|
||||||
? SurfaceControl.DISPLAY_RECEIVES_INPUT : 0);
|
? SurfaceControl.DISPLAY_RECEIVES_INPUT
|
||||||
|
: 0);
|
||||||
|
|
||||||
// Set the color mode and allowed display mode.
|
// Set the color mode and allowed display mode.
|
||||||
if (device == mPrimaryDisplayDevice) {
|
if (device == mPrimaryDisplayDevice) {
|
||||||
|
|||||||
@@ -17,7 +17,11 @@
|
|||||||
package com.android.server.display;
|
package com.android.server.display;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.mockito.Mockito.any;
|
||||||
|
import static org.mockito.Mockito.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.reset;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.app.PropertyInvalidatedCache;
|
import android.app.PropertyInvalidatedCache;
|
||||||
@@ -45,18 +49,21 @@ public class LogicalDisplayTest {
|
|||||||
|
|
||||||
private LogicalDisplay mLogicalDisplay;
|
private LogicalDisplay mLogicalDisplay;
|
||||||
private DisplayDevice mDisplayDevice;
|
private DisplayDevice mDisplayDevice;
|
||||||
|
private final DisplayDeviceInfo mDisplayDeviceInfo = new DisplayDeviceInfo();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
// Share classloader to allow package private access.
|
// Share classloader to allow package private access.
|
||||||
System.setProperty("dexmaker.share_classloader", "true");
|
System.setProperty("dexmaker.share_classloader", "true");
|
||||||
mDisplayDevice = mock(DisplayDevice.class);
|
mDisplayDevice = mock(DisplayDevice.class);
|
||||||
DisplayDeviceInfo displayDeviceInfo = new DisplayDeviceInfo();
|
|
||||||
displayDeviceInfo.width = DISPLAY_WIDTH;
|
|
||||||
displayDeviceInfo.height = DISPLAY_HEIGHT;
|
|
||||||
displayDeviceInfo.flags = DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT;
|
|
||||||
mLogicalDisplay = new LogicalDisplay(DISPLAY_ID, LAYER_STACK, mDisplayDevice);
|
mLogicalDisplay = new LogicalDisplay(DISPLAY_ID, LAYER_STACK, mDisplayDevice);
|
||||||
when(mDisplayDevice.getDisplayDeviceInfoLocked()).thenReturn(displayDeviceInfo);
|
|
||||||
|
mDisplayDeviceInfo.copyFrom(new DisplayDeviceInfo());
|
||||||
|
mDisplayDeviceInfo.width = DISPLAY_WIDTH;
|
||||||
|
mDisplayDeviceInfo.height = DISPLAY_HEIGHT;
|
||||||
|
mDisplayDeviceInfo.flags = DisplayDeviceInfo.FLAG_ROTATES_WITH_CONTENT;
|
||||||
|
mDisplayDeviceInfo.touch = DisplayDeviceInfo.TOUCH_INTERNAL;
|
||||||
|
when(mDisplayDevice.getDisplayDeviceInfoLocked()).thenReturn(mDisplayDeviceInfo);
|
||||||
|
|
||||||
// Disable binder caches in this process.
|
// Disable binder caches in this process.
|
||||||
PropertyInvalidatedCache.disableForTestMode();
|
PropertyInvalidatedCache.disableForTestMode();
|
||||||
@@ -103,4 +110,33 @@ public class LogicalDisplayTest {
|
|||||||
mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
|
mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
|
||||||
assertEquals(expectedPosition, mLogicalDisplay.getDisplayPosition());
|
assertEquals(expectedPosition, mLogicalDisplay.getDisplayPosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDisplayInputFlags() {
|
||||||
|
SurfaceControl.Transaction t = mock(SurfaceControl.Transaction.class);
|
||||||
|
mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
|
||||||
|
verify(t).setDisplayFlags(any(), eq(SurfaceControl.DISPLAY_RECEIVES_INPUT));
|
||||||
|
reset(t);
|
||||||
|
|
||||||
|
mDisplayDeviceInfo.touch = DisplayDeviceInfo.TOUCH_NONE;
|
||||||
|
mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
|
||||||
|
verify(t).setDisplayFlags(any(), eq(0));
|
||||||
|
reset(t);
|
||||||
|
|
||||||
|
mDisplayDeviceInfo.touch = DisplayDeviceInfo.TOUCH_VIRTUAL;
|
||||||
|
mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
|
||||||
|
verify(t).setDisplayFlags(any(), eq(SurfaceControl.DISPLAY_RECEIVES_INPUT));
|
||||||
|
reset(t);
|
||||||
|
|
||||||
|
mLogicalDisplay.setPhase(LogicalDisplay.DISPLAY_PHASE_DISABLED);
|
||||||
|
mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
|
||||||
|
verify(t).setDisplayFlags(any(), eq(0));
|
||||||
|
reset(t);
|
||||||
|
|
||||||
|
mLogicalDisplay.setPhase(LogicalDisplay.DISPLAY_PHASE_ENABLED);
|
||||||
|
mDisplayDeviceInfo.touch = DisplayDeviceInfo.TOUCH_EXTERNAL;
|
||||||
|
mLogicalDisplay.configureDisplayLocked(t, mDisplayDevice, false);
|
||||||
|
verify(t).setDisplayFlags(any(), eq(SurfaceControl.DISPLAY_RECEIVES_INPUT));
|
||||||
|
reset(t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user