Android7.1 强制横屏或竖屏显示

需求

  • 由于设备没有重力加速度传感器,需要始终横屏显示
  • 防止部分应用程序修改显示方向

patch

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/device/rockchip/rk3288/system.prop b/device/rockchip/rk3288/system.prop
index ce784d7..2206861 100644 (file)
--- a/device/rockchip/rk3288/system.prop
+++ b/device/rockchip/rk3288/system.prop
@@ -28,7 +28,7 @@ sys.wallpaper.rgb565=0
sf.power.control=2073600
sys.rkadb.root=0
ro.sf.fakerotation=false
-ro.sf.hwrotation=0
+ro.sf.hwrotation=90
ro.rk.MassStorage=false
ro.rk.systembar.voiceicon=true
ro.rk.systembar.tabletUI=false
1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java b/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
index f4ba143..50a4103 100755 (executable)
--- a/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -4360,7 +4360,7 @@ public class WindowManagerService extends IWindowManager.Stub
boolean updateOrientationFromAppTokensLocked(boolean inTransaction) {
long ident = Binder.clearCallingIdentity();
try {
- int req = getOrientationLocked();
+ int req = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
if (req != mLastOrientation) {
mLastOrientation = req;
//send a message to Policy indicating orientation change to take

SCREEN_ORIENTATION_LANDSCAPE :横屏显示
SCREEN_ORIENTATION_PORTRAIT : 竖屏显示

您的支持将鼓励我继续创作!