Skip to content

Commit 4795039

Browse files
authored
[wakelock_plus] Remove Ecore API (#1031)
1 parent c2e16f8 commit 4795039

4 files changed

Lines changed: 36 additions & 16 deletions

File tree

packages/wakelock_plus/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.1.1
2+
3+
* Remove Ecore API.
4+
15
## 2.1.0
26

37
* Update wakelock_plus to 1.6.0.

packages/wakelock_plus/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This package is not an _endorsed_ implementation of `wakelock_plus`. Therefore,
1111
```yaml
1212
dependencies:
1313
wakelock_plus: ^1.6.0
14-
wakelock_plus_tizen: ^2.1.0
14+
wakelock_plus_tizen: ^2.1.1
1515
```
1616
1717
Then you can import `wakelock_plus` in your Dart code:

packages/wakelock_plus/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: wakelock_plus_tizen
22
description: Tizen implementation of the wakelock_plus plugin.
33
homepage: https://github.com/flutter-tizen/plugins
44
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/wakelock_plus
5-
version: 2.1.0
5+
version: 2.1.1
66

77
environment:
88
sdk: ">=3.11.0 <4.0.0"

packages/wakelock_plus/tizen/src/wakelock_plus_tizen_plugin.cc

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
#include "wakelock_plus_tizen_plugin.h"
66

7-
#include <Ecore.h>
87
#include <dlfcn.h>
98
#include <flutter/method_channel.h>
109
#include <flutter/plugin_registrar.h>
1110
#include <flutter/standard_method_codec.h>
11+
#include <glib.h>
1212
#include <tizen.h>
1313

1414
#include <memory>
@@ -41,7 +41,16 @@ class WakelockPlusTizenPlugin : public flutter::Plugin {
4141

4242
WakelockPlusTizenPlugin() {}
4343

44-
virtual ~WakelockPlusTizenPlugin() = default;
44+
virtual ~WakelockPlusTizenPlugin() {
45+
if (timer_id_ != 0) {
46+
g_source_remove(timer_id_);
47+
timer_id_ = 0;
48+
}
49+
if (screensaver_api_handle_) {
50+
dlclose(screensaver_api_handle_);
51+
screensaver_api_handle_ = nullptr;
52+
}
53+
}
4554

4655
private:
4756
void HandleMethodCall(
@@ -58,20 +67,25 @@ class WakelockPlusTizenPlugin : public flutter::Plugin {
5867
if (std::holds_alternative<bool>(arguments)) {
5968
bool enable = std::get<bool>(arguments);
6069
if (enable) {
70+
if (!screensaver_reset_timeout_) {
71+
result->Error("Not supported",
72+
"The screensaver API is not supported.");
73+
return;
74+
}
6175
int ret = screensaver_reset_timeout_();
6276
if (ret != 0) {
6377
result->Error(std::to_string(ret), get_error_message(ret));
6478
return;
6579
}
66-
if (timer_) {
67-
ecore_timer_del(timer_);
80+
if (timer_id_ != 0) {
81+
g_source_remove(timer_id_);
6882
}
69-
timer_ = ecore_timer_add(30, OnResetScreensaverTimeout, this);
83+
timer_id_ = g_timeout_add(30000, OnResetScreensaverTimeout, this);
7084
is_enabled_ = true;
7185
} else {
72-
if (timer_) {
73-
ecore_timer_del(timer_);
74-
timer_ = nullptr;
86+
if (timer_id_ != 0) {
87+
g_source_remove(timer_id_);
88+
timer_id_ = 0;
7589
}
7690
is_enabled_ = false;
7791
}
@@ -114,24 +128,26 @@ class WakelockPlusTizenPlugin : public flutter::Plugin {
114128
}
115129
}
116130

117-
static Eina_Bool OnResetScreensaverTimeout(void *data) {
131+
static gboolean OnResetScreensaverTimeout(gpointer data) {
118132
auto *plugin = static_cast<WakelockPlusTizenPlugin *>(data);
119133
if (!plugin->screensaver_reset_timeout_) {
120-
return ECORE_CALLBACK_CANCEL;
134+
plugin->timer_id_ = 0;
135+
return G_SOURCE_REMOVE;
121136
}
122137
int ret = plugin->screensaver_reset_timeout_();
123138
if (ret != 0) {
124139
LOG_ERROR("screensaver_reset_timeout failed: %s", get_error_message(ret));
125-
return ECORE_CALLBACK_CANCEL;
140+
plugin->timer_id_ = 0;
141+
return G_SOURCE_REMOVE;
126142
}
127143

128-
return ECORE_CALLBACK_RENEW;
144+
return G_SOURCE_CONTINUE;
129145
}
130146

131147
bool is_initialized_screensaver_api_ = false;
132148
void *screensaver_api_handle_ = nullptr;
133-
Ecore_Timer *timer_ = nullptr;
134-
FuncScreensaverResetTimeout screensaver_reset_timeout_;
149+
guint timer_id_ = 0;
150+
FuncScreensaverResetTimeout screensaver_reset_timeout_ = nullptr;
135151
bool is_enabled_ = false;
136152
};
137153

0 commit comments

Comments
 (0)