1 /* |
|
2 * Copyright (c) 2002 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 <apgtask.h> |
|
19 #include <etelmm.h> |
|
20 #include <AknEcs.h> |
|
21 #include <aknnotedialog.h> |
|
22 #include <aknkeylock.h> |
|
23 #include <AknLayoutDef.h> |
|
24 #include <AknLayout.lag> |
|
25 #include <bldvariant.hrh> |
|
26 #include <aknappui.h> |
|
27 #include <centralrepository.h> |
|
28 #include <settingsinternalcrkeys.h> |
|
29 #include <secuisecurityhandler.h> |
|
30 #include <secui.h> |
|
31 #include <featmgr.h> |
|
32 #include <Autolock.rsg> |
|
33 #include <mmtsy_names.h> |
|
34 #include <e32property.h> |
|
35 #include <PSVariables.h> // Property values |
|
36 #include <coreapplicationuisdomainpskeys.h> |
|
37 #include <startupdomainpskeys.h> |
|
38 #include <ctsydomainpskeys.h> |
|
39 #include <securityuisprivatepskeys.h> |
|
40 #include <AknSgcc.h> |
|
41 |
|
42 #include "AutolockAppUiPS.h" |
|
43 #include "AutoLockValueObserverPS.h" |
|
44 #include "AutoLockModelPS.h" |
|
45 #include "AutolockApp.h" |
|
46 #include "autolock.hrh" |
|
47 #include "AutolockView.h" |
|
48 |
|
49 #include <SCPClient.h> |
|
50 #include <AknSoftNotifier.h> |
|
51 |
|
52 // sysap uid and message enums defined in eikon.hrh |
|
53 // for sending messages to sysap |
|
54 #include <eikon.hrh> |
|
55 #include <apgwgnam.h> |
|
56 #include <aknlayoutscalable_avkon.cdl.h> |
|
57 |
|
58 #include <AknCapServerDefs.h> |
|
59 #include <apgtask.h> |
|
60 |
|
61 #include <keylockpolicyapi.h> |
|
62 |
|
63 // LOCAL CONSTANTS AND MACROS |
|
64 #define KSysApUid TUid::Uid(0x100058F3) |
|
65 #define KPhoneAppUid TUid::Uid(0x100058B3) |
|
66 |
|
67 const TInt KTriesToConnectServer( 2 ); |
|
68 const TInt KTimeBeforeRetryingServerConnection( 50000 ); |
|
69 const TInt PhoneIndex( 0 ); |
|
70 const TInt KCancelKeyScanCode( EStdKeyDevice1 ); // 165 |
|
71 |
|
72 |
|
73 // ================= MEMBER FUNCTIONS ======================= |
|
74 // |
|
75 // ---------------------------------------------------------- |
|
76 // CAutolockAppUi::ConstructL() |
|
77 // ?implementation_description |
|
78 // ---------------------------------------------------------- |
|
79 // |
|
80 void CAutolockAppUi::ConstructL() |
|
81 { |
|
82 #if defined(_DEBUG) |
|
83 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL")); |
|
84 #endif |
|
85 |
|
86 BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknDisableAnimationBackground ); |
|
87 |
|
88 //Disable priority control so that Autolock process priority isn't set to "background" by |
|
89 //window server when it is not active. |
|
90 iEikonEnv->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled ); |
|
91 RThread().SetProcessPriority( EPriorityHigh ); |
|
92 |
|
93 FeatureManager::InitializeLibL(); |
|
94 |
|
95 RTelServer::TPhoneInfo PhoneInfo; |
|
96 // prevent autolock shutdown |
|
97 iEikonEnv->SetSystem( ETrue ); |
|
98 |
|
99 CKeyLockPolicyApi* iCKeyLockPolicyApi = CKeyLockPolicyApi::NewL( EPolicyActivateKeyguard ); |
|
100 TBool keyguardAllowed = iCKeyLockPolicyApi->KeyguardAllowed(); |
|
101 #if defined(_DEBUG) |
|
102 RDebug::Printf( "%s %s (%u) keyguardAllowed=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, keyguardAllowed ); |
|
103 #endif |
|
104 keyguardAllowed = iCKeyLockPolicyApi->EnableKeyguardFeature(); |
|
105 #if defined(_DEBUG) |
|
106 RDebug::Printf( "%s %s (%u) new keyguardAllowed=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, keyguardAllowed ); |
|
107 #endif |
|
108 delete iCKeyLockPolicyApi; |
|
109 |
|
110 iSideKey1 = 0; |
|
111 iSideKey2 = 0; |
|
112 iAppKey = 0; |
|
113 |
|
114 aCallButtonRect = TRect (0,0,0,0); |
|
115 iGotEventDownDuringCall = -1; |
|
116 //connect to ETel |
|
117 |
|
118 TInt err( KErrGeneral ); |
|
119 TInt thisTry( 0 ); |
|
120 |
|
121 /*All server connections are tried to be made KTiesToConnectServer times because occasional |
|
122 fails on connections are possible at least on some servers*/ |
|
123 #if defined(_DEBUG) |
|
124 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() connect to etel server")); |
|
125 #endif |
|
126 // connect etel server |
|
127 while ( ( err = iServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
128 { |
|
129 User::After( KTimeBeforeRetryingServerConnection ); |
|
130 } |
|
131 User::LeaveIfError( err ); |
|
132 |
|
133 #if defined(_DEBUG) |
|
134 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() load tsy")); |
|
135 #endif |
|
136 // load tsy |
|
137 err = iServer.LoadPhoneModule( KMmTsyModuleName ); |
|
138 #if defined(_DEBUG) |
|
139 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() load tsy ERROR: %d"), err); |
|
140 #endif |
|
141 if ( err != KErrAlreadyExists ) |
|
142 { |
|
143 // may return also KErrAlreadyExists if some other |
|
144 // is already loaded the tsy module. And that is |
|
145 // not an error. |
|
146 User::LeaveIfError( err ); |
|
147 } |
|
148 |
|
149 thisTry = 0; |
|
150 #if defined(_DEBUG) |
|
151 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() open phone")); |
|
152 #endif |
|
153 //open phone |
|
154 User::LeaveIfError(iServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended)); |
|
155 User::LeaveIfError(iServer.GetPhoneInfo(PhoneIndex, PhoneInfo)); |
|
156 User::LeaveIfError(iPhone.Open(iServer,PhoneInfo.iName)); |
|
157 User::LeaveIfError(iCustomPhone.Open(iPhone)); |
|
158 #if defined(_DEBUG) |
|
159 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() phone opened")); |
|
160 #endif |
|
161 |
|
162 TBool systemLocked = EFalse; |
|
163 TBool phoneLocked = EFalse; |
|
164 |
|
165 iWait = NULL; |
|
166 iWait = CWait::NewL(); |
|
167 |
|
168 RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice; |
|
169 RMobilePhone::TMobilePhoneLockInfoV1 lockInfo; |
|
170 RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo); |
|
171 TInt cRresult = KErrNone; |
|
172 |
|
173 #ifndef __WINS__ |
|
174 |
|
175 |
|
176 /***************************************************** |
|
177 * Series 60 Customer / ETEL |
|
178 * Series 60 ETEL API |
|
179 *****************************************************/ |
|
180 |
|
181 // set autolock period to 0, if lock is disabled in DOS side |
|
182 #if defined(_DEBUG) |
|
183 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() set autolock period to 0")); |
|
184 #endif |
|
185 |
|
186 iWait->SetRequestType(EMobilePhoneGetLockInfo); |
|
187 iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg); |
|
188 TInt res = iWait->WaitForRequestL(); |
|
189 User::LeaveIfError(res); |
|
190 |
|
191 // Eventhough we might lock the device on boot-up (systemLocked == ETrue), we |
|
192 // want to hide the app until the handshake is done. StartUp application will |
|
193 // active the app when it is finished. |
|
194 TApaTask self(iCoeEnv->WsSession()); |
|
195 self.SetWgId(iCoeEnv->RootWin().Identifier()); |
|
196 self.SendToBackground(); |
|
197 // flush |
|
198 iCoeEnv->WsSession().Flush(); |
|
199 |
|
200 TInt lockValue = 0; |
|
201 CRepository* repository = CRepository::NewL(KCRUidSecuritySettings); |
|
202 cRresult = repository->Get(KSettingsAutolockStatus, lockValue); |
|
203 TBool hiddenReset = HiddenReset(); |
|
204 #if defined(_DEBUG) |
|
205 if(hiddenReset) |
|
206 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() Hidden reset")); |
|
207 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() CR get result: %d"), cRresult); |
|
208 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() CR lock value: %d"), lockValue); |
|
209 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() CR lockInfo.iSetting: %d"), lockInfo.iSetting); |
|
210 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() RMobilePhone::ELockSetEnabled: %d"), RMobilePhone::ELockSetEnabled); |
|
211 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() RMobilePhone::ELockSetDisabled: %d"), RMobilePhone::ELockSetDisabled); |
|
212 #endif |
|
213 if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled) |
|
214 { |
|
215 repository->Set(KSettingsAutoLockTime, 0); |
|
216 if ( FeatureManager::FeatureSupported( KFeatureIdProtocolCdma ) ) |
|
217 { |
|
218 repository->Set(KSettingsLockOnPowerUp, 0); |
|
219 } |
|
220 } |
|
221 // In CDMA, the system can stay locked on after the boot-up sequence. |
|
222 else if ( FeatureManager::FeatureSupported( KFeatureIdProtocolCdma ) || (hiddenReset && (lockValue == 1))) |
|
223 { |
|
224 #if defined(_DEBUG) |
|
225 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() Hidden reset when locked")); |
|
226 #endif |
|
227 phoneLocked = systemLocked = ETrue; |
|
228 } |
|
229 else if (lockInfo.iSetting == RMobilePhone::ELockSetEnabled && !hiddenReset) { |
|
230 #if defined(_DEBUG) |
|
231 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() Set phone locked")); |
|
232 #endif |
|
233 phoneLocked = ETrue; |
|
234 } |
|
235 |
|
236 |
|
237 delete repository; |
|
238 #endif //__WINS__ |
|
239 |
|
240 #if defined(_DEBUG) |
|
241 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() Enable emergency call support")); |
|
242 #endif |
|
243 |
|
244 #if defined(_DEBUG) |
|
245 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() Autolock view")); |
|
246 #endif |
|
247 |
|
248 |
|
249 |
|
250 // ------------------------------------------------------------------------------------------------------------- |
|
251 // part of emergency call handling when telephony+devicelock is active |
|
252 // this solution is meant only for 3.1 and 3.2 |
|
253 |
|
254 iEcsNote = new (ELeave) CEcsNote(); |
|
255 iEcsNote->ConstructSleepingNoteL(R_AVKON_EMERGENCY_CALL_NOTE); |
|
256 iEcsNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(0,2); |
|
257 |
|
258 if (AknLayoutUtils::PenEnabled()) // on touch devices, if Autolock is activated from IdleScreen in landscape, the buttons need to be drawn. |
|
259 { |
|
260 iEcsNote->ButtonGroupContainer().SetCommandL( 0, _L("") ); // as keyboard is locked, these buttons do nothing. Better to hide their labels. |
|
261 iEcsNote->ButtonGroupContainer().SetCommandL( EAknSoftkeyCancel, _L("") ); |
|
262 iEcsNote->ButtonGroupContainer().ButtonGroup()->AsControl()->MakeVisible(ETrue); |
|
263 } |
|
264 |
|
265 // Emergency call support |
|
266 iEcsDetector = CAknEcsDetector::NewL(); |
|
267 iEcsDetector->SetObserver( this ); |
|
268 iEmergencySupportReady = ETrue; |
|
269 // ------------------------------------------------------------------------------------------------------------- |
|
270 |
|
271 |
|
272 // Autolock view |
|
273 CAutolockView* lockView = new(ELeave) CAutolockView; |
|
274 CleanupStack::PushL(lockView); |
|
275 lockView->ConstructL(); |
|
276 CleanupStack::Pop(); // lockView |
|
277 AddViewL(lockView); // transfer ownership to CAknViewAppUi |
|
278 SetDefaultViewL(*lockView); |
|
279 |
|
280 // start autolock timer |
|
281 iModel = CAutoLockModel::NewL(this, phoneLocked); |
|
282 |
|
283 // phone event observer |
|
284 iPhoneObserver = CValueObserver::NewL(this); |
|
285 //call bubble |
|
286 iIncallBubble = CAknIncallBubble::NewL(); |
|
287 |
|
288 //Autokeyguard Period observer |
|
289 #ifdef RD_AUTO_KEYGUARD |
|
290 iKeyguardObserver = CAutoKeyguardObserver::NewL(this); |
|
291 #else //!RD_AUTO_KEYGUARD |
|
292 iKeyguardObserver = NULL; |
|
293 #endif //RD_AUTO_KEYGUARD |
|
294 // Create the write policy. Also processes with write device data can write the value. |
|
295 TSecurityPolicy writePolicy( ECapabilityWriteDeviceData ); |
|
296 // Create the read policy. Also processes with read device data can read the value. |
|
297 TSecurityPolicy readPolicy( ECapabilityReadDeviceData ); |
|
298 |
|
299 TInt tRet = RProperty::Define( KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, RProperty::EInt, readPolicy, writePolicy ); |
|
300 |
|
301 if ( tRet != KErrNone ) |
|
302 { |
|
303 #if defined(_DEBUG) |
|
304 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL():\ |
|
305 FAILED to define the SECUI query Flag: %d"), tRet); |
|
306 #endif |
|
307 } |
|
308 |
|
309 tRet = RProperty::Define( KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, RProperty::EInt, readPolicy, writePolicy ); |
|
310 if ( tRet != KErrNone ) |
|
311 { |
|
312 #if defined(_DEBUG) |
|
313 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL():\ |
|
314 FAILED to define the SECUI query request state Flag: %d"), tRet); |
|
315 #endif |
|
316 } |
|
317 |
|
318 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw )) |
|
319 { |
|
320 |
|
321 // Define the TARM admin flag. |
|
322 |
|
323 tRet = RProperty::Define( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, RProperty::EInt, |
|
324 readPolicy, writePolicy ); |
|
325 if ( tRet != KErrNone ) |
|
326 { |
|
327 #if defined(_DEBUG) |
|
328 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL():\ |
|
329 FAILED to define the TARM Admin Flag")); |
|
330 #endif |
|
331 } |
|
332 |
|
333 // The following sequence is used to validate the configuration on SCP server. |
|
334 // This is needed on the first boot (initial or RFS) or if the C-drive has been formatted |
|
335 // (3-button format) and Autolock is not active. |
|
336 |
|
337 RSCPClient scpClient; |
|
338 if ( scpClient.Connect() == KErrNone ) |
|
339 { |
|
340 TInt confStatus = KErrNone; |
|
341 // check whether this is normal or exceptional boot. This solves the issue when PIN is requested, Autolock starts, and scpClient.CheckConfiguration verifies the internal lock code |
|
342 TInt startupReason(ENormalStartup); |
|
343 RProperty::Get(KPSUidStartup, KPSStartupReason, startupReason); |
|
344 |
|
345 TInt secQueryStatus = ESecurityQueryUninitialized; |
|
346 TInt tRet = RProperty::Get(KPSUidStartup, KStartupSecurityCodeQueryStatus, secQueryStatus); |
|
347 #if defined(_DEBUG) |
|
348 RDebug::Printf( "%s %s (%u) startupReason=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, startupReason ); |
|
349 RDebug::Printf( "%s %s (%u) secQueryStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, secQueryStatus ); |
|
350 RDebug::Printf( "%s %s (%u) cRresult=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, cRresult ); |
|
351 RDebug::Printf( "%s %s (%u) lockInfo.iSetting=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, lockInfo.iSetting ); |
|
352 RDebug::Printf( "%s %s (%u) tRet=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, tRet ); |
|
353 #endif |
|
354 |
|
355 TInt simStatusValue; |
|
356 tRet = RProperty::Get(KPSUidStartup, KPSSimStatus, simStatusValue); |
|
357 #if defined(_DEBUG) |
|
358 RDebug::Printf( "%s %s (%u) tRet=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, tRet ); |
|
359 RDebug::Printf( "%s %s (%u) simStatusValue=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, simStatusValue ); |
|
360 RDebug::Printf( "%s %s (%u) ESimReadable=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ESimReadable ); |
|
361 #endif |
|
362 |
|
363 if( simStatusValue==ESimReadable && secQueryStatus==ESecurityQueryActive) |
|
364 { // query during SIM-query. This should not happen because check on CSecurityNotifier::GetParamsL iEvent != RMobilePhone::EPin1Required |
|
365 #if defined(_DEBUG) |
|
366 RDebug::Printf( "%s %s (%u) tRet=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, tRet ); |
|
367 #endif |
|
368 confStatus = KErrNone; // the best thing to do is to skip CheckConfiguration, because it might secretly accept the lock-code |
|
369 } |
|
370 else |
|
371 confStatus = scpClient.CheckConfiguration( KSCPInitial ); |
|
372 #if defined(_DEBUG) |
|
373 RDebug::Printf( "%s %s (%u) confStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, confStatus ); |
|
374 RDebug::Printf( "%s %s (%u) KErrAccessDenied=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, KErrAccessDenied ); |
|
375 #endif |
|
376 if ( confStatus == KErrAccessDenied ) |
|
377 { |
|
378 #ifndef __WINS__ |
|
379 if ( 1 ) // Previously was ( lockInfo.iSetting == RMobilePhone::ELockSetDisabled ) but now it needs to handle scenarios : ISA_format without drive format, and the opposite |
|
380 #else // __WINS__ |
|
381 if ( 1 ) // DOS lock is never active in WINS |
|
382 #endif // __WINS__ |
|
383 { |
|
384 // DOS lock is not active. Note that if DOS is locked, checking the code here will |
|
385 // mess up the query sequence. On initial startup DOS is not locked. |
|
386 |
|
387 TInt finalConfStatus = scpClient.CheckConfiguration( KSCPComplete ); |
|
388 #if defined(_DEBUG) |
|
389 RDebug::Printf( "%s %s (%u) finalConfStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, finalConfStatus ); |
|
390 #endif |
|
391 if ( finalConfStatus == KErrAccessDenied ) |
|
392 { |
|
393 #ifdef __WINS__ |
|
394 #if defined(_DEBUG) |
|
395 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL():\ |
|
396 DOS validation FAILED in WINS, something wrong!")); |
|
397 #endif |
|
398 #else // !__WINS__ |
|
399 |
|
400 // The SCP server is out of sync and Autolock is not active. (c-drive formatted) |
|
401 // We must ask the security code. ( Note that it is very rare that this is executed ) |
|
402 #if defined(_DEBUG) |
|
403 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL():\ |
|
404 Lock setting disabled, calling setlocksetting")); |
|
405 #endif |
|
406 |
|
407 // Wait here until the startup is complete |
|
408 |
|
409 TInt tarmErr = KErrNone; |
|
410 while ( tarmErr == KErrNone ) |
|
411 { |
|
412 TInt sysState=0; |
|
413 tarmErr = RProperty::Get(KPSUidStartup, KPSGlobalSystemState, sysState); |
|
414 |
|
415 if ((sysState == ESwStateNormalRfOn) || (sysState == ESwStateNormalRfOff) |
|
416 || (sysState == ESwStateNormalBTSap)) |
|
417 { |
|
418 break; |
|
419 } |
|
420 User::After(500000); |
|
421 } |
|
422 |
|
423 // Just change the lock setting again to disabled to request the security code. |
|
424 // Set the TARM flag so SecUi knows it should display the "login" query. |
|
425 TInt tarmFlag=0; |
|
426 tRet = RProperty::Get( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag ); |
|
427 if ( tRet == KErrNone ) |
|
428 { |
|
429 tarmFlag |= KSCPFlagResyncQuery; |
|
430 tRet = RProperty::Set( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag ); |
|
431 } |
|
432 |
|
433 if ( tRet != KErrNone ) |
|
434 { |
|
435 #if defined(_DEBUG) |
|
436 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL():\ |
|
437 FAILED to set TARM Admin Flag")); |
|
438 #endif |
|
439 } |
|
440 |
|
441 RMobilePhone::TMobilePhoneLockSetting lockChange; |
|
442 lockChange = RMobilePhone::ELockSetDisabled; |
|
443 iWait->SetRequestType(EMobilePhoneSetLockSetting); |
|
444 iPhone.SetLockSetting(iWait->iStatus, lockType, lockChange); |
|
445 |
|
446 res = iWait->WaitForRequestL(); |
|
447 #endif // __WINS__ |
|
448 } |
|
449 } |
|
450 |
|
451 } // if ( confStatus == KErrAccessDenied ) |
|
452 |
|
453 scpClient.Close(); |
|
454 } |
|
455 |
|
456 } |
|
457 |
|
458 // Eventhough we might lock the device on boot-up (systemLocked == ETrue), we |
|
459 // want to hide the app until the handshake is done. StartUp application will |
|
460 // active the app when it is finished. |
|
461 #if defined(_DEBUG) |
|
462 RDebug::Printf( "%s %s (%u) systemLocked=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, systemLocked ); |
|
463 RDebug::Printf( "%s %s (%u) phoneLocked=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, phoneLocked ); |
|
464 #endif |
|
465 if( !systemLocked ) |
|
466 { |
|
467 // incoming call on boot |
|
468 TInt value(EStartupUiPhaseUninitialized); |
|
469 RProperty::Get(KPSUidStartup, KPSStartupUiPhase, value); |
|
470 #if defined(_DEBUG) |
|
471 RDebug::Printf( "%s %s (%u) KPSStartupUiPhase value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, value ); |
|
472 #endif |
|
473 if( value<EStartupUiPhaseSystemWelcomeDone ) |
|
474 { |
|
475 TInt err=iPhoneObserver->Start(); |
|
476 #if defined(_DEBUG) |
|
477 RDebug::Printf( "%s %s (%u) err=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, err ); |
|
478 #endif |
|
479 } |
|
480 // app to background |
|
481 #if defined(_DEBUG) |
|
482 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() app to background")); |
|
483 #endif |
|
484 TApaTask self(iCoeEnv->WsSession()); |
|
485 self.SetWgId(iCoeEnv->RootWin().Identifier()); |
|
486 self.SendToBackground(); |
|
487 // flush |
|
488 iCoeEnv->WsSession().Flush(); |
|
489 } |
|
490 else |
|
491 { |
|
492 #if defined(_DEBUG) |
|
493 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() LOCK SYSTEM")); |
|
494 #endif |
|
495 TInt lockState = 0; |
|
496 |
|
497 #ifdef RD_REMOTELOCK |
|
498 lockState = EManualLocked; |
|
499 #else //!RD_REMOTELOCK |
|
500 lockState = EAutolockOn; |
|
501 #endif//RD_REMOTELOCK |
|
502 iModel->LockSystemL(lockState); |
|
503 } |
|
504 |
|
505 iGripStatusObserver = CAutolockGripStatusObserver::NewL( this, iEikonEnv->WsSession() ); |
|
506 iFpsStatusObserver = CAutolockFpsStatusObserver::NewL( this, iEikonEnv->WsSession() ); |
|
507 iDeviceLockQueryStatus = EFalse; |
|
508 #if defined(_DEBUG) |
|
509 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::ConstructL() END")); |
|
510 #endif |
|
511 } |
|
512 // ---------------------------------------------------- |
|
513 // CAutolockAppUi::~CAutolockAppUi() |
|
514 // Destructor |
|
515 // Frees reserved resources |
|
516 // ---------------------------------------------------- |
|
517 // |
|
518 CAutolockAppUi::~CAutolockAppUi() |
|
519 { |
|
520 #if defined(_DEBUG) |
|
521 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::~CAutolockAppUi() BEGIN")); |
|
522 #endif |
|
523 |
|
524 if(iWait) |
|
525 { |
|
526 // Cancel active requests |
|
527 if(iWait->IsActive()) |
|
528 { |
|
529 #if defined(_DEBUG) |
|
530 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::~CAutolockAppUi() CANCEL REQ")); |
|
531 #endif |
|
532 iPhone.CancelAsyncRequest(iWait->GetRequestType()); |
|
533 } |
|
534 } |
|
535 //close ETel connections |
|
536 if (iCustomPhone.SubSessionHandle()) |
|
537 iCustomPhone.Close(); |
|
538 |
|
539 if (iPhone.SubSessionHandle()) |
|
540 iPhone.Close(); |
|
541 |
|
542 if (iServer.Handle()) |
|
543 { |
|
544 iServer.UnloadPhoneModule(KMmTsyModuleName); |
|
545 iServer.Close(); |
|
546 } |
|
547 delete iModel; |
|
548 delete iPhoneObserver; |
|
549 delete iIncallBubble; |
|
550 #ifdef RD_AUTO_KEYGUARD |
|
551 delete iKeyguardObserver; |
|
552 #endif |
|
553 |
|
554 delete iEcsDetector; |
|
555 delete iEcsNote; // Ecs change |
|
556 delete iWait; |
|
557 FeatureManager::UnInitializeLib(); |
|
558 delete iGripStatusObserver; |
|
559 delete iFpsStatusObserver; |
|
560 #if defined(_DEBUG) |
|
561 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::~CAutolockAppUi() END")); |
|
562 #endif |
|
563 } |
|
564 // ---------------------------------------------------- |
|
565 // CAutolockAppUi::HandleForegroundEventL() |
|
566 // Handles foreground event. |
|
567 // ---------------------------------------------------- |
|
568 // |
|
569 void CAutolockAppUi::HandleForegroundEventL(TBool aForeground) |
|
570 { |
|
571 #if defined(_DEBUG) |
|
572 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::HandleForegroundEventL()")); |
|
573 #endif |
|
574 if (aForeground ) |
|
575 { |
|
576 if (iLocked) |
|
577 { |
|
578 // lock voice key |
|
579 LockSideKeyL(); |
|
580 CAknView* view = View(KAutoLockViewId); |
|
581 if(view) |
|
582 { |
|
583 TRect aInitialRect; |
|
584 STATIC_CAST(CAutolockView*, view)->HandleCall(0x15, aInitialRect); |
|
585 } |
|
586 |
|
587 } |
|
588 else |
|
589 { |
|
590 // app back to background |
|
591 TApaTask self(iCoeEnv->WsSession()); |
|
592 self.SetWgId(iCoeEnv->RootWin().Identifier()); |
|
593 self.SendToBackground(); |
|
594 } |
|
595 } |
|
596 |
|
597 if (!aForeground && iLocked) |
|
598 { |
|
599 TInt callState=0; |
|
600 TInt simStatus=0; |
|
601 RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callState ); |
|
602 RProperty::Get(KPSUidStartup, KPSSimStatus, simStatus); |
|
603 |
|
604 if (callState == EPSCTsyCallStateNone && simStatus != ESimNotPresent) |
|
605 { |
|
606 // try put autolock back to foreground |
|
607 CAknView* view = View(KAutoLockViewId); |
|
608 if(view) |
|
609 { |
|
610 TRect aInitialRect; |
|
611 STATIC_CAST(CAutolockView*, view)->HandleCall(0x19, aInitialRect); |
|
612 } |
|
613 TApaTask self(iCoeEnv->WsSession()); |
|
614 self.SetWgId(iCoeEnv->RootWin().Identifier()); |
|
615 self.BringToForeground(); |
|
616 } |
|
617 else |
|
618 { |
|
619 // unlock voice key while there is active call |
|
620 UnLockSideKey(); |
|
621 CAknView* view = View(KAutoLockViewId); |
|
622 if(view) |
|
623 { |
|
624 TRect aInitialRect; |
|
625 STATIC_CAST(CAutolockView*, view)->HandleCall(0x16, aInitialRect); |
|
626 } |
|
627 } |
|
628 } |
|
629 |
|
630 CAknAppUi::HandleForegroundEventL(aForeground); |
|
631 |
|
632 } |
|
633 |
|
634 |
|
635 // ---------------------------------------------------- |
|
636 // HideSoftNotification() |
|
637 // dismiss all the pending notes just before asking the unlocking code |
|
638 // ---------------------------------------------------- |
|
639 // |
|
640 void HideSoftNotification() |
|
641 { |
|
642 #if defined(_DEBUG) |
|
643 RDebug::Print(_L("(AUTOLOCK)HideSoftNotification")); |
|
644 #endif |
|
645 CAknSoftNotifier *softNotifier = NULL; |
|
646 TRAPD (err, { |
|
647 softNotifier = CAknSoftNotifier::NewL(); |
|
648 softNotifier->AddNotificationL(ESetIdleState, 0); |
|
649 };) |
|
650 delete softNotifier; |
|
651 } |
|
652 // CAutolockAppUi::HandleCommandL(TInt aCommand) |
|
653 // ---------------------------------------------------- |
|
654 |
|
655 |
|
656 // ---------------------------------------------------- |
|
657 // CAutolockAppUi::HandleMessageL |
|
658 // |
|
659 // Handles the TARM command to unlock the phone. |
|
660 // ---------------------------------------------------- |
|
661 // |
|
662 MCoeMessageObserver::TMessageResponse CAutolockAppUi::HandleMessageL( |
|
663 TUint32 aClientHandleOfTargetWindowGroup, |
|
664 TUid aMessageUid, |
|
665 const TDesC8& aMessageParameters |
|
666 ) |
|
667 { |
|
668 |
|
669 if(!FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw )) |
|
670 { |
|
671 User::Leave(KErrNotSupported); |
|
672 } |
|
673 #if defined(_DEBUG) |
|
674 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::HandleMessageL()")); |
|
675 #endif |
|
676 |
|
677 MCoeMessageObserver::TMessageResponse messageResponse( EMessageHandled ); |
|
678 |
|
679 if ( aMessageUid.iUid == SCP_CMDUID_UNLOCK+1 ) |
|
680 { |
|
681 #if defined(_DEBUG) |
|
682 RDebug::Printf( "%s %s (%u) calling CancelDeviceLockQuery=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
683 #endif |
|
684 CancelDeviceLockQuery(); |
|
685 } |
|
686 else if ( aMessageUid.iUid == SCP_CMDUID_UNLOCK ) |
|
687 { |
|
688 // For security reasons we must check from the SCP server did this |
|
689 // command originate from it. |
|
690 RSCPClient scpClient; |
|
691 if ( scpClient.Connect() == KErrNone ) |
|
692 { |
|
693 CleanupClosePushL( scpClient ); |
|
694 |
|
695 if ( scpClient.QueryAdminCmd( ESCPCommandUnlockPhone ) ) |
|
696 { |
|
697 // Switch autolock to BG |
|
698 #if defined(_DEBUG) |
|
699 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::HandleMessageL():\ |
|
700 Admin command received, unlocking")); |
|
701 #endif |
|
702 |
|
703 if ( !iLocked ) |
|
704 { |
|
705 #if defined(_DEBUG) |
|
706 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::HandleMessageL():\ |
|
707 Ignoring Unlock message - not locked.")); |
|
708 #endif |
|
709 } |
|
710 else |
|
711 { |
|
712 iLocked = EFalse; |
|
713 HideSoftNotification(); // dismiss all the pending notes |
|
714 DisableWGListChangeEventListening(); |
|
715 UnLockKeys(); |
|
716 iModel->SetLockedL(EFalse); |
|
717 // Disable keyguard after remote unlock |
|
718 RAknKeyLock iKeyLock; |
|
719 TInt tempResult = iKeyLock.Connect(); |
|
720 iKeyLock.DisableKeyLock(); |
|
721 // end Disable keyguard after remote unlock |
|
722 SwitchToPreviousAppL(); |
|
723 } |
|
724 } |
|
725 else |
|
726 { |
|
727 #if defined(_DEBUG) |
|
728 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::HandleMessageL():\ |
|
729 Unauthorized attempt to unlock")); |
|
730 #endif |
|
731 } |
|
732 |
|
733 CleanupStack::PopAndDestroy(); // scpClient |
|
734 } |
|
735 else |
|
736 { |
|
737 #if defined(_DEBUG) |
|
738 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::HandleMessageL():\ |
|
739 Failed to connect to SCP, ignoring unlock-message.")); |
|
740 #endif |
|
741 |
|
742 } |
|
743 } |
|
744 else // aMessageUid.iUid != SCP_CMDUID_UNLOCK |
|
745 { |
|
746 messageResponse = CAknAppUi::HandleMessageL( aClientHandleOfTargetWindowGroup, |
|
747 aMessageUid, |
|
748 aMessageParameters |
|
749 ); |
|
750 } |
|
751 |
|
752 return messageResponse; |
|
753 } |
|
754 |
|
755 |
|
756 // ------------------------------------------------------------------------------ |
|
757 // CAutolockAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) |
|
758 // This function is called by the UIKON framework just before it displays |
|
759 // a menu pane. Its default implementation is empty, and by overriding it, |
|
760 // the application can set the state of menu items dynamically according |
|
761 // to the state of application data. |
|
762 // ------------------------------------------------------------------------------ |
|
763 // |
|
764 void CAutolockAppUi::DynInitMenuPaneL( |
|
765 TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/) |
|
766 { |
|
767 } |
|
768 |
|
769 void CAutolockAppUi::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
770 { |
|
771 #if defined(_DEBUG) |
|
772 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
773 #endif |
|
774 } |
|
775 // ---------------------------------------------------- |
|
776 // CAutolockAppUi::HandleKeyEventL( |
|
777 // const TKeyEvent& aKeyEvent,TEventCode /*aType*/) |
|
778 // ---------------------------------------------------- |
|
779 // |
|
780 TKeyResponse CAutolockAppUi::HandleKeyEventL( |
|
781 const TKeyEvent& aKeyEvent,TEventCode aType) |
|
782 { |
|
783 |
|
784 if ( aKeyEvent.iCode == EKeyBell || (aType == EEventKeyUp && aKeyEvent.iScanCode == EStdKeyDeviceF) || (aKeyEvent.iCode == EKeyDeviceF) ) |
|
785 { |
|
786 if(iLocked) |
|
787 HandleCommandL(ESecUiCmdUnlock); |
|
788 return EKeyWasConsumed; |
|
789 } |
|
790 |
|
791 TBool featureNoPowerkey = FeatureManager::FeatureSupported( KFeatureIdNoPowerkey ); |
|
792 // If power key pressed, tell SysAp about if |
|
793 if( (aKeyEvent.iScanCode == EStdKeyDevice2 && aType == EEventKeyDown ) |
|
794 || (aType == EEventKey && featureNoPowerkey && aKeyEvent.iCode == EKeyNo)) |
|
795 { |
|
796 SendMessageToSysAp(EEikKeyLockPowerKeyPressed); |
|
797 if ( featureNoPowerkey ) |
|
798 { |
|
799 SendMessageToSysAp(EEikKeyLockLightsOnRequest); |
|
800 } |
|
801 } |
|
802 return EKeyWasNotConsumed; |
|
803 } |
|
804 |
|
805 void CAutolockAppUi::SendMessageToSysAp(TInt aMessage) |
|
806 { |
|
807 RWsSession& ws = iEikonEnv->WsSession(); |
|
808 TInt wgId=0; |
|
809 CApaWindowGroupName::FindByAppUid(KSysApUid, ws, wgId); |
|
810 if (wgId) |
|
811 { |
|
812 TWsEvent event; |
|
813 event.SetType(aMessage); |
|
814 event.SetTimeNow(); |
|
815 ws.SendEventToWindowGroup(wgId, event); |
|
816 } |
|
817 } |
|
818 |
|
819 |
|
820 void CAutolockAppUi::HandleCommandL(TInt aCommand) |
|
821 { |
|
822 #if defined(_DEBUG) |
|
823 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::HandleCommandL()")); |
|
824 #endif |
|
825 switch ( aCommand ) |
|
826 { |
|
827 case EEikCmdExit: |
|
828 { |
|
829 #if defined(_DEBUG) |
|
830 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::HandleCommandL() EEikCmdExit")); |
|
831 #endif |
|
832 Exit(); |
|
833 break; |
|
834 } |
|
835 case ESecUiCmdUnlock: |
|
836 { |
|
837 #if defined(_DEBUG) |
|
838 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::HandleCommandL() ESecUiCmdUnlock")); |
|
839 #endif |
|
840 // stop observing emergency call event |
|
841 iEmergencySupportReady = EFalse; |
|
842 iEcsDetector->Reset(); // Ecs queue is cleared; keys up til here are forgotten |
|
843 // ask secuity code |
|
844 CSecurityHandler* handler = new (ELeave) CSecurityHandler(iPhone); |
|
845 CleanupStack::PushL(handler); |
|
846 TSecUi::InitializeLibL(); |
|
847 |
|
848 // Put the lights on when security query is shown |
|
849 SendMessageToSysAp( EEikSecurityQueryLights ); |
|
850 HideSoftNotification(); // dismiss all the pending notes just before asking the unlocking code |
|
851 |
|
852 TRAPD(err, |
|
853 { |
|
854 iDeviceLockQueryStatus = ETrue; |
|
855 if(handler->AskSecCodeInAutoLockL()) |
|
856 { |
|
857 iLocked = EFalse; |
|
858 DisableWGListChangeEventListening(); |
|
859 iDeviceLockQueryStatus = EFalse; |
|
860 UnLockKeys(); |
|
861 iModel->SetLockedL(EFalse); |
|
862 SwitchToPreviousAppL(); |
|
863 } |
|
864 else |
|
865 { // make sure that we will be topmost still |
|
866 iDeviceLockQueryStatus = EFalse; |
|
867 TInt callState; |
|
868 RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, callState ); |
|
869 if ( callState == EPSCTsyCallStateNone && |
|
870 !FeatureManager::FeatureSupported( KFeatureIdProtocolCdma ) ) |
|
871 { |
|
872 TApaTask self(CCoeEnv::Static()->WsSession()); |
|
873 self.SetWgId(CCoeEnv::Static()->RootWin().Identifier()); |
|
874 self.BringToForeground(); |
|
875 TBool featureNoPowerkey = FeatureManager::FeatureSupported( KFeatureIdNoPowerkey ); |
|
876 if ( featureNoPowerkey ) |
|
877 {//set lights on in case user pressed "red button". If he pressed cancel the lights are on anyway so it doesn't matter. |
|
878 SendMessageToSysAp(EEikKeyLockLightsOnRequest); |
|
879 } |
|
880 // we don't want enable lock if call in progress |
|
881 RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, callState ); |
|
882 TInt keyguardDisableState(ECoreAppUIsDisableKeyguardUninitialized); |
|
883 //If there is alarm on the keyguard status is set to disabled. In that case don't enable keyguard as it will be done by SysAp |
|
884 //after the alarm has been disabled/snoozed. Otherwise the alarm CBA is left under keyguard CBA. |
|
885 RProperty::Get( KPSUidCoreApplicationUIs, KCoreAppUIsDisableKeyguard, keyguardDisableState ); |
|
886 if ((callState == EPSCTsyCallStateNone) && (keyguardDisableState != ECoreAppUIsDisableKeyguard)) |
|
887 { |
|
888 RAknKeyLock keylock; |
|
889 if ( keylock.Connect() == KErrNone ) |
|
890 { |
|
891 keylock.EnableAutoLockEmulation(); |
|
892 keylock.Close(); |
|
893 } |
|
894 } |
|
895 } |
|
896 } |
|
897 };) |
|
898 |
|
899 // start observing emergency call event |
|
900 iEmergencySupportReady = ETrue; |
|
901 CleanupStack::PopAndDestroy(handler); // handler |
|
902 TSecUi::UnInitializeLib(); // secui |
|
903 |
|
904 User::LeaveIfError(err); |
|
905 |
|
906 break; |
|
907 } |
|
908 default: |
|
909 break; |
|
910 } |
|
911 } |
|
912 |
|
913 // ---------------------------------------------------- |
|
914 // CAutolockAppUi::SwitchToPreviousAppL() |
|
915 // Activates previous app |
|
916 //---------------------------------------------------- |
|
917 // |
|
918 void CAutolockAppUi::SwitchToPreviousAppL() |
|
919 { |
|
920 #if defined(_DEBUG) |
|
921 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::SwitchToPreviousAppL()")); |
|
922 #endif |
|
923 iEcsDetector->Reset(); // Ecs queue is cleared; keys up til here are forgotten |
|
924 // stop observing phone events |
|
925 iPhoneObserver->Stop(); |
|
926 CAknView* view = View(KAutoLockViewId); |
|
927 if(view) |
|
928 { |
|
929 STATIC_CAST(CAutolockView*, view)->MakeVisible(EFalse); |
|
930 } |
|
931 else |
|
932 { |
|
933 #if defined(_DEBUG) |
|
934 RDebug::Printf( "%s %s (%u) no view ????=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, view ); |
|
935 #endif |
|
936 } |
|
937 // app to background |
|
938 TApaTask self(iCoeEnv->WsSession()); |
|
939 self.SetWgId(iCoeEnv->RootWin().Identifier()); |
|
940 self.SendToBackground(); |
|
941 // flush |
|
942 iCoeEnv->WsSession().Flush(); |
|
943 } |
|
944 // ---------------------------------------------------- |
|
945 // CAutolockAppUi::BringAppToForegroundL() |
|
946 // Activates autolock app |
|
947 //---------------------------------------------------- |
|
948 // |
|
949 void CAutolockAppUi::BringAppToForegroundL() |
|
950 { |
|
951 #if defined(_DEBUG) |
|
952 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::BringAppToForegroundL()")); |
|
953 #endif |
|
954 TBool tarmAdminFlag(EFalse); |
|
955 TBool remotelockState(EFalse); |
|
956 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw )) |
|
957 { |
|
958 tarmAdminFlag = TarmState(); |
|
959 } |
|
960 |
|
961 #ifdef RD_REMOTELOCK |
|
962 TInt autolockState; |
|
963 RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState); |
|
964 remotelockState = (autolockState == ERemoteLocked); |
|
965 #endif//RD_REMOTELOCK |
|
966 // If TARM admin flag is set, bring Autolock to foreground regardless of call state. |
|
967 |
|
968 |
|
969 if(!tarmAdminFlag) |
|
970 { //If phone has been remote locked bring Autolock to foreground regardless of call state. |
|
971 if(!remotelockState) |
|
972 { // check if there is active call |
|
973 TInt callState; |
|
974 RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, callState ); |
|
975 #if defined(_DEBUG) |
|
976 RDebug::Printf( "%s %s (%u) callState=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, callState ); |
|
977 #endif |
|
978 |
|
979 TInt value(EStartupUiPhaseUninitialized); |
|
980 RProperty::Get(KPSUidStartup, KPSStartupUiPhase, value); |
|
981 #if defined(_DEBUG) |
|
982 RDebug::Printf( "%s %s (%u) KPSStartupUiPhase value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, value ); |
|
983 RDebug::Printf( "%s %s (%u) EStartupUiPhaseSystemWelcomeDone=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EStartupUiPhaseSystemWelcomeDone ); |
|
984 #endif |
|
985 if(value<EStartupUiPhaseSystemWelcomeDone && callState == EPSCTsyCallStateNone) |
|
986 { |
|
987 callState = EPSCTsyCallStateNone+1; // so that is unlocks |
|
988 iLocked = EFalse; |
|
989 #if defined(_DEBUG) |
|
990 RDebug::Printf( "%s %s (%u) iLocked=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iLocked ); |
|
991 #endif |
|
992 } |
|
993 else if(value<EStartupUiPhaseSystemWelcomeDone && callState > EPSCTsyCallStateNone) |
|
994 { |
|
995 callState = EPSCTsyCallStateNone+0; // so that is locks |
|
996 #if defined(_DEBUG) |
|
997 RDebug::Printf( "%s %s (%u) new+0 callState=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, callState ); |
|
998 #endif |
|
999 } |
|
1000 if (callState != EPSCTsyCallStateNone ) |
|
1001 { |
|
1002 #if defined(_DEBUG) |
|
1003 RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
1004 #endif |
|
1005 UnLockKeys(); |
|
1006 iModel->SetLockedL(EFalse); |
|
1007 iModel->ResetInactivityTimeout(); |
|
1008 return; |
|
1009 } |
|
1010 } |
|
1011 |
|
1012 } |
|
1013 |
|
1014 |
|
1015 #ifndef __WINS__ |
|
1016 |
|
1017 #ifndef __NO_DOS__ |
|
1018 |
|
1019 /***************************************************** |
|
1020 * Series 60 Customer / ETEL |
|
1021 * Series 60 ETEL API |
|
1022 *****************************************************/ |
|
1023 |
|
1024 // check that device locked in DOS side too |
|
1025 RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice; |
|
1026 RMobilePhone::TMobilePhoneLockInfoV1 lockInfo; |
|
1027 RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo); |
|
1028 |
|
1029 #if defined(_DEBUG) |
|
1030 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::BringAppToForegroundL() GetLockInfo")); |
|
1031 #endif |
|
1032 iWait->SetRequestType(EMobilePhoneGetLockInfo); |
|
1033 iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg); |
|
1034 TInt res = iWait->WaitForRequestL(); |
|
1035 User::LeaveIfError(res); |
|
1036 if (iWait->iStatus == KErrNone) |
|
1037 { |
|
1038 // if not don't lock ui either |
|
1039 #if defined(_DEBUG) |
|
1040 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::BringAppToForegroundL() KErrNone")); |
|
1041 RDebug::Printf( "%s %s (%u) lockInfo.iSetting=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, lockInfo.iSetting ); |
|
1042 RDebug::Printf( "%s %s (%u) RMobilePhone::ELockSetDisabled=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, RMobilePhone::ELockSetDisabled ); |
|
1043 #endif |
|
1044 if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled) |
|
1045 { |
|
1046 iModel->SetLockedL(EFalse); |
|
1047 UnLockKeys(); |
|
1048 return; |
|
1049 } |
|
1050 } |
|
1051 #endif |
|
1052 |
|
1053 #endif |
|
1054 |
|
1055 // in case Telephone-app is topmost, then the user is confused because he sees but can't use it. |
|
1056 // therefore it's required to hide it, by sending to background. ETMA-7M8A2Y 20090105 |
|
1057 if ( AknLayoutUtils::PenEnabled() ) |
|
1058 { |
|
1059 TApaTaskList apaTaskList(CCoeEnv::Static()->WsSession()); |
|
1060 |
|
1061 TApaTask apaTask = apaTaskList.FindApp(KPhoneAppUid); |
|
1062 if (apaTask.Exists()) |
|
1063 { |
|
1064 #if defined(_DEBUG) |
|
1065 RDebug::Print(_L("(AUTOLOCK)CAknKeyLockControl::EnableKeylock() Bring phone to background")); |
|
1066 #endif |
|
1067 // Bring phone to background |
|
1068 apaTask.SendToBackground(); |
|
1069 } |
|
1070 } |
|
1071 #if defined(_DEBUG) |
|
1072 RDebug::Printf( "%s %s (%u) iPhoneObserver->Start=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
1073 #endif |
|
1074 |
|
1075 iPhoneObserver->Start(); |
|
1076 iLocked = ETrue; |
|
1077 // app to foreground |
|
1078 TApaTask self(iCoeEnv->WsSession()); |
|
1079 self.SetWgId(iCoeEnv->RootWin().Identifier()); |
|
1080 self.BringToForeground(); |
|
1081 ActivateLocalViewL(KAutoLockViewId); |
|
1082 CAknView* view = View(KAutoLockViewId); |
|
1083 if(view) |
|
1084 { |
|
1085 TRect aInitialRect; |
|
1086 STATIC_CAST(CAutolockView*, view)->HandleCall(0x17, aInitialRect); |
|
1087 STATIC_CAST(CAutolockView*, view)->MakeVisible(ETrue); |
|
1088 } |
|
1089 else |
|
1090 { |
|
1091 #if defined(_DEBUG) |
|
1092 RDebug::Printf( "%s %s (%u) no view ????=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, view ); |
|
1093 #endif |
|
1094 } |
|
1095 } |
|
1096 |
|
1097 // ---------------------------------------------------- |
|
1098 // CAutolockAppUi::LockKeysL() |
|
1099 // locks keys |
|
1100 //---------------------------------------------------- |
|
1101 // |
|
1102 void CAutolockAppUi::LockKeysL() |
|
1103 { |
|
1104 #if defined(_DEBUG) |
|
1105 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::LockKeysL()")); |
|
1106 #endif |
|
1107 // capture appkey & volume key |
|
1108 if (!iAppKey) |
|
1109 { |
|
1110 RWindowGroup& groupWin=iCoeEnv->RootWin(); |
|
1111 iAppKey = groupWin.CaptureKeyUpAndDowns(EStdKeyApplication0, 0, 0); // Capture app key |
|
1112 } |
|
1113 TInt gripStatus = EPSHWRMGripClosed; |
|
1114 RProperty::Get( KPSUidHWRM, KHWRMGripStatus, gripStatus ); |
|
1115 #if defined(_DEBUG) |
|
1116 RDebug::Printf( "%s %s (%u) gripStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, gripStatus ); |
|
1117 #endif |
|
1118 if(gripStatus==EPSHWRMGripOpen) |
|
1119 ForceOrientation(0); |
|
1120 else |
|
1121 ForceOrientation(1); |
|
1122 LockSideKeyL(); |
|
1123 } |
|
1124 // ---------------------------------------------------- |
|
1125 // CAutolockAppUi::UnLockKeys() |
|
1126 // unlocks keys |
|
1127 //---------------------------------------------------- |
|
1128 // |
|
1129 void CAutolockAppUi::UnLockKeys() |
|
1130 { |
|
1131 #if defined(_DEBUG) |
|
1132 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::UnLockKeysL()")); |
|
1133 #endif |
|
1134 // uncapture appkey |
|
1135 if (iAppKey) |
|
1136 { |
|
1137 RWindowGroup& groupWin=iCoeEnv->RootWin(); |
|
1138 groupWin.CancelCaptureKeyUpAndDowns(iAppKey); |
|
1139 iAppKey = 0; |
|
1140 } |
|
1141 UnLockSideKey(); |
|
1142 } |
|
1143 // ---------------------------------------------------- |
|
1144 // CAutolockAppUi::LockSideKeyL() |
|
1145 // unlocks side-key |
|
1146 //---------------------------------------------------- |
|
1147 // |
|
1148 void CAutolockAppUi::LockSideKeyL() |
|
1149 { |
|
1150 #if defined(_DEBUG) |
|
1151 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::LockSideKeyL()")); |
|
1152 #endif |
|
1153 if (!iSideKey1) |
|
1154 { |
|
1155 RWindowGroup& groupWin=iCoeEnv->RootWin(); |
|
1156 iSideKey1 = groupWin.CaptureKey(EKeyDeviceF,0,0); // EKeySide -> EKeyDeviceF |
|
1157 #if defined(_DEBUG) |
|
1158 RDebug::Printf( "%s %s (%u) capturing EStdKeyDeviceF=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EStdKeyDeviceF ); |
|
1159 #endif |
|
1160 iSideKey2 = groupWin.CaptureKeyUpAndDowns(EStdKeyDeviceF, 0, 0); // EStdKeyDevice6 -> EStdKeyDeviceF |
|
1161 } |
|
1162 } |
|
1163 |
|
1164 // ------------------------------------------------------------------------------------------------------------- |
|
1165 // part of emergency call handling when telephony+devicelock is active |
|
1166 // this solution is meant only for 3.1 and 3.2 |
|
1167 void CAutolockAppUi::HandleEcsEvent( CAknEcsDetector* aEcsDetector, CAknEcsDetector::TState aState ) |
|
1168 { |
|
1169 switch ( aState ) |
|
1170 { |
|
1171 case CAknEcsDetector::ECompleteMatchThenSendKey: |
|
1172 // Do nothing since note will be removed on ECallAttempted event |
|
1173 break; |
|
1174 case CAknEcsDetector::ECompleteMatch: |
|
1175 iEcsNote->SetEmergencyNumber( aEcsDetector->CurrentMatch() ); |
|
1176 |
|
1177 // Tell sysAp to switch lights on |
|
1178 SendMessageToSysAp( EEikEcsQueryLights ); |
|
1179 |
|
1180 iEcsNote->ShowNote(); |
|
1181 iEcsNote->iNoteOnScreen =ETrue; |
|
1182 break; |
|
1183 case CAknEcsDetector::EPartialMatch: |
|
1184 iEcsNote->SleepNote(); |
|
1185 break; |
|
1186 case CAknEcsDetector::ECallAttempted: |
|
1187 iEcsNote->SleepNote(); |
|
1188 break; |
|
1189 case CAknEcsDetector::EEmpty: |
|
1190 iEcsNote->SleepNote(); |
|
1191 break; |
|
1192 case CAknEcsDetector::ENoMatch: |
|
1193 iEcsNote->SleepNote(); |
|
1194 break; |
|
1195 default: |
|
1196 break; |
|
1197 } |
|
1198 } |
|
1199 |
|
1200 CEcsNote::CEcsNote() : iNoteOnScreen( EFalse ) |
|
1201 {} |
|
1202 |
|
1203 void CEcsNote::ConstructSleepingNoteL(TInt aResourceId) |
|
1204 { |
|
1205 CAknNoteDialog::ConstructSleepingDialogL(aResourceId); |
|
1206 } |
|
1207 |
|
1208 TInt CEcsNote::ShowNote() |
|
1209 { |
|
1210 ReportUserActivity(); |
|
1211 iTimeoutInMicroseconds = CAknNoteDialog::EUndefinedTimeout; |
|
1212 iTone = CAknNoteDialog::ENoTone; |
|
1213 if (!iNoteOnScreen) |
|
1214 { |
|
1215 return RouseSleepingDialog(); |
|
1216 } |
|
1217 // return value not used |
|
1218 else |
|
1219 // return value not used |
|
1220 return NULL; |
|
1221 } |
|
1222 |
|
1223 void CEcsNote::SleepNote() |
|
1224 { |
|
1225 if (iNoteOnScreen) |
|
1226 ExitSleepingDialog(); // Causes flicker to other notes if called when note is not on screen |
|
1227 iNoteOnScreen = EFalse; |
|
1228 } |
|
1229 |
|
1230 TKeyResponse CEcsNote::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) |
|
1231 { |
|
1232 return EKeyWasConsumed; |
|
1233 } |
|
1234 |
|
1235 void CEcsNote::SetEmergencyNumber( const TDesC& aMatchedNumber ) |
|
1236 { |
|
1237 TRect screen(iAvkonAppUi->ApplicationRect()); |
|
1238 TAknLayoutRect mainPane; |
|
1239 mainPane.LayoutRect(screen, AKN_LAYOUT_WINDOW_main_pane(screen, 0, 1, 1)); |
|
1240 TAknLayoutRect popupNoteWindow; |
|
1241 AknLayoutUtils::TAknCbaLocation cbaLocation( AknLayoutUtils::CbaLocation() ); |
|
1242 TInt variety( 0 ); |
|
1243 if ( cbaLocation == AknLayoutUtils::EAknCbaLocationRight ) |
|
1244 { |
|
1245 variety = 5; |
|
1246 } |
|
1247 else if ( cbaLocation == AknLayoutUtils::EAknCbaLocationLeft ) |
|
1248 { |
|
1249 variety = 8; |
|
1250 } |
|
1251 else |
|
1252 { |
|
1253 variety = 2; |
|
1254 } |
|
1255 |
|
1256 popupNoteWindow.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon::popup_note_window( variety )); |
|
1257 TAknLayoutText textRect; |
|
1258 textRect.LayoutText(popupNoteWindow.Rect(), AKN_LAYOUT_TEXT_Note_pop_up_window_texts_Line_1(4)); |
|
1259 |
|
1260 // Size of a temporary buffer that contains new lines, spaces and |
|
1261 // emergency number for a note. |
|
1262 TBuf16<KAknEcsMaxMatchingLength+80> number; |
|
1263 number.Append('\n'); |
|
1264 number.Append('\n'); |
|
1265 |
|
1266 TInt spaceCharWidthInPixels = textRect.Font()->CharWidthInPixels(' '); |
|
1267 if (spaceCharWidthInPixels < 1) |
|
1268 { |
|
1269 // Avoid divide by zero situation even the space char would have zero length. |
|
1270 spaceCharWidthInPixels = 1; |
|
1271 } |
|
1272 |
|
1273 TInt length = (textRect.TextRect().Width() - textRect.Font()->TextWidthInPixels(aMatchedNumber)) |
|
1274 / spaceCharWidthInPixels; |
|
1275 |
|
1276 const TInt matchedNumberLength = aMatchedNumber.Length(); |
|
1277 const TInt numberLength = number.Length(); |
|
1278 const TInt numberMaxLength = number.MaxLength(); |
|
1279 |
|
1280 if ( numberLength + length + matchedNumberLength > numberMaxLength) |
|
1281 { |
|
1282 // To make sure that buffer overflow does not happen. |
|
1283 length = numberMaxLength - numberLength - matchedNumberLength; |
|
1284 } |
|
1285 for (int i = 0; i < length ; i++) |
|
1286 { |
|
1287 number.Append(' '); |
|
1288 } |
|
1289 |
|
1290 number.Append(aMatchedNumber); |
|
1291 TRAP_IGNORE(SetTextL(number)); |
|
1292 |
|
1293 } |
|
1294 |
|
1295 // ------------------------------------------------------------------------------------------------------------- |
|
1296 |
|
1297 // ---------------------------------------------------- |
|
1298 // CAutolockAppUi::UnLockSideKey() |
|
1299 // unlocks side-key |
|
1300 //---------------------------------------------------- |
|
1301 // |
|
1302 void CAutolockAppUi::UnLockSideKey() |
|
1303 { |
|
1304 #if defined(_DEBUG) |
|
1305 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::UnLockSideKeyL()")); |
|
1306 #endif |
|
1307 if (iSideKey1) |
|
1308 { |
|
1309 RWindowGroup& groupWin=iCoeEnv->RootWin(); |
|
1310 groupWin.CancelCaptureKeyUpAndDowns(iSideKey2); |
|
1311 groupWin.CancelCaptureKey(iSideKey1); |
|
1312 iSideKey1 = 0; |
|
1313 iSideKey2 = 0; |
|
1314 } |
|
1315 } |
|
1316 |
|
1317 |
|
1318 // |
|
1319 // --------------------------------------------------------- |
|
1320 // CAutolockAppUi::HandleScreenDeviceChangedL() |
|
1321 // Handles screen layout changes, called by CCoeAppUi |
|
1322 // --------------------------------------------------------- |
|
1323 // |
|
1324 void CAutolockAppUi::HandleScreenDeviceChangedL() |
|
1325 { |
|
1326 CAknAppUiBase::HandleScreenDeviceChangedL(); |
|
1327 //get autolock view from CAknViewAppUi |
|
1328 CAknView* view = View(KAutoLockViewId); |
|
1329 if(view) |
|
1330 { |
|
1331 STATIC_CAST(CAutolockView*, view)->ScreenDeviceChanged(); |
|
1332 } |
|
1333 |
|
1334 } |
|
1335 |
|
1336 // |
|
1337 // ---------------------------------------------------------- |
|
1338 // CAutolockAppUi::IsPinBlocked() |
|
1339 // Checks whether PIN1/UPIN is blocked |
|
1340 // ---------------------------------------------------------- |
|
1341 // |
|
1342 TBool CAutolockAppUi::IsPinBlocked() |
|
1343 { |
|
1344 RMmCustomAPI::TSecurityCodeType secCodeType; |
|
1345 TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma )); |
|
1346 TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin )); |
|
1347 |
|
1348 if(wcdmaSupported || upinSupported) |
|
1349 { |
|
1350 RMobilePhone::TMobilePhoneSecurityCode activePin; |
|
1351 iCustomPhone.GetActivePin(activePin); |
|
1352 if(activePin == RMobilePhone::ESecurityUniversalPin) |
|
1353 secCodeType = RMmCustomAPI::ESecurityUniversalPin; |
|
1354 else |
|
1355 secCodeType = RMmCustomAPI::ESecurityCodePin1; |
|
1356 } |
|
1357 else |
|
1358 secCodeType = RMmCustomAPI::ESecurityCodePin1; |
|
1359 |
|
1360 TBool isBlocked = EFalse; |
|
1361 iCustomPhone.IsBlocked(secCodeType,isBlocked); |
|
1362 #if defined(_DEBUG) |
|
1363 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::IsPinBlocked result: %d"), isBlocked); |
|
1364 #endif |
|
1365 return isBlocked; |
|
1366 } |
|
1367 |
|
1368 // |
|
1369 // ---------------------------------------------------------- |
|
1370 // CAutolockAppUi::HandleWsEventL() |
|
1371 // |
|
1372 // ---------------------------------------------------------- |
|
1373 // |
|
1374 void CAutolockAppUi::HandleWsEventL( const TWsEvent& aEvent,CCoeControl* aDestination ) |
|
1375 { |
|
1376 const TInt type = aEvent.Type(); |
|
1377 #if defined(_DEBUG) |
|
1378 RDebug::Printf( "%s %s (%u) type=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, type ); |
|
1379 #endif |
|
1380 |
|
1381 switch ( type ) |
|
1382 { |
|
1383 case KAknFullOrPartialForegroundLost: // partial or full fg lost |
|
1384 if( iIncallBubble ) |
|
1385 { |
|
1386 #if defined(_DEBUG) |
|
1387 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::HandleWsEventL: DISABLE call bubble")); |
|
1388 #endif |
|
1389 iIncallBubble->SetIncallBubbleAllowedInIdleL( EFalse ); |
|
1390 } |
|
1391 break; |
|
1392 case KAknFullOrPartialForegroundGained: // partial or full fg gained |
|
1393 if( iIncallBubble ) |
|
1394 { |
|
1395 #if defined(_DEBUG) |
|
1396 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::HandleWsEventL: ENABLE call bubble")); |
|
1397 #endif |
|
1398 CAknView* view = View(KAutoLockViewId); |
|
1399 if(view) |
|
1400 { |
|
1401 TRect aInitialRect; |
|
1402 STATIC_CAST(CAutolockView*, view)->HandleCall(0x1A, aInitialRect); |
|
1403 } |
|
1404 |
|
1405 iIncallBubble->SetIncallBubbleAllowedInIdleL( ETrue ); |
|
1406 } |
|
1407 break; |
|
1408 case EEventWindowGroupListChanged: |
|
1409 HandleWindowGroupListChange(); |
|
1410 break; |
|
1411 case EEventPointer: |
|
1412 case EEventDragDrop: |
|
1413 { |
|
1414 TInt gripStatus = EPSHWRMGripClosed; |
|
1415 RProperty::Get( KPSUidHWRM, KHWRMGripStatus, gripStatus ); |
|
1416 #if defined(_DEBUG) |
|
1417 RDebug::Printf( "%s %s (%u) 1 gripStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, gripStatus ); |
|
1418 RDebug::Printf( "%s %s (%u) EPSHWRMGripClosed=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EPSHWRMGripClosed ); |
|
1419 #endif |
|
1420 if(gripStatus==EPSHWRMGripStatusUninitialized) |
|
1421 { |
|
1422 gripStatus=EPSHWRMGripClosed; |
|
1423 #if defined(_DEBUG) |
|
1424 RDebug::Printf( "%s %s (%u) new gripStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, gripStatus ); |
|
1425 #endif |
|
1426 } |
|
1427 TInt callState = 0; |
|
1428 RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, callState ); |
|
1429 #if defined(_DEBUG) |
|
1430 RDebug::Printf( "%s %s (%u) callState=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, callState ); |
|
1431 #endif |
|
1432 TPointerEvent *pointer = aEvent.Pointer(); |
|
1433 CAknView* view = View(KAutoLockViewId); |
|
1434 if(view) |
|
1435 { |
|
1436 STATIC_CAST(CAutolockView*, view)->ScreenDeviceChanged(); |
|
1437 TRect aInitialRect; |
|
1438 STATIC_CAST(CAutolockView*, view)->HandleCall(0x1, aInitialRect); |
|
1439 if(aCallButtonRect.iBr.iX==0) // initialize if not done already |
|
1440 aCallButtonRect = TRect (aInitialRect); |
|
1441 } |
|
1442 if ( callState != EPSCTsyCallStateNone && callState != EPSCTsyCallStateUninitialized ) |
|
1443 { |
|
1444 if(pointer->iType==TPointerEvent::EButton1Down) |
|
1445 { |
|
1446 TPoint iPosition = pointer->iPosition; |
|
1447 #if defined(_DEBUG) |
|
1448 RDebug::Printf( "%s %s (%u) iPosition.iX=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iPosition.iX ); |
|
1449 RDebug::Printf( "%s %s (%u) aCallButtonRect.iBr.iX=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aCallButtonRect.iBr.iX ); |
|
1450 RDebug::Printf( "%s %s (%u) iPosition.iY=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iPosition.iY ); |
|
1451 RDebug::Printf( "%s %s (%u) aCallButtonRect.iBr.iY=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aCallButtonRect.iBr.iY ); |
|
1452 #endif |
|
1453 if(aCallButtonRect.iBr.iX<iPosition.iX && iPosition.iX<aCallButtonRect.iBr.iX+aCallButtonRect.iTl.iX && |
|
1454 ( (gripStatus==EPSHWRMGripClosed && iPosition.iY>400) || (gripStatus!=EPSHWRMGripClosed && aCallButtonRect.iBr.iY<iPosition.iY && iPosition.iY<aCallButtonRect.iBr.iY+aCallButtonRect.iTl.iY ) ) |
|
1455 ) |
|
1456 { |
|
1457 #if defined(_DEBUG) |
|
1458 RDebug::Printf( "%s %s (%u) iGotEventDownDuringCall=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iGotEventDownDuringCall ); |
|
1459 #endif |
|
1460 iGotEventDownDuringCall=1; |
|
1461 } |
|
1462 } |
|
1463 if(pointer->iType==TPointerEvent::EButton1Up) |
|
1464 { |
|
1465 TPoint iPosition = pointer->iPosition; |
|
1466 // touching at any point inside and below the BigRedButton. This is to handle the case where another dialog overlaps |
|
1467 #if defined(_DEBUG) |
|
1468 RDebug::Printf( "%s %s (%u) iGotEventDownDuringCall=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iGotEventDownDuringCall ); |
|
1469 RDebug::Printf( "%s %s (%u) iPosition.iX=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iPosition.iX ); |
|
1470 RDebug::Printf( "%s %s (%u) aCallButtonRect.iBr.iX=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aCallButtonRect.iBr.iX ); |
|
1471 RDebug::Printf( "%s %s (%u) iPosition.iY=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iPosition.iY ); |
|
1472 RDebug::Printf( "%s %s (%u) aCallButtonRect.iBr.iY=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aCallButtonRect.iBr.iY ); |
|
1473 #endif |
|
1474 if(iGotEventDownDuringCall==1 && aCallButtonRect.iBr.iX<iPosition.iX && iPosition.iX<aCallButtonRect.iBr.iX+aCallButtonRect.iTl.iX && |
|
1475 ( (gripStatus==EPSHWRMGripClosed && iPosition.iY>400) || (gripStatus!=EPSHWRMGripClosed && aCallButtonRect.iBr.iY<iPosition.iY && iPosition.iY<aCallButtonRect.iBr.iY+aCallButtonRect.iTl.iY ) ) |
|
1476 ) |
|
1477 { |
|
1478 // on some devices, simulating End-Key might not end the call. First, try the API |
|
1479 RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, callState ); |
|
1480 #if defined(_DEBUG) |
|
1481 RDebug::Printf( "%s %s (%u) callState=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, callState ); |
|
1482 #endif |
|
1483 if ( callState != EPSCTsyCallStateNone && callState != EPSCTsyCallStateUninitialized ) |
|
1484 { |
|
1485 RTelServer telServer; |
|
1486 RMobilePhone mPhone; |
|
1487 User::LeaveIfError(telServer.Connect()); |
|
1488 TInt err; |
|
1489 err = telServer.LoadPhoneModule(KMmTsyModuleName); |
|
1490 if (err != KErrNone && err != KErrAlreadyExists) |
|
1491 User::Leave(err); |
|
1492 User::LeaveIfError(mPhone.Open(telServer, KMmTsyPhoneName)); |
|
1493 CleanupClosePushL(mPhone); |
|
1494 RMobileLine mLine; |
|
1495 TPtrC lineName; |
|
1496 lineName.Set(KMmTsyVoice1LineName); |
|
1497 User::LeaveIfError(mLine.Open(mPhone, lineName)); |
|
1498 CleanupClosePushL(mLine); |
|
1499 |
|
1500 TInt count(0); |
|
1501 User::LeaveIfError(mLine.EnumerateCall(count)); |
|
1502 #if defined(_DEBUG) |
|
1503 RDebug::Printf( "%s %s (%u) count=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, count ); |
|
1504 #endif |
|
1505 for (TInt jj = 0; jj < count; jj++) |
|
1506 { |
|
1507 RLine::TCallInfo cinfo; |
|
1508 User::LeaveIfError(mLine.GetCallInfo(jj, cinfo)); |
|
1509 RMobileCall mCall; |
|
1510 User::LeaveIfError(mCall.OpenExistingCall(mLine, cinfo.iCallName)); |
|
1511 #if defined(_DEBUG) |
|
1512 RDebug::Printf( "%s %s (%u) calling mCall.HangUp 0=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
1513 #endif |
|
1514 mCall.HangUp(); // this gives an error, but succeeds |
|
1515 } |
|
1516 CleanupStack::PopAndDestroy(&mLine); |
|
1517 CleanupStack::PopAndDestroy(&mPhone); |
|
1518 } |
|
1519 User::After(100000); // give time for the call to end |
|
1520 #if defined(_DEBUG) |
|
1521 RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, callState ); |
|
1522 RDebug::Printf( "%s %s (%u) callState=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, callState ); |
|
1523 #endif |
|
1524 if ( callState != EPSCTsyCallStateNone && callState != EPSCTsyCallStateUninitialized ) |
|
1525 { |
|
1526 // send End key to Telephony to end the call. This works for GSM and VOIP |
|
1527 #if defined(_DEBUG) |
|
1528 RDebug::Printf( "%s %s (%u) sending EStdKeyNo=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EStdKeyNo ); |
|
1529 #endif |
|
1530 TRawEvent event; |
|
1531 event.Set(TRawEvent::EKeyDown, EStdKeyNo); |
|
1532 iEikonEnv->WsSession().SimulateRawEvent(event); |
|
1533 User::After(1000); |
|
1534 event.Set(TRawEvent::EKeyUp, EStdKeyNo); |
|
1535 iEikonEnv->WsSession().SimulateRawEvent(event); |
|
1536 User::After(100000); // give time for the call to end |
|
1537 } |
|
1538 } |
|
1539 iGotEventDownDuringCall=0; // even if outside the touch area |
|
1540 aCallButtonRect.iBr.iX = 0; |
|
1541 } |
|
1542 } |
|
1543 } |
|
1544 break; |
|
1545 case EEventKeyUp: // on touch devices, this happens only for the switch-key, which should turn on the lights. |
|
1546 case EEventKey: |
|
1547 case EEventKeyDown: |
|
1548 if(iLocked) |
|
1549 { // need to capture the switch-key for the case activeCall because Autolock stays on top, even over Akn |
|
1550 TKeyEvent *key = aEvent.Key(); |
|
1551 #if defined(_DEBUG) |
|
1552 RDebug::Printf( "%s %s (%u) key->iCode=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, key->iCode ); |
|
1553 RDebug::Printf( "%s %s (%u) key->iScanCode=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, key->iScanCode ); |
|
1554 #endif |
|
1555 if ( (key->iScanCode == EStdKeyDeviceF) || (key->iCode == EKeyDeviceF) ) |
|
1556 { |
|
1557 #if defined(_DEBUG) |
|
1558 RDebug::Printf( "%s %s (%u) good key=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
1559 #endif |
|
1560 RWsSession& ws = iEikonEnv->WsSession(); |
|
1561 TApaTaskList tasklist( ws ); |
|
1562 TApaTask capserver = tasklist.FindApp( KAknCapServerUid ); |
|
1563 if( capserver.Exists() ) |
|
1564 { |
|
1565 #if defined(_DEBUG) |
|
1566 RDebug::Printf( "%s %s (%u) found KAknCapServerUid=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, KAknCapServerUid ); |
|
1567 #endif |
|
1568 capserver.SendKey( *key ); |
|
1569 } |
|
1570 SendMessageToSysAp( EEikSecurityQueryLights ); |
|
1571 } |
|
1572 } |
|
1573 break; |
|
1574 default: |
|
1575 iGotEventDownDuringCall=0; // any other event invalidates the Press inside the BigRedButton |
|
1576 break; |
|
1577 } |
|
1578 |
|
1579 // All events are sent to base class. |
|
1580 CAknViewAppUi::HandleWsEventL( aEvent, aDestination ); |
|
1581 |
|
1582 // part of emergency call handling when telephony+devicelock is active |
|
1583 // this solution is meant only for 3.1 and 3.2 |
|
1584 // Emergency detector only handles key down events |
|
1585 if ( iEmergencySupportReady ) |
|
1586 iEcsDetector->HandleWsEventL( aEvent, aDestination); |
|
1587 #if defined(_DEBUG) |
|
1588 RDebug::Printf( "%s %s (%u) 0=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
1589 #endif |
|
1590 } |
|
1591 |
|
1592 TBool CAutolockAppUi::DeviceLockQueryStatus() |
|
1593 { |
|
1594 return iDeviceLockQueryStatus; |
|
1595 } |
|
1596 |
|
1597 TBool CAutolockAppUi::DeviceLockStatus() |
|
1598 { |
|
1599 return iLocked; |
|
1600 } |
|
1601 |
|
1602 void CAutolockAppUi::ForceOrientation(TInt value) |
|
1603 { |
|
1604 #if defined(_DEBUG) |
|
1605 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, value ); |
|
1606 #endif |
|
1607 if(value==1) |
|
1608 { |
|
1609 SetOrientationL( EAppUiOrientationLandscape ); |
|
1610 SetOrientationL( EAppUiOrientationPortrait ); |
|
1611 } |
|
1612 if(value==0) |
|
1613 { |
|
1614 SetOrientationL( EAppUiOrientationPortrait ); |
|
1615 SetOrientationL( EAppUiOrientationLandscape ); |
|
1616 } |
|
1617 aCallButtonRect.iBr.iX = 0; |
|
1618 #if defined(_DEBUG) |
|
1619 RDebug::Printf( "%s %s (%u) done value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, value ); |
|
1620 #endif |
|
1621 } |
|
1622 |
|
1623 void CAutolockAppUi::CancelDeviceLockQuery() |
|
1624 { |
|
1625 #if defined(_DEBUG) |
|
1626 RDebug::Printf( "%s %s (%u) 0=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
1627 #endif |
|
1628 TRawEvent rawEvent; |
|
1629 rawEvent.Set( TRawEvent::EKeyDown, KCancelKeyScanCode ); |
|
1630 iCoeEnv->WsSession().SimulateRawEvent( rawEvent ); |
|
1631 rawEvent.Set( TRawEvent::EKeyUp, KCancelKeyScanCode ); |
|
1632 iCoeEnv->WsSession().SimulateRawEvent( rawEvent ); |
|
1633 } |
|
1634 |
|
1635 TBool CAutolockAppUi::DeviceFpsLock(TInt iStatus) |
|
1636 { |
|
1637 if(iStatus) |
|
1638 HandleCommandL(ESecUiCmdUnlock); |
|
1639 else |
|
1640 iModel->SetLockedL(ETimerLocked); |
|
1641 return ETrue; |
|
1642 } |
|
1643 void CAutolockAppUi::HandleWindowGroupListChange() |
|
1644 { |
|
1645 #if defined(_DEBUG) |
|
1646 RDebug::Printf( "%s %s (%u) iLocked=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iLocked ); |
|
1647 #endif |
|
1648 if ( !iLocked ) |
|
1649 { |
|
1650 // System is not locked, make sure app is not on the foreground. |
|
1651 if ( !iCoeEnv->RootWin().OrdinalPosition() ) |
|
1652 { |
|
1653 CAknSgcClient::MoveApp( |
|
1654 iCoeEnv->RootWin().Identifier(), |
|
1655 ESgcMoveAppToBackground ); |
|
1656 } |
|
1657 } |
|
1658 else |
|
1659 { |
|
1660 CAknView* view = View(KAutoLockViewId); |
|
1661 if(view) |
|
1662 { |
|
1663 TRect aInitialRect; |
|
1664 STATIC_CAST(CAutolockView*, view)->HandleCall(0x10, aInitialRect); |
|
1665 if(aCallButtonRect.iBr.iX==0) // initialize if not done already |
|
1666 aCallButtonRect = TRect (aInitialRect); |
|
1667 } |
|
1668 // So now system is locked. When call is not ongoing, autolock should |
|
1669 // be on the foreground. |
|
1670 TInt callState = 0; |
|
1671 RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, callState ); |
|
1672 if ( callState == EPSCTsyCallStateNone || |
|
1673 callState == EPSCTsyCallStateUninitialized ) |
|
1674 { |
|
1675 // No calls ongoing. |
|
1676 if ( iCoeEnv->RootWin().OrdinalPosition() > 0 ) |
|
1677 { |
|
1678 // Not on foreground |
|
1679 CAknSgcClient::MoveApp( |
|
1680 iCoeEnv->RootWin().Identifier(), |
|
1681 ESgcMoveAppToForeground ); |
|
1682 } |
|
1683 } |
|
1684 } |
|
1685 } |
|
1686 |
|
1687 TBool CAutolockAppUi::TarmState() |
|
1688 { |
|
1689 TBool ret(EFalse); |
|
1690 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw )) |
|
1691 { |
|
1692 // Get the TARM admin flag value |
|
1693 TInt tarmFlag; |
|
1694 TInt tRet = RProperty::Get( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag ); |
|
1695 |
|
1696 if ( tRet != KErrNone ) |
|
1697 { |
|
1698 #if defined(_DEBUG) |
|
1699 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::BringAppToForegroundL(): Warning: failed to get TARM Admin Flag state")); |
|
1700 #endif |
|
1701 } |
|
1702 else |
|
1703 { |
|
1704 #if defined(_DEBUG) |
|
1705 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::BringAppToForegroundL(): TARM flag: %d"), |
|
1706 tarmFlag ); |
|
1707 #endif |
|
1708 } |
|
1709 |
|
1710 // Unset the admin flag if set |
|
1711 if ( tarmFlag & KSCPFlagAdminLock ) |
|
1712 { |
|
1713 ret = ETrue; |
|
1714 TInt tRet = RProperty::Get( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag ); |
|
1715 |
|
1716 if ( tRet == KErrNone ) |
|
1717 { |
|
1718 tarmFlag &= ~KSCPFlagAdminLock; |
|
1719 tRet = RProperty::Set( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag ); |
|
1720 } |
|
1721 |
|
1722 if ( tRet != KErrNone ) |
|
1723 { |
|
1724 #if defined(_DEBUG) |
|
1725 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::BringAppToForegroundL(): FAILED to unset TARM Admin Flag")); |
|
1726 #endif |
|
1727 } |
|
1728 } |
|
1729 |
|
1730 } |
|
1731 #if defined(_DEBUG) |
|
1732 RDebug::Printf( "%s %s (%u) ret=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ret ); |
|
1733 #endif |
|
1734 return ret; |
|
1735 } |
|
1736 |
|
1737 // --------------------------------------------------------- |
|
1738 // CAutolockAppUi::HiddenReset() |
|
1739 // --------------------------------------------------------- |
|
1740 TBool CAutolockAppUi::HiddenReset() |
|
1741 { |
|
1742 #if defined(_DEBUG) |
|
1743 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::HiddenReset() begin")); |
|
1744 #endif |
|
1745 |
|
1746 TBool ret_val ( EFalse ); |
|
1747 TInt startupReason(ENormalStartup); |
|
1748 TInt errorCode(KErrNone); |
|
1749 |
|
1750 RProperty::Get(KPSUidStartup, KPSStartupReason, startupReason); |
|
1751 |
|
1752 if ( errorCode != KErrNone ) |
|
1753 { |
|
1754 #if defined(_DEBUG) |
|
1755 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::HiddenReset() error getting startup reason")); |
|
1756 #endif |
|
1757 } |
|
1758 ret_val = (startupReason != ENormalStartup); |
|
1759 #if defined(_DEBUG) |
|
1760 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::HiddenReset() END: %d"), ret_val); |
|
1761 #endif |
|
1762 return ret_val; |
|
1763 } |
|
1764 void CAutolockAppUi::EnableWGListChangeEventListening() |
|
1765 { |
|
1766 #if defined(_DEBUG) |
|
1767 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::EnableWGListChangeEventListening()")); |
|
1768 #endif |
|
1769 RWindowGroup& rootWin = iCoeEnv->RootWin(); |
|
1770 rootWin.EnableGroupListChangeEvents(); |
|
1771 rootWin.EnableScreenChangeEvents(); |
|
1772 } |
|
1773 void CAutolockAppUi::DisableWGListChangeEventListening() |
|
1774 { |
|
1775 #if defined(_DEBUG) |
|
1776 RDebug::Print(_L("(AUTOLOCK)CAutolockAppUi::DisableWGListChangeEventListening()")); |
|
1777 #endif |
|
1778 RWindowGroup& rootWin = iCoeEnv->RootWin(); |
|
1779 rootWin.DisableGroupListChangeEvents(); |
|
1780 rootWin.DisableScreenChangeEvents(); |
|
1781 } |
|
1782 // End of File |
|