Skip to content

Instantly share code, notes, and snippets.

@jedld
Created February 17, 2017 18:46
Show Gist options
  • Save jedld/84958d2412f1cae61fa9b2799ef73a44 to your computer and use it in GitHub Desktop.
Save jedld/84958d2412f1cae61fa9b2799ef73a44 to your computer and use it in GitHub Desktop.
patch so that screen does not turn upside down during power off fade out sequence
diff --git a/services/core/java/com/android/server/display/ColorFade.java b/services/core/java/com/android/server/display/ColorFade.java
index a16fcd2..fee6bd0 100644
--- a/services/core/java/com/android/server/display/ColorFade.java
+++ b/services/core/java/com/android/server/display/ColorFade.java
@@ -42,6 +42,7 @@ import android.view.Surface.OutOfResourcesException;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.SurfaceSession;
+import android.os.SystemProperties;
import libcore.io.Streams;
@@ -91,6 +92,7 @@ final class ColorFade {
private EGLSurface mEglSurface;
private boolean mSurfaceVisible;
private float mSurfaceAlpha;
+ private final int mHWRotation;
// Texture names. We only use one texture, which contains the screenshot.
private final int[] mTexNames = new int[1];
@@ -124,6 +126,7 @@ final class ColorFade {
public ColorFade(int displayId) {
mDisplayId = displayId;
+ mHWRotation = Integer.parseInt(SystemProperties.get("ro.sf.hwrotation", "0")) / 90;
mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
}
@@ -594,7 +597,7 @@ final class ColorFade {
mSurface.copyFrom(mSurfaceControl);
mSurfaceLayout = new NaturalSurfaceLayout(mDisplayManagerInternal,
- mDisplayId, mSurfaceControl);
+ mDisplayId, mSurfaceControl, mHWRotation);
mSurfaceLayout.onDisplayTransaction();
}
} finally {
@@ -728,13 +731,16 @@ final class ColorFade {
private final DisplayManagerInternal mDisplayManagerInternal;
private final int mDisplayId;
private SurfaceControl mSurfaceControl;
+ private final int mHWRotation;
public NaturalSurfaceLayout(DisplayManagerInternal displayManagerInternal,
- int displayId, SurfaceControl surfaceControl) {
+ int displayId, SurfaceControl surfaceControl,
+ int hwRotation) {
mDisplayManagerInternal = displayManagerInternal;
mDisplayId = displayId;
mSurfaceControl = surfaceControl;
mDisplayManagerInternal.registerDisplayTransactionListener(this);
+ mHWRotation = hwRotation;
}
public void dispose() {
@@ -752,7 +758,7 @@ final class ColorFade {
}
DisplayInfo displayInfo = mDisplayManagerInternal.getDisplayInfo(mDisplayId);
- switch (displayInfo.rotation) {
+ switch ((displayInfo.rotation + mHWRotation) % 4) {
case Surface.ROTATION_0:
mSurfaceControl.setPosition(0, 0);
mSurfaceControl.setMatrix(1, 0, 0, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment