summaryrefslogtreecommitdiff
path: root/same-android/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'same-android/src/main')
-rw-r--r--same-android/src/main/java/com/orbekk/same/SameService.java11
-rw-r--r--same-android/src/main/java/com/orbekk/same/android/ClientInterfaceBridge.java18
2 files changed, 26 insertions, 3 deletions
diff --git a/same-android/src/main/java/com/orbekk/same/SameService.java b/same-android/src/main/java/com/orbekk/same/SameService.java
index 386b9b8..9662d6f 100644
--- a/same-android/src/main/java/com/orbekk/same/SameService.java
+++ b/same-android/src/main/java/com/orbekk/same/SameService.java
@@ -29,6 +29,7 @@ public class SameService extends Service {
public final static int UPDATED_STATE_MESSAGE = 5;
public final static int ADD_STATE_RECEIVER = 6;
public final static int REMOVE_STATE_RECEIVER = 7;
+ public final static int SET_STATE = 8;
public final static String AVAILABLE_NETWORKS_UPDATE =
"com.orbekk.same.SameService.action.AVAILABLE_NETWORKS_UPDATE";
@@ -110,6 +111,16 @@ public class SameService extends Service {
Messenger droppedMessenger = (Messenger)message.obj;
stateReceivers.remove(droppedMessenger);
break;
+ case SET_STATE:
+ // TODO: Respond to the callee somehow.
+ State.Component updatedComponent =
+ (State.Component)message.obj;
+ try {
+ sameController.getClient().getInterface().set(
+ updatedComponent);
+ } catch (UpdateConflict e) {
+ logger.info("Update failed: {}", updatedComponent);
+ }
default:
super.handleMessage(message);
}
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 662816b..cbfeff3 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
@@ -18,6 +18,7 @@ import android.os.RemoteException;
import com.orbekk.same.ClientInterface;
import com.orbekk.same.SameService;
import com.orbekk.same.State;
+import com.orbekk.same.State.Component;
import com.orbekk.same.StateChangedListener;
import com.orbekk.same.UpdateConflict;
import com.orbekk.same.VariableFactory;
@@ -113,9 +114,19 @@ public class ClientInterfaceBridge implements ClientInterface {
@Override
public void set(String name, String data, long revision) throws UpdateConflict {
- logger.info("set({}, {}, {}",
- new Object[]{name, data, revision});
- throw new RuntimeException("Not implemented.");
+ set(new Component(name, revision, data));
+ }
+
+ @Override
+ public void set(Component component) throws UpdateConflict {
+ Message message = Message.obtain(null, SameService.SET_STATE);
+ message.obj = component;
+ try {
+ serviceMessenger.send(message);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ throw new UpdateConflict(e.getMessage());
+ }
}
@Override
@@ -131,4 +142,5 @@ public class ClientInterfaceBridge implements ClientInterface {
public VariableFactory createVariableFactory() {
return VariableFactory.create(this);
}
+
}