diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2012-08-21 11:13:04 +0200 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2012-08-21 11:13:58 +0200 |
commit | e392440a2af0586638795570f17c57223177054f (patch) | |
tree | 77b6505e24727754cddf51843fe8ca9981ca7803 | |
parent | 9b71498d373408ae596371c0a0bf5aaf637cb593 (diff) |
Device name now based on bluetooth name, or hardware name.
Change-Id: I0be93ff79d3dbd56bf847a081b310985c77e43f5
-rw-r--r-- | android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java | 21 | ||||
-rw-r--r-- | android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java | 2 |
2 files changed, 17 insertions, 6 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java index efa65146d651..b3fc690031a8 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java @@ -11,6 +11,7 @@ package org.libreoffice.impressremote.communication; import java.util.ArrayList; import android.app.Service; +import android.bluetooth.BluetoothAdapter; import android.content.Intent; import android.os.Binder; import android.os.IBinder; @@ -22,6 +23,21 @@ public class CommunicationService extends Service implements Runnable { }; /** + * Get the publicly visible device name -- generally the bluetooth name, + * however for bluetoothless devices the device model name is used. + * + * @return The device name. + */ + public static String getDeviceName() { + BluetoothAdapter aAdapter = BluetoothAdapter.getDefaultAdapter(); + if (aAdapter != null) { + return aAdapter.getName(); + } else { + return android.os.Build.MODEL; + } + } + + /** * Used to protect all writes to mState, mStateDesired, and mServerDesired. */ private Object mConnectionVariableMutex = new Object(); @@ -36,11 +52,6 @@ public class CommunicationService extends Service implements Runnable { return Client.getPin(); } - public String getDeviceName() { - return "Bob"; - // FIXME: get the device name somehow. - } - private State mStateDesired = State.DISCONNECTED; private Server mServerDesired = null; diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java b/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java index 1e04747c9d7d..47e0e3779616 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java @@ -50,7 +50,7 @@ public class NetworkClient extends Client { mPin = aPin; LocalBroadcastManager.getInstance(mContext).sendBroadcast(aIntent); // Send out - String aName = "Bob"; // TODO: get the proper name + String aName = CommunicationService.getDeviceName(); // TODO: get the proper name sendCommand("LO_SERVER_CLIENT_PAIR\n" + aName + "\n" + aPin + "\n\n"); |