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

Commit 22a7c840 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira 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 cm-11.0
parents 016664aa 7fce58e0
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -343,6 +343,8 @@ class GlobalScreenshot {

    private MediaActionSound mCameraSound;

    private final int mSfHwRotation;


    /**
     * @param context everything needs a context :(
@@ -396,6 +398,9 @@ class GlobalScreenshot {
        // Setup the Camera shutter sound
        mCameraSound = new MediaActionSound();
        mCameraSound.load(MediaActionSound.SHUTTER_CLICK);

        // Load hardware rotation from prop
        mSfHwRotation = android.os.SystemProperties.getInt("ro.sf.hwrotation",0) / 90;
    }

    /**
@@ -437,7 +442,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 + mSfHwRotation) % 4;
        float degrees = getDegreesForRotation(rot);
        boolean requiresRotation = (degrees > 0);
        if (requiresRotation) {
            // Get the dimensions of the device in its native orientation
+21 −7
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ class ScreenRotationAnimation {
    BlackFrame mExitingBlackFrame;
    BlackFrame mEnteringBlackFrame;
    int mWidth, mHeight;
    int mSnapshotRotation;

    int mOriginalRotation;
    int mOriginalWidth, mOriginalHeight;
@@ -220,6 +221,9 @@ class ScreenRotationAnimation {
            originalWidth = displayInfo.logicalWidth;
            originalHeight = displayInfo.logicalHeight;
        }
        // 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;
@@ -228,6 +232,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;
@@ -346,7 +360,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);
+8 −0
Original line number Diff line number Diff line
@@ -297,6 +297,8 @@ public class WindowManagerService extends IWindowManager.Stub

    private final boolean mHeadless;

    private final int mSfHwRotation;

    private BroadcastReceiver mThemeChangeReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            mUiContext = null;
@@ -814,6 +816,9 @@ public class WindowManagerService extends IWindowManager.Stub
        }

        ThemeUtils.registerThemeChangeReceiver(mContext, mThemeChangeReceiver);

        // Load hardware rotation from prop
        mSfHwRotation = android.os.SystemProperties.getInt("ro.sf.hwrotation",0) / 90;
    }

    private Context getUiContext() {
@@ -5678,6 +5683,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 + mSfHwRotation) % 4;

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