最近在项目中遇到了一个连接蓝牙耳机听歌,手机功耗太大的问题,手机的电流大于参考标椎40ma左右。
log分析, 出问题的时间点,avrcp一直在更新歌曲的进度,但是是负值,这个值表示的是下一个播放位置减去当前的播放位置,所以这个值不可能是负的。
06-17 21:12:30.839735 21887 21997 D Avrcp_ext: sendPlayPosNotificationRsp: (false) 738445 <=? 792497 <=? 740445 mLastReportedPosition 739445 Playing State: 3 Timeout -52052ms
06-17 21:12:30.839749 21887 21997 V Avrcp_ext: AvrcpMessageHandler: received message=14
06-17 21:12:30.839765 21887 21997 D Avrcp_ext: isPlayerPaused: state=3
06-17 21:12:30.839777 21887 21997 D Avrcp_ext: Exit getPlayPosition, position: 792497
06-17 21:12:30.839797 21887 21997 D Avrcp_ext: isPlayerPaused: state=3
06-17 21:12:30.839810 21887 21997 D Avrcp_ext: sendPlayPosNotificationRsp: (false) 738445 <=? 792497 <=? 740445 mLastReportedPosition 739445 Playing State: 3 Timeout -52052ms
06-17 21:12:30.839825 21887 21997 V Avrcp_ext: AvrcpMessageHandler: received message=14
整个异常log一直在打印上述log,造成CPU使用率

在项目中遇到连接蓝牙耳机听歌时手机功耗过大的问题,主要是由于avrcp持续更新歌曲进度且出现负值。通过分析log发现错误地处理了负值,导致CPU使用率高。解决方案是在代码中修正,当检测到负值时将其强制转换为固定值,从而避免频繁发送handler消息,降低手机功耗。
最低0.47元/天 解锁文章
722

被折叠的 条评论
为什么被折叠?



