|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <barsc.h> |
|
19 #include <barsread.h> |
|
20 #include <coreapplicationuisdomainpskeys.h> |
|
21 #include <e32debug.h> |
|
22 #include <e32property.h> |
|
23 #include <f32file.h> |
|
24 #include <lafshut.h> |
|
25 #include <w32std.h> |
|
26 |
|
27 |
|
28 #include "ut_oodmonitor_const.h" |
|
29 #include "ut_oodmonitor_timer.h" |
|
30 |
|
31 Cut_OODMonitor_Timer* Cut_OODMonitor_Timer::NewLC(CLafShutdownManager* aShutdownManager, Tut_LafShutdownManager& aFriendLafShutdownManager, TTestCase aTestCase) |
|
32 { |
|
33 Cut_OODMonitor_Timer* self=new(ELeave) Cut_OODMonitor_Timer(aShutdownManager, aFriendLafShutdownManager, aTestCase); |
|
34 CleanupStack::PushL(self); |
|
35 self->ConstructL(); |
|
36 return self; |
|
37 } |
|
38 |
|
39 Cut_OODMonitor_Timer* Cut_OODMonitor_Timer::NewL(CLafShutdownManager* aShutdownManager, Tut_LafShutdownManager& aFriendLafShutdownManager, TTestCase aTestCase) |
|
40 { |
|
41 Cut_OODMonitor_Timer* self=Cut_OODMonitor_Timer::NewLC(aShutdownManager, aFriendLafShutdownManager, aTestCase); |
|
42 CleanupStack::Pop(self); |
|
43 return self; |
|
44 } |
|
45 |
|
46 Cut_OODMonitor_Timer::Cut_OODMonitor_Timer(CLafShutdownManager* aShutdownManager, Tut_LafShutdownManager& aFriendLafShutdownManager, TTestCase aTestCase): |
|
47 CTimer(EPriorityStandard), iFriendLafShutdownManager(aFriendLafShutdownManager), iShutdownManager(aShutdownManager), iTestCase(aTestCase), |
|
48 iPhase(EPhase1) |
|
49 { |
|
50 |
|
51 } |
|
52 |
|
53 Cut_OODMonitor_Timer::~Cut_OODMonitor_Timer() |
|
54 { |
|
55 iFileNameArray->Reset(); |
|
56 delete iFileNameArray; |
|
57 } |
|
58 |
|
59 void Cut_OODMonitor_Timer::ConstructL() |
|
60 { |
|
61 iFileNameArray = new (ELeave) CDesCArrayFlat(KArraySize); |
|
62 CTimer::ConstructL(); |
|
63 CActiveScheduler::Add(this); |
|
64 After(KTwoSecondInMicro); |
|
65 } |
|
66 |
|
67 void Cut_OODMonitor_Timer::RunL() |
|
68 { |
|
69 switch(iTestCase) |
|
70 { |
|
71 case EMMCTest: |
|
72 { |
|
73 switch(iPhase) |
|
74 { |
|
75 case EPhase1: |
|
76 { |
|
77 ChangeMMCStatus(); |
|
78 iPhase = EPhase2; |
|
79 After(KTwoSecondInMicro); |
|
80 break; |
|
81 } |
|
82 case EPhase2: |
|
83 { |
|
84 ChangeMMCStatus(); |
|
85 iPhase = EPhase3; |
|
86 After(KTwoSecondInMicro); |
|
87 break; |
|
88 } |
|
89 default: |
|
90 { |
|
91 CActiveScheduler::Stop(); |
|
92 break; |
|
93 } |
|
94 } |
|
95 break; |
|
96 } // EMMCTest |
|
97 case EDisplayNotes: |
|
98 { |
|
99 switch(iPhase) |
|
100 { |
|
101 case EPhase1: |
|
102 { |
|
103 iFriendLafShutdownManager.EatDiskL(iFileNameArray, EDriveC, ECritical); |
|
104 ChangeDisplayNotes(); |
|
105 iPhase = EPhase2; |
|
106 After(KTwoSecondInMicro); |
|
107 break; |
|
108 } |
|
109 case EPhase2: |
|
110 { |
|
111 ChangeDisplayNotes(); |
|
112 iPhase = EPhase3; |
|
113 After(KTwoSecondInMicro); |
|
114 break; |
|
115 } |
|
116 case EPhase3: |
|
117 { |
|
118 iPhase = EPhase4; |
|
119 iFriendLafShutdownManager.FreeDiskL(iFileNameArray); |
|
120 iFileNameArray->Reset(); |
|
121 After(KTwoSecondInMicro); |
|
122 break; |
|
123 } |
|
124 default: |
|
125 { |
|
126 CActiveScheduler::Stop(); |
|
127 break; |
|
128 } |
|
129 } |
|
130 break; |
|
131 } // EDisplayNotes |
|
132 case EAutolock: |
|
133 { |
|
134 switch(iPhase) |
|
135 { |
|
136 case EPhase1: |
|
137 { |
|
138 iFriendLafShutdownManager.EatDiskL(iFileNameArray, EDriveC, EWarning); |
|
139 ChangeAutoLockStatus(); |
|
140 iPhase = EPhase2; |
|
141 After(KTwoSecondInMicro); |
|
142 break; |
|
143 } |
|
144 case EPhase2: |
|
145 { |
|
146 ChangeAutoLockStatus(); |
|
147 iPhase = EPhase3; |
|
148 After(KTwoSecondInMicro); |
|
149 break; |
|
150 } |
|
151 case EPhase3: |
|
152 { |
|
153 iPhase = EPhase4; |
|
154 iFriendLafShutdownManager.FreeDiskL(iFileNameArray); |
|
155 iFileNameArray->Reset(); |
|
156 After(KTwoSecondInMicro); |
|
157 break; |
|
158 } |
|
159 default: |
|
160 { |
|
161 CActiveScheduler::Stop(); |
|
162 break; |
|
163 } |
|
164 } |
|
165 break; |
|
166 } // EAutolock |
|
167 case EOODWatcher: |
|
168 { |
|
169 switch(iPhase) |
|
170 { |
|
171 case EPhase1: |
|
172 { |
|
173 iFriendLafShutdownManager.EatDiskL(iFileNameArray, EDriveC, ECritical); |
|
174 iPhase = EPhase2; |
|
175 After(KTwoSecondInMicro); |
|
176 break; |
|
177 } |
|
178 case EPhase2: |
|
179 { |
|
180 iFriendLafShutdownManager.FreeDiskL(iFileNameArray); |
|
181 iFileNameArray->Reset(); |
|
182 iPhase = EPhase3; |
|
183 After(KTwoSecondInMicro); |
|
184 break; |
|
185 } |
|
186 default: |
|
187 { |
|
188 CActiveScheduler::Stop(); |
|
189 break; |
|
190 } |
|
191 } |
|
192 break; |
|
193 } // EOODWatcher |
|
194 default: |
|
195 { |
|
196 CActiveScheduler::Stop(); |
|
197 } // default |
|
198 } |
|
199 } |
|
200 void Cut_OODMonitor_Timer::ChangeMMCStatus() |
|
201 { |
|
202 TInt value; |
|
203 |
|
204 RProperty enableMMCWatchProperty = iFriendLafShutdownManager.GetEnableMMCWatchProperty(iShutdownManager); |
|
205 enableMMCWatchProperty.Get(value); |
|
206 |
|
207 RDebug::Print(_L("CLafShutdownManager::enableMMCWatchProperty=%d"), value); |
|
208 |
|
209 const TInt mmcRemovedStatus = 0; |
|
210 const TInt mmcInsertedStatus = 1; |
|
211 |
|
212 if(mmcRemovedStatus == value) |
|
213 { |
|
214 value = mmcInsertedStatus; |
|
215 } |
|
216 else |
|
217 { |
|
218 value = mmcRemovedStatus; |
|
219 } |
|
220 |
|
221 enableMMCWatchProperty.Set(value); |
|
222 } |
|
223 |
|
224 void Cut_OODMonitor_Timer::ChangeDisplayNotes() |
|
225 { |
|
226 TInt value; |
|
227 |
|
228 RProperty canDisplayNotesProperty = iFriendLafShutdownManager.GetCanDisplayNotesProperty(iShutdownManager); |
|
229 canDisplayNotesProperty.Get(value); |
|
230 |
|
231 RDebug::Print(_L("CLafShutdownManager::canDisplayNotesProperty=%d"), value); |
|
232 |
|
233 const TInt notShowDisplayNotes = 0; |
|
234 const TInt ShowDisplayNotes = 1; |
|
235 |
|
236 if(notShowDisplayNotes == value) |
|
237 { |
|
238 value = ShowDisplayNotes; |
|
239 } |
|
240 else |
|
241 { |
|
242 value = notShowDisplayNotes; |
|
243 } |
|
244 |
|
245 canDisplayNotesProperty.Set(value); |
|
246 } |
|
247 |
|
248 void Cut_OODMonitor_Timer::ChangeAutoLockStatus() |
|
249 { |
|
250 TInt value; |
|
251 |
|
252 RProperty autolockStatusProperty = iFriendLafShutdownManager.GetAutolockStatusProperty(iShutdownManager); |
|
253 autolockStatusProperty.Get(value); |
|
254 |
|
255 RDebug::Print(_L("CLafShutdownManager::autolockStatusProperty=%d"), value); |
|
256 |
|
257 if(EAutolockOff == value) |
|
258 { |
|
259 value = EManualLocked; |
|
260 } |
|
261 else |
|
262 { |
|
263 value = EAutolockOff; |
|
264 } |
|
265 |
|
266 autolockStatusProperty.Set(value); |
|
267 } |