diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-10-08 17:36:18 -0400 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-10-08 17:36:18 -0400 |
commit | ff94720b8bf9f83f326197cb0cb27576168e9448 (patch) | |
tree | 6ccaacc0b29611661453c00673e3efb4154ed9d4 /core/java/android | |
parent | 9d5b58991ef90e91b3c942c80ae3502ed62d10aa (diff) | |
parent | 80a6a229b33b0868944fe011af2d778e23c83322 (diff) | |
download | frameworks_base-ff94720b8bf9f83f326197cb0cb27576168e9448.zip frameworks_base-ff94720b8bf9f83f326197cb0cb27576168e9448.tar.gz frameworks_base-ff94720b8bf9f83f326197cb0cb27576168e9448.tar.bz2 |
Merge change I80a6a229 into eclair
* changes:
Fix issue 2174002: After rejecting Call when device ringtone is mute and playing music, audio is not transfered to BT device.
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/server/BluetoothA2dpService.java | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/core/java/android/server/BluetoothA2dpService.java b/core/java/android/server/BluetoothA2dpService.java index b73e53f..9a2d6d9 100644 --- a/core/java/android/server/BluetoothA2dpService.java +++ b/core/java/android/server/BluetoothA2dpService.java @@ -72,6 +72,8 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { private final AudioManager mAudioManager; private final BluetoothService mBluetoothService; private final BluetoothAdapter mAdapter; + private boolean mSuspending; + private boolean mResuming; private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override @@ -149,6 +151,8 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { if (mBluetoothService.isEnabled()) onBluetoothEnable(); + mSuspending = false; + mResuming = false; } @Override @@ -241,6 +245,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { } } mAudioManager.setParameters(BLUETOOTH_ENABLED+"=true"); + mAudioManager.setParameters("A2dpSuspended=false"); } private synchronized void onBluetoothDisable() { @@ -336,7 +341,10 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { public synchronized boolean suspendSink(BluetoothDevice device) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); - if (DBG) log("suspendSink(" + device + ")"); + if (DBG) log("suspendSink(" + device + "), mSuspending: "+mSuspending+", mResuming: "+mResuming); + if (mSuspending) { + return true; + } if (device == null || mAudioDevices == null) { return false; } @@ -347,9 +355,14 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { } switch (state.intValue()) { case BluetoothA2dp.STATE_CONNECTED: + if (mResuming) { + mSuspending = true; + } return true; case BluetoothA2dp.STATE_PLAYING: - return suspendSinkNative(path); + mAudioManager.setParameters("A2dpSuspended=true"); + mSuspending = suspendSinkNative(path); + return mSuspending; default: return false; } @@ -358,7 +371,10 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { public synchronized boolean resumeSink(BluetoothDevice device) { mContext.enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission"); - if (DBG) log("resumeSink(" + device + ")"); + if (DBG) log("resumeSink(" + device + "), mResuming: "+mResuming+", mSuspending: "+mSuspending); + if (mResuming) { + return true; + } if (device == null || mAudioDevices == null) { return false; } @@ -369,9 +385,14 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { } switch (state.intValue()) { case BluetoothA2dp.STATE_PLAYING: + if (mSuspending) { + mResuming = true; + } return true; case BluetoothA2dp.STATE_CONNECTED: - return resumeSinkNative(path); + mResuming = resumeSinkNative(path); + mAudioManager.setParameters("A2dpSuspended=false"); + return mResuming; default: return false; } @@ -437,6 +458,10 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { } private void handleSinkStateChange(BluetoothDevice device, int prevState, int state) { + if (state == BluetoothA2dp.STATE_DISCONNECTED) { + mSuspending = false; + mResuming = false; + } if (state != prevState) { if (state == BluetoothA2dp.STATE_DISCONNECTED || state == BluetoothA2dp.STATE_DISCONNECTING) { @@ -452,6 +477,29 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { } mAudioDevices.put(device, state); + if (state == BluetoothA2dp.STATE_CONNECTED && prevState == BluetoothA2dp.STATE_PLAYING) { + if (DBG) log("handleSinkStateChange() STATE_PLAYING -> STATE_CONNECTED: mSuspending: " + +mSuspending+", mResuming: "+mResuming); + if (mSuspending) { + mSuspending = false; + if (mResuming) { + mResuming = false; + resumeSink(device); + } + } + } + if (state == BluetoothA2dp.STATE_PLAYING && prevState == BluetoothA2dp.STATE_CONNECTED) { + if (DBG) log("handleSinkStateChange() STATE_CONNECTED -> STATE_PLAYING: mSuspending: " + +mSuspending+", mResuming: "+mResuming); + + if (mResuming) { + mResuming = false; + if (mSuspending) { + mSuspending = false; + suspendSink(device); + } + } + } Intent intent = new Intent(BluetoothA2dp.ACTION_SINK_STATE_CHANGED); intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); intent.putExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE, prevState); |