From d5ac1ae36b4e096eb97984334f86d0c68abea2f7 Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Tue, 5 May 2009 22:26:12 -0700 Subject: Framework changes for bluez4. Changes in the Bluetooth JNI calls and framework functions for Bluez4. --- core/java/android/bluetooth/BluetoothDevice.java | 192 ++------------------- core/java/android/bluetooth/BluetoothUuid.java | 62 +++++++ core/java/android/bluetooth/IBluetoothDevice.aidl | 26 +-- .../bluetooth/IBluetoothDeviceCallback.aidl | 25 --- 4 files changed, 80 insertions(+), 225 deletions(-) create mode 100644 core/java/android/bluetooth/BluetoothUuid.java delete mode 100644 core/java/android/bluetooth/IBluetoothDeviceCallback.aidl (limited to 'core/java/android/bluetooth') diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java index 951b4b0..c942a27 100644 --- a/core/java/android/bluetooth/BluetoothDevice.java +++ b/core/java/android/bluetooth/BluetoothDevice.java @@ -75,7 +75,7 @@ public class BluetoothDevice { public static final int UNBOND_REASON_REMOVED = 6; private static final String TAG = "BluetoothDevice"; - + private final IBluetoothDevice mService; /** * @hide - hide this because it takes a parameter of type @@ -180,31 +180,6 @@ public class BluetoothDevice { return false; } - public String getVersion() { - try { - return mService.getVersion(); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return null; - } - public String getRevision() { - try { - return mService.getRevision(); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return null; - } - public String getManufacturer() { - try { - return mService.getManufacturer(); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return null; - } - public String getCompany() { - try { - return mService.getCompany(); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return null; - } - /** * Get the current scan mode. * Used to determine if the local device is connectable and/or discoverable @@ -241,11 +216,8 @@ public class BluetoothDevice { } public boolean startDiscovery() { - return startDiscovery(true); - } - public boolean startDiscovery(boolean resolveNames) { try { - return mService.startDiscovery(resolveNames); + return mService.startDiscovery(); } catch (RemoteException e) {Log.e(TAG, "", e);} return false; } @@ -263,88 +235,17 @@ public class BluetoothDevice { return false; } - public boolean startPeriodicDiscovery() { - try { - return mService.startPeriodicDiscovery(); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return false; - } - public boolean stopPeriodicDiscovery() { - try { - return mService.stopPeriodicDiscovery(); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return false; - } - public boolean isPeriodicDiscovery() { - try { - return mService.isPeriodicDiscovery(); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return false; - } - - public String[] listRemoteDevices() { - try { - return mService.listRemoteDevices(); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return null; - } - - /** - * List remote devices that have a low level (ACL) connection. - * - * RFCOMM, SDP and L2CAP are all built on ACL connections. Devices can have - * an ACL connection even when not paired - this is common for SDP queries - * or for in-progress pairing requests. - * - * In most cases you probably want to test if a higher level protocol is - * connected, rather than testing ACL connections. - * - * @return bluetooth hardware addresses of remote devices with a current - * ACL connection. Array size is 0 if no devices have a - * connection. Null on error. - */ - public String[] listAclConnections() { - try { - return mService.listAclConnections(); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return null; - } - - /** - * Check if a specified remote device has a low level (ACL) connection. - * - * RFCOMM, SDP and L2CAP are all built on ACL connections. Devices can have - * an ACL connection even when not paired - this is common for SDP queries - * or for in-progress pairing requests. - * - * In most cases you probably want to test if a higher level protocol is - * connected, rather than testing ACL connections. - * - * @param address the Bluetooth hardware address you want to check. - * @return true if there is an ACL connection, false otherwise and on - * error. - */ - public boolean isAclConnected(String address) { - try { - return mService.isAclConnected(address); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return false; - } - /** - * Perform a low level (ACL) disconnection of a remote device. - * - * This forcably disconnects the ACL layer connection to a remote device, - * which will cause all RFCOMM, SDP and L2CAP connections to this remote - * device to close. + * Removes the remote device and the pairing information associated + * with it. * * @param address the Bluetooth hardware address you want to disconnect. * @return true if the device was disconnected, false otherwise and on * error. */ - public boolean disconnectRemoteDeviceAcl(String address) { + public boolean removeBond(String address) { try { - return mService.disconnectRemoteDeviceAcl(address); + return mService.removeBond(address); } catch (RemoteException e) {Log.e(TAG, "", e);} return false; } @@ -377,16 +278,6 @@ public class BluetoothDevice { } /** - * Remove an already exisiting bonding (delete the link key). - */ - public boolean removeBond(String address) { - try { - return mService.removeBond(address); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return false; - } - - /** * List remote devices that are bonded (paired) to the local device. * * Bonding (pairing) is the process by which the user enters a pin code for @@ -440,78 +331,25 @@ public class BluetoothDevice { return null; } - public String getRemoteVersion(String address) { - try { - return mService.getRemoteVersion(address); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return null; - } - public String getRemoteRevision(String address) { - try { - return mService.getRemoteRevision(address); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return null; - } - public String getRemoteManufacturer(String address) { - try { - return mService.getRemoteManufacturer(address); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return null; - } - public String getRemoteCompany(String address) { - try { - return mService.getRemoteCompany(address); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return null; - } - - /** - * Returns the RFCOMM channel associated with the 16-byte UUID on - * the remote Bluetooth address. - * - * Performs a SDP ServiceSearchAttributeRequest transaction. The provided - * uuid is verified in the returned record. If there was a problem, or the - * specified uuid does not exist, -1 is returned. - */ - public boolean getRemoteServiceChannel(String address, short uuid16, - IBluetoothDeviceCallback callback) { - try { - return mService.getRemoteServiceChannel(address, uuid16, callback); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return false; - } - - /** - * Get the major, minor and servics classes of a remote device. - * These classes are encoded as a 32-bit integer. See BluetoothClass. - * @param address remote device - * @return 32-bit class suitable for use with BluetoothClass, or - * BluetoothClass.ERROR on error - */ public int getRemoteClass(String address) { try { return mService.getRemoteClass(address); } catch (RemoteException e) {Log.e(TAG, "", e);} - return BluetoothClass.ERROR; + return BluetoothError.ERROR_IPC; } - public byte[] getRemoteFeatures(String address) { + public String[] getRemoteUuids(String address) { try { - return mService.getRemoteFeatures(address); + return mService.getRemoteUuids(address); } catch (RemoteException e) {Log.e(TAG, "", e);} return null; } - public String lastSeen(String address) { - try { - return mService.lastSeen(address); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return null; - } - public String lastUsed(String address) { - try { - return mService.lastUsed(address); - } catch (RemoteException e) {Log.e(TAG, "", e);} - return null; + + public int getRemoteServiceChannel(String address, String uuid) { + try { + return mService.getRemoteServiceChannel(address, uuid); + } catch (RemoteException e) {Log.e(TAG, "", e);} + return BluetoothError.ERROR_IPC; } public boolean setPin(String address, byte[] pin) { diff --git a/core/java/android/bluetooth/BluetoothUuid.java b/core/java/android/bluetooth/BluetoothUuid.java new file mode 100644 index 0000000..96b93f9 --- /dev/null +++ b/core/java/android/bluetooth/BluetoothUuid.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.bluetooth; + +import java.util.UUID; + +/** +* Static helper methods and constants to decode the UUID of remote devices. +* @hide +*/ +public final class BluetoothUuid { + + /* See Bluetooth Assigned Numbers document - SDP section, to get the values of UUIDs + * for the various services. + * + * The following 128 bit values are calculated as: + * uuid * 2^96 + BASE_UUID + */ + public static final UUID AudioSink = UUID.fromString("0000110A-0000-1000-8000-00805F9B34FB"); + public static final UUID AudioSource = UUID.fromString("0000110B-0000-1000-8000-00805F9B34FB"); + public static final UUID AdvAudioDist = UUID.fromString("0000110D-0000-1000-8000-00805F9B34FB"); + public static final UUID HSP = UUID.fromString("00001108-0000-1000-8000-00805F9B34FB"); + public static final UUID HeadsetHS = UUID.fromString("00001131-0000-1000-8000-00805F9B34FB"); + public static final UUID Handsfree = UUID.fromString("0000111e-0000-1000-8000-00805F9B34FB"); + public static final UUID HandsfreeAudioGateway + = UUID.fromString("0000111f-0000-1000-8000-00805F9B34FB"); + + public static boolean isAudioSource(UUID uuid) { + return uuid.equals(AudioSource); + } + + public static boolean isAudioSink(UUID uuid) { + return uuid.equals(AudioSink); + } + + public static boolean isAdvAudioDist(UUID uuid) { + return uuid.equals(AdvAudioDist); + } + + public static boolean isHandsfree(UUID uuid) { + return uuid.equals(Handsfree) || uuid.equals(HandsfreeAudioGateway); + } + + public static boolean isHeadset(UUID uuid) { + return uuid.equals(HSP) || uuid.equals(HeadsetHS); + } +} + diff --git a/core/java/android/bluetooth/IBluetoothDevice.aidl b/core/java/android/bluetooth/IBluetoothDevice.aidl index 6cd792e..c249c81 100644 --- a/core/java/android/bluetooth/IBluetoothDevice.aidl +++ b/core/java/android/bluetooth/IBluetoothDevice.aidl @@ -16,8 +16,6 @@ package android.bluetooth; -import android.bluetooth.IBluetoothDeviceCallback; - /** * System private API for talking with the Bluetooth service. * @@ -33,10 +31,6 @@ interface IBluetoothDevice String getAddress(); String getName(); boolean setName(in String name); - String getVersion(); - String getRevision(); - String getManufacturer(); - String getCompany(); int getScanMode(); boolean setScanMode(int mode); @@ -44,17 +38,9 @@ interface IBluetoothDevice int getDiscoverableTimeout(); boolean setDiscoverableTimeout(int timeout); - boolean startDiscovery(boolean resolveNames); + boolean startDiscovery(); boolean cancelDiscovery(); boolean isDiscovering(); - boolean startPeriodicDiscovery(); - boolean stopPeriodicDiscovery(); - boolean isPeriodicDiscovery(); - String[] listRemoteDevices(); - - String[] listAclConnections(); - boolean isAclConnected(in String address); - boolean disconnectRemoteDeviceAcl(in String address); boolean createBond(in String address); boolean cancelBondProcess(in String address); @@ -63,15 +49,9 @@ interface IBluetoothDevice int getBondState(in String address); String getRemoteName(in String address); - String getRemoteVersion(in String address); - String getRemoteRevision(in String address); int getRemoteClass(in String address); - String getRemoteManufacturer(in String address); - String getRemoteCompany(in String address); - boolean getRemoteServiceChannel(in String address, int uuid16, in IBluetoothDeviceCallback callback); - byte[] getRemoteFeatures(in String adddress); - String lastSeen(in String address); - String lastUsed(in String address); + String[] getRemoteUuids(in String address); + int getRemoteServiceChannel(in String address, String uuid); boolean setPin(in String address, in byte[] pin); boolean cancelPin(in String address); diff --git a/core/java/android/bluetooth/IBluetoothDeviceCallback.aidl b/core/java/android/bluetooth/IBluetoothDeviceCallback.aidl deleted file mode 100644 index d057093..0000000 --- a/core/java/android/bluetooth/IBluetoothDeviceCallback.aidl +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2008, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.bluetooth; - -/** - * {@hide} - */ -oneway interface IBluetoothDeviceCallback -{ - void onGetRemoteServiceChannelResult(in String address, int channel); -} -- cgit v1.1