use of android.view.Display in project mobile-center-sdk-android by Microsoft.
the class DeviceInfoHelper method getScreenSize.
/**
* Gets a size of a device for base orientation.
*
* @param context The context of the application.
* @return A string with {@code <width>x<height>} format.
*/
@SuppressLint("SwitchIntDef")
@SuppressWarnings("SuspiciousNameCombination")
private static String getScreenSize(Context context) {
/* Guess resolution based on the natural device orientation */
int screenWidth;
int screenHeight;
Display defaultDisplay = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Point size = new Point();
defaultDisplay.getSize(size);
switch(defaultDisplay.getRotation()) {
case Surface.ROTATION_90:
case Surface.ROTATION_270:
screenHeight = size.x;
screenWidth = size.y;
break;
default:
screenWidth = size.x;
screenHeight = size.y;
}
/* Serialize screen resolution */
return screenWidth + "x" + screenHeight;
}
use of android.view.Display in project android_frameworks_base by DirtyUnicorns.
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.view.Display in project android_frameworks_base by DirtyUnicorns.
the class VirtualDisplayTest method testPrivatePresentationVirtualDisplay.
/**
* Ensures that an application can create a private presentation virtual display and show
* its own windows on it.
*/
public void testPrivatePresentationVirtualDisplay() throws Exception {
VirtualDisplay virtualDisplay = mDisplayManager.createVirtualDisplay(NAME, WIDTH, HEIGHT, DENSITY, mSurface, DisplayManager.VIRTUAL_DISPLAY_FLAG_PRESENTATION);
assertNotNull("virtual display must not be null", virtualDisplay);
Display display = virtualDisplay.getDisplay();
try {
assertDisplayRegistered(display, Display.FLAG_PRIVATE | Display.FLAG_PRESENTATION);
// 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.view.Display in project android_frameworks_base by DirtyUnicorns.
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.view.Display in project android_frameworks_base by DirtyUnicorns.
the class KeyguardDisplayManager method updateDisplays.
protected void updateDisplays(boolean showing) {
if (showing) {
MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY);
boolean useDisplay = route != null && route.getPlaybackType() == MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE;
Display presentationDisplay = useDisplay ? route.getPresentationDisplay() : null;
if (mPresentation != null && mPresentation.getDisplay() != presentationDisplay) {
if (DEBUG)
Slog.v(TAG, "Display gone: " + mPresentation.getDisplay());
mPresentation.dismiss();
mPresentation = null;
}
if (mPresentation == null && presentationDisplay != null) {
if (DEBUG)
Slog.i(TAG, "Keyguard enabled on display: " + presentationDisplay);
mPresentation = new KeyguardPresentation(mContext, presentationDisplay, R.style.keyguard_presentation_theme);
mPresentation.setOnDismissListener(mOnDismissListener);
try {
mPresentation.show();
} catch (WindowManager.InvalidDisplayException ex) {
Slog.w(TAG, "Invalid display:", ex);
mPresentation = null;
}
}
} else {
if (mPresentation != null) {
mPresentation.dismiss();
mPresentation = null;
}
}
}
Aggregations