安卓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个方向旋转,其他的特殊的功能不需要,误差大点无所谓,这样修改能满足产品需求就行

相关推荐
丁引几秒前
《数据清洗的艺术:如何用20行核心逻辑优雅地删除无标签图片》
前端·数据库·python
梦想的旅途24 分钟前
企业微信API二次开发:外部群模块功能清单与全场景对接
java·python·企业微信
c2385614 分钟前
MySQL 基础用法(下):查询进阶与核心特性
android·c语言·c++·mysql
05664616 分钟前
Python高级——迭代器
开发语言·python·学习
初级代码游戏24 分钟前
iOS开发 Swift 速记4:函数与闭包
开发语言·ios·swift
math_hongfan29 分钟前
鸿蒙Agent高级技能自定义开发:自定义意图服务/能力注册/Agent技能编排/服务插件开发实战
android·学习·华为·harmonyos·鸿蒙
郭涤生37 分钟前
C++ 零拷贝(Zero-Copy)
linux·开发语言·c++
老白干1 小时前
基于 Spring AOP 的操作日志记录:以 DeptController 增删接口为例
java·python·spring
回忆2012初秋1 小时前
C# 中的 EAP:基于事件的异步编程全面指南(一)
开发语言·c#
ty_xiumud1 小时前
以太网 MAC 详解:帧格式、位序、FCS 与收发流程
开发语言·macos·php