Search in sources :

Example 51 with Display

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;
}
Also used : Point(android.graphics.Point) Point(android.graphics.Point) SuppressLint(android.annotation.SuppressLint) Display(android.view.Display) WindowManager(android.view.WindowManager) SuppressLint(android.annotation.SuppressLint)

Example 52 with Display

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);
}
Also used : VirtualDisplay(android.hardware.display.VirtualDisplay) Display(android.view.Display) VirtualDisplay(android.hardware.display.VirtualDisplay)

Example 53 with 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);
}
Also used : VirtualDisplay(android.hardware.display.VirtualDisplay) Display(android.view.Display) VirtualDisplay(android.hardware.display.VirtualDisplay)

Example 54 with 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);
}
Also used : VirtualDisplay(android.hardware.display.VirtualDisplay) Display(android.view.Display) VirtualDisplay(android.hardware.display.VirtualDisplay)

Example 55 with 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;
        }
    }
}
Also used : RouteInfo(android.media.MediaRouter.RouteInfo) MediaRouter(android.media.MediaRouter) Display(android.view.Display) WindowManager(android.view.WindowManager)

Aggregations

Display (android.view.Display)697 Point (android.graphics.Point)356 WindowManager (android.view.WindowManager)349 DisplayMetrics (android.util.DisplayMetrics)126 View (android.view.View)57 TextView (android.widget.TextView)54 LinearLayout (android.widget.LinearLayout)45 SuppressLint (android.annotation.SuppressLint)43 Method (java.lang.reflect.Method)41 ImageView (android.widget.ImageView)39 Bitmap (android.graphics.Bitmap)38 Resources (android.content.res.Resources)36 Intent (android.content.Intent)34 Camera (android.hardware.Camera)31 Context (android.content.Context)26 Rect (android.graphics.Rect)25 IOException (java.io.IOException)24 ViewGroup (android.view.ViewGroup)23 Canvas (android.graphics.Canvas)22 RemoteException (android.os.RemoteException)22