summaryrefslogtreecommitdiff
path: root/same-android/src/main/java/com/orbekk/same
diff options
context:
space:
mode:
Diffstat (limited to 'same-android/src/main/java/com/orbekk/same')
-rw-r--r--same-android/src/main/java/com/orbekk/same/android/ClientInterfaceBridge.java15
-rw-r--r--same-android/src/main/java/com/orbekk/same/android/SameService.java9
2 files changed, 11 insertions, 13 deletions
diff --git a/same-android/src/main/java/com/orbekk/same/android/ClientInterfaceBridge.java b/same-android/src/main/java/com/orbekk/same/android/ClientInterfaceBridge.java
index 892e9a5..6ae979c 100644
--- a/same-android/src/main/java/com/orbekk/same/android/ClientInterfaceBridge.java
+++ b/same-android/src/main/java/com/orbekk/same/android/ClientInterfaceBridge.java
@@ -42,16 +42,17 @@ import com.orbekk.util.DelayedOperation;
public class ClientInterfaceBridge implements ClientInterface {
private State state;
- private ArrayList<StateChangedListener> listeners =
+ private final ArrayList<StateChangedListener> listeners =
new ArrayList<StateChangedListener>();
- private Map<Integer, DelayedOperation> ongoingOperations =
+ private final Map<Integer, DelayedOperation> ongoingOperations =
new HashMap<Integer, DelayedOperation>();
/** This is used to queue operations until connected to the service. */
- private ArrayList<Message> pendingOperations = new ArrayList<Message>();
- private int nextOperationNumber = 0;
+ private final ArrayList<Message> pendingOperations = new ArrayList<Message>();
+ private volatile int nextOperationNumber = 0;
class ResponseHandler extends Handler {
@Override public synchronized void handleMessage(Message message) {
+ logger.info("ResponseHandler: Got here. Message: {}", message);
if (serviceMessenger == null) {
logger.warn("Ignoring message to disabled ResponseHandler.");
return;
@@ -79,9 +80,9 @@ public class ClientInterfaceBridge implements ClientInterface {
}
private Logger logger = LoggerFactory.getLogger(getClass());
- private Messenger serviceMessenger = null;
- private Messenger responseMessenger = new Messenger(new ResponseHandler());
- private Context context;
+ private volatile Messenger serviceMessenger = null;
+ private volatile Messenger responseMessenger = new Messenger(new ResponseHandler());
+ private volatile Context context;
private ServiceConnection serviceConnection = new ServiceConnection() {
@Override
diff --git a/same-android/src/main/java/com/orbekk/same/android/SameService.java b/same-android/src/main/java/com/orbekk/same/android/SameService.java
index 18c13af..f369b3a 100644
--- a/same-android/src/main/java/com/orbekk/same/android/SameService.java
+++ b/same-android/src/main/java/com/orbekk/same/android/SameService.java
@@ -147,12 +147,9 @@ public class SameService extends Service {
State.Component updatedComponent =
new ComponentBundle(message.getData()).getComponent();
int id = message.arg1;
- logger.info("Running operation. Component: " + updatedComponent);
DelayedOperation op = sameController.getClient().getInterface()
.set(updatedComponent);
- logger.info("Operation finished. Sending callback.");
operationStatusCallback(op, id, message.replyTo);
- logger.info("Callback sent.");
break;
case KILL_MASTER:
logger.info("Kill master.");
@@ -193,10 +190,10 @@ public class SameService extends Service {
Message message = Message.obtain(null,
OPERATION_STATUS_CALLBACK);
message.arg1 = id;
- message.arg2 = op.getStatus().getStatusCode();
- message.obj = op.getStatus().getMessage();
+ message.getData().putInt("statusCode", op.getStatus().getStatusCode());
+ message.getData().putString("statusMessage", op.getStatus().getMessage());
try {
- messenger.send(message);
+ replyTo.send(message);
} catch (RemoteException e) {
logger.warn("Unable to send update result: " +
op.getStatus());