4
4
5
5
#include " lifecycle_channel.h"
6
6
7
+ #include < variant>
8
+
7
9
#include " flutter/shell/platform/common/client_wrapper/include/flutter/standard_message_codec.h"
8
- #include " flutter/shell/platform/tizen/flutter_tizen_engine.h"
9
10
#include " flutter/shell/platform/tizen/tizen_log.h"
10
11
11
12
namespace flutter {
@@ -19,13 +20,38 @@ constexpr char kResumed[] = "AppLifecycleState.resumed";
19
20
constexpr char kPaused [] = " AppLifecycleState.paused" ;
20
21
constexpr char kDetached [] = " AppLifecycleState.detached" ;
21
22
23
+ // Codec extension for UTF-8 strings.
24
+ class StringSerializer : public StandardCodecSerializer {
25
+ public:
26
+ StringSerializer () = default ;
27
+ virtual ~StringSerializer () = default ;
28
+
29
+ // Returns the shared serializer instance.
30
+ static const StringSerializer& GetInstance () {
31
+ static StringSerializer sInstance ;
32
+ return sInstance ;
33
+ }
34
+
35
+ virtual void WriteValue (const EncodableValue& value,
36
+ ByteStreamWriter* stream) const override {
37
+ if (auto string_value = std::get_if<std::string>(&value)) {
38
+ size_t size = string_value->size ();
39
+ if (size > 0 ) {
40
+ stream->WriteBytes (
41
+ reinterpret_cast <const uint8_t *>(string_value->data ()), size);
42
+ }
43
+ }
44
+ }
45
+ };
46
+
22
47
} // namespace
23
48
24
49
LifecycleChannel::LifecycleChannel (BinaryMessenger* messenger)
25
50
: channel_(std::make_unique<BasicMessageChannel<EncodableValue>>(
26
51
messenger,
27
52
kChannelName ,
28
- &StandardMessageCodec::GetInstance ())) {}
53
+ &StandardMessageCodec::GetInstance (
54
+ &StringSerializer::GetInstance ()))) {}
29
55
30
56
LifecycleChannel::~LifecycleChannel () {}
31
57
0 commit comments