diff --git a/packages/wakelock_plus/CHANGELOG.md b/packages/wakelock_plus/CHANGELOG.md index d7396d20d..174d4aece 100644 --- a/packages/wakelock_plus/CHANGELOG.md +++ b/packages/wakelock_plus/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.1.1 + +* Remove Ecore API. + ## 2.1.0 * Update wakelock_plus to 1.6.0. diff --git a/packages/wakelock_plus/README.md b/packages/wakelock_plus/README.md index f6af13bc3..6bc412ceb 100644 --- a/packages/wakelock_plus/README.md +++ b/packages/wakelock_plus/README.md @@ -11,7 +11,7 @@ This package is not an _endorsed_ implementation of `wakelock_plus`. Therefore, ```yaml dependencies: wakelock_plus: ^1.6.0 - wakelock_plus_tizen: ^2.1.0 + wakelock_plus_tizen: ^2.1.1 ``` Then you can import `wakelock_plus` in your Dart code: diff --git a/packages/wakelock_plus/pubspec.yaml b/packages/wakelock_plus/pubspec.yaml index cbcb46167..4d2a19008 100644 --- a/packages/wakelock_plus/pubspec.yaml +++ b/packages/wakelock_plus/pubspec.yaml @@ -2,7 +2,7 @@ name: wakelock_plus_tizen description: Tizen implementation of the wakelock_plus plugin. homepage: https://github.com/flutter-tizen/plugins repository: https://github.com/flutter-tizen/plugins/tree/master/packages/wakelock_plus -version: 2.1.0 +version: 2.1.1 environment: sdk: ">=3.11.0 <4.0.0" diff --git a/packages/wakelock_plus/tizen/src/wakelock_plus_tizen_plugin.cc b/packages/wakelock_plus/tizen/src/wakelock_plus_tizen_plugin.cc index 6f073beb1..39ee194c7 100644 --- a/packages/wakelock_plus/tizen/src/wakelock_plus_tizen_plugin.cc +++ b/packages/wakelock_plus/tizen/src/wakelock_plus_tizen_plugin.cc @@ -4,11 +4,11 @@ #include "wakelock_plus_tizen_plugin.h" -#include #include #include #include #include +#include #include #include @@ -41,7 +41,16 @@ class WakelockPlusTizenPlugin : public flutter::Plugin { WakelockPlusTizenPlugin() {} - virtual ~WakelockPlusTizenPlugin() = default; + virtual ~WakelockPlusTizenPlugin() { + if (timer_id_ != 0) { + g_source_remove(timer_id_); + timer_id_ = 0; + } + if (screensaver_api_handle_) { + dlclose(screensaver_api_handle_); + screensaver_api_handle_ = nullptr; + } + } private: void HandleMethodCall( @@ -58,20 +67,25 @@ class WakelockPlusTizenPlugin : public flutter::Plugin { if (std::holds_alternative(arguments)) { bool enable = std::get(arguments); if (enable) { + if (!screensaver_reset_timeout_) { + result->Error("Not supported", + "The screensaver API is not supported."); + return; + } int ret = screensaver_reset_timeout_(); if (ret != 0) { result->Error(std::to_string(ret), get_error_message(ret)); return; } - if (timer_) { - ecore_timer_del(timer_); + if (timer_id_ != 0) { + g_source_remove(timer_id_); } - timer_ = ecore_timer_add(30, OnResetScreensaverTimeout, this); + timer_id_ = g_timeout_add(30000, OnResetScreensaverTimeout, this); is_enabled_ = true; } else { - if (timer_) { - ecore_timer_del(timer_); - timer_ = nullptr; + if (timer_id_ != 0) { + g_source_remove(timer_id_); + timer_id_ = 0; } is_enabled_ = false; } @@ -114,24 +128,26 @@ class WakelockPlusTizenPlugin : public flutter::Plugin { } } - static Eina_Bool OnResetScreensaverTimeout(void *data) { + static gboolean OnResetScreensaverTimeout(gpointer data) { auto *plugin = static_cast(data); if (!plugin->screensaver_reset_timeout_) { - return ECORE_CALLBACK_CANCEL; + plugin->timer_id_ = 0; + return G_SOURCE_REMOVE; } int ret = plugin->screensaver_reset_timeout_(); if (ret != 0) { LOG_ERROR("screensaver_reset_timeout failed: %s", get_error_message(ret)); - return ECORE_CALLBACK_CANCEL; + plugin->timer_id_ = 0; + return G_SOURCE_REMOVE; } - return ECORE_CALLBACK_RENEW; + return G_SOURCE_CONTINUE; } bool is_initialized_screensaver_api_ = false; void *screensaver_api_handle_ = nullptr; - Ecore_Timer *timer_ = nullptr; - FuncScreensaverResetTimeout screensaver_reset_timeout_; + guint timer_id_ = 0; + FuncScreensaverResetTimeout screensaver_reset_timeout_ = nullptr; bool is_enabled_ = false; };