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

相关推荐
小章UPUP3 分钟前
2026 信息技术中考复习资料大全
python
2401_882273723 分钟前
CSS 背景色无法撑满父容器?解决浮动导致的高度塌陷问题
jvm·数据库·python
wuyoula6 分钟前
尹之盾企业版网络验证
服务器·开发语言·javascript·c++·人工智能·ui·c#
好家伙VCC9 分钟前
上市公司产学研合作及专利数据(1998-2022年)
人工智能·python
Via_Neo11 分钟前
区间dp算法
开发语言·javascript·算法
Carson带你学Android13 分钟前
谁才是地表最强 Android Agent 大模型?Google官方测评来了!
android·openai
weixin_3812881815 分钟前
jsoup如何读取html
jvm·数据库·python
aq553560015 分钟前
Laravel 10.x重磅升级:PHP 8.1+新时代
开发语言·php·laravel
秋雨梧桐叶落莳21 分钟前
iOS——Masonry约束内容整理
开发语言·学习·macos·ios·objective-c·cocoa
2401_8822737221 分钟前
golang如何处理zip压缩包_golang zip压缩包处理思路
jvm·数据库·python