summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMatthew Xie <mattx@google.com>2011-11-11 13:42:42 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-11-11 13:42:42 -0800
commit44ada1845d721500e4bbddabfd70c8188cf80dbf (patch)
tree9ade25aab3f97a86d37fa5c0e61046d4470f4143 /core
parent6c934436d4d1d6e87de6ff875ba05322b5c1d3b0 (diff)
parent5a8ad0717dad332cab4b2d9f7a6030b76cb8d6bb (diff)
downloadframeworks_base-44ada1845d721500e4bbddabfd70c8188cf80dbf.zip
frameworks_base-44ada1845d721500e4bbddabfd70c8188cf80dbf.tar.gz
frameworks_base-44ada1845d721500e4bbddabfd70c8188cf80dbf.tar.bz2
am 5a8ad071: am a303f0ec: Merge "Send CONNECT_OTHER_PROFILE to Device profile for hfp and a2dp incoming connect" into ics-mr1
* commit '5a8ad0717dad332cab4b2d9f7a6030b76cb8d6bb': Send CONNECT_OTHER_PROFILE to Device profile for hfp and a2dp incoming connect
Diffstat (limited to 'core')
-rw-r--r--core/java/android/bluetooth/BluetoothDeviceProfileState.java2
-rw-r--r--core/java/android/bluetooth/IBluetooth.aidl2
-rw-r--r--core/java/android/server/BluetoothEventLoop.java3
-rwxr-xr-xcore/java/android/server/BluetoothService.java65
4 files changed, 47 insertions, 25 deletions
diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
index 7addd4a..b1d0070 100644
--- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java
+++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
@@ -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
diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl
index fefeb93..deea2b8 100644
--- a/core/java/android/bluetooth/IBluetooth.aidl
+++ b/core/java/android/bluetooth/IBluetooth.aidl
@@ -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);
diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java
index 1b473ec..aa62cd7 100644
--- a/core/java/android/server/BluetoothEventLoop.java
+++ b/core/java/android/server/BluetoothEventLoop.java
@@ -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.
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index 9ca5847..d604a01 100755
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -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;
@@ -605,6 +605,7 @@ public class BluetoothService extends IBluetooth.Stub {
}
mBondState.initBondState();
initProfileState();
+ getProfileProxy();
}
/**
@@ -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 {
@@ -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) {
@@ -1824,7 +1824,6 @@ public class BluetoothService extends IBluetooth.Stub {
pw.println(device);
}
}
- mAdapter.closeProfileProxy(BluetoothProfile.INPUT_DEVICE, mBluetoothHeadset);
}
private void dumpPanProfile(PrintWriter pw) {
@@ -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;
@@ -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) {
@@ -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) {
@@ -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) {
@@ -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();
- msg.what = BluetoothDeviceProfileState.CONNECT_HFP_INCOMING;
- state.sendMessage(msg);
+ 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();
- msg.what = BluetoothDeviceProfileState.CONNECT_A2DP_INCOMING;
- state.sendMessage(msg);
+ 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;