分析:在开发过程中,针对一些定制的特殊设备,客户提出不需要横竖屏切换
framework层路径:
–a /frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
++b /frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java
第1种修改方法:找到 updateOrientationFromAppTokensLocked方法
(直接修改req 使窗口默认旋转
SCREEN_ORIENTATION_LANDSCAPE :横屏显示
SCREEN_ORIENTATION_PORTRAIT : 竖屏显示)
boolean updateOrientationFromAppTokensLocked(boolean inTransaction) {
long ident = Binder.clearCallingIdentity();
try {
++ //start:add by wf 2021/05/14
– // int req = getOrientationLocked();
++ int req=ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
//end
if (req != mLastOrientation) {
mLastOrientation = req;
//send a message to Policy indicating orientation change to take
//action like disabling/enabling sensors etc.,
mPolicy.setCurrentOrientationLw(req);
if (updateRotationUncheckedLocked(inTransaction)) {
// changed
return true;
}
}
return false;
} finally {
Binder.restoreCallingIdentity(ident);
}
}
第2种修改方式:也是在WindowManagerService.java类下面:
0:代表横竖 3:代表竖屏)
if (mRotateOnBoot) {
mRotation = Surface.ROTATION_0;
rotation = Surface.ROTATION_90;
}
++ rotation= 3;//add by wf 2021/05/14
if (mRotation == rotation && mAltOrientation == altOrientation) {
// No change.
return false;
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)