问题描述:
ES8316或ES8336 播放音乐时切换耳机,当状态栏耳机图标消失时,播放的音乐声音会关闭再打开一下的解决办法如下:
frameworks\base\services\core\java\com\android\server\audio\AudioService.java
private int checkSendBecomingNoisyIntent(int device, int state, int musicDevice) {int delay = 0;if ((state == 0) && ((device & mBecomingNoisyIntentDevices) != 0)) {int devices = 0;for (int i = 0; i < mConnectedDevices.size(); i++) {int dev = mConnectedDevices.valueAt(i).mDeviceType;if (((dev & AudioSystem.DEVICE_BIT_IN) == 0)&& ((dev & mBecomingNoisyIntentDevices) != 0)) {devices |= dev;}}if (musicDevice == AudioSystem.DEVICE_NONE) {musicDevice = getDeviceForStream(AudioSystem.STREAM_MUSIC);}// ignore condition on device being actually used for music when in communication// because music routing is altered in this case.// also checks whether media routing if affected by a dynamic policyif (((device == musicDevice) || isInCommunication()) && (device == devices)&& !hasMediaDynamicPolicy()) {mAudioHandler.removeMessages(MSG_BROADCAST_AUDIO_BECOMING_NOISY);sendMsg(mAudioHandler,MSG_BROADCAST_AUDIO_BECOMING_NOISY,SENDMSG_REPLACE,0,0,null,0);
- //delay = 1000;
+ delay = 0;}}return delay;}