diff options
| author | Matthew Xie <mattx@google.com> | 2011-07-28 17:46:45 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-07-28 17:46:45 -0700 |
| commit | 6903a7de88e32e04965f41f1cf6371d855cdfa88 (patch) | |
| tree | 060a2c949c9ab70c5fffc7dbe8e0ce55e3ad07f7 /core/java/android/bluetooth | |
| parent | 318fecea61f65e74b52116f8d1196b33646d477a (diff) | |
| parent | 269e81a563cfe080d7f241d0d46411d3c946c111 (diff) | |
| download | frameworks_base-6903a7de88e32e04965f41f1cf6371d855cdfa88.zip frameworks_base-6903a7de88e32e04965f41f1cf6371d855cdfa88.tar.gz frameworks_base-6903a7de88e32e04965f41f1cf6371d855cdfa88.tar.bz2 | |
Merge "Provide an API to set the friendly name of a remote device."
Diffstat (limited to 'core/java/android/bluetooth')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothDevice.java | 48 | ||||
| -rw-r--r-- | core/java/android/bluetooth/IBluetooth.aidl | 2 |
2 files changed, 50 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java index d9525a3..4cb8220 100644 --- a/core/java/android/bluetooth/BluetoothDevice.java +++ b/core/java/android/bluetooth/BluetoothDevice.java @@ -566,6 +566,54 @@ public final class BluetoothDevice implements Parcelable { } /** + * Get the Bluetooth alias of the remote device. + * <p>Alias is the locally modified name of a remote device. + * + * @return the Bluetooth alias, or null if no alias or there was a problem + * @hide + */ + public String getAlias() { + try { + return sService.getRemoteAlias(mAddress); + } catch (RemoteException e) {Log.e(TAG, "", e);} + return null; + } + + /** + * Set the Bluetooth alias of the remote device. + * <p>Alias is the locally modified name of a remote device. + * <p>This methoid overwrites the alias. The changed + * alias is saved in the local storage so that the change + * is preserved over power cycle. + * + * @return true on success, false on error + * @hide + */ + public boolean setAlias(String alias) { + try { + return sService.setRemoteAlias(mAddress, alias); + } catch (RemoteException e) {Log.e(TAG, "", e);} + return false; + } + + /** + * Get the Bluetooth alias of the remote device. + * If Alias is null, get the Bluetooth name instead. + * @see #getAlias() + * @see #getName() + * + * @return the Bluetooth alias, or null if no alias or there was a problem + * @hide + */ + public String getAliasName() { + String name = getAlias(); + if (name == null) { + name = getName(); + } + return name; + } + + /** * Start the bonding (pairing) process with the remote device. * <p>This is an asynchronous call, it will return immediately. Register * for {@link #ACTION_BOND_STATE_CHANGED} intents to be notified when diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl index be43c51..ddede9c 100644 --- a/core/java/android/bluetooth/IBluetooth.aidl +++ b/core/java/android/bluetooth/IBluetooth.aidl @@ -66,6 +66,8 @@ interface IBluetooth boolean setDeviceOutOfBandData(in String address, in byte[] hash, in byte[] randomizer); String getRemoteName(in String address); + String getRemoteAlias(in String address); + boolean setRemoteAlias(in String address, in String name); int getRemoteClass(in String address); ParcelUuid[] getRemoteUuids(in String address); boolean fetchRemoteUuids(in String address, in ParcelUuid uuid, in IBluetoothCallback callback); |
