高通 插入蓝牙耳机之后,声音变的很大!尝试了,苹果,MTK等等机器都是这样,
后分析,发现这个是 耳机发的广播MESSAGE_VOLUME_CHANGED: volume=104 ctype=15 自带的音量数据,
我们能处理就是,在获取到广播之后,对声音过大的时候,判断,然后设置一个小点的值!
Line 5738: 01-02 04:39:45.018 8373 8419 V Avrcp : MESSAGE_VOLUME_CHANGED: volume=24 ctype=15
Line 5739: 01-02 04:39:45.019 8373 8419 V Avrcp : event for device address 1C:52:16:63:EB:99
Line 5746: 01-02 04:39:45.019 8373 8419 I Avrcp : device found at index 0
Line 5747: 01-02 04:39:45.019 8373 8419 V Avrcp : Volume Index = 3
Line 5748: 01-02 04:39:45.023 8373 8419 E Avrcp : percent volume changed: 18%
Line 8228: 01-02 04:40:25.607 8373 8419 V Avrcp : MESSAGE_VOLUME_CHANGED: volume=104 ctype=15
Line 8229: 01-02 04:40:25.607 8373 8419 V Avrcp : event for device address 1C:52:16:63:EB:99
Line 8230: 01-02 04:40:25.608 8373 8419 I Avrcp : device found at index 0
Line 8231: 01-02 04:40:25.608 8373 8419 V Avrcp : Volume Index = 12
Line 8242: 01-02 04:40:25.616 8373 8419 E Avrcp : percent volume changed: 81%
高通代码,其实代码已经有了这个功能,但是没有进去,后面分析deviceFeatures[deviceIndex].mAbsVolThreshold 是这个值默认为0导致的,后面把这个初始值改成7,问题解决。
mAbsVolThreshold = 7; // 修改这个初始值
if (deviceFeatures[deviceIndex].mInitialRemoteVolume == -1) {
deviceFeatures[deviceIndex].mInitialRemoteVolume = absVol;
if (deviceFeatures[deviceIndex].mAbsVolThreshold > 0 &&
deviceFeatures[deviceIndex].mAbsVolThreshold <
mAudioStreamMax &&
volIndex > deviceFeatures[deviceIndex].mAbsVolThreshold) {
if (DEBUG) Log.v(TAG, "remote inital volume too high " + volIndex + ">" +
deviceFeatures[deviceIndex].mAbsVolThreshold);
Message msg1 = mHandler.obtainMessage(MESSAGE_SET_ABSOLUTE_VOLUME,
deviceFeatures[deviceIndex].mAbsVolThreshold , 0);
mHandler.sendMessage(msg1);
deviceFeatures[deviceIndex].mRemoteVolume = absVol;
deviceFeatures[deviceIndex].mLocalVolume = volIndex;
break;
}
}