use of android.hardware.display.VirtualDisplay in project android_frameworks_base by AOSPA.
the class VirtualDisplayTest method testSecurePublicPresentationVirtualDisplay.
/**
* Ensures that an application can create a secure public virtual display and show
* its own windows on it. This test requires the CAPTURE_SECURE_VIDEO_OUTPUT permission.
*
* Because this test does not have an activity token, we use the TOAST window
* type to create the window. Another choice might be SYSTEM_ALERT_WINDOW but
* that requires a permission.
*/
public void testSecurePublicPresentationVirtualDisplay() throws Exception {
VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(NAME, WIDTH, HEIGHT, DENSITY, mSurface, DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE | DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION);
assertNotNull("virtual display must not be null", virtualDisplay);
Display display = virtualDisplay.getDisplay();
try {
assertDisplayRegistered(display, Display.FLAG_PRESENTATION | Display.FLAG_SECURE);
// Mirroring case with secure window (and display is secure).
// Show a window on the default display. It should be mirrored to the
// virtual display automatically.
Display defaultDisplay = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY);
assertDisplayCanShowPresentation("mirrored secure window on secure display", defaultDisplay, GREENISH, WindowManager.LayoutParams.TYPE_TOAST, WindowManager.LayoutParams.FLAG_SECURE);
// Presentation case with secure window (and display is secure).
// Show a normal presentation on the display.
assertDisplayCanShowPresentation("secure presentation window on secure display", display, BLUEISH, WindowManager.LayoutParams.TYPE_TOAST, WindowManager.LayoutParams.FLAG_SECURE);
} finally {
virtualDisplay.release();
}
assertDisplayUnregistered(display);
}
use of android.hardware.display.VirtualDisplay in project android_frameworks_base by crdroidandroid.
the class VirtualDisplayTest method testPrivateVirtualDisplay.
/**
* Ensures that an application can create a private virtual display and show
* its own windows on it.
*/
public void testPrivateVirtualDisplay() throws Exception {
VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(NAME, WIDTH, HEIGHT, DENSITY, mSurface, 0);
assertNotNull("virtual display must not be null", virtualDisplay);
Display display = virtualDisplay.getDisplay();
try {
assertDisplayRegistered(display, Display.FLAG_PRIVATE);
// Show a private presentation on the display.
assertDisplayCanShowPresentation("private presentation window", display, BLUEISH, WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION, 0);
} finally {
virtualDisplay.release();
}
assertDisplayUnregistered(display);
}
use of android.hardware.display.VirtualDisplay in project platform_frameworks_base by android.
the class VirtualDisplayTest method testPrivateVirtualDisplay.
/**
* Ensures that an application can create a private virtual display and show
* its own windows on it.
*/
public void testPrivateVirtualDisplay() throws Exception {
VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(NAME, WIDTH, HEIGHT, DENSITY, mSurface, 0);
assertNotNull("virtual display must not be null", virtualDisplay);
Display display = virtualDisplay.getDisplay();
try {
assertDisplayRegistered(display, Display.FLAG_PRIVATE);
// Show a private presentation on the display.
assertDisplayCanShowPresentation("private presentation window", display, BLUEISH, WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION, 0);
} finally {
virtualDisplay.release();
}
assertDisplayUnregistered(display);
}
use of android.hardware.display.VirtualDisplay in project platform_frameworks_base by android.
the class VirtualDisplayTest method testPublicPresentationVirtualDisplay.
/**
* Ensures that an application can create a public virtual display and show
* its own windows on it. This test requires the CAPTURE_VIDEO_OUTPUT permission.
*
* Because this test does not have an activity token, we use the TOAST window
* type to create the window. Another choice might be SYSTEM_ALERT_WINDOW but
* that requires a permission.
*/
public void testPublicPresentationVirtualDisplay() throws Exception {
VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(NAME, WIDTH, HEIGHT, DENSITY, mSurface, DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION);
assertNotNull("virtual display must not be null", virtualDisplay);
Display display = virtualDisplay.getDisplay();
try {
assertDisplayRegistered(display, Display.FLAG_PRESENTATION);
// Mirroring case.
// Show a window on the default display. It should be mirrored to the
// virtual display automatically.
Display defaultDisplay = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY);
assertDisplayCanShowPresentation("mirrored window", defaultDisplay, GREENISH, WindowManager.LayoutParams.TYPE_TOAST, 0);
// Mirroring case with secure window (but display is not secure).
// Show a window on the default display. It should be replaced with black on
// the virtual display.
assertDisplayCanShowPresentation("mirrored secure window on non-secure display", defaultDisplay, Color.BLACK, WindowManager.LayoutParams.TYPE_TOAST, WindowManager.LayoutParams.FLAG_SECURE);
// Presentation case.
// Show a normal presentation on the display.
assertDisplayCanShowPresentation("presentation window", display, BLUEISH, WindowManager.LayoutParams.TYPE_TOAST, 0);
// Presentation case with secure window (but display is not secure).
// Show a normal presentation on the display. It should be replaced with black.
assertDisplayCanShowPresentation("secure presentation window on non-secure display", display, Color.BLACK, WindowManager.LayoutParams.TYPE_TOAST, WindowManager.LayoutParams.FLAG_SECURE);
} finally {
virtualDisplay.release();
}
assertDisplayUnregistered(display);
}
use of android.hardware.display.VirtualDisplay in project platform_frameworks_base by android.
the class VirtualDisplayTest method testSecurePublicPresentationVirtualDisplay.
/**
* Ensures that an application can create a secure public virtual display and show
* its own windows on it. This test requires the CAPTURE_SECURE_VIDEO_OUTPUT permission.
*
* Because this test does not have an activity token, we use the TOAST window
* type to create the window. Another choice might be SYSTEM_ALERT_WINDOW but
* that requires a permission.
*/
public void testSecurePublicPresentationVirtualDisplay() throws Exception {
VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(NAME, WIDTH, HEIGHT, DENSITY, mSurface, DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE | DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION);
assertNotNull("virtual display must not be null", virtualDisplay);
Display display = virtualDisplay.getDisplay();
try {
assertDisplayRegistered(display, Display.FLAG_PRESENTATION | Display.FLAG_SECURE);
// Mirroring case with secure window (and display is secure).
// Show a window on the default display. It should be mirrored to the
// virtual display automatically.
Display defaultDisplay = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY);
assertDisplayCanShowPresentation("mirrored secure window on secure display", defaultDisplay, GREENISH, WindowManager.LayoutParams.TYPE_TOAST, WindowManager.LayoutParams.FLAG_SECURE);
// Presentation case with secure window (and display is secure).
// Show a normal presentation on the display.
assertDisplayCanShowPresentation("secure presentation window on secure display", display, BLUEISH, WindowManager.LayoutParams.TYPE_TOAST, WindowManager.LayoutParams.FLAG_SECURE);
} finally {
virtualDisplay.release();
}
assertDisplayUnregistered(display);
}
Aggregations