Loading src/com/android/bluetooth/a2dp/A2dpService.java +1 −1 Original line number Diff line number Diff line Loading @@ -170,7 +170,7 @@ public class A2dpService extends ProfileService { return mStateMachine.getDevicesMatchingConnectionStates(states); } int getConnectionState(BluetoothDevice device) { public int getConnectionState(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); return mStateMachine.getConnectionState(device); } Loading src/com/android/bluetooth/a2dp/A2dpStateMachine.java +0 −13 Original line number Diff line number Diff line Loading @@ -235,12 +235,6 @@ final class A2dpStateMachine extends StateMachine { //reject the connection and stay in Disconnected state itself logi("Incoming A2DP rejected"); disconnectA2dpNative(getByteAddress(device)); // the other profile connection should be initiated AdapterService adapterService = AdapterService.getAdapterService(); if (adapterService != null) { adapterService.connectOtherProfile(device, AdapterService.PROFILE_CONN_REJECTED); } } break; case CONNECTION_STATE_CONNECTED: Loading @@ -257,12 +251,6 @@ final class A2dpStateMachine extends StateMachine { //reject the connection and stay in Disconnected state itself logi("Incoming A2DP rejected"); disconnectA2dpNative(getByteAddress(device)); // the other profile connection should be initiated AdapterService adapterService = AdapterService.getAdapterService(); if (adapterService != null) { adapterService.connectOtherProfile(device, AdapterService.PROFILE_CONN_REJECTED); } } break; case CONNECTION_STATE_DISCONNECTING: Loading Loading @@ -820,7 +808,6 @@ final class A2dpStateMachine extends StateMachine { intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); mContext.sendBroadcast(intent, ProfileService.BLUETOOTH_PERM); log("Connection state " + device + ": " + prevState + "->" + state); mService.notifyProfileConnectionStateChanged(device, BluetoothProfile.A2DP, state, prevState); } @Override Loading src/com/android/bluetooth/a2dpsink/A2dpSinkStateMachine.java +0 −14 Original line number Diff line number Diff line Loading @@ -266,12 +266,6 @@ final class A2dpSinkStateMachine extends StateMachine { //reject the connection and stay in Disconnected state itself logi("Incoming A2DP rejected"); disconnectA2dpNative(getByteAddress(device)); // the other profile connection should be initiated AdapterService adapterService = AdapterService.getAdapterService(); if (adapterService != null) { adapterService.connectOtherProfile(device, AdapterService.PROFILE_CONN_REJECTED); } } break; case CONNECTION_STATE_CONNECTED: Loading @@ -288,12 +282,6 @@ final class A2dpSinkStateMachine extends StateMachine { //reject the connection and stay in Disconnected state itself logi("Incoming A2DP rejected"); disconnectA2dpNative(getByteAddress(device)); // the other profile connection should be initiated AdapterService adapterService = AdapterService.getAdapterService(); if (adapterService != null) { adapterService.connectOtherProfile(device, AdapterService.PROFILE_CONN_REJECTED); } } break; case CONNECTION_STATE_DISCONNECTING: Loading Loading @@ -840,8 +828,6 @@ final class A2dpSinkStateMachine extends StateMachine { //FIXME intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); mContext.sendBroadcast(intent, ProfileService.BLUETOOTH_PERM); log("Connection state " + device + ": " + prevState + "->" + state); mService.notifyProfileConnectionStateChanged(device, BluetoothProfile.A2DP_SINK, state, prevState); } @Override Loading src/com/android/bluetooth/btservice/AdapterProperties.java +40 −0 Original line number Diff line number Diff line Loading @@ -16,10 +16,17 @@ package com.android.bluetooth.btservice; import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothA2dpSink; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; import android.bluetooth.BluetoothHeadsetClient; import android.bluetooth.BluetoothProfile; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.ParcelUuid; import android.os.UserHandle; import android.util.Log; Loading Loading @@ -68,6 +75,24 @@ class AdapterProperties { private boolean mIsDebugLogSupported; private boolean mIsActivityAndEnergyReporting; private BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "Received intent " + intent); if (BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED.equals(intent.getAction())) { sendConnectionStateChange(BluetoothProfile.HEADSET, intent); } else if (BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED.equals(intent.getAction())) { sendConnectionStateChange(BluetoothProfile.A2DP, intent); } else if (BluetoothHeadsetClient.ACTION_CONNECTION_STATE_CHANGED.equals( intent.getAction())) { sendConnectionStateChange(BluetoothProfile.HEADSET_CLIENT, intent); } else if (BluetoothA2dpSink.ACTION_CONNECTION_STATE_CHANGED.equals( intent.getAction())) { sendConnectionStateChange(BluetoothProfile.A2DP_SINK, intent); } } }; // Lock for all getters and setters. // If finer grained locking is needer, more locks // can be added here. Loading @@ -84,6 +109,14 @@ class AdapterProperties { mProfileConnectionState.clear(); } mRemoteDevices = remoteDevices; IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED); filter.addAction(BluetoothHeadsetClient.ACTION_CONNECTION_STATE_CHANGED); filter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED); filter.addAction(BluetoothA2dpSink.ACTION_CONNECTION_STATE_CHANGED); filter.addAction(BluetoothDevice.ACTION_UUID); mService.registerReceiver(mReceiver, filter); } public void cleanup() { Loading @@ -92,6 +125,7 @@ class AdapterProperties { mProfileConnectionState.clear(); mProfileConnectionState = null; } mService.unregisterReceiver(mReceiver); mService = null; mBondedDevices.clear(); } Loading Loading @@ -319,6 +353,12 @@ class AdapterProperties { return mDiscovering; } private void sendConnectionStateChange(int profile, Intent connIntent) { BluetoothDevice device = connIntent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); int prevState = connIntent.getIntExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, -1); int state = connIntent.getIntExtra(BluetoothProfile.EXTRA_STATE, -1); sendConnectionStateChange(device, profile, state, prevState); } void sendConnectionStateChange(BluetoothDevice device, int profile, int state, int prevState) { if (!validateProfileConnectionState(state) || !validateProfileConnectionState(prevState)) { Loading src/com/android/bluetooth/btservice/AdapterService.java +92 −549 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
src/com/android/bluetooth/a2dp/A2dpService.java +1 −1 Original line number Diff line number Diff line Loading @@ -170,7 +170,7 @@ public class A2dpService extends ProfileService { return mStateMachine.getDevicesMatchingConnectionStates(states); } int getConnectionState(BluetoothDevice device) { public int getConnectionState(BluetoothDevice device) { enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission"); return mStateMachine.getConnectionState(device); } Loading
src/com/android/bluetooth/a2dp/A2dpStateMachine.java +0 −13 Original line number Diff line number Diff line Loading @@ -235,12 +235,6 @@ final class A2dpStateMachine extends StateMachine { //reject the connection and stay in Disconnected state itself logi("Incoming A2DP rejected"); disconnectA2dpNative(getByteAddress(device)); // the other profile connection should be initiated AdapterService adapterService = AdapterService.getAdapterService(); if (adapterService != null) { adapterService.connectOtherProfile(device, AdapterService.PROFILE_CONN_REJECTED); } } break; case CONNECTION_STATE_CONNECTED: Loading @@ -257,12 +251,6 @@ final class A2dpStateMachine extends StateMachine { //reject the connection and stay in Disconnected state itself logi("Incoming A2DP rejected"); disconnectA2dpNative(getByteAddress(device)); // the other profile connection should be initiated AdapterService adapterService = AdapterService.getAdapterService(); if (adapterService != null) { adapterService.connectOtherProfile(device, AdapterService.PROFILE_CONN_REJECTED); } } break; case CONNECTION_STATE_DISCONNECTING: Loading Loading @@ -820,7 +808,6 @@ final class A2dpStateMachine extends StateMachine { intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); mContext.sendBroadcast(intent, ProfileService.BLUETOOTH_PERM); log("Connection state " + device + ": " + prevState + "->" + state); mService.notifyProfileConnectionStateChanged(device, BluetoothProfile.A2DP, state, prevState); } @Override Loading
src/com/android/bluetooth/a2dpsink/A2dpSinkStateMachine.java +0 −14 Original line number Diff line number Diff line Loading @@ -266,12 +266,6 @@ final class A2dpSinkStateMachine extends StateMachine { //reject the connection and stay in Disconnected state itself logi("Incoming A2DP rejected"); disconnectA2dpNative(getByteAddress(device)); // the other profile connection should be initiated AdapterService adapterService = AdapterService.getAdapterService(); if (adapterService != null) { adapterService.connectOtherProfile(device, AdapterService.PROFILE_CONN_REJECTED); } } break; case CONNECTION_STATE_CONNECTED: Loading @@ -288,12 +282,6 @@ final class A2dpSinkStateMachine extends StateMachine { //reject the connection and stay in Disconnected state itself logi("Incoming A2DP rejected"); disconnectA2dpNative(getByteAddress(device)); // the other profile connection should be initiated AdapterService adapterService = AdapterService.getAdapterService(); if (adapterService != null) { adapterService.connectOtherProfile(device, AdapterService.PROFILE_CONN_REJECTED); } } break; case CONNECTION_STATE_DISCONNECTING: Loading Loading @@ -840,8 +828,6 @@ final class A2dpSinkStateMachine extends StateMachine { //FIXME intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); mContext.sendBroadcast(intent, ProfileService.BLUETOOTH_PERM); log("Connection state " + device + ": " + prevState + "->" + state); mService.notifyProfileConnectionStateChanged(device, BluetoothProfile.A2DP_SINK, state, prevState); } @Override Loading
src/com/android/bluetooth/btservice/AdapterProperties.java +40 −0 Original line number Diff line number Diff line Loading @@ -16,10 +16,17 @@ package com.android.bluetooth.btservice; import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothA2dpSink; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHeadset; import android.bluetooth.BluetoothHeadsetClient; import android.bluetooth.BluetoothProfile; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.ParcelUuid; import android.os.UserHandle; import android.util.Log; Loading Loading @@ -68,6 +75,24 @@ class AdapterProperties { private boolean mIsDebugLogSupported; private boolean mIsActivityAndEnergyReporting; private BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "Received intent " + intent); if (BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED.equals(intent.getAction())) { sendConnectionStateChange(BluetoothProfile.HEADSET, intent); } else if (BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED.equals(intent.getAction())) { sendConnectionStateChange(BluetoothProfile.A2DP, intent); } else if (BluetoothHeadsetClient.ACTION_CONNECTION_STATE_CHANGED.equals( intent.getAction())) { sendConnectionStateChange(BluetoothProfile.HEADSET_CLIENT, intent); } else if (BluetoothA2dpSink.ACTION_CONNECTION_STATE_CHANGED.equals( intent.getAction())) { sendConnectionStateChange(BluetoothProfile.A2DP_SINK, intent); } } }; // Lock for all getters and setters. // If finer grained locking is needer, more locks // can be added here. Loading @@ -84,6 +109,14 @@ class AdapterProperties { mProfileConnectionState.clear(); } mRemoteDevices = remoteDevices; IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED); filter.addAction(BluetoothHeadsetClient.ACTION_CONNECTION_STATE_CHANGED); filter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED); filter.addAction(BluetoothA2dpSink.ACTION_CONNECTION_STATE_CHANGED); filter.addAction(BluetoothDevice.ACTION_UUID); mService.registerReceiver(mReceiver, filter); } public void cleanup() { Loading @@ -92,6 +125,7 @@ class AdapterProperties { mProfileConnectionState.clear(); mProfileConnectionState = null; } mService.unregisterReceiver(mReceiver); mService = null; mBondedDevices.clear(); } Loading Loading @@ -319,6 +353,12 @@ class AdapterProperties { return mDiscovering; } private void sendConnectionStateChange(int profile, Intent connIntent) { BluetoothDevice device = connIntent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); int prevState = connIntent.getIntExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, -1); int state = connIntent.getIntExtra(BluetoothProfile.EXTRA_STATE, -1); sendConnectionStateChange(device, profile, state, prevState); } void sendConnectionStateChange(BluetoothDevice device, int profile, int state, int prevState) { if (!validateProfileConnectionState(state) || !validateProfileConnectionState(prevState)) { Loading
src/com/android/bluetooth/btservice/AdapterService.java +92 −549 File changed.Preview size limit exceeded, changes collapsed. Show changes