android|android4.2 lcd 旋转180度

--- a/services/surfaceflinger/DisplayDevice.cpp
+++ 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& 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;
+}



【android|android4.2 lcd 旋转180度】init.rc: setprop ro.sf.hwrotation 180

    推荐阅读