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
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
推荐阅读
- android第三方框架(五)ButterKnife
- Android中的AES加密-下
- 带有Hilt的Android上的依赖注入
- android|android studio中ndk的使用
- Android事件传递源码分析
- RxJava|RxJava 在Android项目中的使用(一)
- Android7.0|Android7.0 第三方应用无法访问私有库
- 深入理解|深入理解 Android 9.0 Crash 机制(二)
- android防止连续点击的简单实现(kotlin)
- Android|Android install 多个设备时指定设备