强制横屏或竖屏

来源:互联网 发布:js push json 编辑:程序博客网 时间:2024/05/22 00:03


OS:安卓5.1


修改文件:frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java 

在函数updateOrientationFromAppTokensLocked添加蓝色字体表示强制为横屏,
强制为竖屏添加:req = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT




boolean updateOrientationFromAppTokensLocked(boolean inTransaction) {        long ident = Binder.clearCallingIdentity();        try {            int req = getOrientationFromWindowsLocked();            if (req == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {                req = getOrientationFromAppTokensLocked();            }           req = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;//强制为横屏,            if (req != mForcedAppOrientation) {                mForcedAppOrientation = 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);        }    }


原创粉丝点击