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

相关推荐
弥巷7 小时前
【Android】Binder机制浅析
android
龙泉寺天下行走7 小时前
[PowerShell 入门教程] 第9.5天(间章):PowerShell 常见 Cmdlet 速查手册
开发语言·php
muxin-始终如一7 小时前
Semaphore 使用及原理详解
java·开发语言·python
水水不水啊7 小时前
通过一个域名,借助IPV6免费远程访问自己家里的设备
前端·python·算法
不会写代码的猴子7 小时前
安卓兼容性框架变更记录
android
nju_spy8 小时前
力扣每日一题(11.10-11.29)0-1 和 k 整除系列
python·算法·leetcode·前缀和·单调栈·最大公约数·0-1背包
名扬9118 小时前
webrtc编译问题-ubuntu
开发语言·python
无风之翼8 小时前
android12下拉菜单栏界面上方显示无内容
android·java
6***94158 小时前
MySQL 字符串日期格式转换
android·数据库·mysql
岁月宁静8 小时前
从 JavaScript 到 Python:前端工程师的完全转换指南
前端·javascript·python