Skip to content

Commit 7c8858b

Browse files
committed
[wakelock_plus] Remove Ecore API
Change ecore api to glib api.
1 parent 3fec864 commit 7c8858b

4 files changed

Lines changed: 30 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: 24 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,12 @@ 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+
}
4550

4651
private:
4752
void HandleMethodCall(
@@ -58,20 +63,25 @@ class WakelockPlusTizenPlugin : public flutter::Plugin {
5863
if (std::holds_alternative<bool>(arguments)) {
5964
bool enable = std::get<bool>(arguments);
6065
if (enable) {
66+
if (!screensaver_reset_timeout_) {
67+
result->Error("Not supported",
68+
"The screensaver API is not supported.");
69+
return;
70+
}
6171
int ret = screensaver_reset_timeout_();
6272
if (ret != 0) {
6373
result->Error(std::to_string(ret), get_error_message(ret));
6474
return;
6575
}
66-
if (timer_) {
67-
ecore_timer_del(timer_);
76+
if (timer_id_ != 0) {
77+
g_source_remove(timer_id_);
6878
}
69-
timer_ = ecore_timer_add(30, OnResetScreensaverTimeout, this);
79+
timer_id_ = g_timeout_add(30000, OnResetScreensaverTimeout, this);
7080
is_enabled_ = true;
7181
} else {
72-
if (timer_) {
73-
ecore_timer_del(timer_);
74-
timer_ = nullptr;
82+
if (timer_id_ != 0) {
83+
g_source_remove(timer_id_);
84+
timer_id_ = 0;
7585
}
7686
is_enabled_ = false;
7787
}
@@ -114,24 +124,24 @@ class WakelockPlusTizenPlugin : public flutter::Plugin {
114124
}
115125
}
116126

117-
static Eina_Bool OnResetScreensaverTimeout(void *data) {
127+
static gboolean OnResetScreensaverTimeout(gpointer data) {
118128
auto *plugin = static_cast<WakelockPlusTizenPlugin *>(data);
119129
if (!plugin->screensaver_reset_timeout_) {
120-
return ECORE_CALLBACK_CANCEL;
130+
return G_SOURCE_REMOVE;
121131
}
122132
int ret = plugin->screensaver_reset_timeout_();
123133
if (ret != 0) {
124134
LOG_ERROR("screensaver_reset_timeout failed: %s", get_error_message(ret));
125-
return ECORE_CALLBACK_CANCEL;
135+
return G_SOURCE_REMOVE;
126136
}
127137

128-
return ECORE_CALLBACK_RENEW;
138+
return G_SOURCE_CONTINUE;
129139
}
130140

131141
bool is_initialized_screensaver_api_ = false;
132142
void *screensaver_api_handle_ = nullptr;
133-
Ecore_Timer *timer_ = nullptr;
134-
FuncScreensaverResetTimeout screensaver_reset_timeout_;
143+
guint timer_id_ = 0;
144+
FuncScreensaverResetTimeout screensaver_reset_timeout_ = nullptr;
135145
bool is_enabled_ = false;
136146
};
137147

0 commit comments

Comments
 (0)