power: add padding timer to power lock 58/59358/4 accepted/tizen/common/20160804.174407 accepted/tizen/ivi/20160804.081139 accepted/tizen/mobile/20160804.081210 accepted/tizen/tv/20160804.081102 accepted/tizen/wearable/20160804.081123 submit/tizen/20160803.081834
authorTaeyoung Kim <ty317.kim@samsung.com>
Mon, 15 Feb 2016 04:29:07 +0000 (13:29 +0900)
committertaeyoung <ty317.kim@samsung.com>
Wed, 3 Aug 2016 07:47:48 +0000 (16:47 +0900)
commit4ef5c21187f14817f10b5da5249ae867efd0fe44
tree890a01f69c2c48db1e7f1cc6732ca7981cc05d7d
parentd5de302eb00d73bd8cf9e85600b60e44d9f9278a
power: add padding timer to power lock

- If Power Lock timeout (10 minutes) is expired during apps do
  something with reference count 0 for very short time,
  Power Lock will be released. Thus Suspend mode can be entered.

 (Problem example)
==============================================================
Time  |  Music player  |  device-power       | libtracker
==============================================================
00:00    power lock       power lock
                          add timer
         play start                             ref count:1
--------------------------------------------------------------
09:50    play stop                              ref count:0
         search music
--------------------------------------------------------------
10:00                     timer expired
                          check ref count (== 0)
                            -> power unlock
--------------------------------------------------------------
10:10    search done
         play start                             ref count:1
--------------------------------------------------------------
 After
  few                < Power Suspend Mode >
minutes
==============================================================

- To fix the issue, power lock api uses the padding timeout
  whose callback is called after 20 seconds of power lock timeout.
  Apps can do something without increasing reference count.
  If the ref count is still 0 after 20 seconds, the Power Lock
  will be released.

- If the ref count is changed during 20 seconds but the value is
  still 0, Power Lock should not be released. Thus libtracker
  supports the total reference count which means the accumulated
  ref count. Thus The accumulated ref count is checked if the
  ref count is still 0.

Change-Id: I307fbda4313d14fec2a4a31640096020c3c21485
Signed-off-by: Taeyoung Kim <ty317.kim@samsung.com>
Signed-off-by: taeyoung <ty317.kim@samsung.com>
src/power.c