Fix issue : fail to make thumbnail
[platform/core/messaging/msg-service.git] / externals / MsgDevicedWrapper.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */
16
17
18 #include <device/power.h>
19 #include <device/display.h>
20
21 #include "MsgCallStatusManager.h"
22 #include "MsgDebug.h"
23 #include "MsgMutex.h"
24 #include "MsgGconfWrapper.h"
25 #include "MsgDevicedWrapper.h"
26
27 int g_lock_cnt = 0;
28 MsgMutex mx;
29
30 void MsgDisplayLock()
31 {
32         MSG_BEGIN();
33
34         int ret = 0;
35
36         mx.lock();
37
38         if (g_lock_cnt <= 0) {
39                 ret = device_power_request_lock(POWER_LOCK_CPU, 0);
40                 if (ret < 0) {
41                         MSG_DEBUG("device_power_request_lock() is failed [%d]", ret);
42                 }
43         }
44
45         g_lock_cnt++;
46
47         mx.unlock();
48
49         MSG_DEBUG("Display lock count = [%d]", g_lock_cnt);
50
51         MSG_END();
52 }
53
54
55 void MsgDisplayUnlock()
56 {
57         MSG_BEGIN();
58
59         int ret = 0;
60
61         mx.lock();
62
63         g_lock_cnt--;
64
65         MSG_DEBUG("Display lock count = [%d]", g_lock_cnt);
66
67         if (g_lock_cnt <= 0) {
68                 ret = device_power_release_lock(POWER_LOCK_CPU);
69                 if (ret < 0) {
70                         MSG_DEBUG("device_power_release_lock() is failed [%d]", ret);
71                 }
72         }
73
74         mx.unlock();
75
76         MSG_END();
77 }
78
79
80 void MsgChangePmState()
81 {
82         MSG_BEGIN();
83         int callStatus = 0;
84
85         callStatus = MsgGetCallStatus();
86         MSG_DEBUG("Call Status = %d", callStatus);
87
88         if (callStatus > 0 && callStatus < 3) {
89                 MSG_DEBUG("Call is activated. Do not turn on the lcd.");
90         } else {
91                 MSG_DEBUG("Call is not activated. Turn on the lcd.");
92                 device_display_change_state(DISPLAY_STATE_NORMAL);
93         }
94
95         MSG_END();
96 }