+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -358,6 +358,20 @@ status_t DisplayDevice::orientationToTransfrom(
int orientation, int w, int h, Transform* tr)
{
uint32_t flags = 0;
+ char value[PROPERTY_VALUE_MAX];
+ property_get("ro.sf.hwrotation", value, "0");
+ int additionalRot = atoi(value);
+
+ if (additionalRot) {
+ additionalRot /= 90;
+ if (orientation == DisplayState::eOrientationUnchanged) {
+ orientation = additionalRot;
+ } else {
+ orientation += additionalRot;
+ orientation %= 4;
+ }
+ }
+
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -683,10 +683,21 @@ status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo*
info->orientation = 0;
}
- info->w = hwc.getWidth(type);
- info->h = hwc.getHeight(type);
- info->xdpi = xdpi;
- info->ydpi = ydpi;
+ char value[PROPERTY_VALUE_MAX];
+ property_get("ro.sf.hwrotation", value, "0");
+ int additionalRot = atoi(value) / 90;
+ if ((type == DisplayDevice::DISPLAY_PRIMARY) && (additionalRot & DisplayState::eOrientationSwapMask)) {
+ info->h = hwc.getWidth(type);
+ info->w = hwc.getHeight(type);
+ info->xdpi = ydpi;
+ info->ydpi = xdpi;
+ }
+ else {
+ info->w = hwc.getWidth(type);
+ info->h = hwc.getHeight(type);
+ info->xdpi = xdpi;
+ info->ydpi = ydpi;
+ }
init.rc : setprop ro.sf.hwrotation 180