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;
}
}
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();
}
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);
}
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);
}
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);
}
Aggregations