安卓源码-保持屏幕旋转角度

frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java

1
2
3
4
5
6
7
8
9
10
11
12
13
public boolean updateRotationUncheckedLocked(boolean inTransaction) {
...

if (DEBUG_ORIENTATION) {
Slog.v(TAG_WM, "Selected orientation "
+ mLastOrientation + ", got rotation " + rotation
+ " which has " + (altOrientation ? "incompatible" : "compatible")
+ " metrics");
}

...
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* Add By e0040: Force show rotation .
* Test using adb shell setprop sys.rotation.LANDSCAPE 0/90/180/270
*/

switch (SystemProperties.getInt("sys.rotation.LANDSCAPE", 0)) {

case 0:
rotation = Surface.ROTATION_0;
break;

case 90:
rotation = Surface.ROTATION_90;
break;

case 180:
rotation = Surface.ROTATION_180;
break;

case 270:
rotation = Surface.ROTATION_270;
break;

default:
rotation = Surface.ROTATION_0;
};

Test

1
2
adb shell setprop sys.rotation.LANDSCAPE 0


安卓源码-保持屏幕旋转角度
https://blackist.org/2018-08-24-android-source-screen-rotation/
作者
董猿外
发布于
2018年8月24日
许可协议