15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "tmactivitymanager.h" |
18 #include "tmactivitymanager.h" |
19 #include "thumbnaillog.h" |
19 #include "thumbnaillog.h" |
|
20 #include "OstTraceDefinitions.h" |
|
21 #ifdef OST_TRACE_COMPILER_IN_USE |
|
22 #include "tmactivitymanagerTraces.h" |
|
23 #endif |
20 |
24 |
21 // --------------------------------------------------------------------------- |
25 // --------------------------------------------------------------------------- |
22 // CTMActivityManager::NewL() |
26 // CTMActivityManager::NewL() |
23 // --------------------------------------------------------------------------- |
27 // --------------------------------------------------------------------------- |
24 // |
28 // |
25 CTMActivityManager* CTMActivityManager::NewL(MTMActivityManagerObserver* aObserver, TInt aTimeout) |
29 CTMActivityManager* CTMActivityManager::NewL(MTMActivityManagerObserver* aObserver, TInt aTimeout) |
26 { |
30 { |
27 TN_DEBUG1( "CTMActivityManager::NewL()"); |
31 TN_DEBUG1( "CTMActivityManager::NewL()"); |
|
32 OstTrace0( TRACE_NORMAL, CTMACTIVITYMANAGER_NEWL, "CTMActivityManager::NewL" ); |
28 |
33 |
29 CTMActivityManager* self = new (ELeave) CTMActivityManager(aObserver, aTimeout); |
34 CTMActivityManager* self = new (ELeave) CTMActivityManager(aObserver, aTimeout); |
30 CleanupStack::PushL(self); |
35 CleanupStack::PushL(self); |
31 self->ConstructL(); |
36 self->ConstructL(); |
32 CleanupStack::Pop(self); |
37 CleanupStack::Pop(self); |
39 // |
44 // |
40 CTMActivityManager::CTMActivityManager(MTMActivityManagerObserver* aObserver, TInt aTimeout) |
45 CTMActivityManager::CTMActivityManager(MTMActivityManagerObserver* aObserver, TInt aTimeout) |
41 : CActive(CActive::EPriorityHigh), iObserver(aObserver), iTimeout(aTimeout), iPreviousStatus(KErrNotFound) |
46 : CActive(CActive::EPriorityHigh), iObserver(aObserver), iTimeout(aTimeout), iPreviousStatus(KErrNotFound) |
42 { |
47 { |
43 TN_DEBUG1( "CTMActivityManager::CTMActivityManager()"); |
48 TN_DEBUG1( "CTMActivityManager::CTMActivityManager()"); |
|
49 OstTrace0( TRACE_NORMAL, CTMACTIVITYMANAGER_CTMACTIVITYMANAGER, "CTMActivityManager::CTMActivityManager" ); |
44 |
50 |
45 CActiveScheduler::Add(this); |
51 CActiveScheduler::Add(this); |
46 } |
52 } |
47 |
53 |
48 // --------------------------------------------------------------------------- |
54 // --------------------------------------------------------------------------- |
94 // --------------------------------------------------------------------------- |
103 // --------------------------------------------------------------------------- |
95 // |
104 // |
96 void CTMActivityManager::Reset() |
105 void CTMActivityManager::Reset() |
97 { |
106 { |
98 TN_DEBUG1( "CTMActivityManager::Reset()"); |
107 TN_DEBUG1( "CTMActivityManager::Reset()"); |
|
108 OstTrace0( TRACE_NORMAL, CTMACTIVITYMANAGER_RESET, "CTMActivityManager::Reset" ); |
99 |
109 |
100 #ifdef MONITOR_LIGHTS |
110 #ifdef MONITOR_LIGHTS |
101 delete iLight; |
111 delete iLight; |
102 iLight = NULL; |
112 iLight = NULL; |
103 #endif |
113 #endif |
110 // CTMActivityManager::DoCancel() |
120 // CTMActivityManager::DoCancel() |
111 // --------------------------------------------------------------------------- |
121 // --------------------------------------------------------------------------- |
112 void CTMActivityManager::DoCancel() |
122 void CTMActivityManager::DoCancel() |
113 { |
123 { |
114 TN_DEBUG1( "CTMActivityManager::DoCancel()"); |
124 TN_DEBUG1( "CTMActivityManager::DoCancel()"); |
|
125 OstTrace0( TRACE_NORMAL, CTMACTIVITYMANAGER_DOCANCEL, "CTMActivityManager::DoCancel" ); |
115 |
126 |
116 #ifdef MONITOR_LIGHTS |
127 #ifdef MONITOR_LIGHTS |
117 delete iLight; |
128 delete iLight; |
118 iLight = NULL; |
129 iLight = NULL; |
119 #endif |
130 #endif |
127 // --------------------------------------------------------------------------- |
138 // --------------------------------------------------------------------------- |
128 // |
139 // |
129 void CTMActivityManager::Start() |
140 void CTMActivityManager::Start() |
130 { |
141 { |
131 TN_DEBUG1( "CTMActivityManager::Start()"); |
142 TN_DEBUG1( "CTMActivityManager::Start()"); |
|
143 OstTrace0( TRACE_NORMAL, CTMACTIVITYMANAGER_START, "CTMActivityManager::Start" ); |
132 |
144 |
133 #ifdef MONITOR_LIGHTS |
145 #ifdef MONITOR_LIGHTS |
134 if(!iLight) |
146 if(!iLight) |
135 { |
147 { |
136 TRAP_IGNORE(iLight = CHWRMLight::NewL(this)); |
148 TRAP_IGNORE(iLight = CHWRMLight::NewL(this)); |
155 // --------------------------------------------------------------------------- |
167 // --------------------------------------------------------------------------- |
156 // |
168 // |
157 void CTMActivityManager::RunL() |
169 void CTMActivityManager::RunL() |
158 { |
170 { |
159 TN_DEBUG4( "CTMActivityManager::RunL(0x%08x) %d, observer = 0x%08x", this, iStatus.Int(), iObserver); |
171 TN_DEBUG4( "CTMActivityManager::RunL(0x%08x) %d, observer = 0x%08x", this, iStatus.Int(), iObserver); |
|
172 OstTrace1( TRACE_NORMAL, CTMACTIVITYMANAGER_RUNL, "CTMActivityManager::RunL;this=%o", this ); |
|
173 OstTrace1( TRACE_NORMAL, DUP5_CTMACTIVITYMANAGER_RUNL, "CTMActivityManager::RunL;iStatus.Int()=%d", iStatus.Int() ); |
160 |
174 |
161 if(iFirstRound) |
175 if(iFirstRound) |
162 { |
176 { |
163 TN_DEBUG1( "CTMActivityManager::RunL() iFirstRound"); |
177 TN_DEBUG1( "CTMActivityManager::RunL() iFirstRound"); |
|
178 OstTrace0( TRACE_NORMAL, DUP1_CTMACTIVITYMANAGER_RUNL, "CTMActivityManager::RunL - iFirstRound" ); |
164 iFirstRound = EFalse; |
179 iFirstRound = EFalse; |
165 if (!IsActive()) |
180 if (!IsActive()) |
166 { |
181 { |
167 iWatch = EWaitingForInactivity; |
182 iWatch = EWaitingForInactivity; |
168 iTimer.Inactivity(iStatus, iTimeout); |
183 iTimer.Inactivity(iStatus, iTimeout); |
178 { |
193 { |
179 TInt inactivity = User::InactivityTime().Int(); |
194 TInt inactivity = User::InactivityTime().Int(); |
180 if (inactivity >= iTimeout) |
195 if (inactivity >= iTimeout) |
181 { |
196 { |
182 TN_DEBUG1( "CTMActivityManager::RunL() inactive"); |
197 TN_DEBUG1( "CTMActivityManager::RunL() inactive"); |
|
198 OstTrace0( TRACE_NORMAL, DUP2_CTMACTIVITYMANAGER_RUNL, "CTMActivityManager::RunL - inactive" ); |
183 NotifyObserver(); |
199 NotifyObserver(); |
184 |
200 |
185 if (!IsActive()) //observer might have called a Reset() |
201 if (!IsActive()) //observer might have called a Reset() |
186 { |
202 { |
187 iTimer.Inactivity(iStatus,0); |
203 iTimer.Inactivity(iStatus,0); |
194 } |
210 } |
195 } |
211 } |
196 else if (iWatch == EWaitingForActivity) |
212 else if (iWatch == EWaitingForActivity) |
197 { |
213 { |
198 TN_DEBUG1( "CTMActivityManager::RunL() active"); |
214 TN_DEBUG1( "CTMActivityManager::RunL() active"); |
|
215 OstTrace0( TRACE_NORMAL, DUP3_CTMACTIVITYMANAGER_RUNL, "CTMActivityManager::RunL - active" ); |
199 NotifyObserver(); |
216 NotifyObserver(); |
200 |
217 |
201 if (!IsActive()) //observer might have called a Reset() |
218 if (!IsActive()) //observer might have called a Reset() |
202 { |
219 { |
203 iTimer.Inactivity(iStatus,iTimeout); |
220 iTimer.Inactivity(iStatus,iTimeout); |
213 else |
230 else |
214 { |
231 { |
215 iWatch = ENone; |
232 iWatch = ENone; |
216 } |
233 } |
217 TN_DEBUG1( "CTMActivityManager::RunL() end"); |
234 TN_DEBUG1( "CTMActivityManager::RunL() end"); |
|
235 OstTrace0( TRACE_NORMAL, DUP4_CTMACTIVITYMANAGER_RUNL, "CTMActivityManager::RunL - end" ); |
218 } |
236 } |
219 |
237 |
220 // --------------------------------------------------------------------------- |
238 // --------------------------------------------------------------------------- |
221 // CTMActivityManager::RunError() |
239 // CTMActivityManager::RunError() |
222 // --------------------------------------------------------------------------- |
240 // --------------------------------------------------------------------------- |
223 // |
241 // |
224 TInt CTMActivityManager::RunError(TInt aError) |
242 TInt CTMActivityManager::RunError(TInt aError) |
225 { |
243 { |
226 TN_DEBUG2( "CTMActivityManager::RunError() %d", aError); |
244 TN_DEBUG2( "CTMActivityManager::RunError() %d", aError); |
|
245 OstTrace1( TRACE_NORMAL, CTMACTIVITYMANAGER_RUNERROR, "CTMActivityManager::RunError;aError=%d", aError ); |
227 |
246 |
228 if (aError != KErrNone) |
247 if (aError != KErrNone) |
229 { |
248 { |
230 Reset(); |
249 Reset(); |
231 } |
250 } |
240 // |
259 // |
241 TBool CTMActivityManager::IsInactive() |
260 TBool CTMActivityManager::IsInactive() |
242 { |
261 { |
243 #ifdef MONITOR_LIGHTS |
262 #ifdef MONITOR_LIGHTS |
244 #ifdef _DEBUG |
263 #ifdef _DEBUG |
|
264 TInt inactivityTime = User::InactivityTime().Int(); |
245 TN_DEBUG3( "CTMActivityManager::IsInactive()= %d, iLights = %d", User::InactivityTime().Int(), iLights); |
265 TN_DEBUG3( "CTMActivityManager::IsInactive()= %d, iLights = %d", User::InactivityTime().Int(), iLights); |
|
266 OstTrace1( TRACE_NORMAL, DUP6_CTMACTIVITYMANAGER_RUNL, "CTMActivityManager::RunL;inactivityTime=%d", inactivityTime ); |
246 #endif |
267 #endif |
247 #else |
268 #else |
|
269 TInt inactivityTime = User::InactivityTime().Int(); |
248 TN_DEBUG2( "CTMActivityManager::IsInactive()= %d", User::InactivityTime().Int()); |
270 TN_DEBUG2( "CTMActivityManager::IsInactive()= %d", User::InactivityTime().Int()); |
|
271 OstTrace1( TRACE_NORMAL, DUP7_CTMACTIVITYMANAGER_RUNL, "CTMActivityManager::RunL;inactivityTime=%d", inactivityTime ); |
249 #endif |
272 #endif |
250 |
273 |
251 //if lights are off or inactivity timer is less that target the device is not idle |
274 //if lights are off or inactivity timer is less that target the device is not idle |
252 if( User::InactivityTime() >= TTimeIntervalSeconds(iTimeout) |
275 if( User::InactivityTime() >= TTimeIntervalSeconds(iTimeout) |
253 #ifdef MONITOR_LIGHTS |
276 #ifdef MONITOR_LIGHTS |
254 || !iLights |
277 || !iLights |
255 #endif |
278 #endif |
256 ) |
279 ) |
257 { |
280 { |
258 TN_DEBUG1( "CTMActivityManager::IsInactive() ETrue"); |
281 TN_DEBUG1( "CTMActivityManager::IsInactive() ETrue"); |
|
282 OstTrace0( TRACE_NORMAL, CTMACTIVITYMANAGER_ISINACTIVE, "CTMActivityManager::IsInactive - ETrue" ); |
259 return ETrue; |
283 return ETrue; |
260 } |
284 } |
261 TN_DEBUG1( "CTMActivityManager::IsInactive() EFalse"); |
285 TN_DEBUG1( "CTMActivityManager::IsInactive() EFalse"); |
|
286 OstTrace0( TRACE_NORMAL, DUP1_CTMACTIVITYMANAGER_ISINACTIVE, "CTMActivityManager::IsInactive - EFalse" ); |
262 return EFalse; |
287 return EFalse; |
263 } |
288 } |
264 |
289 |
265 #ifdef MONITOR_LIGHTS |
290 #ifdef MONITOR_LIGHTS |
266 // ----------------------------------------------------------------------------- |
291 // ----------------------------------------------------------------------------- |
268 // ----------------------------------------------------------------------------- |
293 // ----------------------------------------------------------------------------- |
269 // |
294 // |
270 void CTMActivityManager::LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus) |
295 void CTMActivityManager::LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus) |
271 { |
296 { |
272 TN_DEBUG3( "CTMActivityManager::LightStatusChanged() aTarget = %d, aStatus == %d", aTarget, aStatus); |
297 TN_DEBUG3( "CTMActivityManager::LightStatusChanged() aTarget = %d, aStatus == %d", aTarget, aStatus); |
|
298 OstTraceExt2( TRACE_NORMAL, CTMACTIVITYMANAGER_LIGHTSTATUSCHANGED, "CTMActivityManager::LightStatusChanged;aTarget=%d;aStatus=%u", aTarget, aStatus ); |
273 |
299 |
274 if(aTarget & CHWRMLight::EPrimaryDisplay) |
300 if(aTarget & CHWRMLight::EPrimaryDisplay) |
275 { |
301 { |
276 if( aStatus == CHWRMLight::ELightOff ) |
302 if( aStatus == CHWRMLight::ELightOff ) |
277 { |
303 { |
278 TN_DEBUG1( "CTMActivityManager::LightStatusChanged() -- OFF"); |
304 TN_DEBUG1( "CTMActivityManager::LightStatusChanged() -- OFF"); |
|
305 OstTrace0( TRACE_NORMAL, DUP1_CTMACTIVITYMANAGER_LIGHTSTATUSCHANGED, "CTMActivityManager::LightStatusChanged - OFF" ); |
279 iLights = EFalse; |
306 iLights = EFalse; |
280 } |
307 } |
281 else |
308 else |
282 { |
309 { |
283 TN_DEBUG1( "CTMActivityManager::LightStatusChanged() -- ON"); |
310 TN_DEBUG1( "CTMActivityManager::LightStatusChanged() -- ON"); |
|
311 OstTrace0( TRACE_NORMAL, DUP2_CTMACTIVITYMANAGER_LIGHTSTATUSCHANGED, "CTMActivityManager::LightStatusChanged - ON" ); |
284 iLights = ETrue; |
312 iLights = ETrue; |
285 } |
313 } |
286 |
314 |
287 NotifyObserver(); |
315 NotifyObserver(); |
288 } |
316 } |
294 // ----------------------------------------------------------------------------- |
322 // ----------------------------------------------------------------------------- |
295 // |
323 // |
296 void CTMActivityManager::NotifyObserver() |
324 void CTMActivityManager::NotifyObserver() |
297 { |
325 { |
298 TN_DEBUG1( "void CTMAActivityManager::NotifyObserver()"); |
326 TN_DEBUG1( "void CTMAActivityManager::NotifyObserver()"); |
|
327 OstTrace0( TRACE_NORMAL, CTMACTIVITYMANAGER_NOTIFYOBSERVER, "CTMActivityManager::NotifyObserver" ); |
299 |
328 |
300 TBool status = IsInactive(); |
329 TBool status = IsInactive(); |
301 |
330 |
302 if( iPreviousStatus != status ) |
331 if( iPreviousStatus != status ) |
303 { |
332 { |