Loading core/java/android/bluetooth/BluetoothAdapter.java +25 −0 Original line number Diff line number Diff line Loading @@ -773,6 +773,31 @@ public final class BluetoothAdapter { return BluetoothAdapter.STATE_DISCONNECTED; } /** * Get the current connection state of a profile. * This function can be used to check whether the local Bluetooth adapter * is connected to any remote device for a specific profile. * Profile can be one of {@link BluetoothProfile.HEADSET}, * {@link BluetoothProfile.A2DP}. * * <p>Requires {@link android.Manifest.permission#BLUETOOTH}. * * <p> Return value can be one of * {@link * BluetoothProfile.STATE_DISCONNECTED}, * {@link * BluetoothProfile.STATE_CONNECTING}, * {@link * BluetoothProfile.STATE_CONNECTED}, * {@link * BluetoothProfile.STATE_DISCONNECTING} * @hide */ public int getProfileConnectionState(int profile) { if (getState() != STATE_ON) return BluetoothProfile.STATE_DISCONNECTED; try { return mService.getProfileConnectionState(profile); } catch (RemoteException e) {Log.e(TAG, "getProfileConnectionState:", e);} return BluetoothProfile.STATE_DISCONNECTED; } /** /** * Picks RFCOMM channels until none are left. * Avoids reserved channels. Loading core/java/android/bluetooth/BluetoothProfile.java +6 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,12 @@ public interface BluetoothProfile { */ public static final int PAN = 5; /** * PBAP * @hide */ public static final int PBAP = 6; /** * Default priority for devices that we try to auto-connect to and * and allow incoming connections for the profile Loading core/java/android/bluetooth/IBluetooth.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ interface IBluetooth byte[] readOutOfBandData(); int getAdapterConnectionState(); int getProfileConnectionState(int profile); boolean changeApplicationBluetoothState(boolean on, in IBluetoothStateChangeCallback callback, in IBinder b); Loading Loading @@ -121,5 +122,5 @@ interface IBluetooth List<BluetoothDevice> getHealthDevicesMatchingConnectionStates(in int[] states); int getHealthDeviceConnectionState(in BluetoothDevice device); void sendConnectionStateChange(in BluetoothDevice device, int state, int prevState); void sendConnectionStateChange(in BluetoothDevice device, int profile, int state, int prevState); } core/java/android/server/BluetoothA2dpService.java +2 −1 Original line number Diff line number Diff line Loading @@ -523,7 +523,8 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { if (DBG) log("A2DP state : device: " + device + " State:" + prevState + "->" + state); mBluetoothService.sendConnectionStateChange(device, state, prevState); mBluetoothService.sendConnectionStateChange(device, BluetoothProfile.A2DP, state, prevState); } } Loading core/java/android/server/BluetoothHealthProfileHandler.java +3 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHealth; import android.bluetooth.BluetoothHealthAppConfiguration; import android.bluetooth.BluetoothProfile; import android.bluetooth.IBluetoothHealthCallback; import android.content.Context; import android.os.Handler; Loading Loading @@ -567,7 +568,8 @@ final class BluetoothHealthProfileHandler { private void updateAndSendIntent(BluetoothDevice device, int prevDeviceState, int newDeviceState) { mHealthDevices.put(device, newDeviceState); mBluetoothService.sendConnectionStateChange(device, prevDeviceState, newDeviceState); mBluetoothService.sendConnectionStateChange(device, BluetoothProfile.HEALTH, prevDeviceState, newDeviceState); } /** Loading Loading
core/java/android/bluetooth/BluetoothAdapter.java +25 −0 Original line number Diff line number Diff line Loading @@ -773,6 +773,31 @@ public final class BluetoothAdapter { return BluetoothAdapter.STATE_DISCONNECTED; } /** * Get the current connection state of a profile. * This function can be used to check whether the local Bluetooth adapter * is connected to any remote device for a specific profile. * Profile can be one of {@link BluetoothProfile.HEADSET}, * {@link BluetoothProfile.A2DP}. * * <p>Requires {@link android.Manifest.permission#BLUETOOTH}. * * <p> Return value can be one of * {@link * BluetoothProfile.STATE_DISCONNECTED}, * {@link * BluetoothProfile.STATE_CONNECTING}, * {@link * BluetoothProfile.STATE_CONNECTED}, * {@link * BluetoothProfile.STATE_DISCONNECTING} * @hide */ public int getProfileConnectionState(int profile) { if (getState() != STATE_ON) return BluetoothProfile.STATE_DISCONNECTED; try { return mService.getProfileConnectionState(profile); } catch (RemoteException e) {Log.e(TAG, "getProfileConnectionState:", e);} return BluetoothProfile.STATE_DISCONNECTED; } /** /** * Picks RFCOMM channels until none are left. * Avoids reserved channels. Loading
core/java/android/bluetooth/BluetoothProfile.java +6 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,12 @@ public interface BluetoothProfile { */ public static final int PAN = 5; /** * PBAP * @hide */ public static final int PBAP = 6; /** * Default priority for devices that we try to auto-connect to and * and allow incoming connections for the profile Loading
core/java/android/bluetooth/IBluetooth.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ interface IBluetooth byte[] readOutOfBandData(); int getAdapterConnectionState(); int getProfileConnectionState(int profile); boolean changeApplicationBluetoothState(boolean on, in IBluetoothStateChangeCallback callback, in IBinder b); Loading Loading @@ -121,5 +122,5 @@ interface IBluetooth List<BluetoothDevice> getHealthDevicesMatchingConnectionStates(in int[] states); int getHealthDeviceConnectionState(in BluetoothDevice device); void sendConnectionStateChange(in BluetoothDevice device, int state, int prevState); void sendConnectionStateChange(in BluetoothDevice device, int profile, int state, int prevState); }
core/java/android/server/BluetoothA2dpService.java +2 −1 Original line number Diff line number Diff line Loading @@ -523,7 +523,8 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub { if (DBG) log("A2DP state : device: " + device + " State:" + prevState + "->" + state); mBluetoothService.sendConnectionStateChange(device, state, prevState); mBluetoothService.sendConnectionStateChange(device, BluetoothProfile.A2DP, state, prevState); } } Loading
core/java/android/server/BluetoothHealthProfileHandler.java +3 −1 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothHealth; import android.bluetooth.BluetoothHealthAppConfiguration; import android.bluetooth.BluetoothProfile; import android.bluetooth.IBluetoothHealthCallback; import android.content.Context; import android.os.Handler; Loading Loading @@ -567,7 +568,8 @@ final class BluetoothHealthProfileHandler { private void updateAndSendIntent(BluetoothDevice device, int prevDeviceState, int newDeviceState) { mHealthDevices.put(device, newDeviceState); mBluetoothService.sendConnectionStateChange(device, prevDeviceState, newDeviceState); mBluetoothService.sendConnectionStateChange(device, BluetoothProfile.HEALTH, prevDeviceState, newDeviceState); } /** Loading