安卓11重力感应不灵敏问题

在安卓11上调试da218-gsensor芯片,底层数据上报正常,但就是在机器旋转的时候,系统旋转时灵时不灵,排除底层数据的问题,直接打开frameworks\base\services\core\java\com\android\server\policy\WindowOrientationListener.java

看这里监听处理数据的位置,日志打开后,发现不灵敏的时候一直报:Ignoring sensor data, device is overhead: tiltAngle=-88 ,就是底层的数据在处理的时候被忽略了,找到代码位置:

复制代码
public void onSensorChanged(SensorEvent event) {

                // If the tilt angle is too close to horizontal then we cannot determine
                // the orientation angle of the screen.
                if (tiltAngle <= TILT_OVERHEAD_ENTER) {
                    mOverhead = true;
                } else if (tiltAngle >= TILT_OVERHEAD_EXIT) {
                    mOverhead = false;
                }
                if (mOverhead) {
                    if (LOG) {
                        Slog.v(TAG, "Ignoring sensor data, device is overhead: "
                                + "tiltAngle=" + tiltAngle);
                    }
                    clearPredictedRotationLocked();
                } else if (Math.abs(tiltAngle) > MAX_TILT) {
                    if (LOG) {
                        Slog.v(TAG, "Ignoring sensor data, tilt angle too high: "
                                + "tiltAngle=" + tiltAngle);
                    }
                    clearPredictedRotationLocked();
                }
                直接吧这个宏修改为:
                        private static final int TILT_OVERHEAD_ENTER = -100;

问题解决,反正机器只需要4个方向旋转,其他的特殊的功能不需要,误差大点无所谓,这样修改能满足产品需求就行

相关推荐
Kratzdisteln3 分钟前
【Python】绘制椭圆眼睛跟随鼠标交互算法配图详解
python·数学·numpy·pillow·matplotlib·仿射变换
maxruan13 分钟前
PyTorch学习
人工智能·pytorch·python·学习
꒰ঌ 安卓开发໒꒱26 分钟前
Mysql 坏表修复
android·mysql·adb
_李小白27 分钟前
【Android Gradle学习笔记】第八天:NDK的使用
android·笔记·学习
ftpeak31 分钟前
JavaScript性能优化实战
开发语言·javascript·性能优化
袁震32 分钟前
Android-Compose 列表组件详解
android·recyclerview·compose
唐古乌梁海34 分钟前
【python】在Django中,执行原生SQL查询
python·sql·django
一个很帅的帅哥1 小时前
JavaScript事件循环
开发语言·前端·javascript
驰羽1 小时前
[GO]gin框架:ShouldBindJSON与其他常见绑定方法
开发语言·golang·gin
程序员大雄学编程1 小时前
「用Python来学微积分」5. 曲线的极坐标方程
开发语言·python·微积分