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即可。

相关推荐
过期动态26 分钟前
JDBC高级篇:优化、封装与事务全流程指南
android·java·开发语言·数据库·python·mysql
没有了遇见3 小时前
Android 音乐播放器之MotionLayout实现View流畅变换
android
TheNextByte13 小时前
在 PC 和Android之间同步音乐的 4 种方法
android
君莫啸ོ4 小时前
Android基础-Activity属性 android:configChanges
android
TimeFine4 小时前
Android AI解放生产力(七):更丰富的AI运用前瞻
android
保持低旋律节奏4 小时前
linux——进程状态
android·linux·php
明川4 小时前
Android Gradle - ASM + AsmClassVisitorFactory插桩使用
android·前端·gradle
csdn12259873365 小时前
Android将应用添加到默认打开方式
android
百锦再5 小时前
京东云鼎入驻方案解读——通往协同的“高架桥”与“快速路”
android·java·python·rust·django·restful·京东云
成都大菠萝5 小时前
1-2-3 Kotlin与C++基础-JNI原理与使用
android