Loading core/java/android/bluetooth/BluetoothDeviceProfileState.java +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ public final class BluetoothDeviceProfileState extends StateMachine { private static final int CONNECTION_ACCESS_REQUEST_REPLY = 104; private static final int CONNECTION_ACCESS_REQUEST_EXPIRY = 105; private static final int CONNECT_OTHER_PROFILES_DELAY = 4000; // 4 secs public static final int CONNECT_OTHER_PROFILES_DELAY = 4000; // 4 secs private static final int CONNECTION_ACCESS_REQUEST_EXPIRY_TIMEOUT = 7000; // 7 secs private static final int CONNECTION_ACCESS_UNDEFINED = -1; private static final long INIT_INCOMING_REJECT_TIMER = 1000; // 1 sec Loading core/java/android/bluetooth/IBluetooth.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ interface IBluetooth boolean connectHeadset(String address); boolean disconnectHeadset(String address); boolean notifyIncomingConnection(String address); boolean notifyIncomingConnection(String address, boolean rejected); // HID profile APIs boolean connectInputDevice(in BluetoothDevice device); Loading core/java/android/server/BluetoothEventLoop.java +2 −1 Original line number Diff line number Diff line Loading @@ -784,11 +784,12 @@ class BluetoothEventLoop { // machine. We don't handle AVCTP signals currently. We only send // intents for AVDTP state changes. We need to handle both of them in // some cases. For now, just don't move to incoming state in this case. mBluetoothService.notifyIncomingA2dpConnection(address); mBluetoothService.notifyIncomingA2dpConnection(address, true); } else { Log.i(TAG, "" + authorized + "Incoming A2DP / AVRCP connection from " + address); mA2dp.allowIncomingConnect(device, authorized); mBluetoothService.notifyIncomingA2dpConnection(address, false); } } else if (BluetoothUuid.isInputDevice(uuid)) { // We can have more than 1 input device connected. Loading core/java/android/server/BluetoothService.java +43 −22 Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ public class BluetoothService extends IBluetooth.Stub { private int mNativeData; private BluetoothEventLoop mEventLoop; private BluetoothHeadset mBluetoothHeadset; private BluetoothHeadset mHeadsetProxy; private BluetoothInputDevice mInputDevice; private BluetoothPan mPan; private boolean mIsAirplaneSensitive; Loading Loading @@ -605,6 +605,7 @@ public class BluetoothService extends IBluetooth.Stub { } mBondState.initBondState(); initProfileState(); getProfileProxy(); } /** Loading Loading @@ -1766,8 +1767,8 @@ public class BluetoothService extends IBluetooth.Stub { private void dumpHeadsetService(PrintWriter pw) { pw.println("\n--Headset Service--"); if (mBluetoothHeadset != null) { List<BluetoothDevice> deviceList = mBluetoothHeadset.getConnectedDevices(); if (mHeadsetProxy != null) { List<BluetoothDevice> deviceList = mHeadsetProxy.getConnectedDevices(); if (deviceList.size() == 0) { pw.println("No headsets connected"); } else { Loading @@ -1775,21 +1776,20 @@ public class BluetoothService extends IBluetooth.Stub { pw.println("\ngetConnectedDevices[0] = " + device); dumpHeadsetConnectionState(pw, device); pw.println("getBatteryUsageHint() = " + mBluetoothHeadset.getBatteryUsageHint(device)); mHeadsetProxy.getBatteryUsageHint(device)); } deviceList.clear(); deviceList = mBluetoothHeadset.getDevicesMatchingConnectionStates(new int[] { deviceList = mHeadsetProxy.getDevicesMatchingConnectionStates(new int[] { BluetoothProfile.STATE_CONNECTED, BluetoothProfile.STATE_DISCONNECTED}); pw.println("--Connected and Disconnected Headsets"); for (BluetoothDevice device: deviceList) { pw.println(device); if (mBluetoothHeadset.isAudioConnected(device)) { if (mHeadsetProxy.isAudioConnected(device)) { pw.println("SCO audio connected to device:" + device); } } } mAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset); } private void dumpInputDeviceProfile(PrintWriter pw) { Loading Loading @@ -1824,7 +1824,6 @@ public class BluetoothService extends IBluetooth.Stub { pw.println(device); } } mAdapter.closeProfileProxy(BluetoothProfile.INPUT_DEVICE, mBluetoothHeadset); } private void dumpPanProfile(PrintWriter pw) { Loading Loading @@ -1862,7 +1861,7 @@ public class BluetoothService extends IBluetooth.Stub { private void dumpHeadsetConnectionState(PrintWriter pw, BluetoothDevice device) { switch (mBluetoothHeadset.getConnectionState(device)) { switch (mHeadsetProxy.getConnectionState(device)) { case BluetoothHeadset.STATE_CONNECTING: pw.println("getConnectionState() = STATE_CONNECTING"); break; Loading @@ -1884,7 +1883,6 @@ public class BluetoothService extends IBluetooth.Stub { Integer pid = mServiceRecordToPid.get(handle).first; pw.println("\tpid " + pid + " handle " + Integer.toHexString(handle)); } mAdapter.closeProfileProxy(BluetoothProfile.PAN, mBluetoothHeadset); } private void dumpAclConnectedDevices(PrintWriter pw) { Loading Loading @@ -1927,11 +1925,16 @@ public class BluetoothService extends IBluetooth.Stub { } } private void getProfileProxy() { mAdapter.getProfileProxy(mContext, mBluetoothProfileServiceListener, BluetoothProfile.HEADSET); } private BluetoothProfile.ServiceListener mBluetoothProfileServiceListener = new BluetoothProfile.ServiceListener() { public void onServiceConnected(int profile, BluetoothProfile proxy) { if (profile == BluetoothProfile.HEADSET) { mBluetoothHeadset = (BluetoothHeadset) proxy; mHeadsetProxy = (BluetoothHeadset) proxy; } else if (profile == BluetoothProfile.INPUT_DEVICE) { mInputDevice = (BluetoothInputDevice) proxy; } else if (profile == BluetoothProfile.PAN) { Loading @@ -1940,7 +1943,7 @@ public class BluetoothService extends IBluetooth.Stub { } public void onServiceDisconnected(int profile) { if (profile == BluetoothProfile.HEADSET) { mBluetoothHeadset = null; mHeadsetProxy = null; } else if (profile == BluetoothProfile.INPUT_DEVICE) { mInputDevice = null; } else if (profile == BluetoothProfile.PAN) { Loading Loading @@ -2424,25 +2427,43 @@ public class BluetoothService extends IBluetooth.Stub { } } public boolean notifyIncomingConnection(String address) { BluetoothDeviceProfileState state = mDeviceProfileState.get(address); public boolean notifyIncomingConnection(String address, boolean rejected) { BluetoothDeviceProfileState state = mDeviceProfileState.get(address); if (state != null) { Message msg = new Message(); if (rejected) { if (mA2dpService.getPriority(getRemoteDevice(address)) >= BluetoothProfile.PRIORITY_ON) { msg.what = BluetoothDeviceProfileState.CONNECT_OTHER_PROFILES; msg.arg1 = BluetoothDeviceProfileState.CONNECT_A2DP_OUTGOING; state.sendMessageDelayed(msg, BluetoothDeviceProfileState.CONNECT_OTHER_PROFILES_DELAY); } } else { msg.what = BluetoothDeviceProfileState.CONNECT_HFP_INCOMING; state.sendMessage(msg); } return true; } return false; } /*package*/ boolean notifyIncomingA2dpConnection(String address) { BluetoothDeviceProfileState state = mDeviceProfileState.get(address); /*package*/ boolean notifyIncomingA2dpConnection(String address, boolean rejected) { BluetoothDeviceProfileState state = mDeviceProfileState.get(address); if (state != null) { Message msg = new Message(); if (rejected) { if (mHeadsetProxy.getPriority(getRemoteDevice(address)) >= BluetoothProfile.PRIORITY_ON) { msg.what = BluetoothDeviceProfileState.CONNECT_OTHER_PROFILES; msg.arg1 = BluetoothDeviceProfileState.CONNECT_HFP_OUTGOING; state.sendMessageDelayed(msg, BluetoothDeviceProfileState.CONNECT_OTHER_PROFILES_DELAY); } } else { msg.what = BluetoothDeviceProfileState.CONNECT_A2DP_INCOMING; state.sendMessage(msg); } return true; } return false; Loading Loading
core/java/android/bluetooth/BluetoothDeviceProfileState.java +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ public final class BluetoothDeviceProfileState extends StateMachine { private static final int CONNECTION_ACCESS_REQUEST_REPLY = 104; private static final int CONNECTION_ACCESS_REQUEST_EXPIRY = 105; private static final int CONNECT_OTHER_PROFILES_DELAY = 4000; // 4 secs public static final int CONNECT_OTHER_PROFILES_DELAY = 4000; // 4 secs private static final int CONNECTION_ACCESS_REQUEST_EXPIRY_TIMEOUT = 7000; // 7 secs private static final int CONNECTION_ACCESS_UNDEFINED = -1; private static final long INIT_INCOMING_REJECT_TIMER = 1000; // 1 sec Loading
core/java/android/bluetooth/IBluetooth.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ interface IBluetooth boolean connectHeadset(String address); boolean disconnectHeadset(String address); boolean notifyIncomingConnection(String address); boolean notifyIncomingConnection(String address, boolean rejected); // HID profile APIs boolean connectInputDevice(in BluetoothDevice device); Loading
core/java/android/server/BluetoothEventLoop.java +2 −1 Original line number Diff line number Diff line Loading @@ -784,11 +784,12 @@ class BluetoothEventLoop { // machine. We don't handle AVCTP signals currently. We only send // intents for AVDTP state changes. We need to handle both of them in // some cases. For now, just don't move to incoming state in this case. mBluetoothService.notifyIncomingA2dpConnection(address); mBluetoothService.notifyIncomingA2dpConnection(address, true); } else { Log.i(TAG, "" + authorized + "Incoming A2DP / AVRCP connection from " + address); mA2dp.allowIncomingConnect(device, authorized); mBluetoothService.notifyIncomingA2dpConnection(address, false); } } else if (BluetoothUuid.isInputDevice(uuid)) { // We can have more than 1 input device connected. Loading
core/java/android/server/BluetoothService.java +43 −22 Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ public class BluetoothService extends IBluetooth.Stub { private int mNativeData; private BluetoothEventLoop mEventLoop; private BluetoothHeadset mBluetoothHeadset; private BluetoothHeadset mHeadsetProxy; private BluetoothInputDevice mInputDevice; private BluetoothPan mPan; private boolean mIsAirplaneSensitive; Loading Loading @@ -605,6 +605,7 @@ public class BluetoothService extends IBluetooth.Stub { } mBondState.initBondState(); initProfileState(); getProfileProxy(); } /** Loading Loading @@ -1766,8 +1767,8 @@ public class BluetoothService extends IBluetooth.Stub { private void dumpHeadsetService(PrintWriter pw) { pw.println("\n--Headset Service--"); if (mBluetoothHeadset != null) { List<BluetoothDevice> deviceList = mBluetoothHeadset.getConnectedDevices(); if (mHeadsetProxy != null) { List<BluetoothDevice> deviceList = mHeadsetProxy.getConnectedDevices(); if (deviceList.size() == 0) { pw.println("No headsets connected"); } else { Loading @@ -1775,21 +1776,20 @@ public class BluetoothService extends IBluetooth.Stub { pw.println("\ngetConnectedDevices[0] = " + device); dumpHeadsetConnectionState(pw, device); pw.println("getBatteryUsageHint() = " + mBluetoothHeadset.getBatteryUsageHint(device)); mHeadsetProxy.getBatteryUsageHint(device)); } deviceList.clear(); deviceList = mBluetoothHeadset.getDevicesMatchingConnectionStates(new int[] { deviceList = mHeadsetProxy.getDevicesMatchingConnectionStates(new int[] { BluetoothProfile.STATE_CONNECTED, BluetoothProfile.STATE_DISCONNECTED}); pw.println("--Connected and Disconnected Headsets"); for (BluetoothDevice device: deviceList) { pw.println(device); if (mBluetoothHeadset.isAudioConnected(device)) { if (mHeadsetProxy.isAudioConnected(device)) { pw.println("SCO audio connected to device:" + device); } } } mAdapter.closeProfileProxy(BluetoothProfile.HEADSET, mBluetoothHeadset); } private void dumpInputDeviceProfile(PrintWriter pw) { Loading Loading @@ -1824,7 +1824,6 @@ public class BluetoothService extends IBluetooth.Stub { pw.println(device); } } mAdapter.closeProfileProxy(BluetoothProfile.INPUT_DEVICE, mBluetoothHeadset); } private void dumpPanProfile(PrintWriter pw) { Loading Loading @@ -1862,7 +1861,7 @@ public class BluetoothService extends IBluetooth.Stub { private void dumpHeadsetConnectionState(PrintWriter pw, BluetoothDevice device) { switch (mBluetoothHeadset.getConnectionState(device)) { switch (mHeadsetProxy.getConnectionState(device)) { case BluetoothHeadset.STATE_CONNECTING: pw.println("getConnectionState() = STATE_CONNECTING"); break; Loading @@ -1884,7 +1883,6 @@ public class BluetoothService extends IBluetooth.Stub { Integer pid = mServiceRecordToPid.get(handle).first; pw.println("\tpid " + pid + " handle " + Integer.toHexString(handle)); } mAdapter.closeProfileProxy(BluetoothProfile.PAN, mBluetoothHeadset); } private void dumpAclConnectedDevices(PrintWriter pw) { Loading Loading @@ -1927,11 +1925,16 @@ public class BluetoothService extends IBluetooth.Stub { } } private void getProfileProxy() { mAdapter.getProfileProxy(mContext, mBluetoothProfileServiceListener, BluetoothProfile.HEADSET); } private BluetoothProfile.ServiceListener mBluetoothProfileServiceListener = new BluetoothProfile.ServiceListener() { public void onServiceConnected(int profile, BluetoothProfile proxy) { if (profile == BluetoothProfile.HEADSET) { mBluetoothHeadset = (BluetoothHeadset) proxy; mHeadsetProxy = (BluetoothHeadset) proxy; } else if (profile == BluetoothProfile.INPUT_DEVICE) { mInputDevice = (BluetoothInputDevice) proxy; } else if (profile == BluetoothProfile.PAN) { Loading @@ -1940,7 +1943,7 @@ public class BluetoothService extends IBluetooth.Stub { } public void onServiceDisconnected(int profile) { if (profile == BluetoothProfile.HEADSET) { mBluetoothHeadset = null; mHeadsetProxy = null; } else if (profile == BluetoothProfile.INPUT_DEVICE) { mInputDevice = null; } else if (profile == BluetoothProfile.PAN) { Loading Loading @@ -2424,25 +2427,43 @@ public class BluetoothService extends IBluetooth.Stub { } } public boolean notifyIncomingConnection(String address) { BluetoothDeviceProfileState state = mDeviceProfileState.get(address); public boolean notifyIncomingConnection(String address, boolean rejected) { BluetoothDeviceProfileState state = mDeviceProfileState.get(address); if (state != null) { Message msg = new Message(); if (rejected) { if (mA2dpService.getPriority(getRemoteDevice(address)) >= BluetoothProfile.PRIORITY_ON) { msg.what = BluetoothDeviceProfileState.CONNECT_OTHER_PROFILES; msg.arg1 = BluetoothDeviceProfileState.CONNECT_A2DP_OUTGOING; state.sendMessageDelayed(msg, BluetoothDeviceProfileState.CONNECT_OTHER_PROFILES_DELAY); } } else { msg.what = BluetoothDeviceProfileState.CONNECT_HFP_INCOMING; state.sendMessage(msg); } return true; } return false; } /*package*/ boolean notifyIncomingA2dpConnection(String address) { BluetoothDeviceProfileState state = mDeviceProfileState.get(address); /*package*/ boolean notifyIncomingA2dpConnection(String address, boolean rejected) { BluetoothDeviceProfileState state = mDeviceProfileState.get(address); if (state != null) { Message msg = new Message(); if (rejected) { if (mHeadsetProxy.getPriority(getRemoteDevice(address)) >= BluetoothProfile.PRIORITY_ON) { msg.what = BluetoothDeviceProfileState.CONNECT_OTHER_PROFILES; msg.arg1 = BluetoothDeviceProfileState.CONNECT_HFP_OUTGOING; state.sendMessageDelayed(msg, BluetoothDeviceProfileState.CONNECT_OTHER_PROFILES_DELAY); } } else { msg.what = BluetoothDeviceProfileState.CONNECT_A2DP_INCOMING; state.sendMessage(msg); } return true; } return false; Loading