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

Commit 29ffe084 authored by Tom Giordano's avatar Tom Giordano Committed by Gerrit Code Review
Browse files

framework: fix screenshot and rotation aimation for devices with abnormal hw rotation

Change-Id: I42694931cb1a754aa6c7652c0a96304ef1f88492
parent 4dbaf3ee
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -382,7 +382,10 @@ class GlobalScreenshot {
        // only in the natural orientation of the device :!)
        // only in the natural orientation of the device :!)
        mDisplay.getRealMetrics(mDisplayMetrics);
        mDisplay.getRealMetrics(mDisplayMetrics);
        float[] dims = {mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels};
        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);
        boolean requiresRotation = (degrees > 0);
        if (requiresRotation) {
        if (requiresRotation) {
            // Get the dimensions of the device in its native orientation
            // Get the dimensions of the device in its native orientation
+19 −8
Original line number Original line Diff line number Diff line
@@ -188,8 +188,10 @@ class ScreenRotationAnimation {
    public ScreenRotationAnimation(Context context, SurfaceSession session,
    public ScreenRotationAnimation(Context context, SurfaceSession session,
            boolean inTransaction, int originalWidth, int originalHeight, int originalRotation) {
            boolean inTransaction, int originalWidth, int originalHeight, int originalRotation) {
        mContext = context;
        mContext = context;

        int mSnapshotRotation;
        // 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
            if (originalRotation == Surface.ROTATION_90
                || originalRotation == Surface.ROTATION_270) {
                || originalRotation == Surface.ROTATION_270) {
                mWidth = originalHeight;
                mWidth = originalHeight;
@@ -198,7 +200,16 @@ class ScreenRotationAnimation {
                mWidth = originalWidth;
                mWidth = originalWidth;
                mHeight = originalHeight;
                mHeight = originalHeight;
            }
            }

        } else {
            if (originalRotation == Surface.ROTATION_90
                || originalRotation == Surface.ROTATION_270) {
                mWidth = originalWidth;
                mHeight = originalHeight;
            } else {
                mWidth = originalHeight;
                mHeight = originalWidth;
            }
        }
        mOriginalRotation = originalRotation;
        mOriginalRotation = originalRotation;
        mOriginalWidth = originalWidth;
        mOriginalWidth = originalWidth;
        mOriginalHeight = originalHeight;
        mOriginalHeight = originalHeight;
+3 −0
Original line number Original line Diff line number Diff line
@@ -5528,6 +5528,9 @@ public class WindowManagerService extends IWindowManager.Stub


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

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