summaryrefslogtreecommitdiffstats
path: root/core/java/android/bluetooth
diff options
context:
space:
mode:
authorMatthew Xie <mattx@google.com>2011-07-26 18:36:49 -0700
committerMatthew Xie <mattx@google.com>2011-07-28 15:56:11 -0700
commit269e81a563cfe080d7f241d0d46411d3c946c111 (patch)
treefb62527f5a1dc5bda21202c87e7c026a6c914ed1 /core/java/android/bluetooth
parent686200cb5f3e80c0b0519ec14cc54b280a560863 (diff)
downloadframeworks_base-269e81a563cfe080d7f241d0d46411d3c946c111.zip
frameworks_base-269e81a563cfe080d7f241d0d46411d3c946c111.tar.gz
frameworks_base-269e81a563cfe080d7f241d0d46411d3c946c111.tar.bz2
Provide an API to set the friendly name of a remote device.
BluetoothDevice setName overwrite the locally cached remote name. The changed name is saved in the local storage so that the change is preserved over power cycle. bug 5081605 Change-Id: I486966033828d153bfb1076a99e274c8a7f41636
Diffstat (limited to 'core/java/android/bluetooth')
-rw-r--r--core/java/android/bluetooth/BluetoothDevice.java48
-rw-r--r--core/java/android/bluetooth/IBluetooth.aidl2
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 183772d..da66b1a 100644
--- a/core/java/android/bluetooth/IBluetooth.aidl
+++ b/core/java/android/bluetooth/IBluetooth.aidl
@@ -62,6 +62,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);