Skip to content

Commit a45473d

Browse files
committed
Remove engine dependency of LifecycleChannel
1 parent f1add55 commit a45473d

File tree

5 files changed

+23
-22
lines changed

5 files changed

+23
-22
lines changed

shell/platform/tizen/channels/key_event_channel.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <map>
88

9+
#include "flutter/shell/platform/common/json_message_codec.h"
910
#include "flutter/shell/platform/tizen/tizen_log.h"
1011

1112
static constexpr char kChannelName[] = "flutter/keyevent";

shell/platform/tizen/channels/key_event_channel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include "flutter/shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h"
1111
#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"
12-
#include "flutter/shell/platform/common/json_message_codec.h"
1312
#include "rapidjson/document.h"
1413

1514
class KeyEventChannel {

shell/platform/tizen/channels/lifecycle_channel.cc

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "lifecycle_channel.h"
66

7+
#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_message_codec.h"
78
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
89
#include "flutter/shell/platform/tizen/tizen_log.h"
910

@@ -13,33 +14,31 @@ static constexpr char kResumed[] = "AppLifecycleState.resumed";
1314
static constexpr char kPaused[] = "AppLifecycleState.paused";
1415
static constexpr char kDetached[] = "AppLifecycleState.detached";
1516

16-
LifecycleChannel::LifecycleChannel(FlutterTizenEngine* engine)
17-
: engine_(engine) {}
17+
LifecycleChannel::LifecycleChannel(flutter::BinaryMessenger* messenger)
18+
: channel_(std::make_unique<
19+
flutter::BasicMessageChannel<flutter::EncodableValue>>(
20+
messenger,
21+
kChannelName,
22+
&flutter::StandardMessageCodec::GetInstance())) {}
1823

1924
LifecycleChannel::~LifecycleChannel() {}
2025

21-
void LifecycleChannel::SendLifecycleMessage(const char message[]) {
22-
engine_->SendPlatformMessage(kChannelName,
23-
reinterpret_cast<const uint8_t*>(message),
24-
strlen(message), nullptr, nullptr);
25-
}
26-
2726
void LifecycleChannel::AppIsInactive() {
28-
FT_LOGI("send app lifecycle state inactive.");
29-
SendLifecycleMessage(kInactive);
27+
FT_LOGI("Sending %s message.", kInactive);
28+
channel_->Send(flutter::EncodableValue(kInactive));
3029
}
3130

3231
void LifecycleChannel::AppIsResumed() {
33-
FT_LOGI("send app lifecycle state resumed.");
34-
SendLifecycleMessage(kResumed);
32+
FT_LOGI("Sending %s message.", kResumed);
33+
channel_->Send(flutter::EncodableValue(kResumed));
3534
}
3635

3736
void LifecycleChannel::AppIsPaused() {
38-
FT_LOGI("send app lifecycle state paused.");
39-
SendLifecycleMessage(kPaused);
37+
FT_LOGI("Sending %s message.", kPaused);
38+
channel_->Send(flutter::EncodableValue(kPaused));
4039
}
4140

4241
void LifecycleChannel::AppIsDetached() {
43-
FT_LOGI("send app lifecycle state detached.");
44-
SendLifecycleMessage(kDetached);
42+
FT_LOGI("Sending %s message.", kDetached);
43+
channel_->Send(flutter::EncodableValue(kDetached));
4544
}

shell/platform/tizen/channels/lifecycle_channel.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@
55
#ifndef EMBEDDER_LIFECYCLE_CHANNEL_H_
66
#define EMBEDDER_LIFECYCLE_CHANNEL_H_
77

8-
class FlutterTizenEngine;
8+
#include "flutter/shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h"
9+
#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"
910

1011
class LifecycleChannel {
1112
public:
12-
explicit LifecycleChannel(FlutterTizenEngine* engine);
13+
explicit LifecycleChannel(flutter::BinaryMessenger* messenger);
1314
virtual ~LifecycleChannel();
1415

1516
void AppIsInactive();
1617
void AppIsResumed();
1718
void AppIsPaused();
1819
void AppIsDetached();
19-
void SendLifecycleMessage(const char message[]);
2020

2121
private:
22-
FlutterTizenEngine* engine_{nullptr};
22+
std::unique_ptr<flutter::BasicMessageChannel<flutter::EncodableValue>>
23+
channel_;
2324
};
2425

2526
#endif // EMBEDDER_LIFECYCLE_CHANNEL_H_

shell/platform/tizen/flutter_tizen_engine.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ bool FlutterTizenEngine::RunEngine(
234234
internal_plugin_registrar_->messenger());
235235
localization_channel = std::make_unique<LocalizationChannel>(this);
236236
localization_channel->SendLocales();
237-
lifecycle_channel = std::make_unique<LifecycleChannel>(this);
237+
lifecycle_channel = std::make_unique<LifecycleChannel>(
238+
internal_plugin_registrar_->messenger());
238239

239240
if (IsHeaded()) {
240241
texture_registrar_ = std::make_unique<FlutterTizenTextureRegistrar>(this);

0 commit comments

Comments
 (0)