Fix issues 2333450 and 2333559:
Add new config values to AudioSystem::FOR_DOCK force usage to differenciate car and desk docks. Use a receiver for the sticky Intent.ACTION_DOCK_EVENT in AudioService to detect the type of dock and select force usage accordingly.
This commit is contained in:
committed by
Jean-Michel Trivi
parent
f0cdfa9955
commit
eb14a783be
@ -282,7 +282,8 @@ public:
|
||||
FORCE_BT_SCO,
|
||||
FORCE_BT_A2DP,
|
||||
FORCE_WIRED_ACCESSORY,
|
||||
FORCE_BT_DOCK,
|
||||
FORCE_BT_CAR_DOCK,
|
||||
FORCE_BT_DESK_DOCK,
|
||||
NUM_FORCE_CONFIG,
|
||||
FORCE_DEFAULT = FORCE_NONE
|
||||
};
|
||||
|
@ -112,7 +112,7 @@ public class AudioService extends IAudioService.Stub {
|
||||
private boolean mMediaServerOk;
|
||||
|
||||
/** cached value of the BT dock address to recognize undocking events */
|
||||
private static String sBtDockAddress;
|
||||
private static String sBtDockAddress = "";
|
||||
|
||||
private SoundPool mSoundPool;
|
||||
private Object mSoundEffectsLock = new Object();
|
||||
@ -231,6 +231,7 @@ public class AudioService extends IAudioService.Stub {
|
||||
// Forced device usage for communications
|
||||
private int mForcedUseForComm;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Construction
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -1414,9 +1415,25 @@ public class AudioService extends IAudioService.Stub {
|
||||
(state == BluetoothA2dp.STATE_CONNECTED ||
|
||||
state == BluetoothA2dp.STATE_PLAYING)) {
|
||||
if (btDevice.isBluetoothDock()) {
|
||||
Log.v(TAG, "Recognized docking to BT dock");
|
||||
Log.v(TAG, "Recognized connection to BT dock");
|
||||
sBtDockAddress = address;
|
||||
AudioSystem.setForceUse(AudioSystem.FOR_DOCK, AudioSystem.FORCE_BT_DOCK);
|
||||
Intent i = context.registerReceiver(null, new IntentFilter(Intent.ACTION_DOCK_EVENT));
|
||||
if (i != null) {
|
||||
int dockState = i.getIntExtra(Intent.EXTRA_DOCK_STATE, Intent.EXTRA_DOCK_STATE_UNDOCKED);
|
||||
int config;
|
||||
switch (dockState) {
|
||||
case Intent.EXTRA_DOCK_STATE_DESK:
|
||||
config = AudioSystem.FORCE_BT_DESK_DOCK;
|
||||
break;
|
||||
case Intent.EXTRA_DOCK_STATE_CAR:
|
||||
config = AudioSystem.FORCE_BT_CAR_DOCK;
|
||||
break;
|
||||
case Intent.EXTRA_DOCK_STATE_UNDOCKED:
|
||||
default:
|
||||
config = AudioSystem.FORCE_NONE;
|
||||
}
|
||||
AudioSystem.setForceUse(AudioSystem.FOR_DOCK, config);
|
||||
}
|
||||
}
|
||||
AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP,
|
||||
AudioSystem.DEVICE_STATE_AVAILABLE,
|
||||
|
@ -271,7 +271,8 @@ public class AudioSystem
|
||||
public static final int FORCE_BT_SCO = 3;
|
||||
public static final int FORCE_BT_A2DP = 4;
|
||||
public static final int FORCE_WIRED_ACCESSORY = 5;
|
||||
public static final int FORCE_BT_DOCK = 6;
|
||||
public static final int FORCE_BT_CAR_DOCK = 6;
|
||||
public static final int FORCE_BT_DESK_DOCK = 7;
|
||||
public static final int FORCE_DEFAULT = FORCE_NONE;
|
||||
|
||||
// usage for serForceUse
|
||||
|
Reference in New Issue
Block a user