Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3cbfd10b authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "Partial fix for issue 3515250: video chat and SCO" into honeycomb-mr1

parents 3ec9d06f fa640154
Loading
Loading
Loading
Loading
+22 −26
Original line number Original line Diff line number Diff line
@@ -110,6 +110,8 @@ public class AudioService extends IAudioService.Stub {
    private static final int MSG_PLAY_SOUND_EFFECT = 7;
    private static final int MSG_PLAY_SOUND_EFFECT = 7;
    private static final int MSG_BTA2DP_DOCK_TIMEOUT = 8;
    private static final int MSG_BTA2DP_DOCK_TIMEOUT = 8;
    private static final int MSG_LOAD_SOUND_EFFECTS = 9;
    private static final int MSG_LOAD_SOUND_EFFECTS = 9;
    private static final int MSG_SET_FORCE_USE = 10;



    private static final int BTA2DP_DOCK_TIMEOUT_MILLIS = 8000;
    private static final int BTA2DP_DOCK_TIMEOUT_MILLIS = 8000;


@@ -1170,22 +1172,15 @@ public class AudioService extends IAudioService.Stub {
        if (!checkAudioSettingsPermission("setSpeakerphoneOn()")) {
        if (!checkAudioSettingsPermission("setSpeakerphoneOn()")) {
            return;
            return;
        }
        }
        if (on) {
        mForcedUseForComm = on ? AudioSystem.FORCE_SPEAKER : AudioSystem.FORCE_NONE;
            AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION, AudioSystem.FORCE_SPEAKER);

            mForcedUseForComm = AudioSystem.FORCE_SPEAKER;
        sendMsg(mAudioHandler, MSG_SET_FORCE_USE, SHARED_MSG, SENDMSG_QUEUE,
        } else {
                AudioSystem.FOR_COMMUNICATION, mForcedUseForComm, null, 0);
            AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION, AudioSystem.FORCE_NONE);
            mForcedUseForComm = AudioSystem.FORCE_NONE;
        }
    }
    }


    /** @see AudioManager#isSpeakerphoneOn() */
    /** @see AudioManager#isSpeakerphoneOn() */
    public boolean isSpeakerphoneOn() {
    public boolean isSpeakerphoneOn() {
        if (mForcedUseForComm == AudioSystem.FORCE_SPEAKER) {
        return (mForcedUseForComm == AudioSystem.FORCE_SPEAKER);
            return true;
        } else {
            return false;
        }
    }
    }


    /** @see AudioManager#setBluetoothScoOn() */
    /** @see AudioManager#setBluetoothScoOn() */
@@ -1193,24 +1188,17 @@ public class AudioService extends IAudioService.Stub {
        if (!checkAudioSettingsPermission("setBluetoothScoOn()")) {
        if (!checkAudioSettingsPermission("setBluetoothScoOn()")) {
            return;
            return;
        }
        }
        if (on) {
        mForcedUseForComm = on ? AudioSystem.FORCE_BT_SCO : AudioSystem.FORCE_NONE;
            AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION, AudioSystem.FORCE_BT_SCO);

            AudioSystem.setForceUse(AudioSystem.FOR_RECORD, AudioSystem.FORCE_BT_SCO);
        sendMsg(mAudioHandler, MSG_SET_FORCE_USE, SHARED_MSG, SENDMSG_QUEUE,
            mForcedUseForComm = AudioSystem.FORCE_BT_SCO;
                AudioSystem.FOR_COMMUNICATION, mForcedUseForComm, null, 0);
        } else {
        sendMsg(mAudioHandler, MSG_SET_FORCE_USE, SHARED_MSG, SENDMSG_QUEUE,
            AudioSystem.setForceUse(AudioSystem.FOR_COMMUNICATION, AudioSystem.FORCE_NONE);
                AudioSystem.FOR_RECORD, mForcedUseForComm, null, 0);
            AudioSystem.setForceUse(AudioSystem.FOR_RECORD, AudioSystem.FORCE_NONE);
            mForcedUseForComm = AudioSystem.FORCE_NONE;
        }
    }
    }


    /** @see AudioManager#isBluetoothScoOn() */
    /** @see AudioManager#isBluetoothScoOn() */
    public boolean isBluetoothScoOn() {
    public boolean isBluetoothScoOn() {
        if (mForcedUseForComm == AudioSystem.FORCE_BT_SCO) {
        return (mForcedUseForComm == AudioSystem.FORCE_BT_SCO);
            return true;
        } else {
            return false;
        }
    }
    }


    /** @see AudioManager#startBluetoothSco() */
    /** @see AudioManager#startBluetoothSco() */
@@ -1935,6 +1923,10 @@ public class AudioService extends IAudioService.Stub {
            }
            }
        }
        }


        private void setForceUse(int usage, int config) {
            AudioSystem.setForceUse(usage, config);
        }

        @Override
        @Override
        public void handleMessage(Message msg) {
        public void handleMessage(Message msg) {
            int baseMsgWhat = getMsgBase(msg.what);
            int baseMsgWhat = getMsgBase(msg.what);
@@ -2026,6 +2018,10 @@ public class AudioService extends IAudioService.Stub {
                    // msg.obj  == address of BTA2DP device
                    // msg.obj  == address of BTA2DP device
                    makeA2dpDeviceUnavailableNow( (String) msg.obj );
                    makeA2dpDeviceUnavailableNow( (String) msg.obj );
                    break;
                    break;

                case MSG_SET_FORCE_USE:
                    setForceUse(msg.arg1, msg.arg2);
                    break;
            }
            }
        }
        }
    }
    }