|
...
|
...
|
@@ -141,7 +141,7 @@ interface WearEngineHostApi { |
|
|
|
fun checkConnectedDevice(): WearDeviceInfo?
|
|
|
|
fun registerMessageReceiver(): Boolean
|
|
|
|
fun sendTextMessage(message: String): Boolean
|
|
|
|
fun sendWatchSyncPayload(jsonPayload: String): Boolean
|
|
|
|
fun sendWatchSyncPayload(jsonPayload: String, callback: (Result<Boolean>) -> Unit)
|
|
|
|
/**
|
|
|
|
* Opens the system photo picker and returns a local PNG file path after
|
|
|
|
* removing the image background on the host platform.
|
|
...
|
...
|
@@ -227,12 +227,15 @@ interface WearEngineHostApi { |
|
|
|
channel.setMessageHandler { message, reply ->
|
|
|
|
val args = message as List<Any?>
|
|
|
|
val jsonPayloadArg = args[0] as String
|
|
|
|
val wrapped: List<Any?> = try {
|
|
|
|
listOf(api.sendWatchSyncPayload(jsonPayloadArg))
|
|
|
|
} catch (exception: Throwable) {
|
|
|
|
WearEngineApiPigeonUtils.wrapError(exception)
|
|
|
|
api.sendWatchSyncPayload(jsonPayloadArg) { result: Result<Boolean> ->
|
|
|
|
val error = result.exceptionOrNull()
|
|
|
|
if (error != null) {
|
|
|
|
reply.reply(WearEngineApiPigeonUtils.wrapError(error))
|
|
|
|
} else {
|
|
|
|
val data = result.getOrNull()
|
|
|
|
reply.reply(WearEngineApiPigeonUtils.wrapResult(data))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reply.reply(wrapped)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
channel.setMessageHandler(null)
|
...
|
...
|
|