Android11 强制所有APP 横屏显示
发布日期:2021-06-29 13:07:48
浏览次数:2
分类:技术文章
本文共 2202 字,大约阅读时间需要 7 分钟。
前言
由于平板项目没有 Gsensor,需要将所有第三方APP强制横屏, 无视 android:screenOrientation=“portrait” 属性
效果图
修改前
修改后
修改源码
alps\frameworks\base\services\core\java\com\android\server\wm\DisplayRotation.java
@Surface.Rotation- private int mRotation;+ private int mRotation = 3; @Override boolean updateRotationUnchecked(boolean forceUpdate) { //add+ if (true) { + return true;+ }//end final int displayId = mDisplayContent.getDisplayId(); if (!forceUpdate) { if (mDeferredRotationPauseCount > 0) { // Rotation updates have been paused temporarily. Defer the update until updates // have been resumed. ProtoLog.v(WM_DEBUG_ORIENTATION, "Deferring rotation, rotation is paused."); return false; }
alps\frameworks\base\services\core\java\com\android\server\wm\DisplayContent.java
@ScreenOrientation @Override int getOrientation() { //add+ if (true) { + return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;+ }//end mLastOrientationSource = null; if (mIgnoreRotationForApps) { return SCREEN_ORIENTATION_USER; } if (mWmService.mDisplayFrozen) { if (mWmService.mPolicy.isKeyguardLocked()) { // Use the last orientation the while the display is frozen with the keyguard // locked. This could be the keyguard forced orientation or from a SHOW_WHEN_LOCKED // window. We don't want to check the show when locked window directly though as // things aren't stable while the display is frozen, for example the window could be // momentarily unavailable due to activity relaunch. ProtoLog.v(WM_DEBUG_ORIENTATION, "Display id=%d is frozen while keyguard locked, return %d", mDisplayId, getLastOrientation()); return getLastOrientation(); } } final int rootOrientation = mRootDisplayArea.getOrientation(); mLastOrientationSource = mRootDisplayArea.getLastOrientationSource(); return rootOrientation; }
转载地址:https://cczheng.blog.csdn.net/article/details/117379528 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
不错!
[***.144.177.141]2024年04月03日 15时45分53秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
中国信息化发展八大趋势(二)
2019-04-29
中国信息化发展八大趋势(三)
2019-04-29
中国信息化发展八大趋势(四)
2019-04-29
电商大战二十年
2019-04-29
神奇的麦考林
2019-04-29
centos7使用rpm安装mysql遇到的error: Failed dependencies: mysql-community-common(x86-64) 5.7.9 is needed
2019-04-29
spark报错:warn util.utils::service ‘sparkUI‘ can not bind on part 4040.Attempting port 4041.4042等错误
2019-04-29
Error getting authority: Error initializing authority: Could not connect: No such file or directory
2019-04-29
编程程软件测试思维方式:如何科学制定测试计划
2019-04-29
BLE蓝牙4.0串口调试助手
2019-04-29
树莓派WIFI设置
2019-04-29
用vcgencmd获取树莓派硬件状态数据
2019-04-29
IIS 多域名多张证书配置
2019-04-29
树莓派LINUX 截屏
2019-04-29
树莓派Raspberry Pi的嵌入式QT平台
2019-04-29
apache https
2019-04-29
Debian Jessie安装支持HTML5音视频的Chromium浏览器听百度音乐
2019-04-29
nanopi2 启动信息
2019-04-29
POS打印机驱动大全
2019-04-29