Loading android/app/src/com/android/bluetooth/a2dp/A2dpService.java +1 −29 Original line number Diff line number Diff line Loading @@ -111,7 +111,6 @@ public class A2dpService extends ProfileService { boolean mA2dpOffloadEnabled = false; private BroadcastReceiver mBondStateChangedReceiver; private BroadcastReceiver mConnectionStateChangedReceiver; public static boolean isEnabled() { return BluetoothProperties.isProfileA2dpSourceEnabled().orElse(false); Loading Loading @@ -175,10 +174,6 @@ public class A2dpService extends ProfileService { filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); mBondStateChangedReceiver = new BondStateChangedReceiver(); registerReceiver(mBondStateChangedReceiver, filter); filter = new IntentFilter(); filter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED); mConnectionStateChangedReceiver = new ConnectionStateChangedReceiver(); registerReceiver(mConnectionStateChangedReceiver, filter); // Step 8: Mark service as started setA2dpService(this); Loading Loading @@ -214,8 +209,6 @@ public class A2dpService extends ProfileService { setA2dpService(null); // Step 7: Unregister broadcast receivers unregisterReceiver(mConnectionStateChangedReceiver); mConnectionStateChangedReceiver = null; unregisterReceiver(mBondStateChangedReceiver); mBondStateChangedReceiver = null; Loading Loading @@ -1250,7 +1243,7 @@ public class A2dpService extends ProfileService { } } private void connectionStateChanged(BluetoothDevice device, int fromState, int toState) { void connectionStateChanged(BluetoothDevice device, int fromState, int toState) { if ((device == null) || (fromState == toState)) { return; } Loading @@ -1276,27 +1269,6 @@ public class A2dpService extends ProfileService { } } /** * Receiver for processing device connection state changes. * * <ul> * <li> Update codec support per device when device is (re)connected * <li> Delete the state machine instance if the device is disconnected and unbond * </ul> */ private class ConnectionStateChangedReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (!BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED.equals(intent.getAction())) { return; } BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); int toState = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, -1); int fromState = intent.getIntExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, -1); connectionStateChanged(device, fromState, toState); } } /** * Retrieves the most recently connected device in the A2DP connected devices list. */ Loading android/app/src/com/android/bluetooth/a2dp/A2dpStateMachine.java +1 −0 Original line number Diff line number Diff line Loading @@ -701,6 +701,7 @@ final class A2dpStateMachine extends StateMachine { intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); mA2dpService.connectionStateChanged(mDevice, prevState, newState); Utils.sendBroadcast(mA2dpService, intent, BLUETOOTH_CONNECT, Utils.getTempAllowlistBroadcastOptions()); } Loading Loading
android/app/src/com/android/bluetooth/a2dp/A2dpService.java +1 −29 Original line number Diff line number Diff line Loading @@ -111,7 +111,6 @@ public class A2dpService extends ProfileService { boolean mA2dpOffloadEnabled = false; private BroadcastReceiver mBondStateChangedReceiver; private BroadcastReceiver mConnectionStateChangedReceiver; public static boolean isEnabled() { return BluetoothProperties.isProfileA2dpSourceEnabled().orElse(false); Loading Loading @@ -175,10 +174,6 @@ public class A2dpService extends ProfileService { filter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); mBondStateChangedReceiver = new BondStateChangedReceiver(); registerReceiver(mBondStateChangedReceiver, filter); filter = new IntentFilter(); filter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED); mConnectionStateChangedReceiver = new ConnectionStateChangedReceiver(); registerReceiver(mConnectionStateChangedReceiver, filter); // Step 8: Mark service as started setA2dpService(this); Loading Loading @@ -214,8 +209,6 @@ public class A2dpService extends ProfileService { setA2dpService(null); // Step 7: Unregister broadcast receivers unregisterReceiver(mConnectionStateChangedReceiver); mConnectionStateChangedReceiver = null; unregisterReceiver(mBondStateChangedReceiver); mBondStateChangedReceiver = null; Loading Loading @@ -1250,7 +1243,7 @@ public class A2dpService extends ProfileService { } } private void connectionStateChanged(BluetoothDevice device, int fromState, int toState) { void connectionStateChanged(BluetoothDevice device, int fromState, int toState) { if ((device == null) || (fromState == toState)) { return; } Loading @@ -1276,27 +1269,6 @@ public class A2dpService extends ProfileService { } } /** * Receiver for processing device connection state changes. * * <ul> * <li> Update codec support per device when device is (re)connected * <li> Delete the state machine instance if the device is disconnected and unbond * </ul> */ private class ConnectionStateChangedReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (!BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED.equals(intent.getAction())) { return; } BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); int toState = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, -1); int fromState = intent.getIntExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, -1); connectionStateChanged(device, fromState, toState); } } /** * Retrieves the most recently connected device in the A2DP connected devices list. */ Loading
android/app/src/com/android/bluetooth/a2dp/A2dpStateMachine.java +1 −0 Original line number Diff line number Diff line Loading @@ -701,6 +701,7 @@ final class A2dpStateMachine extends StateMachine { intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); mA2dpService.connectionStateChanged(mDevice, prevState, newState); Utils.sendBroadcast(mA2dpService, intent, BLUETOOTH_CONNECT, Utils.getTempAllowlistBroadcastOptions()); } Loading