@@ -81,25 +81,14 @@ PlatformChannel::PlatformChannel(BinaryMessenger* messenger,
8181 kChannelName ,
8282 &JsonMethodCodec::GetInstance ())),
8383 view_(view) {
84- #if defined(MOBILE_PROFILE) || defined(COMMON_PROFILE)
85- int ret = cbhm_open_service (&cbhm_handle_);
86- if (ret != CBHM_ERROR_NONE) {
87- FT_LOG (Error) << " Failed to initialize the clipboard service." ;
88- }
89- #endif
90-
9184 channel_->SetMethodCallHandler (
9285 [this ](const MethodCall<rapidjson::Document>& call,
9386 std::unique_ptr<MethodResult<rapidjson::Document>> result) {
9487 HandleMethodCall (call, std::move (result));
9588 });
9689}
9790
98- PlatformChannel::~PlatformChannel () {
99- #if defined(MOBILE_PROFILE) || defined(COMMON_PROFILE)
100- cbhm_close_service (cbhm_handle_);
101- #endif
102- }
91+ PlatformChannel::~PlatformChannel () {}
10392
10493void PlatformChannel::HandleMethodCall (
10594 const MethodCall<rapidjson::Document>& method_call,
@@ -231,56 +220,15 @@ void PlatformChannel::HapticFeedbackVibrate(const std::string& feedback_type) {
231220}
232221
233222void PlatformChannel::GetClipboardData (ClipboardCallback on_data) {
234- on_clipboard_data_ = std::move (on_data);
235-
236- #if defined(MOBILE_PROFILE) || defined(COMMON_PROFILE)
237- int ret = cbhm_selection_get (
238- cbhm_handle_, CBHM_SEL_TYPE_TEXT,
239- [](cbhm_h cbhm_handle, const char * buf, size_t len,
240- void * user_data) -> int {
241- auto * self = static_cast <PlatformChannel*>(user_data);
242- std::string data;
243- if (buf) {
244- data = std::string (buf, len);
245- }
246- self->on_clipboard_data_ (data);
247- self->on_clipboard_data_ = nullptr ;
248- return CBHM_ERROR_NONE;
249- },
250- this );
251- if (ret != CBHM_ERROR_NONE) {
252- if (ret == CBHM_ERROR_NO_DATA) {
253- FT_LOG (Info) << " No clipboard data available." ;
254- } else {
255- FT_LOG (Error) << " Failed to get clipboard data." ;
256- }
257- on_clipboard_data_ (" " );
258- on_clipboard_data_ = nullptr ;
259- }
260- #else
261- on_clipboard_data_ (clipboard_);
262- on_clipboard_data_ = nullptr ;
263- #endif
223+ on_data (clipboard_);
264224}
265225
266226void PlatformChannel::SetClipboardData (const std::string& data) {
267- #if defined(MOBILE_PROFILE) || defined(COMMON_PROFILE)
268- int ret = cbhm_selection_set (cbhm_handle_, CBHM_SEL_TYPE_TEXT, data.c_str (),
269- data.length ());
270- if (ret != CBHM_ERROR_NONE) {
271- FT_LOG (Error) << " Failed to set clipboard data." ;
272- }
273- #else
274227 clipboard_ = data;
275- #endif
276228}
277229
278230bool PlatformChannel::ClipboardHasStrings () {
279- #if defined(MOBILE_PROFILE) || defined(COMMON_PROFILE)
280- return cbhm_item_count_get (cbhm_handle_) > 0 ;
281- #else
282231 return !clipboard_.empty ();
283- #endif
284232}
285233
286234void PlatformChannel::RestoreSystemUiOverlays () {
0 commit comments