Skip to content

Commit

Permalink
Add initial ProtoBuf for DevToolsMessages. (#6438)
Browse files Browse the repository at this point in the history
- Add devtools_message.proto file
- Create and send message in DevToolsService with the new ProtoBuf.

cc: @piotrswigon @jasonwyatt

Closes #6438

COPYBARA_INTEGRATE_REVIEW=#6438 from SHeimlich:devtools-protos 226b0ab
PiperOrigin-RevId: 339127009
  • Loading branch information
SHeimlich authored and arcs-c3po committed Oct 26, 2020
1 parent 96c4992 commit 6f03590
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
19 changes: 19 additions & 0 deletions java/arcs/android/devtools/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
load("//third_party/java/arcs/build_defs:build_defs.bzl", "arcs_kt_android_library")
load(
"//third_party/java/arcs/build_defs:native.oss.bzl",
"android_proto_library",
"proto_library",
)
load("//tools/build_defs/android:rules.bzl", "android_library")

licenses(["notice"])
Expand All @@ -22,6 +27,7 @@ arcs_kt_android_library(
resource_files = glob(["res/**/*"]),
deps = [
":aidl",
":devtools_message_android_proto",
"//java/arcs/android/storage",
"//java/arcs/android/storage/service:aidl",
"//java/arcs/core/common",
Expand All @@ -39,3 +45,16 @@ arcs_kt_android_library(
"//third_party/kotlin/kotlinx_coroutines",
],
)

proto_library(
name = "devtools_message_proto",
srcs = ["devtools_message.proto"],
deps = [
"//java/arcs/android/storage:proxy_message_proto",
],
)

android_proto_library(
name = "devtools_message_android_proto",
deps = [":devtools_message_proto"],
)
7 changes: 7 additions & 0 deletions java/arcs/android/devtools/DevToolsService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import arcs.android.storage.decodeProxyMessage
import arcs.android.storage.service.IDevToolsProxy
import arcs.android.storage.service.IDevToolsProxyCallback
import arcs.android.storage.service.IDevToolsStorageManager
import arcs.android.storage.toProto
import arcs.core.crdt.CrdtData
import arcs.core.crdt.CrdtOperation
import arcs.core.storage.ProxyMessage
Expand Down Expand Up @@ -79,6 +80,12 @@ open class DevToolsService : Service() {
object : IDevToolsProxyCallback.Stub() {
override fun onProxyMessage(proxyMessage: ByteArray, storageKey: String) {
scope.launch {
val proto = DevtoolsMessage.DevToolsProxyMessageProto.newBuilder()
.setProxyMessage(proxyMessage.decodeProxyMessage().toProto())
.setStoreType(DevtoolsMessage.DevToolsProxyMessageProto.StoreType.REFERENCE_MODE)
.setStorageKey(storageKey)
.build()
devToolsServer.send(proto.toString())
createAndSendProxyMessages(
proxyMessage.decodeProxyMessage(),
REFERENCEMODE,
Expand Down
18 changes: 18 additions & 0 deletions java/arcs/android/devtools/devtools_message.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";

package arcs.android.devtools;

import "java/arcs/android/storage/proxy_message.proto";

option java_package = "arcs.android.devtools";

message DevToolsProxyMessageProto {
arcs.android.storage.ProxyMessageProto proxy_message = 1;
enum StoreType {
DIRECT = 0;
REFERENCE_MODE = 1;
}

string storage_key = 2;
StoreType store_type = 3;
}

0 comments on commit 6f03590

Please sign in to comment.