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

Commit 2191ff96 authored by Ayan Ghosh's avatar Ayan Ghosh Committed by Linux Build Service Account
Browse files

Bluetooth: Audio Squashed gerrits for propagation

Bluetooth: pause music player on A2dp service disconnect

When A2dp service disconnects as part of SSR, it marks a2dp state
as unavailable in Audio module but does not pause music player, as
a result when bluedroid stack restarts as part of sub system restart,
media player does not pause and music continues to play on device
speaker.
This change helps to pause the media player, in addition to marking
a2dp as unavailable, so that media player pauses when a2dp service
forcibly disconnects as part of sub system restart with A2dp in
connected state.

CRs-Fixed: 590462
Change-Id: I05ee5bcc808eb438156b64181d54e8ccabe1e186

Bluetooth: Add Total track number.

Add support to add total number of tracks in
Meta-data

Change-Id: I5b1287f791615adcd4f920fe5c7cae0c7c7b04ea
CRs-Fixed: 627869

Bluetooth: use  virtual sco calls for VOIP

 - use virtualvoicesco connection set-up for VOIP calls
 - cannot simply revert c18c9138
and 25fc29b3 changes because
of aidl modifications involved.

Change-Id: Ib49cb01151a9cea2e94bc7a51ad1f58e877271aa
CRs-Fixed: 598072

Send Media button events as foreground Intent

Send foreground intent for Media Button events to Music Player
so that there is no delay in handling these Intents after the
device is rebooted.

Change-Id: I952a8af93586cb96c0a9f6dc910bfb49287f4b9a
CRs-fixed: 611219
Conflicts:
media/java/android/media/AudioService.java
parent 0bf8e0cd
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -2392,6 +2392,7 @@ public class AudioManager {
        }
        }
        // construct a PendingIntent for the media button and register it
        // construct a PendingIntent for the media button and register it
        Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
        Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
        mediaButtonIntent.addFlags(mediaButtonIntent.FLAG_RECEIVER_FOREGROUND);
        //     the associated intent will be handled by the component being registered
        //     the associated intent will be handled by the component being registered
        mediaButtonIntent.setComponent(eventReceiver);
        mediaButtonIntent.setComponent(eventReceiver);
        PendingIntent pi = PendingIntent.getBroadcast(mContext,
        PendingIntent pi = PendingIntent.getBroadcast(mContext,
+31 −29
Original line number Original line Diff line number Diff line
@@ -2555,17 +2555,14 @@ public class AudioService extends IAudioService.Stub {
                                    }
                                    }
                                }
                                }
                                if (mBluetoothHeadset != null && mBluetoothHeadsetDevice != null) {
                                if (mBluetoothHeadset != null && mBluetoothHeadsetDevice != null) {
                                    boolean status = false;
                                    boolean status;
                                    if (mScoAudioMode == SCO_MODE_RAW) {
                                    if (mScoAudioMode == SCO_MODE_VR) {
                                        status = mBluetoothHeadset.connectAudio();
                                    } else if (mScoAudioMode == SCO_MODE_VIRTUAL_CALL) {
                                        status = mBluetoothHeadset.startScoUsingVirtualVoiceCall(
                                                                            mBluetoothHeadsetDevice);
                                    } else if (mScoAudioMode == SCO_MODE_VR) {
                                        status = mBluetoothHeadset.startVoiceRecognition(
                                        status = mBluetoothHeadset.startVoiceRecognition(
                                                                            mBluetoothHeadsetDevice);
                                                                            mBluetoothHeadsetDevice);
                                    } else {
                                        status = mBluetoothHeadset.startScoUsingVirtualVoiceCall(
                                                                            mBluetoothHeadsetDevice);
                                    }
                                    }

                                    if (status) {
                                    if (status) {
                                        mScoAudioState = SCO_STATE_ACTIVE_INTERNAL;
                                        mScoAudioState = SCO_STATE_ACTIVE_INTERNAL;
                                    } else {
                                    } else {
@@ -2588,15 +2585,13 @@ public class AudioService extends IAudioService.Stub {
                               mScoAudioState == SCO_STATE_ACTIVATE_REQ)) {
                               mScoAudioState == SCO_STATE_ACTIVATE_REQ)) {
                    if (mScoAudioState == SCO_STATE_ACTIVE_INTERNAL) {
                    if (mScoAudioState == SCO_STATE_ACTIVE_INTERNAL) {
                        if (mBluetoothHeadset != null && mBluetoothHeadsetDevice != null) {
                        if (mBluetoothHeadset != null && mBluetoothHeadsetDevice != null) {
                            boolean status = false;
                            boolean status;
                            if (mScoAudioMode == SCO_MODE_RAW) {
                            if (mScoAudioMode == SCO_MODE_VR) {
                                status = mBluetoothHeadset.disconnectAudio();
                            } else if (mScoAudioMode == SCO_MODE_VIRTUAL_CALL) {
                                status = mBluetoothHeadset.stopScoUsingVirtualVoiceCall(
                                                                        mBluetoothHeadsetDevice);
                            } else if (mScoAudioMode == SCO_MODE_VR) {
                                status = mBluetoothHeadset.stopVoiceRecognition(
                                status = mBluetoothHeadset.stopVoiceRecognition(
                                                                        mBluetoothHeadsetDevice);
                                                                        mBluetoothHeadsetDevice);
                            } else {
                                status = mBluetoothHeadset.stopScoUsingVirtualVoiceCall(
                                                                        mBluetoothHeadsetDevice);
                            }
                            }


                            if (!status) {
                            if (!status) {
@@ -2790,25 +2785,21 @@ public class AudioService extends IAudioService.Stub {
                            switch (mScoAudioState) {
                            switch (mScoAudioState) {
                            case SCO_STATE_ACTIVATE_REQ:
                            case SCO_STATE_ACTIVATE_REQ:
                                mScoAudioState = SCO_STATE_ACTIVE_INTERNAL;
                                mScoAudioState = SCO_STATE_ACTIVE_INTERNAL;
                                if (mScoAudioMode == SCO_MODE_RAW) {
                                if (mScoAudioMode == SCO_MODE_VR) {
                                    status = mBluetoothHeadset.connectAudio();
                                } else if (mScoAudioMode == SCO_MODE_VIRTUAL_CALL) {
                                    status = mBluetoothHeadset.startScoUsingVirtualVoiceCall(
                                                                        mBluetoothHeadsetDevice);
                                } else if (mScoAudioMode == SCO_MODE_VR) {
                                    status = mBluetoothHeadset.startVoiceRecognition(
                                    status = mBluetoothHeadset.startVoiceRecognition(
                                                                      mBluetoothHeadsetDevice);
                                                                      mBluetoothHeadsetDevice);
                                } else {
                                    status = mBluetoothHeadset.startScoUsingVirtualVoiceCall(
                                                                        mBluetoothHeadsetDevice);
                                }
                                }
                                break;
                                break;
                            case SCO_STATE_DEACTIVATE_REQ:
                            case SCO_STATE_DEACTIVATE_REQ:
                                if (mScoAudioMode == SCO_MODE_RAW) {
                                if (mScoAudioMode == SCO_MODE_VR) {
                                    status = mBluetoothHeadset.disconnectAudio();
                                } else if (mScoAudioMode == SCO_MODE_VIRTUAL_CALL) {
                                    status = mBluetoothHeadset.stopScoUsingVirtualVoiceCall(
                                                                        mBluetoothHeadsetDevice);
                                } else if (mScoAudioMode == SCO_MODE_VR) {
                                    status = mBluetoothHeadset.stopVoiceRecognition(
                                    status = mBluetoothHeadset.stopVoiceRecognition(
                                                                      mBluetoothHeadsetDevice);
                                                                      mBluetoothHeadsetDevice);
                                } else {
                                    status = mBluetoothHeadset.stopScoUsingVirtualVoiceCall(
                                                                        mBluetoothHeadsetDevice);
                                }
                                }
                                break;
                                break;
                            case SCO_STATE_DEACTIVATE_EXT_REQ:
                            case SCO_STATE_DEACTIVATE_EXT_REQ:
@@ -2829,14 +2820,25 @@ public class AudioService extends IAudioService.Stub {
            }
            }
        }
        }
        public void onServiceDisconnected(int profile) {
        public void onServiceDisconnected(int profile) {
            Log.d(TAG, "onServiceDisconnected: Bluetooth profile: " + profile);
            switch(profile) {
            switch(profile) {
            case BluetoothProfile.A2DP:
            case BluetoothProfile.A2DP:
                synchronized (mA2dpAvrcpLock) {
                synchronized (mA2dpAvrcpLock) {
                    mA2dp = null;
                    mA2dp = null;
                    synchronized (mConnectedDevices) {
                    synchronized (mConnectedDevices) {
                        if (mConnectedDevices.containsKey(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP)) {
                        if (mConnectedDevices.containsKey(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP)) {
                            makeA2dpDeviceUnavailableNow(
                            Log.d(TAG, "A2dp service disconnects, pause music player");
                                    mConnectedDevices.get(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP));
                            BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
                            BluetoothDevice btDevice = adapter.getRemoteDevice
                                    (mConnectedDevices.get(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP));
                            int delay = checkSendBecomingNoisyIntent(
                                                AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, 0);
                            queueMsgUnderWakeLock(mAudioHandler,
                                                MSG_SET_A2DP_SRC_CONNECTION_STATE,
                                                BluetoothA2dp.STATE_DISCONNECTED,
                                                0,
                                                btDevice,
                                                delay);
                        }
                        }
                    }
                    }
                }
                }
+3 −1
Original line number Original line Diff line number Diff line
@@ -439,7 +439,7 @@ import android.util.SparseIntArray;
    protected static final SparseIntArray METADATA_KEYS_TYPE;
    protected static final SparseIntArray METADATA_KEYS_TYPE;


    static {
    static {
        METADATA_KEYS_TYPE = new SparseIntArray(17);
        METADATA_KEYS_TYPE = new SparseIntArray(18);
        // NOTE: if adding to the list below, make sure you increment the array initialization size
        // NOTE: if adding to the list below, make sure you increment the array initialization size
        // keys with long values
        // keys with long values
        METADATA_KEYS_TYPE.put(
        METADATA_KEYS_TYPE.put(
@@ -465,5 +465,7 @@ import android.util.SparseIntArray;
        // keys with Rating values
        // keys with Rating values
        METADATA_KEYS_TYPE.put(RATING_KEY_BY_OTHERS, METADATA_TYPE_RATING);
        METADATA_KEYS_TYPE.put(RATING_KEY_BY_OTHERS, METADATA_TYPE_RATING);
        METADATA_KEYS_TYPE.put(RATING_KEY_BY_USER, METADATA_TYPE_RATING);
        METADATA_KEYS_TYPE.put(RATING_KEY_BY_USER, METADATA_TYPE_RATING);
        // Meta data for total number of tracks in Album
        METADATA_KEYS_TYPE.put(MediaMetadataRetriever.METADATA_KEY_NUM_TRACKS, METADATA_TYPE_LONG);
    }
    }
}
}