Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93fa3191 authored by David van Tonder's avatar David van Tonder Committed by Gerrit Code Review
Browse files

Merge "framework: fix screenshot and rotation animation for devices with...

Merge "framework: fix screenshot and rotation animation for devices with abnormal hw rotation" into mr1-staging
parents 3e65d1e9 ac555b9c
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -381,7 +381,10 @@ class GlobalScreenshot {
        // only in the natural orientation of the device :!)
        mDisplay.getRealMetrics(mDisplayMetrics);
        float[] dims = {mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels};
        float degrees = getDegreesForRotation(mDisplay.getRotation());
        int rot = mDisplay.getRotation();
        // Allow for abnormal hardware orientation
        rot = (rot + (android.os.SystemProperties.getInt("ro.sf.hwrotation",0) / 90 )) % 4;
        float degrees = getDegreesForRotation(rot);
        boolean requiresRotation = (degrees > 0);
        if (requiresRotation) {
            // Get the dimensions of the device in its native orientation
+20 −8
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ class ScreenRotationAnimation {
    BlackFrame mEnteringBlackFrame;
    int mWidth, mHeight;
    int mExitAnimId, mEnterAnimId;
    int mSnapshotRotation;

    int mOriginalRotation;
    int mOriginalWidth, mOriginalHeight;
@@ -196,7 +197,9 @@ class ScreenRotationAnimation {
        mExitAnimId = exitAnim;
        mEnterAnimId = enterAnim;

        // Screenshot does NOT include rotation!
        // Allow for abnormal hardware orientation
        mSnapshotRotation = (4 - android.os.SystemProperties.getInt("ro.sf.hwrotation",0) / 90) % 4;
        if (mSnapshotRotation == Surface.ROTATION_0 || mSnapshotRotation == Surface.ROTATION_180) {
            if (originalRotation == Surface.ROTATION_90
                || originalRotation == Surface.ROTATION_270) {
                mWidth = originalHeight;
@@ -205,7 +208,16 @@ class ScreenRotationAnimation {
                mWidth = originalWidth;
                mHeight = originalHeight;
            }

        } else {
            if (originalRotation == Surface.ROTATION_90
                || originalRotation == Surface.ROTATION_270) {
                mWidth = originalWidth;
                mHeight = originalHeight;
            } else {
                mWidth = originalHeight;
                mHeight = originalWidth;
            }
        }
        mOriginalRotation = originalRotation;
        mOriginalWidth = originalWidth;
        mOriginalHeight = originalHeight;
@@ -313,7 +325,7 @@ class ScreenRotationAnimation {
        // Compute the transformation matrix that must be applied
        // to the snapshot to make it stay in the same original position
        // with the current screen rotation.
        int delta = deltaRotation(rotation, Surface.ROTATION_0);
        int delta = deltaRotation(rotation, mSnapshotRotation);
        createRotationMatrix(delta, mWidth, mHeight, mSnapshotInitialMatrix);

        if (DEBUG_STATE) Slog.v(TAG, "**** ROTATION: " + delta);
+3 −0
Original line number Diff line number Diff line
@@ -5861,6 +5861,9 @@ public class WindowManagerService extends IWindowManager.Stub

            // The screenshot API does not apply the current screen rotation.
            rot = getDefaultDisplayContentLocked().getDisplay().getRotation();
            // Allow for abnormal hardware orientation
            rot = (rot + (android.os.SystemProperties.getInt("ro.sf.hwrotation",0) / 90 )) % 4;

            int fw = frame.width();
            int fh = frame.height();