Merge "Update BT code for voice capability cases."
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index 556fb10..32df4e8 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -521,6 +521,21 @@
}
/**
+ * Get the UUIDs supported by the local Bluetooth adapter.
+ *
+ * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
+ *
+ * @return the UUIDs supported by the local Bluetooth Adapter.
+ * @hide
+ */
+ public ParcelUuid[] getUuids() {
+ try {
+ return mService.getUuids();
+ } catch (RemoteException e) {Log.e(TAG, "", e);}
+ return null;
+ }
+
+ /**
* Set the friendly Bluetooth name of the local Bluetooth adapter.
* <p>This name is visible to remote Bluetooth devices.
* <p>Valid Bluetooth names are a maximum of 248 bytes using UTF-8
diff --git a/core/java/android/bluetooth/BluetoothDeviceProfileState.java b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
index 138e7f2..d1a6ed5 100644
--- a/core/java/android/bluetooth/BluetoothDeviceProfileState.java
+++ b/core/java/android/bluetooth/BluetoothDeviceProfileState.java
@@ -301,10 +301,9 @@
if (isPhoneDocked(mDevice)) {
// Don't auto connect to docks.
break;
- } else if (mHeadsetService == null) {
- deferMessage(message);
} else {
- if (mHeadsetService.getPriority(mDevice) ==
+ if (mHeadsetService != null &&
+ mHeadsetService.getPriority(mDevice) ==
BluetoothHeadset.PRIORITY_AUTO_CONNECT &&
mHeadsetService.getDevicesMatchingConnectionStates(
new int[] {BluetoothProfile.STATE_CONNECTED,
@@ -1027,7 +1026,8 @@
// This is again against spec. HFP incoming connections should be made
// before A2DP, so we should not hit this case. But many devices
// don't follow this.
- if (mHeadsetService.getPriority(mDevice) == BluetoothProfile.PRIORITY_ON) {
+ if (mHeadsetService != null &&
+ mHeadsetService.getPriority(mDevice) == BluetoothProfile.PRIORITY_ON) {
Message msg = new Message();
msg.what = CONNECT_OTHER_PROFILES;
msg.arg1 = CONNECT_HFP_OUTGOING;
diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl
index aefb3f2..f3e73cf 100644
--- a/core/java/android/bluetooth/IBluetooth.aidl
+++ b/core/java/android/bluetooth/IBluetooth.aidl
@@ -35,6 +35,7 @@
String getAddress();
String getName();
boolean setName(in String name);
+ ParcelUuid[] getUuids();
int getScanMode();
boolean setScanMode(int mode, int duration);
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index 01a6b94..398b5ae 100644
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -541,14 +541,15 @@
mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 3, -1), 500);
break;
case 3:
- Log.d(TAG, "Registering opush record");
- SystemService.start("opush");
- mHandler.sendMessageDelayed(
- mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 4, -1), 500);
- break;
- case 4:
Log.d(TAG, "Registering pbap record");
SystemService.start("pbap");
+ mHandler.sendMessageDelayed(
+ mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 4, -1), 500);
+
+ break;
+ case 4:
+ Log.d(TAG, "Registering opush record");
+ SystemService.start("opush");
break;
}
break;
@@ -630,8 +631,15 @@
initProfileState();
//Register SDP records.
- mHandler.sendMessageDelayed(
+ if (mContext.getResources().
+ getBoolean(com.android.internal.R.bool.config_voice_capable)) {
+ mHandler.sendMessageDelayed(
mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 1, -1), 3000);
+ } else {
+ // Register only OPP.
+ mHandler.sendMessageDelayed(
+ mHandler.obtainMessage(MESSAGE_REGISTER_SDP_RECORDS, 4, -1), 3000);
+ }
setBluetoothTetheringNative(true, BluetoothPan.NAP_ROLE, BluetoothPan.NAP_BRIDGE);
@@ -1196,6 +1204,24 @@
return getProperty("Name");
}
+ public synchronized ParcelUuid[] getUuids() {
+ mContext.enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
+ String value = getProperty("UUIDs");
+ if (value == null) return null;
+
+ String[] uuidStrings = null;
+ // The UUIDs are stored as a "," separated string.
+ uuidStrings = value.split(",");
+ ParcelUuid[] uuids = new ParcelUuid[uuidStrings.length];
+
+ for (int i = 0; i < uuidStrings.length; i++) {
+ uuids[i] = ParcelUuid.fromString(uuidStrings[i]);
+ }
+ return uuids;
+
+ }
+
+
/**
* Returns the user-friendly name of a remote device. This value is
* returned from our local cache, which is updated when onPropertyChange