Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove engine dependency of LifecycleChannel
  • Loading branch information
swift-kim committed Jun 25, 2021
commit 8523980d2c8928633c0ef157fa58ef3f33b36e63
1 change: 1 addition & 0 deletions shell/platform/tizen/channels/key_event_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <map>

#include "flutter/shell/platform/common/json_message_codec.h"
#include "flutter/shell/platform/tizen/tizen_log.h"

namespace flutter {
Expand Down
1 change: 0 additions & 1 deletion shell/platform/tizen/channels/key_event_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include "flutter/shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h"
#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"
#include "flutter/shell/platform/common/json_message_codec.h"
#include "rapidjson/document.h"

namespace flutter {
Expand Down
30 changes: 14 additions & 16 deletions shell/platform/tizen/channels/lifecycle_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "lifecycle_channel.h"

#include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_message_codec.h"
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
#include "flutter/shell/platform/tizen/tizen_log.h"

Expand All @@ -20,35 +21,32 @@ constexpr char kDetached[] = "AppLifecycleState.detached";

} // namespace

LifecycleChannel::LifecycleChannel(FlutterTizenEngine* engine)
: engine_(engine) {}
LifecycleChannel::LifecycleChannel(BinaryMessenger* messenger)
: channel_(std::make_unique<BasicMessageChannel<EncodableValue>>(
messenger,
kChannelName,
&StandardMessageCodec::GetInstance())) {}

LifecycleChannel::~LifecycleChannel() {}

void LifecycleChannel::SendLifecycleMessage(const char message[]) {
engine_->SendPlatformMessage(kChannelName,
reinterpret_cast<const uint8_t*>(message),
strlen(message), nullptr, nullptr);
}

void LifecycleChannel::AppIsInactive() {
FT_LOGI("send app lifecycle state inactive.");
SendLifecycleMessage(kInactive);
FT_LOGI("Sending %s message.", kInactive);
channel_->Send(EncodableValue(kInactive));
}

void LifecycleChannel::AppIsResumed() {
FT_LOGI("send app lifecycle state resumed.");
SendLifecycleMessage(kResumed);
FT_LOGI("Sending %s message.", kResumed);
channel_->Send(EncodableValue(kResumed));
}

void LifecycleChannel::AppIsPaused() {
FT_LOGI("send app lifecycle state paused.");
SendLifecycleMessage(kPaused);
FT_LOGI("Sending %s message.", kPaused);
channel_->Send(EncodableValue(kPaused));
}

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

} // namespace flutter
12 changes: 7 additions & 5 deletions shell/platform/tizen/channels/lifecycle_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@
#ifndef EMBEDDER_LIFECYCLE_CHANNEL_H_
#define EMBEDDER_LIFECYCLE_CHANNEL_H_

namespace flutter {
#include <memory>

#include "flutter/shell/platform/common/client_wrapper/include/flutter/basic_message_channel.h"
#include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h"

class FlutterTizenEngine;
namespace flutter {

class LifecycleChannel {
public:
explicit LifecycleChannel(FlutterTizenEngine* engine);
explicit LifecycleChannel(BinaryMessenger* messenger);
virtual ~LifecycleChannel();

void AppIsInactive();
void AppIsResumed();
void AppIsPaused();
void AppIsDetached();
void SendLifecycleMessage(const char message[]);

private:
FlutterTizenEngine* engine_{nullptr};
std::unique_ptr<BasicMessageChannel<EncodableValue>> channel_;
};

} // namespace flutter
Expand Down
3 changes: 2 additions & 1 deletion shell/platform/tizen/flutter_tizen_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ bool FlutterTizenEngine::RunEngine(
internal_plugin_registrar_->messenger());
localization_channel = std::make_unique<LocalizationChannel>(this);
localization_channel->SendLocales();
lifecycle_channel = std::make_unique<LifecycleChannel>(this);
lifecycle_channel = std::make_unique<LifecycleChannel>(
internal_plugin_registrar_->messenger());

if (IsHeaded()) {
texture_registrar_ = std::make_unique<FlutterTizenTextureRegistrar>(this);
Expand Down