[Libreoffice-commits] core.git: 3 commits - android/sdremote
Tor Lillqvist
tml at iki.fi
Tue Feb 12 16:15:32 PST 2013
android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java | 2 +
android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java | 6 +++++
android/sdremote/src/org/libreoffice/impressremote/communication/Client.java | 2 -
android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java | 11 +++++-----
android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java | 1
android/sdremote/src/org/libreoffice/impressremote/communication/Server.java | 3 ++
6 files changed, 18 insertions(+), 7 deletions(-)
New commits:
commit 871712ad62bb01359c29713a148a5673e26df1a8
Author: Tor Lillqvist <tml at iki.fi>
Date: Wed Feb 13 02:12:12 2013 +0200
Don't return from the CommunicationService.run() method
This fixes connecting to one computer after connecting to another failed.
Change-Id: I5b13d186d32690a91e4290c81c8d2e12a0a1f2be
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
index 5f8f8c6..5b32661 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
@@ -76,6 +76,7 @@ public class CommunicationService extends Service implements Runnable {
@Override
public void run() {
+ Log.i(Globals.TAG, "CommunicationService.run()");
synchronized (this) {
while (true) {
// Condition
@@ -86,6 +87,7 @@ public class CommunicationService extends Service implements Runnable {
return;
}
// Work
+ Log.i(Globals.TAG, "CommunicationService.run: at \"Work\"");
synchronized (mConnectionVariableMutex) {
if ((mStateDesired == State.CONNECTED && mState == State.CONNECTED)
|| (mStateDesired == State.DISCONNECTED && mState == State.CONNECTED)) {
@@ -107,23 +109,21 @@ public class CommunicationService extends Service implements Runnable {
mBluetoothPreviouslyEnabled);
break;
}
+ mTransmitter = new Transmitter(mClient);
+ mState = State.CONNECTED;
} catch (IOException e) {
- e.printStackTrace();
+ Log.i(Globals.TAG, "CommunicationService.run: " + e);
mClient = null;
mState = State.DISCONNECTED;
Intent aIntent = new Intent(
CommunicationService.STATUS_CONNECTION_FAILED);
LocalBroadcastManager.getInstance(this)
.sendBroadcast(aIntent);
- return;
}
- mTransmitter = new Transmitter(mClient);
- mState = State.CONNECTED;
}
}
}
}
-
}
private boolean mBluetoothPreviouslyEnabled;
@@ -156,6 +156,7 @@ public class CommunicationService extends Service implements Runnable {
}
public void connectTo(Server aServer) {
+ Log.i(Globals.TAG, "CommunicationService.connectTo(" + aServer + ")");
synchronized (mConnectionVariableMutex) {
if (mState == State.SEARCHING) {
mNetworkFinder.stopFinding();
commit 307913304a7636d69fe6847a13c20aa7d9729e01
Author: Tor Lillqvist <tml at iki.fi>
Date: Wed Feb 13 02:10:34 2013 +0200
Do display the computer name in the dialog when connection failed
The latestInstance lifecycle and mName initialisation was borked.
Change-Id: If7ef8a15fdc297e0fe6e401399a3b94dcd8d08c5
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java b/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java
index 1c3dce8..ce5e3ad 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java
@@ -47,6 +47,7 @@ public abstract class Client {
CommunicationService aCommunicationService,
Receiver aReceiver) {
mServer = aServer;
+ mName = aServer.getName();
mCommunicationService = aCommunicationService;
mReceiver = aReceiver;
latestInstance = this;
@@ -92,7 +93,6 @@ public abstract class Client {
// TODO stream couldn't be opened.
e1.printStackTrace();
} finally {
- latestInstance = null;
onDisconnect();
}
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java b/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java
index 778f9c3..2e88a17 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java
@@ -37,7 +37,6 @@ public class NetworkClient extends Client {
Receiver aReceiver) throws UnknownHostException,
IOException {
super(aServer, aCommunicationService, aReceiver);
- mName = aServer.getName();
mSocket = new Socket(aServer.getAddress(), PORT);
mInputStream = mSocket.getInputStream();
mReader = new BufferedReader(new InputStreamReader(mInputStream,
commit 2244bb1467454614140bc71af7395d0129e27bc3
Author: Tor Lillqvist <tml at iki.fi>
Date: Wed Feb 13 02:07:27 2013 +0200
Add comments, logging, empty lines
Change-Id: Ife81ec74b36f71782997219e36ac926ea429c297
diff --git a/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java b/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java
index 207aef7..1b8c044 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java
@@ -183,6 +183,8 @@ public class SelectorActivity extends SherlockActivity {
}
void doBindService() {
+ // This is what creates the first (only?) CommunicationService instance
+ // and calls its run() method (in another thread).
Intent aIntent = new Intent(this, CommunicationService.class);
startService(aIntent);
bindService(aIntent, mConnection, Context.BIND_IMPORTANT);
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java
index 49be8a3..07a626f 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java
@@ -36,6 +36,9 @@ public class BluetoothClient extends Client {
Receiver aReceiver, boolean aBluetoothWasEnabled)
throws IOException {
super(aServer, aCommunicationService, aReceiver);
+
+ Log.i(Globals.TAG, "BluetoothClient(" + aServer + ")");
+
mAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothWasEnabled = aBluetoothWasEnabled;
if (!mBluetoothWasEnabled) {
@@ -45,18 +48,21 @@ public class BluetoothClient extends Client {
BluetoothDevice aDevice = mAdapter
.getRemoteDevice(aServer.getAddress());
mAdapter.cancelDiscovery();
+
// This is the "standard UUID for the Serial Port Profile".
// I.e. the 16-bit SerialPort UUID 0x1101 inserted into the
// Bluetooth BASE_UUID. See
// https://www.bluetooth.org/Technical/AssignedNumbers/service_discovery.htm
mSocket = aDevice.createRfcommSocketToServiceRecord(UUID
.fromString("00001101-0000-1000-8000-00805F9B34FB"));
+
mSocket.connect();
Log.i(Globals.TAG, "BluetoothClient: connected");
mInputStream = mSocket.getInputStream();
mReader = new BufferedReader(new InputStreamReader(mInputStream,
CHARSET));
+
mOutputStream = mSocket.getOutputStream();
String aTemp = mReader.readLine();
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Server.java b/android/sdremote/src/org/libreoffice/impressremote/communication/Server.java
index a09cc6a..82172be 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/Server.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Server.java
@@ -53,6 +53,9 @@ public class Server {
return mTimeDiscovered;
}
+ public String toString() {
+ return getClass().getName() + '@' + Integer.toHexString(hashCode()) + ":{" + mAddress + "," + mName + "}";
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list