From 813f6e713d1fdfb88ee42ef32b020cbea6f26f12 Mon Sep 17 00:00:00 2001 From: Victor Gaydov Date: Mon, 16 Sep 2024 01:05:21 +0700 Subject: [PATCH] Refactoring and fixes in android bridge (#98) --- .../{Connector.g.kt => AndroidConnector.g.kt} | 28 ++- .../connector/AndroidConnectorImpl.kt | 41 ++++ .../org/rocstreaming/connector/Connector.kt | 36 ---- .../org/rocstreaming/rocdroid/MainActivity.kt | 9 +- android/gradle.properties | 1 + dodo.py | 2 +- lib/src/agent/android_backend.dart | 27 +-- lib/src/agent/android_connector.dart | 32 +++ lib/src/agent/android_connector.g.dart | 178 ++++++++++++++++ lib/src/agent/backend.dart | 30 +-- lib/src/agent/backend.g.dart | 190 ------------------ lib/src/model/model_root.dart | 2 +- lib/src/model/receiver.dart | 2 +- lib/src/model/sender.dart | 2 +- 14 files changed, 296 insertions(+), 284 deletions(-) rename android/app/src/main/kotlin/org/rocstreaming/connector/{Connector.g.kt => AndroidConnector.g.kt} (83%) create mode 100644 android/app/src/main/kotlin/org/rocstreaming/connector/AndroidConnectorImpl.kt delete mode 100644 android/app/src/main/kotlin/org/rocstreaming/connector/Connector.kt create mode 100644 lib/src/agent/android_connector.dart create mode 100644 lib/src/agent/android_connector.g.dart delete mode 100644 lib/src/agent/backend.g.dart diff --git a/android/app/src/main/kotlin/org/rocstreaming/connector/Connector.g.kt b/android/app/src/main/kotlin/org/rocstreaming/connector/AndroidConnector.g.kt similarity index 83% rename from android/app/src/main/kotlin/org/rocstreaming/connector/Connector.g.kt rename to android/app/src/main/kotlin/org/rocstreaming/connector/AndroidConnector.g.kt index de83979..1415270 100644 --- a/android/app/src/main/kotlin/org/rocstreaming/connector/Connector.g.kt +++ b/android/app/src/main/kotlin/org/rocstreaming/connector/AndroidConnector.g.kt @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v21.1.0), do not edit directly. +// Autogenerated from Pigeon (v22.3.0), do not edit directly. // See also: https://pub.dev/packages/pigeon @file:Suppress("UNCHECKED_CAST", "ArrayInDataClass") @@ -42,7 +42,7 @@ class FlutterError ( override val message: String? = null, val details: Any? = null ) : Throwable() -private object ConnectorPigeonCodec : StandardMessageCodec() { +private open class AndroidConnectorPigeonCodec : StandardMessageCodec() { override fun readValueOfType(type: Byte, buffer: ByteBuffer): Any? { return super.readValueOfType(type, buffer) } @@ -56,7 +56,7 @@ private object ConnectorPigeonCodec : StandardMessageCodec() { * * Generated interface from Pigeon that represents a handler of messages from Flutter. */ -interface Backend { +interface AndroidConnector { fun startReceiver() fun stopReceiver() fun isReceiverAlive(): Boolean @@ -65,16 +65,16 @@ interface Backend { fun isSenderAlive(): Boolean companion object { - /** The codec used by Backend. */ + /** The codec used by AndroidConnector. */ val codec: MessageCodec by lazy { - ConnectorPigeonCodec + AndroidConnectorPigeonCodec() } - /** Sets up an instance of `Backend` to handle messages through the `binaryMessenger`. */ + /** Sets up an instance of `AndroidConnector` to handle messages through the `binaryMessenger`. */ @JvmOverloads - fun setUp(binaryMessenger: BinaryMessenger, api: Backend?, messageChannelSuffix: String = "") { + fun setUp(binaryMessenger: BinaryMessenger, api: AndroidConnector?, messageChannelSuffix: String = "") { val separatedMessageChannelSuffix = if (messageChannelSuffix.isNotEmpty()) ".$messageChannelSuffix" else "" run { - val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.roc_droid_package.Backend.startReceiver$separatedMessageChannelSuffix", codec) + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.roc_droid.AndroidConnector.startReceiver$separatedMessageChannelSuffix", codec) if (api != null) { channel.setMessageHandler { _, reply -> val wrapped: List = try { @@ -90,7 +90,7 @@ interface Backend { } } run { - val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.roc_droid_package.Backend.stopReceiver$separatedMessageChannelSuffix", codec) + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.roc_droid.AndroidConnector.stopReceiver$separatedMessageChannelSuffix", codec) if (api != null) { channel.setMessageHandler { _, reply -> val wrapped: List = try { @@ -106,7 +106,7 @@ interface Backend { } } run { - val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.roc_droid_package.Backend.isReceiverAlive$separatedMessageChannelSuffix", codec) + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.roc_droid.AndroidConnector.isReceiverAlive$separatedMessageChannelSuffix", codec) if (api != null) { channel.setMessageHandler { _, reply -> val wrapped: List = try { @@ -121,7 +121,7 @@ interface Backend { } } run { - val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.roc_droid_package.Backend.startSender$separatedMessageChannelSuffix", codec) + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.roc_droid.AndroidConnector.startSender$separatedMessageChannelSuffix", codec) if (api != null) { channel.setMessageHandler { message, reply -> val args = message as List @@ -139,7 +139,7 @@ interface Backend { } } run { - val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.roc_droid_package.Backend.stopSender$separatedMessageChannelSuffix", codec) + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.roc_droid.AndroidConnector.stopSender$separatedMessageChannelSuffix", codec) if (api != null) { channel.setMessageHandler { _, reply -> val wrapped: List = try { @@ -155,7 +155,7 @@ interface Backend { } } run { - val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.roc_droid_package.Backend.isSenderAlive$separatedMessageChannelSuffix", codec) + val channel = BasicMessageChannel(binaryMessenger, "dev.flutter.pigeon.roc_droid.AndroidConnector.isSenderAlive$separatedMessageChannelSuffix", codec) if (api != null) { channel.setMessageHandler { _, reply -> val wrapped: List = try { @@ -171,6 +171,4 @@ interface Backend { } } } - - fun getHostLanguage(): String } diff --git a/android/app/src/main/kotlin/org/rocstreaming/connector/AndroidConnectorImpl.kt b/android/app/src/main/kotlin/org/rocstreaming/connector/AndroidConnectorImpl.kt new file mode 100644 index 0000000..5db5171 --- /dev/null +++ b/android/app/src/main/kotlin/org/rocstreaming/connector/AndroidConnectorImpl.kt @@ -0,0 +1,41 @@ +package org.rocstreaming.connector + +import AndroidConnector +import android.util.Log +import org.rocstreaming.service.SenderReceiverService + +private const val LOG_TAG = "[rocdroid.Connector]" + +class AndroidConnectorImpl : AndroidConnector { + //private var senderReceiverService: SenderReceiverService = SenderReceiverService() + + override fun startReceiver() { + Log.d(LOG_TAG, "Start Receiver") + //senderReceiverService.startReceiver() + } + + override fun stopReceiver() { + Log.d(LOG_TAG, "Stop Receiver") + //senderReceiverService.stopReceiver() + } + + override fun isReceiverAlive(): Boolean { + //return senderReceiverService.isReceiverAlive() + return true + } + + override fun startSender(ip: String) { + Log.d(LOG_TAG, "Start Sender") + //senderReceiverService.startSender(ip, null) + } + + override fun stopSender() { + Log.d(LOG_TAG, "Stop Sender") + //senderReceiverService.stopSender() + } + + override fun isSenderAlive(): Boolean { + //return senderReceiverService.isSenderAlive() + return true + } +} diff --git a/android/app/src/main/kotlin/org/rocstreaming/connector/Connector.kt b/android/app/src/main/kotlin/org/rocstreaming/connector/Connector.kt deleted file mode 100644 index 4db8727..0000000 --- a/android/app/src/main/kotlin/org/rocstreaming/connector/Connector.kt +++ /dev/null @@ -1,36 +0,0 @@ -package org.rocstreaming.connector - -import Backend -import org.rocstreaming.service.SenderReceiverService - -private class Connector : Backend { - override fun getHostLanguage(): String { - return "Kotlin" - } - - private var senderReceiverService: SenderReceiverService = SenderReceiverService() - - override fun startReceiver() { - senderReceiverService.startReceiver() - } - - override fun stopReceiver() { - senderReceiverService.stopReceiver() - } - - override fun isReceiverAlive(): Boolean { - return senderReceiverService.isReceiverAlive() - } - - override fun startSender(ip: String) { - senderReceiverService.startSender(ip, null) - } - - override fun stopSender() { - senderReceiverService.stopSender() - } - - override fun isSenderAlive(): Boolean { - return senderReceiverService.isSenderAlive() - } -} \ No newline at end of file diff --git a/android/app/src/main/kotlin/org/rocstreaming/rocdroid/MainActivity.kt b/android/app/src/main/kotlin/org/rocstreaming/rocdroid/MainActivity.kt index 5ed1fe4..f25c434 100644 --- a/android/app/src/main/kotlin/org/rocstreaming/rocdroid/MainActivity.kt +++ b/android/app/src/main/kotlin/org/rocstreaming/rocdroid/MainActivity.kt @@ -3,8 +3,13 @@ package org.rocstreaming.rocdroid import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.engine.FlutterEngine import io.flutter.embedding.engine.plugins.FlutterPlugin +import org.rocstreaming.connector.AndroidConnectorImpl -class MainActivity: FlutterActivity(){ +class MainActivity: FlutterActivity() { override fun configureFlutterEngine(flutterEngine: FlutterEngine) { super.configureFlutterEngine(flutterEngine) -}} + + AndroidConnector.setUp(flutterEngine.dartExecutor.binaryMessenger, + AndroidConnectorImpl()) + } +} diff --git a/android/gradle.properties b/android/gradle.properties index 958b7f2..745316c 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -2,3 +2,4 @@ org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true minSdkVersion=26 +compileSdkVersion=33 diff --git a/dodo.py b/dodo.py index a6bf591..79387ec 100644 --- a/dodo.py +++ b/dodo.py @@ -83,7 +83,7 @@ def task_gen_model_watch(): def task_gen_agent(): """run flutter pigeon Agent code generation""" return { - 'actions': ['dart run pigeon --input lib/src/agent/ibackend.dart'], + 'actions': ['dart run pigeon --input lib/src/agent/android_connector.dart'], 'title': title_with_actions, } diff --git a/lib/src/agent/android_backend.dart b/lib/src/agent/android_backend.dart index 2c05764..7147f66 100644 --- a/lib/src/agent/android_backend.dart +++ b/lib/src/agent/android_backend.dart @@ -1,36 +1,37 @@ -import 'backend.g.dart'; +import 'android_connector.g.dart'; +import 'backend.dart'; /// ???. class AndroidBackend implements Backend { - final Backend _backend = Backend(); + final AndroidConnector _connector = AndroidConnector(); @override - Future isReceiverAlive() async { - return await _backend.isReceiverAlive(); + Future startReceiver() async { + await _connector.startReceiver(); } @override - Future isSenderAlive() async { - return await _backend.isSenderAlive(); + Future stopReceiver() async { + await _connector.stopReceiver(); } @override - Future startReceiver() async { - await _backend.startReceiver(); + Future isReceiverAlive() async { + return await _connector.isReceiverAlive(); } @override Future startSender(String ip) async { - await _backend.startSender(ip); + await _connector.startSender(ip); } @override - Future stopReceiver() async { - await _backend.stopReceiver(); + Future stopSender() async { + await _connector.stopSender(); } @override - Future stopSender() async { - await _backend.stopSender(); + Future isSenderAlive() async { + return await _connector.isSenderAlive(); } } diff --git a/lib/src/agent/android_connector.dart b/lib/src/agent/android_connector.dart new file mode 100644 index 0000000..5b4d4d3 --- /dev/null +++ b/lib/src/agent/android_connector.dart @@ -0,0 +1,32 @@ +import 'package:pigeon/pigeon.dart'; + +@ConfigurePigeon(PigeonOptions( + dartOut: 'lib/src/agent/android_connector.g.dart', + dartOptions: DartOptions(), + kotlinOut: + 'android/app/src/main/kotlin/org/rocstreaming/connector/AndroidConnector.g.kt', + kotlinOptions: KotlinOptions(), + dartPackageName: 'roc_droid', +)) + +/// ???. +@HostApi() +abstract class AndroidConnector { + void startReceiver(); + + void stopReceiver(); + + bool isReceiverAlive(); + + void startSender(String ip); + + void stopSender(); + + bool isSenderAlive(); +} + +// /// ???. +// @FlutterApi() +// abstract class FlutterHandler { +// void textChanged(String text); +// } diff --git a/lib/src/agent/android_connector.g.dart b/lib/src/agent/android_connector.g.dart new file mode 100644 index 0000000..b79bdff --- /dev/null +++ b/lib/src/agent/android_connector.g.dart @@ -0,0 +1,178 @@ +// Autogenerated from Pigeon (v22.3.0), do not edit directly. +// See also: https://pub.dev/packages/pigeon +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers + +import 'dart:async'; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; + +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; +import 'package:flutter/services.dart'; + +PlatformException _createConnectionError(String channelName) { + return PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel: "$channelName".', + ); +} + + +class _PigeonCodec extends StandardMessageCodec { + const _PigeonCodec(); +} + +/// ???. +class AndroidConnector { + /// Constructor for [AndroidConnector]. The [binaryMessenger] named argument is + /// available for dependency injection. If it is left null, the default + /// BinaryMessenger will be used which routes to the host platform. + AndroidConnector({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) + : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + final BinaryMessenger? pigeonVar_binaryMessenger; + + static const MessageCodec pigeonChannelCodec = _PigeonCodec(); + + final String pigeonVar_messageChannelSuffix; + + Future startReceiver() async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.roc_droid.AndroidConnector.startReceiver$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send(null) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + + Future stopReceiver() async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.roc_droid.AndroidConnector.stopReceiver$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send(null) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + + Future isReceiverAlive() async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.roc_droid.AndroidConnector.isReceiverAlive$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send(null) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else if (pigeonVar_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (pigeonVar_replyList[0] as bool?)!; + } + } + + Future startSender(String ip) async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.roc_droid.AndroidConnector.startSender$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([ip]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + + Future stopSender() async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.roc_droid.AndroidConnector.stopSender$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send(null) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + + Future isSenderAlive() async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.roc_droid.AndroidConnector.isSenderAlive$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send(null) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else if (pigeonVar_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (pigeonVar_replyList[0] as bool?)!; + } + } +} diff --git a/lib/src/agent/backend.dart b/lib/src/agent/backend.dart index 3d60882..8dec27d 100644 --- a/lib/src/agent/backend.dart +++ b/lib/src/agent/backend.dart @@ -1,32 +1,14 @@ -import 'package:pigeon/pigeon.dart'; - -@ConfigurePigeon(PigeonOptions( - dartOut: 'lib/src/agent/backend.g.dart', - dartOptions: DartOptions(), - kotlinOut: - 'android/app/src/main/kotlin/org/rocstreaming/connector/Connector.g.kt', - kotlinOptions: KotlinOptions(), - dartPackageName: 'roc_droid_package', -)) - /// ???. -@HostApi() abstract class Backend { - void startReceiver(); + Future startReceiver(); - void stopReceiver(); + Future stopReceiver(); - bool isReceiverAlive(); + Future isReceiverAlive(); - void startSender(String ip); + Future startSender(String ip); - void stopSender(); + Future stopSender(); - bool isSenderAlive(); + Future isSenderAlive(); } - -// /// ???. -// @FlutterApi() -// abstract class FlutterHandler { -// void textChanged(String text); -// } diff --git a/lib/src/agent/backend.g.dart b/lib/src/agent/backend.g.dart deleted file mode 100644 index e6a8f14..0000000 --- a/lib/src/agent/backend.g.dart +++ /dev/null @@ -1,190 +0,0 @@ -// Autogenerated from Pigeon (v21.1.0), do not edit directly. -// See also: https://pub.dev/packages/pigeon -// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers - -import 'dart:async'; -import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; - -import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; -import 'package:flutter/services.dart'; - -PlatformException _createConnectionError(String channelName) { - return PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel: "$channelName".', - ); -} - -class _PigeonCodec extends StandardMessageCodec { - const _PigeonCodec(); -} - -/// ???. -class Backend { - /// Constructor for [Backend]. The [binaryMessenger] named argument is - /// available for dependency injection. If it is left null, the default - /// BinaryMessenger will be used which routes to the host platform. - Backend({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) - : __pigeon_binaryMessenger = binaryMessenger, - __pigeon_messageChannelSuffix = - messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; - final BinaryMessenger? __pigeon_binaryMessenger; - - static const MessageCodec pigeonChannelCodec = _PigeonCodec(); - - final String __pigeon_messageChannelSuffix; - - Future startReceiver() async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.roc_droid_package.Backend.startReceiver$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, - pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, - ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { - throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], - ); - } else { - return; - } - } - - Future stopReceiver() async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.roc_droid_package.Backend.stopReceiver$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, - pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, - ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { - throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], - ); - } else { - return; - } - } - - Future isReceiverAlive() async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.roc_droid_package.Backend.isReceiverAlive$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, - pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, - ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { - throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], - ); - } else if (__pigeon_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (__pigeon_replyList[0] as bool?)!; - } - } - - Future startSender(String ip) async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.roc_droid_package.Backend.startSender$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, - pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, - ); - final List? __pigeon_replyList = - await __pigeon_channel.send([ip]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { - throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], - ); - } else { - return; - } - } - - Future stopSender() async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.roc_droid_package.Backend.stopSender$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, - pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, - ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { - throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], - ); - } else { - return; - } - } - - Future isSenderAlive() async { - final String __pigeon_channelName = - 'dev.flutter.pigeon.roc_droid_package.Backend.isSenderAlive$__pigeon_messageChannelSuffix'; - final BasicMessageChannel __pigeon_channel = - BasicMessageChannel( - __pigeon_channelName, - pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, - ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { - throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], - ); - } else if (__pigeon_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (__pigeon_replyList[0] as bool?)!; - } - } -} diff --git a/lib/src/model/model_root.dart b/lib/src/model/model_root.dart index 40aadef..1400563 100644 --- a/lib/src/model/model_root.dart +++ b/lib/src/model/model_root.dart @@ -1,7 +1,7 @@ import 'package:logger/logger.dart'; import '../agent/android_backend.dart'; -import '../agent/backend.g.dart'; +import '../agent/backend.dart'; import 'receiver.dart'; import 'sender.dart'; diff --git a/lib/src/model/receiver.dart b/lib/src/model/receiver.dart index d6e6f5d..b798930 100644 --- a/lib/src/model/receiver.dart +++ b/lib/src/model/receiver.dart @@ -3,7 +3,7 @@ import 'dart:collection'; import 'package:logger/logger.dart'; import 'package:mobx/mobx.dart'; -import '../agent/backend.g.dart'; +import '../agent/backend.dart'; part 'receiver.g.dart'; diff --git a/lib/src/model/sender.dart b/lib/src/model/sender.dart index 8994a95..cbcb411 100644 --- a/lib/src/model/sender.dart +++ b/lib/src/model/sender.dart @@ -1,7 +1,7 @@ import 'package:logger/logger.dart'; import 'package:mobx/mobx.dart'; -import '../agent/backend.g.dart'; +import '../agent/backend.dart'; import 'capture_source_type.dart'; part 'sender.g.dart';