Search in sources :

Example 36 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by ResurrectionRemix.

the class DeviceUtils method getScreenType.

private static int getScreenType(Context con) {
    WindowManager wm = (WindowManager) con.getSystemService(Context.WINDOW_SERVICE);
    DisplayInfo outDisplayInfo = new DisplayInfo();
    wm.getDefaultDisplay().getDisplayInfo(outDisplayInfo);
    int shortSize = Math.min(outDisplayInfo.logicalHeight, outDisplayInfo.logicalWidth);
    int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / outDisplayInfo.logicalDensityDpi;
    if (shortSizeDp < 600) {
        return DEVICE_PHONE;
    } else if (shortSizeDp < 720) {
        return DEVICE_HYBRID;
    } else {
        return DEVICE_TABLET;
    }
}
Also used : DisplayInfo(android.view.DisplayInfo) WindowManager(android.view.WindowManager)

Example 37 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by ResurrectionRemix.

the class DividerView method updateDisplayInfo.

private void updateDisplayInfo() {
    final DisplayManager displayManager = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE);
    Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
    final DisplayInfo info = new DisplayInfo();
    display.getDisplayInfo(info);
    mDisplayWidth = info.logicalWidth;
    mDisplayHeight = info.logicalHeight;
    mSnapAlgorithm = null;
    initializeSnapAlgorithm();
}
Also used : DisplayInfo(android.view.DisplayInfo) DisplayManager(android.hardware.display.DisplayManager) Display(android.view.Display)

Example 38 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by ResurrectionRemix.

the class DimLayer method getBoundsForFullscreen.

private void getBoundsForFullscreen(Rect outBounds) {
    final int dw, dh;
    final float xPos, yPos;
    // Set surface size to screen size.
    final DisplayInfo info = mUser.getDisplayInfo();
    // Multiply by 1.5 so that rotating a frozen surface that includes this does not expose
    // a corner.
    dw = (int) (info.logicalWidth * 1.5);
    dh = (int) (info.logicalHeight * 1.5);
    // back off position so 1/4 of Surface is before and 1/4 is after.
    xPos = -1 * dw / 6;
    yPos = -1 * dh / 6;
    outBounds.set((int) xPos, (int) yPos, (int) xPos + dw, (int) yPos + dh);
}
Also used : DisplayInfo(android.view.DisplayInfo)

Example 39 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by ResurrectionRemix.

the class DockedStackDividerController method getSmallestWidthDpForBounds.

int getSmallestWidthDpForBounds(Rect bounds) {
    final DisplayInfo di = mDisplayContent.getDisplayInfo();
    // If the bounds are fullscreen, return the value of the fullscreen configuration
    if (bounds == null || (bounds.left == 0 && bounds.top == 0 && bounds.right == di.logicalWidth && bounds.bottom == di.logicalHeight)) {
        return mService.mCurConfiguration.smallestScreenWidthDp;
    }
    final int baseDisplayWidth = mDisplayContent.mBaseDisplayWidth;
    final int baseDisplayHeight = mDisplayContent.mBaseDisplayHeight;
    int minWidth = Integer.MAX_VALUE;
    // smallest width.
    for (int rotation = 0; rotation < 4; rotation++) {
        mTmpRect.set(bounds);
        mDisplayContent.rotateBounds(di.rotation, rotation, mTmpRect);
        final boolean rotated = (rotation == ROTATION_90 || rotation == ROTATION_270);
        mTmpRect2.set(0, 0, rotated ? baseDisplayHeight : baseDisplayWidth, rotated ? baseDisplayWidth : baseDisplayHeight);
        final int orientation = mTmpRect2.width() <= mTmpRect2.height() ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE;
        final int dockSide = TaskStack.getDockSideUnchecked(mTmpRect, mTmpRect2, orientation);
        final int position = DockedDividerUtils.calculatePositionForBounds(mTmpRect, dockSide, getContentWidth());
        // Since we only care about feasible states, snap to the closest snap target, like it
        // would happen when actually rotating the screen.
        final int snappedPosition = mSnapAlgorithmForRotation[rotation].calculateNonDismissingSnapTarget(position).position;
        DockedDividerUtils.calculateBoundsForPosition(snappedPosition, dockSide, mTmpRect, mTmpRect2.width(), mTmpRect2.height(), getContentWidth());
        mService.mPolicy.getStableInsetsLw(rotation, mTmpRect2.width(), mTmpRect2.height(), mTmpRect3);
        mService.subtractInsets(mTmpRect2, mTmpRect3, mTmpRect);
        minWidth = Math.min(mTmpRect.width(), minWidth);
    }
    return (int) (minWidth / mDisplayContent.getDisplayMetrics().density);
}
Also used : DisplayInfo(android.view.DisplayInfo)

Example 40 with DisplayInfo

use of android.view.DisplayInfo in project android_frameworks_base by ResurrectionRemix.

the class TaskStack method snapDockedStackAfterRotation.

/**
     * Snaps the bounds after rotation to the closest snap target for the docked stack.
     */
private void snapDockedStackAfterRotation(Rect outBounds) {
    // Calculate the current position.
    final DisplayInfo displayInfo = mDisplayContent.getDisplayInfo();
    final int dividerSize = mService.getDefaultDisplayContentLocked().getDockedDividerController().getContentWidth();
    final int dockSide = getDockSide(outBounds);
    final int dividerPosition = DockedDividerUtils.calculatePositionForBounds(outBounds, dockSide, dividerSize);
    final int displayWidth = mDisplayContent.getDisplayInfo().logicalWidth;
    final int displayHeight = mDisplayContent.getDisplayInfo().logicalHeight;
    // Snap the position to a target.
    final int rotation = displayInfo.rotation;
    final int orientation = mService.mCurConfiguration.orientation;
    mService.mPolicy.getStableInsetsLw(rotation, displayWidth, displayHeight, outBounds);
    final DividerSnapAlgorithm algorithm = new DividerSnapAlgorithm(mService.mContext.getResources(), displayWidth, displayHeight, dividerSize, orientation == Configuration.ORIENTATION_PORTRAIT, outBounds);
    final SnapTarget target = algorithm.calculateNonDismissingSnapTarget(dividerPosition);
    // Recalculate the bounds based on the position of the target.
    DockedDividerUtils.calculateBoundsForPosition(target.position, dockSide, outBounds, displayInfo.logicalWidth, displayInfo.logicalHeight, dividerSize);
}
Also used : DisplayInfo(android.view.DisplayInfo) DividerSnapAlgorithm(com.android.internal.policy.DividerSnapAlgorithm) SnapTarget(com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)

Aggregations

DisplayInfo (android.view.DisplayInfo)186 Point (android.graphics.Point)53 Rect (android.graphics.Rect)29 RemoteException (android.os.RemoteException)19 Display (android.view.Display)11 Animation (android.view.animation.Animation)10 Bitmap (android.graphics.Bitmap)9 WindowManager (android.view.WindowManager)8 DividerSnapAlgorithm (com.android.internal.policy.DividerSnapAlgorithm)8 Canvas (android.graphics.Canvas)6 SurfaceControl (android.view.SurfaceControl)6 LayoutParams (android.view.WindowManager.LayoutParams)6 DisplayManager (android.hardware.display.DisplayManager)5 DisplayMetrics (android.util.DisplayMetrics)5 Surface (android.view.Surface)5 InputDevice (android.view.InputDevice)4 SnapTarget (com.android.internal.policy.DividerSnapAlgorithm.SnapTarget)4 FileNotFoundException (java.io.FileNotFoundException)4 IOException (java.io.IOException)4 OutOfResourcesException (android.view.Surface.OutOfResourcesException)3