Remove AP wake-lock control from Timer 19/121919/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 29 Mar 2017 10:26:52 +0000 (19:26 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 29 Mar 2017 10:26:52 +0000 (19:26 +0900)
Wake-locking will be managed by the job scheduler.

Change-Id: Ia8a63eabf20216400f55ec7a2d32dfd2ebbfabf6
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
include/Timer.h
src/server/Timer.cpp

index 45a0c1f..3cb867f 100644 (file)
@@ -36,21 +36,16 @@ namespace ctx {
                void cancel(unsigned int timerId);
                void cancelAll();
 
-               /* This runs in a simliar manner to g_idle_add() */
+               /* This runs in a simliar manner to g_idle_add(). */
                unsigned int addIdle(ITimerListener* listener);
 
-               /* This runs in a simliar manner to g_timeout_add().
-                  However, if wakeLock == true, this does not accept the intervals longer than TIMEOUT_MAX. */
-               unsigned int addTimeout(unsigned int intervalMs, ITimerListener* listener, bool wakeLock = false);
+               /* This runs in a simliar manner to g_timeout_add(). */
+               unsigned int addTimeout(unsigned int intervalMs, ITimerListener* listener);
 
                /* This runs on the alarm-service, thus the device will be woken up whenever the interval passes.
                   Unlike the above functions, this takes an interval in minutes. */
                unsigned int addAlarm(unsigned int intervalMin, ITimerListener* listener);
 
-               static void setDBusConnection(GDBusConnection* conn);
-
-               static const unsigned int TIMEOUT_MAX;  /* milli-seconds */
-
        private:
                struct ListenerInfo;
 
index fa97699..91eff91 100644 (file)
 #include <ITimerListener.h>
 #include <Timer.h>
 
-#define TIMEOUT_MAX_SECONDS    10
-#define TIMEOUT_MARGIN         100
-#define MILLIS_PER_MIN         60000
+#define MILLIS_PER_MIN 60000
 #define TIMER_ID               (++__timerCnt)
 #define INIT_CONTEXT   if (!__context) __context = g_main_context_ref_thread_default()
 
 using namespace ctx;
 
-const unsigned int Timer::TIMEOUT_MAX = TIMEOUT_MAX_SECONDS * 1000;
-static GDBusConnection* __dbusConnection = NULL;
 static std::atomic_uint __timerCnt;
 
 struct ctx::Timer::ListenerInfo {
@@ -38,40 +34,15 @@ struct ctx::Timer::ListenerInfo {
        unsigned int intervalMs;
        GSource* gSrc;
        int alarmId;
-       bool wakeLock;
        ListenerInfo(Timer* t, ITimerListener* l) :
                timer(t),
                listener(l),
                timerId(0),
                intervalMs(0),
                gSrc(NULL),
-               alarmId(-1),
-               wakeLock(false) {}
+               alarmId(-1) {}
 };
 
-static void __lockingRequestDone(GObject* srcObj, GAsyncResult* res, gpointer userData)
-{
-       GError *gerr = NULL;
-       GVariant* param = g_dbus_connection_call_finish(__dbusConnection, res, &gerr);
-       HANDLE_GERROR(gerr);
-       if (param)
-               g_variant_unref(param);
-}
-
-static void __requestLock(unsigned int timeoutMs)
-{
-       IF_FAIL_VOID_TAG(__dbusConnection, _E, "No DBus Connection");
-       _D("Lock %u (+%d) ms", timeoutMs, TIMEOUT_MARGIN);
-
-       int timeoutExtended = static_cast<int>(timeoutMs) + TIMEOUT_MARGIN;
-
-       g_dbus_connection_call(__dbusConnection,
-                       "org.tizen.system.deviced", "/Org/Tizen/System/DeviceD/Display",
-                       "org.tizen.system.deviced.display", "lockstate",
-                       g_variant_new("(sssi)", "lcdoff", "staycurstate", "NULL", timeoutExtended),
-                       NULL, G_DBUS_CALL_FLAGS_NONE, CTX_DBUS_TIMEOUT, NULL, __lockingRequestDone, NULL);
-}
-
 Timer::Timer() :
        __context(NULL)
 {
@@ -92,15 +63,11 @@ unsigned int Timer::schedule(unsigned int intervalMs, ITimerListener* listener)
        if (intervalMs == 0)
                return addIdle(listener);
 
-       if (intervalMs <= TIMEOUT_MAX)
-               return addTimeout(intervalMs, listener, true);
+       if (intervalMs < MILLIS_PER_MIN)
+               return addTimeout(intervalMs, listener);
 
        unsigned int intervalMin = intervalMs / MILLIS_PER_MIN;
-
-       if (intervalMin > 0)
-               return addAlarm(intervalMin, listener);
-
-       return 0;
+       return addAlarm(intervalMin, listener);
 }
 
 void Timer::cancel(unsigned int timerId)
@@ -162,7 +129,7 @@ unsigned int Timer::addIdle(ITimerListener* listener)
        return info->timerId;
 }
 
-unsigned int Timer::addTimeout(unsigned int intervalMs, ITimerListener* listener, bool wakeLock)
+unsigned int Timer::addTimeout(unsigned int intervalMs, ITimerListener* listener)
 {
        INIT_CONTEXT;
 
@@ -179,14 +146,10 @@ unsigned int Timer::addTimeout(unsigned int intervalMs, ITimerListener* listener
        info->timerId = TIMER_ID;
        info->intervalMs = intervalMs;
        info->gSrc = gSrc;
-       info->wakeLock = wakeLock;
 
        _D("Add Timeout <Id: %u, Interval: %u ms>", info->timerId, intervalMs);
        __listeners.insert(info);
 
-       if (wakeLock)
-               __requestLock(intervalMs);
-
        g_source_set_callback(gSrc, __onGSourceExpired, info, NULL);
        g_source_attach(gSrc, __context);
        g_source_unref(gSrc);
@@ -208,9 +171,6 @@ gboolean Timer::__onGSourceExpired(gpointer userData)
                return G_SOURCE_REMOVE;
        }
 
-       if (info->wakeLock)
-               __requestLock(info->intervalMs);
-
        return G_SOURCE_CONTINUE;
 }
 
@@ -285,8 +245,3 @@ void Timer::__removeAlarm(ListenerInfo* info)
        alarmmgr_remove_alarm(info->alarmId);
        delete info;
 }
-
-void Timer::setDBusConnection(GDBusConnection* conn)
-{
-       __dbusConnection = conn;
-}