Search in sources :

Example 56 with DisplayInfo

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

the class WallpaperController method updateWallpaperOffsetLocked.

void updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) {
    final DisplayContent displayContent = changingTarget.getDisplayContent();
    if (displayContent == null) {
        return;
    }
    final DisplayInfo displayInfo = displayContent.getDisplayInfo();
    final int dw = displayInfo.logicalWidth;
    final int dh = displayInfo.logicalHeight;
    WindowState target = mWallpaperTarget;
    if (target != null) {
        if (target.mWallpaperX >= 0) {
            mLastWallpaperX = target.mWallpaperX;
        } else if (changingTarget.mWallpaperX >= 0) {
            mLastWallpaperX = changingTarget.mWallpaperX;
        }
        if (target.mWallpaperY >= 0) {
            mLastWallpaperY = target.mWallpaperY;
        } else if (changingTarget.mWallpaperY >= 0) {
            mLastWallpaperY = changingTarget.mWallpaperY;
        }
        if (target.mWallpaperDisplayOffsetX != Integer.MIN_VALUE) {
            mLastWallpaperDisplayOffsetX = target.mWallpaperDisplayOffsetX;
        } else if (changingTarget.mWallpaperDisplayOffsetX != Integer.MIN_VALUE) {
            mLastWallpaperDisplayOffsetX = changingTarget.mWallpaperDisplayOffsetX;
        }
        if (target.mWallpaperDisplayOffsetY != Integer.MIN_VALUE) {
            mLastWallpaperDisplayOffsetY = target.mWallpaperDisplayOffsetY;
        } else if (changingTarget.mWallpaperDisplayOffsetY != Integer.MIN_VALUE) {
            mLastWallpaperDisplayOffsetY = changingTarget.mWallpaperDisplayOffsetY;
        }
        if (target.mWallpaperXStep >= 0) {
            mLastWallpaperXStep = target.mWallpaperXStep;
        } else if (changingTarget.mWallpaperXStep >= 0) {
            mLastWallpaperXStep = changingTarget.mWallpaperXStep;
        }
        if (target.mWallpaperYStep >= 0) {
            mLastWallpaperYStep = target.mWallpaperYStep;
        } else if (changingTarget.mWallpaperYStep >= 0) {
            mLastWallpaperYStep = changingTarget.mWallpaperYStep;
        }
    }
    for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
        WindowList windows = mWallpaperTokens.get(curTokenNdx).windows;
        for (int wallpaperNdx = windows.size() - 1; wallpaperNdx >= 0; wallpaperNdx--) {
            WindowState wallpaper = windows.get(wallpaperNdx);
            if (updateWallpaperOffset(wallpaper, dw, dh, sync)) {
                WindowStateAnimator winAnimator = wallpaper.mWinAnimator;
                if (mService.mSingleHandMode == 1) {
                    winAnimator.computeShownFrameLeftLocked();
                } else if (mService.mSingleHandMode == 2) {
                    winAnimator.computeShownFrameRightLocked();
                } else {
                    winAnimator.computeShownFrameNormalLocked();
                }
                // No need to lay out the windows - we can just set the wallpaper position
                // directly.
                winAnimator.setWallpaperOffset(wallpaper.mShownPosition);
                // We only want to be synchronous with one wallpaper.
                sync = false;
            }
        }
    }
}
Also used : DisplayInfo(android.view.DisplayInfo)

Example 57 with DisplayInfo

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

the class WallpaperController method updateWallpaperVisibility.

void updateWallpaperVisibility() {
    final DisplayContent displayContent = mWallpaperTarget.getDisplayContent();
    if (displayContent == null) {
        return;
    }
    final boolean visible = isWallpaperVisible(mWallpaperTarget);
    final DisplayInfo displayInfo = displayContent.getDisplayInfo();
    final int dw = displayInfo.logicalWidth;
    final int dh = displayInfo.logicalHeight;
    for (int curTokenNdx = mWallpaperTokens.size() - 1; curTokenNdx >= 0; curTokenNdx--) {
        WindowToken token = mWallpaperTokens.get(curTokenNdx);
        if (token.hidden == visible) {
            token.hidden = !visible;
            // Need to do a layout to ensure the wallpaper now has the
            // correct size.
            displayContent.layoutNeeded = true;
        }
        final WindowList windows = token.windows;
        for (int wallpaperNdx = windows.size() - 1; wallpaperNdx >= 0; wallpaperNdx--) {
            WindowState wallpaper = windows.get(wallpaperNdx);
            if (visible) {
                updateWallpaperOffset(wallpaper, dw, dh, false);
            }
            dispatchWallpaperVisibility(wallpaper, visible);
        }
    }
}
Also used : DisplayInfo(android.view.DisplayInfo)

Example 58 with DisplayInfo

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

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 59 with DisplayInfo

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

the class TaskStack method getStackDockedModeBounds.

/**
     * Outputs the bounds a stack should be given the presence of a docked stack on the display.
     * @param displayRect The bounds of the display the docked stack is on.
     * @param outBounds Output bounds that should be used for the stack.
     * @param stackId Id of stack we are calculating the bounds for.
     * @param dockedBounds Bounds of the docked stack.
     * @param dockDividerWidth We need to know the width of the divider make to the output bounds
     *                         close to the side of the dock.
     * @param dockOnTopOrLeft If the docked stack is on the top or left side of the screen.
     */
private void getStackDockedModeBounds(Rect displayRect, Rect outBounds, int stackId, Rect dockedBounds, int dockDividerWidth, boolean dockOnTopOrLeft) {
    final boolean dockedStack = stackId == DOCKED_STACK_ID;
    final boolean splitHorizontally = displayRect.width() > displayRect.height();
    outBounds.set(displayRect);
    if (dockedStack) {
        if (mService.mDockedStackCreateBounds != null) {
            outBounds.set(mService.mDockedStackCreateBounds);
            return;
        }
        // The initial bounds of the docked stack when it is created about half the screen space
        // and its bounds can be adjusted after that. The bounds of all other stacks are
        // adjusted to occupy whatever screen space the docked stack isn't occupying.
        final DisplayInfo di = mDisplayContent.getDisplayInfo();
        mService.mPolicy.getStableInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight, mTmpRect2);
        final int position = new DividerSnapAlgorithm(mService.mContext.getResources(), di.logicalWidth, di.logicalHeight, dockDividerWidth, mService.mCurConfiguration.orientation == ORIENTATION_PORTRAIT, mTmpRect2).getMiddleTarget().position;
        if (dockOnTopOrLeft) {
            if (splitHorizontally) {
                outBounds.right = position;
            } else {
                outBounds.bottom = position;
            }
        } else {
            if (splitHorizontally) {
                outBounds.left = position + dockDividerWidth;
            } else {
                outBounds.top = position + dockDividerWidth;
            }
        }
        return;
    }
    // Other stacks occupy whatever space is left by the docked stack.
    if (!dockOnTopOrLeft) {
        if (splitHorizontally) {
            outBounds.right = dockedBounds.left - dockDividerWidth;
        } else {
            outBounds.bottom = dockedBounds.top - dockDividerWidth;
        }
    } else {
        if (splitHorizontally) {
            outBounds.left = dockedBounds.right + dockDividerWidth;
        } else {
            outBounds.top = dockedBounds.bottom + dockDividerWidth;
        }
    }
    DockedDividerUtils.sanitizeStackBounds(outBounds, !dockOnTopOrLeft);
}
Also used : DisplayInfo(android.view.DisplayInfo) DividerSnapAlgorithm(com.android.internal.policy.DividerSnapAlgorithm)

Example 60 with DisplayInfo

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

the class WindowManagerService method getNonDecorInsetsLocked.

private void getNonDecorInsetsLocked(Rect outInsets) {
    final DisplayInfo di = getDefaultDisplayInfoLocked();
    mPolicy.getNonDecorInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight, outInsets);
}
Also used : DisplayInfo(android.view.DisplayInfo)

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