android13修改系统Launcher不跟随重力感应旋转

android13系统中需要修改系统原生Launcher不跟随重力感应旋转。

通过代码查找发现packages/apps/Launcher3/src/com/android/launcher3/states/RotationHelper.java中存在一个函数getAllowRotationDefaultValue,用于获取是否允许旋转的默认值。

java 复制代码
    public static boolean getAllowRotationDefaultValue(DisplayController.Info info) {
        // If the device's pixel density was scaled (usually via settings for A11y), use the
        // original dimensions to determine if rotation is allowed of not.
        float originalSmallestWidth = dpiFromPx(Math.min(info.currentSize.x, info.currentSize.y),
                DENSITY_DEVICE_STABLE);
        return originalSmallestWidth >= MIN_TABLET_WIDTH;
    }

这个函数主要根据屏幕dpi和尺寸来决定是否允许Luancher允许旋转。如果要禁止旋转直接返回false即可。

相关推荐
许愿OvO6 分钟前
MySQL触发器
android·mysql·adb
循环不息优化不止16 分钟前
Jetpack Compose 从重组到副作用的全方位解析
android
2501_916007472 小时前
iOS文件管理工具深度剖析,从系统沙盒到跨平台文件操作的多工具协同实践
android·macos·ios·小程序·uni-app·cocoa·iphone
Android疑难杂症3 小时前
鸿蒙Notification Kit通知服务开发快速指南
android·前端·harmonyos
lcanfly3 小时前
Mysql作业5
android·数据库·mysql
进阶的小叮当4 小时前
Vue代码打包成apk?Cordova帮你解决!
android·前端·javascript
-指短琴长-5 小时前
MySQL快速入门——基本查询(上)
android·数据库·mysql
下位子6 小时前
『OpenGL学习滤镜相机』- Day6: EGL 与 GLSurfaceView 深入理解
android·opengl
java干货6 小时前
MySQL “灵异事件”:我 INSERT id=11,为什么被 UPDATE id=10 锁住了?
android·数据库·mysql
正经教主7 小时前
【App开发】ADB 详细使用教程- Android 开发新人指南
android·adb