summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorShareef Ali <shareefalis@gmail.com>2013-01-20 11:53:26 +0000
committercodeworkx <codeworkx@cyanogenmod.org>2013-01-20 11:54:42 +0000
commit8d43185c01e50deb8565f14ffda6afa788e52b3a (patch)
tree03eff042dc0ec1771d81f81d331079ff8a2e803f /media
parentfd9a957eb006cdb418800eece47a5adfd8730000 (diff)
downloadframeworks_base-8d43185c01e50deb8565f14ffda6afa788e52b3a.zip
frameworks_base-8d43185c01e50deb8565f14ffda6afa788e52b3a.tar.gz
frameworks_base-8d43185c01e50deb8565f14ffda6afa788e52b3a.tar.bz2
Audioservice: fix A2dp support on Samsung's Audio Policy HAL.
Samsung's audio policy HAL doesn't handle A2DP delay commands correctly which was merged in JB. Adds a nodelaya2dp config option. Change-Id: I188c6e59fdf1b30bef41d8e1aa84ac5319f3bcc3
Diffstat (limited to 'media')
-rwxr-xr-xmedia/java/android/media/AudioService.java65
1 files changed, 45 insertions, 20 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 4c0acf6..cd42da5 100755
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -42,6 +42,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
+import android.content.res.Resources;
import android.database.ContentObserver;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
@@ -61,6 +62,7 @@ import android.os.UserHandle;
import android.os.Vibrator;
import android.provider.Settings;
import android.provider.Settings.System;
+import android.provider.Settings.SettingNotFoundException;
import android.speech.RecognizerIntent;
import android.telephony.PhoneStateListener;
import android.telephony.ServiceState;
@@ -177,6 +179,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
/** @see VolumeStreamState */
private VolumeStreamState[] mStreamStates;
private SettingsObserver mSettingsObserver;
+ //nodelay in a2dp
+ private boolean noDelayInATwoDP = Resources.getSystem().getBoolean(com.android.internal.R.bool.config_noDelayInATwoDP);
private int mMode;
// protects mRingerMode
@@ -503,6 +507,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
// Register for device connection intent broadcasts.
IntentFilter intentFilter =
new IntentFilter(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED);
+ if (noDelayInATwoDP)
+ intentFilter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
intentFilter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);
intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
intentFilter.addAction(Intent.ACTION_USB_AUDIO_ACCESSORY_PLUG);
@@ -1882,6 +1888,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
/** @see AudioManager#setBluetoothA2dpOn() */
public void setBluetoothA2dpOn(boolean on) {
+ if (!checkAudioSettingsPermission("setBluetoothA2dpOn()") && noDelayInATwoDP) {
+ return;
+ }
synchronized (mBluetoothA2dpEnabledLock) {
mBluetoothA2dpEnabled = on;
sendMsg(mAudioHandler, MSG_SET_FORCE_BT_A2DP_USE, SENDMSG_QUEUE,
@@ -2188,17 +2197,21 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
deviceList = a2dp.getConnectedDevices();
if (deviceList.size() > 0) {
btDevice = deviceList.get(0);
- synchronized (mConnectedDevices) {
- int state = a2dp.getConnectionState(btDevice);
- int delay = checkSendBecomingNoisyIntent(
- AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
- (state == BluetoothA2dp.STATE_CONNECTED) ? 1 : 0);
- queueMsgUnderWakeLock(mAudioHandler,
- MSG_SET_A2DP_CONNECTION_STATE,
- state,
- 0,
- btDevice,
- delay);
+ if (!noDelayInATwoDP){
+ synchronized (mConnectedDevices) {
+ int state = a2dp.getConnectionState(btDevice);
+ int delay = checkSendBecomingNoisyIntent(
+ AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
+ (state == BluetoothA2dp.STATE_CONNECTED) ? 1 : 0);
+ queueMsgUnderWakeLock(mAudioHandler,
+ MSG_SET_A2DP_CONNECTION_STATE,
+ state,
+ 0,
+ btDevice,
+ delay);
+ }
+ } else {
+ onSetA2dpConnectionState(btDevice, a2dp.getConnectionState(btDevice));
}
}
break;
@@ -2617,15 +2630,19 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
public int setBluetoothA2dpDeviceConnectionState(BluetoothDevice device, int state)
{
int delay;
- synchronized (mConnectedDevices) {
- delay = checkSendBecomingNoisyIntent(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
- (state == BluetoothA2dp.STATE_CONNECTED) ? 1 : 0);
- queueMsgUnderWakeLock(mAudioHandler,
- MSG_SET_A2DP_CONNECTION_STATE,
- state,
- 0,
- device,
- delay);
+ if(!noDelayInATwoDP) {
+ synchronized (mConnectedDevices) {
+ delay = checkSendBecomingNoisyIntent(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
+ (state == BluetoothA2dp.STATE_CONNECTED) ? 1 : 0);
+ queueMsgUnderWakeLock(mAudioHandler,
+ MSG_SET_A2DP_CONNECTION_STATE,
+ state,
+ 0,
+ device,
+ delay);
+ }
+ } else {
+ delay = 0;
}
return delay;
}
@@ -3534,6 +3551,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
// must be called synchronized on mConnectedDevices
private void makeA2dpDeviceUnavailableNow(String address) {
+ if (noDelayInATwoDP)
+ onSendBecomingNoisyIntent();
AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
AudioSystem.DEVICE_STATE_UNAVAILABLE,
address);
@@ -3806,6 +3825,12 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
}
AudioSystem.setForceUse(AudioSystem.FOR_DOCK, config);
+ } else if (action.equals(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED) && noDelayInATwoDP) {
+ state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE,
+ BluetoothProfile.STATE_DISCONNECTED);
+ BluetoothDevice btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
+
+ onSetA2dpConnectionState(btDevice, state);
} else if (action.equals(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED)) {
state = intent.getIntExtra(BluetoothProfile.EXTRA_STATE,
BluetoothProfile.STATE_DISCONNECTED);