aboutsummaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothDevice.java
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
commit549181ef2fdbc96523a372fcbb6e72a6556dbc4f (patch)
tree8c452b95682f722d4076bf64b5886d8cf8ac687b /framework/java/android/bluetooth/BluetoothDevice.java
parent5acfd83b4617c6339b0ec7b2f66677f8df5584f3 (diff)
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 'framework/java/android/bluetooth/BluetoothDevice.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothDevice.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java
index d9525a347f..4cb8220479 100644
--- a/framework/java/android/bluetooth/BluetoothDevice.java
+++ b/framework/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