Loading android/app/src/com/android/bluetooth/a2dp/A2dpService.java +11 −3 Original line number Diff line number Diff line Loading @@ -76,6 +76,8 @@ public class A2dpService extends ProfileService { private static final int MAX_A2DP_STATE_MACHINES = 50; // Upper limit of all A2DP devices that are Connected or Connecting private int mMaxConnectedAudioDevices = 1; // A2DP Offload Enabled in platform boolean mA2dpOffloadEnabled = false; private BroadcastReceiver mBondStateChangedReceiver; private BroadcastReceiver mConnectionStateChangedReceiver; Loading Loading @@ -128,7 +130,13 @@ public class A2dpService extends ProfileService { mA2dpNativeInterface.init(mMaxConnectedAudioDevices, mA2dpCodecConfig.codecConfigPriorities()); // Step 7: Setup broadcast receivers // Step 7: Check if A2DP is in offload mode mA2dpOffloadEnabled = mAdapterService.isA2dpOffloadEnabled(); if (DBG) { Log.d(TAG, "A2DP offload flag set to " + mA2dpOffloadEnabled); } // Step 8: Setup broadcast receivers IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); mBondStateChangedReceiver = new BondStateChangedReceiver(); Loading @@ -138,10 +146,10 @@ public class A2dpService extends ProfileService { mConnectionStateChangedReceiver = new ConnectionStateChangedReceiver(); registerReceiver(mConnectionStateChangedReceiver, filter); // Step 8: Mark service as started // Step 9: Mark service as started setA2dpService(this); // Step 9: Clear active device // Step 10: Clear active device setActiveDevice(null); return true; Loading android/app/src/com/android/bluetooth/a2dp/A2dpStateMachine.java +23 −1 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ final class A2dpStateMachine extends StateMachine { private A2dpService mA2dpService; private A2dpNativeInterface mA2dpNativeInterface; private boolean mA2dpOffloadEnabled = false; private final BluetoothDevice mDevice; private boolean mIsPlaying = false; private BluetoothCodecStatus mCodecStatus; Loading @@ -110,6 +110,7 @@ final class A2dpStateMachine extends StateMachine { addState(mConnecting); addState(mDisconnecting); addState(mConnected); mA2dpOffloadEnabled = mA2dpService.mA2dpOffloadEnabled; setInitialState(mDisconnected); } Loading Loading @@ -307,6 +308,7 @@ final class A2dpStateMachine extends StateMachine { processCodecConfigEvent(event.codecStatus); break; case A2dpStackEvent.EVENT_TYPE_AUDIO_STATE_CHANGED: break; default: Log.e(TAG, "Connecting: ignoring stack event: " + event); break; Loading Loading @@ -623,6 +625,26 @@ final class A2dpStateMachine extends StateMachine { } } if (mA2dpOffloadEnabled) { boolean update = false; BluetoothCodecConfig newCodecConfig = mCodecStatus.getCodecConfig(); if ((prevCodecConfig != null) && (prevCodecConfig.getCodecType() != newCodecConfig.getCodecType())) { update = true; } if (!newCodecConfig.sameAudioFeedingParameters(prevCodecConfig)) { update = true; } if ((newCodecConfig.getCodecType() == BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC) && prevCodecConfig.getCodecSpecific1() != newCodecConfig.getCodecSpecific1()) { update = true; } if (update) { mA2dpService.codecConfigUpdated(mDevice, mCodecStatus, false); } return; } boolean sameAudioFeedingParameters = newCodecStatus.getCodecConfig().sameAudioFeedingParameters(prevCodecConfig); mA2dpService.codecConfigUpdated(mDevice, mCodecStatus, sameAudioFeedingParameters); Loading android/app/src/com/android/bluetooth/btservice/AdapterProperties.java +13 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,8 @@ class AdapterProperties { "persist.bluetooth.maxconnectedaudiodevices"; static final int MAX_CONNECTED_AUDIO_DEVICES_LOWER_BOND = 1; private static final int MAX_CONNECTED_AUDIO_DEVICES_UPPER_BOUND = 5; private static final String A2DP_OFFLOAD_ENABLE_PROPERTY = "persist.bluetooth.a2dp_offload.enable"; private static final long DEFAULT_DISCOVERY_TIMEOUT_MS = 12800; private static final int BD_ADDR_LEN = 6; // in bytes Loading @@ -78,6 +80,7 @@ class AdapterProperties { private volatile int mConnectionState = BluetoothAdapter.STATE_DISCONNECTED; private volatile int mState = BluetoothAdapter.STATE_OFF; private int mMaxConnectedAudioDevices = 1; private boolean mA2dpOffloadEnabled = false; private AdapterService mService; private boolean mDiscovering; Loading Loading @@ -186,6 +189,9 @@ class AdapterProperties { + propertyOverlayedMaxConnectedAudioDevices + ", finalValue=" + mMaxConnectedAudioDevices); mA2dpOffloadEnabled = SystemProperties.getBoolean( A2DP_OFFLOAD_ENABLE_PROPERTY, false); IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED); filter.addAction(BluetoothHeadsetClient.ACTION_CONNECTION_STATE_CHANGED); Loading Loading @@ -426,6 +432,13 @@ class AdapterProperties { return mMaxConnectedAudioDevices; } /** * @return A2DP offload support */ boolean isA2dpOffloadEnabled() { return mA2dpOffloadEnabled; } /** * @return the mBondedDevices */ Loading android/app/src/com/android/bluetooth/btservice/AdapterService.java +20 −0 Original line number Diff line number Diff line Loading @@ -1404,6 +1404,16 @@ public class AdapterService extends Service { return service.getMaxConnectedAudioDevices(); } //@Override public boolean isA2dpOffloadEnabled() { // don't check caller, may be called from system UI AdapterService service = getService(); if (service == null) { return false; } return service.isA2dpOffloadEnabled(); } @Override public boolean factoryReset() { AdapterService service = getService(); Loading Loading @@ -2162,6 +2172,16 @@ public class AdapterService extends Service { return mAdapterProperties.getMaxConnectedAudioDevices(); } /** * Check whether A2DP offload is enabled. * * @return true if A2DP offload is enabled */ public boolean isA2dpOffloadEnabled() { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); return mAdapterProperties.isA2dpOffloadEnabled(); } private BluetoothActivityEnergyInfo reportActivityInfo() { enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, "Need BLUETOOTH permission"); if (mAdapterProperties.getState() != BluetoothAdapter.STATE_ON Loading Loading
android/app/src/com/android/bluetooth/a2dp/A2dpService.java +11 −3 Original line number Diff line number Diff line Loading @@ -76,6 +76,8 @@ public class A2dpService extends ProfileService { private static final int MAX_A2DP_STATE_MACHINES = 50; // Upper limit of all A2DP devices that are Connected or Connecting private int mMaxConnectedAudioDevices = 1; // A2DP Offload Enabled in platform boolean mA2dpOffloadEnabled = false; private BroadcastReceiver mBondStateChangedReceiver; private BroadcastReceiver mConnectionStateChangedReceiver; Loading Loading @@ -128,7 +130,13 @@ public class A2dpService extends ProfileService { mA2dpNativeInterface.init(mMaxConnectedAudioDevices, mA2dpCodecConfig.codecConfigPriorities()); // Step 7: Setup broadcast receivers // Step 7: Check if A2DP is in offload mode mA2dpOffloadEnabled = mAdapterService.isA2dpOffloadEnabled(); if (DBG) { Log.d(TAG, "A2DP offload flag set to " + mA2dpOffloadEnabled); } // Step 8: Setup broadcast receivers IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); mBondStateChangedReceiver = new BondStateChangedReceiver(); Loading @@ -138,10 +146,10 @@ public class A2dpService extends ProfileService { mConnectionStateChangedReceiver = new ConnectionStateChangedReceiver(); registerReceiver(mConnectionStateChangedReceiver, filter); // Step 8: Mark service as started // Step 9: Mark service as started setA2dpService(this); // Step 9: Clear active device // Step 10: Clear active device setActiveDevice(null); return true; Loading
android/app/src/com/android/bluetooth/a2dp/A2dpStateMachine.java +23 −1 Original line number Diff line number Diff line Loading @@ -88,7 +88,7 @@ final class A2dpStateMachine extends StateMachine { private A2dpService mA2dpService; private A2dpNativeInterface mA2dpNativeInterface; private boolean mA2dpOffloadEnabled = false; private final BluetoothDevice mDevice; private boolean mIsPlaying = false; private BluetoothCodecStatus mCodecStatus; Loading @@ -110,6 +110,7 @@ final class A2dpStateMachine extends StateMachine { addState(mConnecting); addState(mDisconnecting); addState(mConnected); mA2dpOffloadEnabled = mA2dpService.mA2dpOffloadEnabled; setInitialState(mDisconnected); } Loading Loading @@ -307,6 +308,7 @@ final class A2dpStateMachine extends StateMachine { processCodecConfigEvent(event.codecStatus); break; case A2dpStackEvent.EVENT_TYPE_AUDIO_STATE_CHANGED: break; default: Log.e(TAG, "Connecting: ignoring stack event: " + event); break; Loading Loading @@ -623,6 +625,26 @@ final class A2dpStateMachine extends StateMachine { } } if (mA2dpOffloadEnabled) { boolean update = false; BluetoothCodecConfig newCodecConfig = mCodecStatus.getCodecConfig(); if ((prevCodecConfig != null) && (prevCodecConfig.getCodecType() != newCodecConfig.getCodecType())) { update = true; } if (!newCodecConfig.sameAudioFeedingParameters(prevCodecConfig)) { update = true; } if ((newCodecConfig.getCodecType() == BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC) && prevCodecConfig.getCodecSpecific1() != newCodecConfig.getCodecSpecific1()) { update = true; } if (update) { mA2dpService.codecConfigUpdated(mDevice, mCodecStatus, false); } return; } boolean sameAudioFeedingParameters = newCodecStatus.getCodecConfig().sameAudioFeedingParameters(prevCodecConfig); mA2dpService.codecConfigUpdated(mDevice, mCodecStatus, sameAudioFeedingParameters); Loading
android/app/src/com/android/bluetooth/btservice/AdapterProperties.java +13 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,8 @@ class AdapterProperties { "persist.bluetooth.maxconnectedaudiodevices"; static final int MAX_CONNECTED_AUDIO_DEVICES_LOWER_BOND = 1; private static final int MAX_CONNECTED_AUDIO_DEVICES_UPPER_BOUND = 5; private static final String A2DP_OFFLOAD_ENABLE_PROPERTY = "persist.bluetooth.a2dp_offload.enable"; private static final long DEFAULT_DISCOVERY_TIMEOUT_MS = 12800; private static final int BD_ADDR_LEN = 6; // in bytes Loading @@ -78,6 +80,7 @@ class AdapterProperties { private volatile int mConnectionState = BluetoothAdapter.STATE_DISCONNECTED; private volatile int mState = BluetoothAdapter.STATE_OFF; private int mMaxConnectedAudioDevices = 1; private boolean mA2dpOffloadEnabled = false; private AdapterService mService; private boolean mDiscovering; Loading Loading @@ -186,6 +189,9 @@ class AdapterProperties { + propertyOverlayedMaxConnectedAudioDevices + ", finalValue=" + mMaxConnectedAudioDevices); mA2dpOffloadEnabled = SystemProperties.getBoolean( A2DP_OFFLOAD_ENABLE_PROPERTY, false); IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED); filter.addAction(BluetoothHeadsetClient.ACTION_CONNECTION_STATE_CHANGED); Loading Loading @@ -426,6 +432,13 @@ class AdapterProperties { return mMaxConnectedAudioDevices; } /** * @return A2DP offload support */ boolean isA2dpOffloadEnabled() { return mA2dpOffloadEnabled; } /** * @return the mBondedDevices */ Loading
android/app/src/com/android/bluetooth/btservice/AdapterService.java +20 −0 Original line number Diff line number Diff line Loading @@ -1404,6 +1404,16 @@ public class AdapterService extends Service { return service.getMaxConnectedAudioDevices(); } //@Override public boolean isA2dpOffloadEnabled() { // don't check caller, may be called from system UI AdapterService service = getService(); if (service == null) { return false; } return service.isA2dpOffloadEnabled(); } @Override public boolean factoryReset() { AdapterService service = getService(); Loading Loading @@ -2162,6 +2172,16 @@ public class AdapterService extends Service { return mAdapterProperties.getMaxConnectedAudioDevices(); } /** * Check whether A2DP offload is enabled. * * @return true if A2DP offload is enabled */ public boolean isA2dpOffloadEnabled() { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); return mAdapterProperties.isA2dpOffloadEnabled(); } private BluetoothActivityEnergyInfo reportActivityInfo() { enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, "Need BLUETOOTH permission"); if (mAdapterProperties.getState() != BluetoothAdapter.STATE_ON Loading