1 /* |
|
2 * Copyright (c) 2007 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: Devicelock UI |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "lockappdevicelockcontrol.h" |
|
20 #include "lockappdevicelockcontainer.h" |
|
21 #include "lockappstatecontrolinterface.h" |
|
22 #include "lockapppubsubobserver.h" |
|
23 #include "lockappcenrepobserver.h" |
|
24 #include "lockapputils.h" |
|
25 #include "lockappwait.h" |
|
26 #include "lockappkeycapturecontroller.h" |
|
27 |
|
28 #include <lockapp.rsg> // general avkon resources |
|
29 #include <avkon.rsg> // general avkon resources |
|
30 #include <aknnotpi.rsg> // keyguard spesific resources |
|
31 #include <AknUtils.h> |
|
32 #include <akntitle.h> // CAknTitlePane |
|
33 #include <activitymanager.h> |
|
34 #include <e32property.h> |
|
35 #include <etelmm.h> |
|
36 #include <mmtsy_names.h> |
|
37 #include <featmgr.h> |
|
38 #include <secui.h> |
|
39 #include <secuisecurityhandler.h> |
|
40 |
|
41 #include <settingsinternalcrkeys.h> // KSettingsAutolockStatus |
|
42 #include <coreapplicationuisdomainpskeys.h> |
|
43 #include <securityuisprivatepskeys.h> |
|
44 #include <startupdomainpskeys.h> |
|
45 #include <startupdomaincrkeys.h> |
|
46 #include <ctsydomainpskeys.h> |
|
47 |
|
48 #ifdef __SAP_TERMINAL_CONTROL_FW |
|
49 #include <SCPClient.h> |
|
50 #endif // __SAP_TERMINAL_CONTROL_FW |
|
51 |
|
52 const TInt KAutoDeviceLockOff( 60000 ); |
|
53 const TInt KPhoneIndex( 0 ); |
|
54 const TInt KTriesToConnectServer( 2 ); |
|
55 const TInt KTimeBeforeRetryingServerConnection( 50000 ); |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // Standard Symbian OS construction sequence |
|
59 // --------------------------------------------------------------------------- |
|
60 CLockAppDevicelockControl* CLockAppDevicelockControl::NewL(MLockAppStateControl& aStateControl, RWindowGroup& aWg ) |
|
61 { |
|
62 CLockAppDevicelockControl* self = new (ELeave) CLockAppDevicelockControl( aStateControl ); |
|
63 RDebug::Printf( "%s %s (%u) self=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, self ); |
|
64 |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL( aWg ); |
|
67 CleanupStack::Pop( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // Constructor passes the reference to the main state control. |
|
73 // --------------------------------------------------------------------------- |
|
74 CLockAppDevicelockControl::CLockAppDevicelockControl(MLockAppStateControl& aStateControl) : |
|
75 CLockAppBaseControl(aStateControl), iShowingSecCodeQuery(EFalse) |
|
76 { |
|
77 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
78 |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // Destructor. |
|
83 // --------------------------------------------------------------------------- |
|
84 CLockAppDevicelockControl::~CLockAppDevicelockControl( ) |
|
85 { |
|
86 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
87 |
|
88 /***************************************************** |
|
89 * S60 Customer / ETel |
|
90 * S60 ETel API |
|
91 *****************************************************/ |
|
92 /***************************************************** |
|
93 * S60 Customer / TSY |
|
94 * Needs customer TSY implementation |
|
95 *****************************************************/ |
|
96 RDebug::Printf( "%s %s (%u) iCustomPhoneInitialized=%x -> -1 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iCustomPhoneInitialized ); |
|
97 iCustomPhoneInitialized=-1; |
|
98 if ( iCustomPhone.SubSessionHandle( ) ) |
|
99 { |
|
100 iCustomPhone.Close( ); |
|
101 RDebug::Printf( "%s %s (%u) iCustomPhoneInitialized=%x -> -2 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iCustomPhoneInitialized ); |
|
102 iCustomPhoneInitialized=-2; |
|
103 } |
|
104 |
|
105 RDebug::Printf( "%s %s (%u) iPhoneInitialized=%x -> -1 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iPhoneInitialized ); |
|
106 iPhoneInitialized=-1; |
|
107 if ( iPhone.SubSessionHandle( ) ) |
|
108 { |
|
109 iPhone.Close( ); |
|
110 RDebug::Printf( "%s %s (%u) iPhoneInitialized=%x -> -2 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iPhoneInitialized ); |
|
111 iPhoneInitialized=-2; |
|
112 } |
|
113 |
|
114 RDebug::Printf( "%s %s (%u) iTelServerInitialized=%x -> -1 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iTelServerInitialized ); |
|
115 iTelServerInitialized=-1; |
|
116 if ( iTelServer.Handle( ) ) |
|
117 { |
|
118 iTelServer.UnloadPhoneModule( KMmTsyModuleName ); |
|
119 iTelServer.Close( ); |
|
120 RDebug::Printf( "%s %s (%u) iTelServerInitialized=%x -> -2 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iTelServerInitialized ); |
|
121 iTelServerInitialized=-2; |
|
122 } |
|
123 if ( iActivityManager ) |
|
124 { |
|
125 iActivityManager->Cancel( ); |
|
126 delete iActivityManager; |
|
127 iActivityManager = NULL; |
|
128 } |
|
129 // CenRep observers |
|
130 if ( iCRAutoLockTime ) |
|
131 { |
|
132 delete iCRAutoLockTime; |
|
133 iCRAutoLockTime = NULL; |
|
134 } |
|
135 if ( iCRAutoLockStatus ) |
|
136 { |
|
137 delete iCRAutoLockStatus; |
|
138 iCRAutoLockStatus = NULL; |
|
139 } |
|
140 // PuSub observers |
|
141 if ( iPSAutolockState ) |
|
142 { |
|
143 delete iPSAutolockState; |
|
144 iPSAutolockState = NULL; |
|
145 } |
|
146 if ( iContainer ) |
|
147 { |
|
148 delete iContainer; |
|
149 iContainer = NULL; |
|
150 } |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // Devicelock UI constructor reserves localized resources, configures itself |
|
155 // using CenRep and FeatureManager and reserves child controls. |
|
156 // --------------------------------------------------------------------------- |
|
157 void CLockAppDevicelockControl::ConstructL( RWindowGroup& aWg ) |
|
158 { |
|
159 INFO( "CLockAppDevicelockControl::ConstructL started" ); |
|
160 CLockAppBaseControl::ConstructL( ); |
|
161 |
|
162 // feature manager is used for determining if the phone is a slider |
|
163 FeatureManager::InitializeLibL( ); |
|
164 iFeatureProtocolCdma = FeatureManager::FeatureSupported( KFeatureIdProtocolCdma ); |
|
165 INFO_1("CLockAppDevicelockControl::ConstructL - iFeatureProtocolCdma: %d", iFeatureProtocolCdma); |
|
166 FeatureManager::UnInitializeLib( ); |
|
167 |
|
168 // Cba control |
|
169 iCba = CEikButtonGroupContainer::NewL( CEikButtonGroupContainer::ECba, |
|
170 CEikButtonGroupContainer::EHorizontal, this, |
|
171 R_KEYLOCK_SOFTKEYS_UNLOCK_EMPTY ); |
|
172 |
|
173 TRect screenRect; |
|
174 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
175 iCba->SetBoundingRect( screenRect ); |
|
176 iCba->MakeVisible( EFalse ); |
|
177 |
|
178 // Set up the status pane |
|
179 CEikStatusPane* sp = iAvkonAppUi->StatusPane(); |
|
180 if ( sp ) |
|
181 { |
|
182 // Switch the layout to show analog clock |
|
183 TRAPD(err, sp->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_IDLE ) ) |
|
184 ERROR(err, "CLockAppDevicelockControl::ConstructL - failed to switch status pane layout"); |
|
185 if ( sp->PaneCapabilities(TUid::Uid(EEikStatusPaneUidTitle)).IsPresent( ) ) |
|
186 { |
|
187 // Get the title pane control from status pane |
|
188 CAknTitlePane* titlePane = NULL; |
|
189 TRAPD(err2, titlePane = static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle) ) ) ) |
|
190 ERROR(err2, "CLockAppDevicelockControl::ConstructL - failed to get status title pane"); |
|
191 if ( titlePane ) |
|
192 { |
|
193 // Read localized "Locked" text from resource. |
|
194 HBufC* lockedString = iCoeEnv->AllocReadResourceL( R_TITLE_PANE_LOCKED ); |
|
195 // Set as title pane text - titlepane takes ownership of the string |
|
196 titlePane->SetText( lockedString ); |
|
197 } |
|
198 } |
|
199 } |
|
200 |
|
201 INFO( "CLockAppDevicelockControl::ConstructL completed" ); |
|
202 } |
|
203 |
|
204 void CLockAppDevicelockControl::ConnectToPhoneL( RWindowGroup& aWg ) |
|
205 { |
|
206 INFO( "CLockAppDevicelockControl::ConnectToPhoneL - connecting to etel server" ); |
|
207 // All server connections are tried to be made KTiesToConnectServer times because |
|
208 // occasional fails on connections are possible at least on some servers |
|
209 TInt err( KErrGeneral); |
|
210 TInt thisTry( 0); |
|
211 while ( ( err = iTelServer.Connect() ) != KErrNone && ( thisTry++ ) <= KTriesToConnectServer ) |
|
212 { |
|
213 User::After( KTimeBeforeRetryingServerConnection ); |
|
214 } |
|
215 ERROR(err, "CLockAppDevicelockControl::ConnectToPhoneL - connecting to etel server"); |
|
216 User::LeaveIfError( err ); |
|
217 RDebug::Printf( "%s %s (%u) iTelServerInitialized=%x -> 2 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iTelServerInitialized ); |
|
218 iTelServerInitialized=2; |
|
219 |
|
220 |
|
221 /***************************************************** |
|
222 * S60 Customer / ETel |
|
223 * S60 ETel API |
|
224 *****************************************************/ |
|
225 /***************************************************** |
|
226 * S60 Customer / TSY |
|
227 * Needs customer TSY implementation |
|
228 *****************************************************/ |
|
229 INFO( "CLockAppDevicelockControl::ConnectToPhoneL - loading TSY"); |
|
230 err = iTelServer.LoadPhoneModule( KMmTsyModuleName ); |
|
231 if ( err != KErrAlreadyExists ) |
|
232 { |
|
233 // may return also KErrAlreadyExists if some other |
|
234 // is already loaded the tsy module. And that is not an error. |
|
235 ERROR(err, "CLockAppDevicelockControl::ConnectToPhoneL - loading TSY"); |
|
236 User::LeaveIfError( err ); |
|
237 } |
|
238 RDebug::Printf( "%s %s (%u) iTelServerInitialized=%x -> 3 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iTelServerInitialized ); |
|
239 iTelServerInitialized=3; |
|
240 |
|
241 /***************************************************** |
|
242 * S60 Customer / ETel |
|
243 * S60 ETel API |
|
244 *****************************************************/ |
|
245 INFO( "CLockAppDevicelockControl::ConnectToPhoneL - opening phone"); |
|
246 RTelServer::TPhoneInfo PhoneInfo; |
|
247 User::LeaveIfError( iTelServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) ); |
|
248 RDebug::Printf( "%s %s (%u) iTelServerInitialized=%x -> 5 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iTelServerInitialized ); |
|
249 iTelServerInitialized=5; |
|
250 User::LeaveIfError( iTelServer.GetPhoneInfo( KPhoneIndex, PhoneInfo ) ); |
|
251 RDebug::Printf( "%s %s (%u) iTelServerInitialized=%x -> 6 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iTelServerInitialized ); |
|
252 iTelServerInitialized=6; |
|
253 User::LeaveIfError( iPhone.Open( iTelServer, PhoneInfo.iName ) ); |
|
254 RDebug::Printf( "%s %s (%u) iPhoneInitialized=%x -> 2 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iPhoneInitialized ); |
|
255 iPhoneInitialized=2; |
|
256 User::LeaveIfError( iCustomPhone.Open( iPhone ) ); |
|
257 RDebug::Printf( "%s %s (%u) iCustomPhoneInitialized=%x -> 2 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iCustomPhoneInitialized ); |
|
258 iCustomPhoneInitialized=2; |
|
259 |
|
260 INFO( "CLockAppDevicelockControl::ConnectToPhoneL - phone opened"); |
|
261 |
|
262 |
|
263 TBool systemLocked(EFalse); |
|
264 |
|
265 // Set up CenRep observers |
|
266 iCRAutoLockTime = CLockAppCenRepObserver::NewL(this, KCRUidSecuritySettings, KSettingsAutoLockTime); |
|
267 iCRAutoLockStatus = CLockAppCenRepObserver::NewL(this, KCRUidSecuritySettings, KSettingsAutolockStatus); |
|
268 |
|
269 #ifndef __WINS__ |
|
270 |
|
271 /***************************************************** |
|
272 * S60 Customer / ETel |
|
273 * S60 ETel API |
|
274 *****************************************************/ |
|
275 |
|
276 RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice; |
|
277 RMobilePhone::TMobilePhoneLockInfoV1 lockInfo; |
|
278 RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo); |
|
279 |
|
280 TRequestStatus getLockInfoStatus; |
|
281 iPhone.GetLockInfo( getLockInfoStatus, lockType, lockInfoPkg ); |
|
282 RDebug::Printf( "%s %s (%u) iPhoneInitialized=%x -> 3 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iPhoneInitialized ); |
|
283 iPhoneInitialized=3; |
|
284 User::WaitForRequest( getLockInfoStatus ); |
|
285 |
|
286 TInt lockValue(0); |
|
287 TInt cRresult = iCRAutoLockStatus->GetValue( lockValue ); |
|
288 INFO_2( "CLockAppDevicelockControl::ConnectToPhoneL - CR autolockstatus=%d , res=%d", lockValue, cRresult); |
|
289 TBool hiddenReset = IsHiddenReset( ); |
|
290 INFO_1( "CLockAppDevicelockControl::ConnectToPhoneL - hiddenReset=%d", hiddenReset ); |
|
291 if ( lockInfo.iSetting == RMobilePhone::ELockSetDisabled ) |
|
292 { |
|
293 INFO( "CLockAppDevicelockControl::ConnectToPhoneL - ELockSetDisabled"); |
|
294 iCRAutoLockTime->SetValue( 0 ); |
|
295 if ( iFeatureProtocolCdma ) |
|
296 { |
|
297 iCRAutoLockTime->SetKeyValue( KSettingsLockOnPowerUp, 0 ); |
|
298 } |
|
299 } |
|
300 else |
|
301 { |
|
302 if ( iFeatureProtocolCdma || (hiddenReset && (lockValue == 1)) ) |
|
303 { |
|
304 // In CDMA, the system can stay locked on after the boot-up sequence. |
|
305 INFO( "CLockAppDevicelockControl::ConnectToPhoneL - Hidden reset when locked"); |
|
306 systemLocked = ETrue; |
|
307 } |
|
308 } |
|
309 #endif //__WINS__ |
|
310 |
|
311 // Create devicelock UI container |
|
312 INFO_1( "CLockAppDevicelockControl::ConnectToPhoneL - creating CLockAppDevicelockContainer=%d", 1 ); |
|
313 iContainer = CLockAppDevicelockContainer::NewL( aWg ); |
|
314 INFO_1( "CLockAppDevicelockControl::ConnectToPhoneL - creating CLockAppDevicelockContainer=%d done", 1 ); |
|
315 |
|
316 INFO_1( "CLockAppDevicelockControl::ConnectToPhoneL - creating DefinePubSubKeysL=%d", 1 ); |
|
317 DefinePubSubKeysL( ); |
|
318 INFO_1( "CLockAppDevicelockControl::ConnectToPhoneL - creating DefinePubSubKeysL=%d", 1 ); |
|
319 |
|
320 // The following sequence is used to validate the configuration on SCP server. |
|
321 // This is needed on the first boot (initial or RFS) or if the C-drive |
|
322 // has been formatted (3-button format) and Autolock is not active. |
|
323 #ifdef __SAP_TERMINAL_CONTROL_FW |
|
324 // This seems to be defined always. |
|
325 INFO( "CLockAppDevicelockControl::ConnectToPhoneL - Validate SCP Config" ); |
|
326 RSCPClient scpClient; |
|
327 if ( scpClient.Connect() == KErrNone ) |
|
328 { |
|
329 CleanupClosePushL( scpClient ); |
|
330 TInt confStatus = scpClient.CheckConfiguration( KSCPInitial ); |
|
331 if ( confStatus == KErrAccessDenied ) |
|
332 { |
|
333 #ifndef __WINS__ |
|
334 if ( ( lockInfo.iSetting == RMobilePhone::ELockSetDisabled ) ) |
|
335 #else // __WINS__ |
|
336 if ( ETrue ) // DOS lock is never active in WINS |
|
337 #endif // __WINS__ |
|
338 { |
|
339 // DOS lock is not active. Note that if DOS is locked, checking the code here will |
|
340 // mess up the query sequence. On initial startup DOS is not locked. |
|
341 TInt finalConfStatus = scpClient.CheckConfiguration( KSCPComplete ); |
|
342 if ( finalConfStatus == KErrAccessDenied ) |
|
343 { |
|
344 #ifdef __WINS__ |
|
345 ERROR(finalConfStatus, "CLockAppDevicelockControl::ConnectToPhoneL - DOS validation FAILED in WINS!"); |
|
346 #else // !__WINS__ |
|
347 // The SCP server is out of sync and Autolock is not active. (c-drive formatted) |
|
348 // We must ask the security code. ( Note that it is very rare that this is executed ) |
|
349 INFO( "CLockAppDevicelockControl::ConnectToPhoneL - Lock setting disabled, calling setlocksetting"); |
|
350 |
|
351 // Wait here until the startup is complete |
|
352 TInt tarmErr(KErrNone); |
|
353 while ( tarmErr == KErrNone ) |
|
354 { |
|
355 TInt sysState; |
|
356 tarmErr = RProperty::Get(KPSUidStartup, KPSGlobalSystemState, sysState); |
|
357 if ((sysState == ESwStateNormalRfOn) || |
|
358 (sysState == ESwStateNormalRfOff) || |
|
359 (sysState == ESwStateNormalBTSap)) |
|
360 { |
|
361 break; |
|
362 } |
|
363 User::After(500000); // half a second |
|
364 } |
|
365 |
|
366 // Just change the lock setting again to disabled to request the security code. |
|
367 // Set the TARM flag so SecUi knows it should display the "login" query. |
|
368 TInt tarmFlag; |
|
369 TInt tRet = RProperty::Get( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag ); |
|
370 if ( tRet == KErrNone ) |
|
371 { |
|
372 tarmFlag |= KSCPFlagResyncQuery; |
|
373 tRet = RProperty::Set( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag ); |
|
374 } |
|
375 ERROR(tRet, "CLockAppDevicelockControl::ConnectToPhoneL - FAILED to set TARM Admin Flag" ); |
|
376 |
|
377 TRequestStatus setLockSettingStatus; |
|
378 RMobilePhone::TMobilePhoneLockSetting lockChange = RMobilePhone::ELockSetDisabled; |
|
379 iPhone.SetLockSetting( setLockSettingStatus, lockType, lockChange ); |
|
380 User::WaitForRequest( setLockSettingStatus ); |
|
381 #endif // __WINS__ |
|
382 } |
|
383 } |
|
384 } |
|
385 CleanupStack::PopAndDestroy(); // calls Close() on scpClient |
|
386 } |
|
387 #endif // __SAP_TERMINAL_CONTROL_FW |
|
388 |
|
389 // Set up P&S observers |
|
390 iPSAutolockState = CLockAppPubSubObserver::NewL( this, KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus ); |
|
391 |
|
392 if ( systemLocked ) |
|
393 { |
|
394 INFO( "CLockAppDevicelockControl::ConnectToPhoneL - Lock system"); |
|
395 RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
396 iStateControl.EnableDevicelockL( EDevicelockManual ); |
|
397 INFO( "CLockAppDevicelockControl::ConnectToPhoneL - Lock system. Done"); |
|
398 } |
|
399 |
|
400 // Activity manager |
|
401 iActivityManager = CUserActivityManager::NewL( CActive::EPriorityStandard ); |
|
402 StartActivityMonitoringL( ); |
|
403 |
|
404 // Setup key pattern matcher |
|
405 if ( !SetupKeyPatternsWithPolicyL( EPolicyDevicelockQuery ) ) |
|
406 { |
|
407 INFO( "CLockAppDevicelockControl::ConnectToPhoneL - No CenRep policy defined" ); |
|
408 iKeyPattern->AddPattern( EStdKeyDevice0, 0 ); // '0' = second key code doesnt matter |
|
409 } |
|
410 #ifdef __WINS__ |
|
411 iKeyPattern->AddPattern( EStdKeyDevice0, 0 ); // LSK + * |
|
412 #endif |
|
413 |
|
414 INFO( "CLockAppDevicelockControl::ConstructL completed" ); |
|
415 } |
|
416 |
|
417 // --------------------------------------------------------------------------- |
|
418 // Define internal P&S autolock status key |
|
419 // --------------------------------------------------------------------------- |
|
420 void CLockAppDevicelockControl::DefinePubSubKeysL() |
|
421 { |
|
422 INFO( "CLockAppDevicelockControl::DefinePubSubKeysL" ); |
|
423 |
|
424 // Create the write policy. Also processes with write device data can write the value. |
|
425 TSecurityPolicy writePolicy( ECapabilityWriteDeviceData ); |
|
426 // Create the read policy. Also processes with read device data can read the value. |
|
427 TSecurityPolicy readPolicy( ECapabilityReadDeviceData ); |
|
428 |
|
429 TInt ret = RProperty::Define( KPSUidSecurityUIs, |
|
430 KSecurityUIsSecUIOriginatedQuery, RProperty::EInt, readPolicy, writePolicy ); |
|
431 ERROR(ret, "CLockAppDevicelockControl::DefinePubSubKeysL - FAILED to define the SECUI query Flag"); |
|
432 |
|
433 ret = RProperty::Define( KPSUidSecurityUIs, |
|
434 KSecurityUIsQueryRequestCancel, RProperty::EInt, readPolicy, writePolicy ); |
|
435 ERROR(ret, "CLockAppDevicelockControl::DefinePubSubKeysL - FAILED to define the SECUI query request state Flag"); |
|
436 |
|
437 _LIT_SECURITY_POLICY_PASS(KReadPolicy); |
|
438 _LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData); |
|
439 ret = RProperty::Define( KPSUidCoreApplicationUIs, |
|
440 KCoreAppUIsAutolockStatus, RProperty::EInt, KReadPolicy, KWritePolicy); |
|
441 RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOff); |
|
442 if (ret != KErrAlreadyExists) |
|
443 { |
|
444 ERROR(ret, "CLockAppDevicelockControl::DefinePubSubKeysL - FAILED to set autolock status"); |
|
445 User::LeaveIfError(ret); |
|
446 } |
|
447 |
|
448 #ifdef __SAP_TERMINAL_CONTROL_FW |
|
449 // Define the TARM admin flag. |
|
450 ret = RProperty::Define( KSCPSIDAutolock, |
|
451 SCP_TARM_ADMIN_FLAG_UID, RProperty::EInt, readPolicy, writePolicy ); |
|
452 ERROR(ret, "CLockAppDevicelockControl::DefinePubSubKeysL - FAILED to define the TARM Admin Flag"); |
|
453 #endif // __SAP_TERMINAL_CONTROL_FW |
|
454 } |
|
455 |
|
456 // ---------------------------------------------------------- |
|
457 // Checks whether we are booting from a Hidden Reset |
|
458 // ---------------------------------------------------------- |
|
459 TBool CLockAppDevicelockControl::IsHiddenReset( ) |
|
460 { |
|
461 RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
462 |
|
463 TBool ret( EFalse ); |
|
464 TInt startupReason( ENormalStartup ); |
|
465 TInt err( KErrNone); |
|
466 err = RProperty::Get( KPSUidStartup, KPSStartupReason, startupReason ); |
|
467 ERROR(err, "CLockAppDevicelockControl::IsHiddenReset - error getting startup reason" ); |
|
468 ret = (startupReason != ENormalStartup); |
|
469 INFO_1( "CLockAppDevicelockControl::IsHiddenReset = %d", ret ); |
|
470 #ifdef _DEBUG |
|
471 // test to simulate HiddenReset |
|
472 RFs fs; |
|
473 _LIT(KTestHiddenReset,"f:\\TestHiddenReset.txt"); |
|
474 RFile file; |
|
475 User::LeaveIfError(fs.Connect()); |
|
476 err=file.Open(fs, KTestHiddenReset, EFileStreamText|EFileRead|EFileShareReadersOnly); |
|
477 if(err==KErrNone) |
|
478 { |
|
479 RDebug::Printf( "%s %s (%u) ??? TestHiddenReset=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
480 ret = ETrue; |
|
481 } |
|
482 file.Close(); |
|
483 fs.Close(); |
|
484 #endif |
|
485 return ret; |
|
486 } |
|
487 |
|
488 // ---------------------------------------------------------- |
|
489 // Checks whether PIN1/UPIN is blocked |
|
490 // ---------------------------------------------------------- |
|
491 TBool CLockAppDevicelockControl::IsPinBlocked( ) |
|
492 { |
|
493 INFO( "CLockAppDevicelockControl::IsPinBlocked" ); |
|
494 TBool ret( EFalse ); |
|
495 RMmCustomAPI::TSecurityCodeType secCodeType; |
|
496 #if defined(__PROTOCOL_WCDMA) || defined(__UPIN) |
|
497 RMobilePhone::TMobilePhoneSecurityCode activePin; |
|
498 iCustomPhone.GetActivePin( activePin ); |
|
499 if ( activePin == RMobilePhone::ESecurityUniversalPin ) |
|
500 secCodeType = RMmCustomAPI::ESecurityUniversalPin; |
|
501 else |
|
502 secCodeType = RMmCustomAPI::ESecurityCodePin1; |
|
503 #else |
|
504 secCodeType = RMmCustomAPI::ESecurityCodePin1; |
|
505 #endif //(__PROTOCOL_WCDMA) || defined(__UPIN) |
|
506 iCustomPhone.IsBlocked( secCodeType, ret ); |
|
507 INFO_1( "CLockAppDevicelockControl::IsPinBlocked = %d", ret ); |
|
508 return ret; |
|
509 } |
|
510 |
|
511 // ---------------------------------------------------------- |
|
512 // Try to get (and optionally unset) the TARM Admin Flag |
|
513 // ---------------------------------------------------------- |
|
514 TBool CLockAppDevicelockControl::TarmAdminFlag( TBool unSetFlag ) |
|
515 { |
|
516 INFO_1( "CLockAppDevicelockControl::TarmAdminFlag(unSet = %d)", unSetFlag ); |
|
517 TBool ret(EFalse); |
|
518 #ifdef __SAP_TERMINAL_CONTROL_FW |
|
519 // Get the TARM admin flag value |
|
520 TInt tarmFlag; |
|
521 TInt err = RProperty::Get( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag ); |
|
522 if ( err != KErrNone ) |
|
523 { |
|
524 ERROR(err, "CLockAppDevicelockControl::TarmAdminFlag - Failed to get TARM flag" ); |
|
525 } |
|
526 else |
|
527 { |
|
528 INFO_1( "CLockAppDevicelockControl::TarmAdminFlag - TARM flag: %d", tarmFlag ); |
|
529 } |
|
530 |
|
531 if ( tarmFlag & KSCPFlagAdminLock ) |
|
532 { |
|
533 ret = ETrue; |
|
534 // Unset the TARM admin flag if set |
|
535 if ( unSetFlag ) |
|
536 { |
|
537 tarmFlag &= ~KSCPFlagAdminLock; |
|
538 err = RProperty::Set( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag ); |
|
539 ERROR(err, "CLockAppDevicelockControl::TarmAdminFlag - FAILED to unset TARM flag" ); |
|
540 } |
|
541 } |
|
542 #endif // __SAP_TERMINAL_CONTROL_FW |
|
543 INFO_1( "CLockAppDevicelockControl::TarmAdminFlag = %d", ret ); |
|
544 return ret; |
|
545 } |
|
546 |
|
547 // --------------------------------------------------------------------------- |
|
548 // Check ETEL lock info and ask sec code if neccessary |
|
549 // --------------------------------------------------------------------------- |
|
550 TBool CLockAppDevicelockControl::ETelActivationAllowed( ) |
|
551 { |
|
552 INFO( "CLockAppDevicelockControl::ETelActivationAllowed" ); |
|
553 TBool ret(EFalse); |
|
554 #ifdef __WINS__ |
|
555 ret = ETrue; |
|
556 #else //__WINS__ |
|
557 |
|
558 /***************************************************** |
|
559 * S60 Customer / ETel |
|
560 * S60 ETel API |
|
561 *****************************************************/ |
|
562 |
|
563 |
|
564 RDebug::Printf( "%s %s (%u) 111 value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
565 |
|
566 // RDebug::Printf( "%s %s (%u) iStateControl=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iStateControl ); |
|
567 |
|
568 RDebug::Printf( "%s %s (%u) checking iPhoneInitialized=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
569 RDebug::Printf( "%s %s (%u) iPhoneInitialized=%x -> 4 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iPhoneInitialized ); |
|
570 iPhoneInitialized=4; |
|
571 |
|
572 RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice; |
|
573 RMobilePhone::TMobilePhoneLockInfoV1 lockInfo; |
|
574 RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo); |
|
575 RMobilePhone::TMobilePhoneLockSetting lockChange(RMobilePhone::ELockSetDisabled); |
|
576 |
|
577 RDebug::Printf( "%s %s (%u) before getLockInfoStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
578 TRequestStatus getLockInfoStatus; |
|
579 RDebug::Printf( "%s %s (%u) after getLockInfoStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 ); |
|
580 |
|
581 RDebug::Printf( "%s %s (%u) iPhoneInitialized=%x -> 5 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iPhoneInitialized ); |
|
582 iPhoneInitialized=5; |
|
583 iPhone.GetLockInfo( getLockInfoStatus, lockType, lockInfoPkg ); |
|
584 RDebug::Printf( "%s %s (%u) iPhoneInitialized=%x -> 6 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iPhoneInitialized ); |
|
585 iPhoneInitialized=6; |
|
586 User::WaitForRequest( getLockInfoStatus ); |
|
587 |
|
588 INFO_1( "CLockAppDevicelockControl::ETelActivationAllowed - GetLockInfo status: %d ", getLockInfoStatus.Int() ); |
|
589 if ( getLockInfoStatus.Int( )== KErrNone ) |
|
590 { |
|
591 if ( lockInfo.iSetting == RMobilePhone::ELockSetDisabled ) |
|
592 { |
|
593 // ask code |
|
594 INFO( "CLockAppDevicelockControl::ETelActivationAllowed - ETel ELockSetDisabled, Ask Code" ); |
|
595 // Raise a flag to indicate that the UPIN request coming from ETEL |
|
596 // has originated from SecUi and not from Engine. |
|
597 RProperty::Set( KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSystemLockOriginated ); |
|
598 TRequestStatus setLockSettingStatus; |
|
599 lockChange = RMobilePhone::ELockSetEnabled; |
|
600 iPhone.SetLockSetting( setLockSettingStatus, lockType, lockChange ); |
|
601 User::WaitForRequest( setLockSettingStatus ); |
|
602 INFO_1( "CLockAppDevicelockControl::ETelActivationAllowed - SetLockSetting status: %d ", setLockSettingStatus.Int() ); |
|
603 // Lower the flag |
|
604 RProperty::Set( KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsETelAPIOriginated ); |
|
605 if (setLockSettingStatus.Int() == KErrNone) |
|
606 { |
|
607 ret = ETrue; |
|
608 } |
|
609 } |
|
610 else |
|
611 { |
|
612 INFO( "CLockAppDevicelockControl::ETelActivationAllowed - Lock System Ok" ); |
|
613 ret = ETrue; |
|
614 } |
|
615 } |
|
616 else |
|
617 { |
|
618 INFO( "CLockAppDevicelockControl::ETelActivationAllowed - Error getting LockInfo - Ask code (SLS)" ); |
|
619 // Raise a flag to indicate that the UPIN request coming from ETEL |
|
620 // has originated from SecUi and not from Engine. |
|
621 RProperty::Set( KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSystemLockOriginated ); |
|
622 TRequestStatus setLockSettingStatus; |
|
623 lockChange = RMobilePhone::ELockSetEnabled; |
|
624 RDebug::Printf( "%s %s (%u) iPhoneInitialized=%x -> 8 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iPhoneInitialized ); |
|
625 iPhoneInitialized=8; |
|
626 iPhone.SetLockSetting( setLockSettingStatus, lockType, lockChange ); |
|
627 RDebug::Printf( "%s %s (%u) iPhoneInitialized=%x -> 9 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iPhoneInitialized ); |
|
628 iPhoneInitialized=9; |
|
629 User::WaitForRequest(setLockSettingStatus); |
|
630 INFO_1( "CLockAppDevicelockControl::ETelActivationAllowed - SetLockSetting status: %d ", setLockSettingStatus.Int() ); |
|
631 // Lower the flag |
|
632 RProperty::Set( KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsETelAPIOriginated ); |
|
633 if (setLockSettingStatus.Int() == KErrNone) |
|
634 { |
|
635 ret = ETrue; |
|
636 } |
|
637 } |
|
638 #endif |
|
639 INFO_1( "CLockAppDevicelockControl::ETelActivationAllowed = %d", ret ); |
|
640 return ret; |
|
641 } |
|
642 |
|
643 // --------------------------------------------------------------------------- |
|
644 // Check weather its allowed to activate the control |
|
645 // --------------------------------------------------------------------------- |
|
646 TBool CLockAppDevicelockControl::ActivationAllowedL( TDevicelockReason aReason ) |
|
647 { |
|
648 INFO_1( "CLockAppDevicelockControl::ActivationAllowedL aReason= %d", aReason ); |
|
649 |
|
650 if (aReason==ETimerLocked) |
|
651 { |
|
652 { // REQ 414-5466 Prevention of device lock in context of Hands Free Voice UI |
|
653 TInt vuiValue = 0; |
|
654 TUid KHFVuiModePSUid = { 0x102818E7 }; |
|
655 enum THFVuiModePSKeys |
|
656 { |
|
657 EHFVuiPSModeId = 1000 |
|
658 }; |
|
659 TInt tRet = RProperty::Get(KHFVuiModePSUid, EHFVuiPSModeId, vuiValue); // also 0 if can't get because permissions or because doesn't exists |
|
660 #if defined(_DEBUG) |
|
661 RDebug::Printf( "%s %s (%u) getting KHFVuiModePSUid+EHFVuiPSModeId=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, tRet ); |
|
662 RDebug::Printf( "%s %s (%u) vuiValue=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, vuiValue ); |
|
663 #endif |
|
664 if(vuiValue) |
|
665 { |
|
666 #if defined(_DEBUG) |
|
667 RDebug::Print(_L("(LOCKAPP)CLockAppDevicelockControl::ActivationAllowedL() Voice functions active. No locking possible.")); |
|
668 #endif |
|
669 return EFalse; |
|
670 } |
|
671 } |
|
672 { // if another query is displayed, the future un-lock query will crash. Don't allow time-lock in this case. |
|
673 TInt secQueryStatus = ESecurityQueryUninitialized; |
|
674 TInt tRet = RProperty::Get(KPSUidStartup, KStartupSecurityCodeQueryStatus, secQueryStatus); // also 0 if can't get because permissions or because doesn't exists |
|
675 #if defined(_DEBUG) |
|
676 RDebug::Printf( "%s %s (%u) getting KPSUidStartup+KStartupSecurityCodeQueryStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, tRet ); |
|
677 RDebug::Printf( "%s %s (%u) secQueryStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, secQueryStatus ); |
|
678 #endif |
|
679 if(secQueryStatus==ESecurityQueryActive) |
|
680 { |
|
681 #if defined(_DEBUG) |
|
682 RDebug::Print(_L("(LOCKAPP)CLockAppDevicelockControl::ActivationAllowedL() Asking some other security code. No locking possible.")); |
|
683 #endif |
|
684 return EFalse; |
|
685 } |
|
686 } |
|
687 } |
|
688 |
|
689 TInt lightStatus=EForcedLightsUninitialized; |
|
690 RProperty::Get(KPSUidCoreApplicationUIs,KLightsVTForcedLightsOn,lightStatus ); |
|
691 //If display is forced on. don't lock |
|
692 if(lightStatus == EForcedLightsOn ) |
|
693 { |
|
694 #if defined(_DEBUG) |
|
695 RDebug::Print(_L("(LOCKAPP)CLockAppDevicelockControl::ActivationAllowedL() Display is forced on deivce not locked")); |
|
696 #endif |
|
697 return EFalse; |
|
698 } |
|
699 |
|
700 // first check ETEL side - and ask sec code if needed |
|
701 if ( !ETelActivationAllowed() ) |
|
702 { |
|
703 return EFalse; |
|
704 } |
|
705 |
|
706 if ( IsPinBlocked( ) ) |
|
707 { |
|
708 return EFalse; |
|
709 } |
|
710 |
|
711 TBool ret(EFalse); |
|
712 TInt sysState(0); |
|
713 RProperty::Get( KPSUidStartup, KPSGlobalSystemState, sysState ); |
|
714 //If NOT in CDMA the Autolock should come up only after the phone has booted up. |
|
715 if ( iFeatureProtocolCdma || IsHiddenReset( ) ) |
|
716 { |
|
717 if ( sysState == ESwStateNormalRfOn || |
|
718 sysState == ESwStateNormalRfOff || |
|
719 sysState == ESwStateCriticalPhaseOK ) |
|
720 { |
|
721 INFO( "CLockAppDevicelockControl::ActivationAllowedL - Locked after Hidden Reset" ); |
|
722 ret = ETrue; |
|
723 } |
|
724 } |
|
725 else |
|
726 { |
|
727 if ( sysState == ESwStateNormalRfOn || sysState == ESwStateNormalRfOff ) |
|
728 { |
|
729 ret = ETrue; |
|
730 } |
|
731 } |
|
732 |
|
733 if ( IsBitFieldSet( iStateControl.EnvironmentStatus( ), KLockAppEnvPhonecallOngoing ) && !TarmAdminFlag(EFalse) ) |
|
734 { |
|
735 if ( aReason == EDevicelockRemote ) |
|
736 { |
|
737 INFO( "CLockAppDevicelockControl::ActivationAllowedL - remote lock allowed" ); |
|
738 ret = ETrue; |
|
739 } |
|
740 } |
|
741 return ret; |
|
742 } |
|
743 |
|
744 // --------------------------------------------------------------------------- |
|
745 // Check weather its allowed to deactivate the control |
|
746 // --------------------------------------------------------------------------- |
|
747 TBool CLockAppDevicelockControl::DeActivationAllowedL() |
|
748 { |
|
749 if ( iShowingSecCodeQuery ) |
|
750 { |
|
751 return ETrue; |
|
752 } |
|
753 else |
|
754 { |
|
755 return EFalse; |
|
756 } |
|
757 } |
|
758 |
|
759 // --------------------------------------------------------------------------- |
|
760 // Set the devicelocking reason |
|
761 // --------------------------------------------------------------------------- |
|
762 void CLockAppDevicelockControl::SetLockingReason( TDevicelockReason aReason ) |
|
763 { |
|
764 #ifndef RD_REMOTELOCK |
|
765 iPSAutolockState->SetKeyValue( EAutolockOn ); |
|
766 #else |
|
767 switch ( aReason ) |
|
768 { |
|
769 case EDevicelockManual: |
|
770 iPSAutolockState->SetKeyValue( EManualLocked ); |
|
771 break; |
|
772 case EDevicelockRemote: |
|
773 iPSAutolockState->SetKeyValue( ERemoteLocked ); |
|
774 break; |
|
775 case EDevicelockTimer: |
|
776 iPSAutolockState->SetKeyValue( ETimerLocked ); |
|
777 break; |
|
778 default: |
|
779 DoPanic( ELockIllegalState ); |
|
780 } |
|
781 #endif // RD_REMOTELOCK |
|
782 } |
|
783 |
|
784 // --------------------------------------------------------------------------- |
|
785 // Activate control |
|
786 // --------------------------------------------------------------------------- |
|
787 void CLockAppDevicelockControl::HandleActivateEventL( TUint aEnvMask ) |
|
788 { |
|
789 INFO_1("CLockAppDevicelockControl::HandleActivateEventL - aEnvMask: %d", aEnvMask); |
|
790 |
|
791 CLockAppBaseControl::HandleActivateEventL( aEnvMask ); |
|
792 |
|
793 if ( IsBitFieldSet( aEnvMask, KLockAppEnvScreenSaverOn ) ) |
|
794 { |
|
795 // if screensaver is on - capture primary keys |
|
796 CapturePrimaryKeys( ETrue ); |
|
797 } |
|
798 // capture keys |
|
799 CLockAppKeyCaptureController::CaptureKey( EStdKeyApplication0, EKeyApplication0, EKeyCaptureAllEvents ); // App key |
|
800 CLockAppKeyCaptureController::CaptureKey( EStdKeyDevice2, EKeyDevice2, EKeyCaptureAllEvents ); // Power key (for lights) |
|
801 CLockAppKeyCaptureController::CaptureKey( EStdKeyDevice6, EKeyDevice6, EKeyCaptureAllEvents ); // Voice key (for lights) |
|
802 CLockAppKeyCaptureController::CaptureKey( EStdKeyNo, EKeyNo, EKeyCaptureAllEvents ); // End key (for Rosetta lights) |
|
803 CLockAppKeyCaptureController::CaptureKey( EStdKeyDeviceF, EKeyDeviceF, EKeyCaptureAllEvents ); // switch key (for touch devices) |
|
804 |
|
805 SetPointerEventCapture( ETrue ); |
|
806 SetKeyguardIndicatorStateL( ETrue ); |
|
807 iContainer->MakeVisible( ETrue ); // maybe not needed - as its in different windowgroup |
|
808 ShowCba( ETrue ); |
|
809 ShowStatusPane( ETrue ); |
|
810 // close task-list in case it is displayed : fast-swap window |
|
811 iEikonEnv->DismissTaskList( ); |
|
812 iCRAutoLockStatus->SetValue( ETrue ); |
|
813 } |
|
814 |
|
815 // --------------------------------------------------------------------------- |
|
816 // DeActivate control |
|
817 // --------------------------------------------------------------------------- |
|
818 void CLockAppDevicelockControl::HandleDeActivateEventL( TUint aEnvMask ) |
|
819 { |
|
820 INFO_1("CLockAppDevicelockControl::HandleDeActivateEventL - aEnvMask: %d", aEnvMask); |
|
821 |
|
822 CLockAppBaseControl::HandleDeActivateEventL( aEnvMask ); |
|
823 |
|
824 if ( IsBitFieldSet( aEnvMask, KLockAppEnvScreenSaverOn ) ) |
|
825 { |
|
826 // if screensaver is on - uncapture primary keys |
|
827 CapturePrimaryKeys( EFalse ); |
|
828 } |
|
829 |
|
830 // uncapture keys |
|
831 CLockAppKeyCaptureController::ReleaseKey( EStdKeyApplication0 ); |
|
832 CLockAppKeyCaptureController::ReleaseKey( EStdKeyDevice2 ); |
|
833 CLockAppKeyCaptureController::ReleaseKey( EStdKeyDevice6 ); |
|
834 CLockAppKeyCaptureController::ReleaseKey( EStdKeyNo ); |
|
835 CLockAppKeyCaptureController::ReleaseKey( EStdKeyDeviceF ); |
|
836 |
|
837 SetPointerEventCapture( EFalse ); |
|
838 SetKeyguardIndicatorStateL( EFalse ); |
|
839 iContainer->MakeVisible( EFalse ); // maybe not needed - as its in different windowgroup |
|
840 ShowCba( EFalse ); |
|
841 ShowStatusPane( EFalse ); |
|
842 iPSAutolockState->SetKeyValue( EAutolockOff ); |
|
843 iCRAutoLockStatus->SetValue( EFalse ); |
|
844 } |
|
845 |
|
846 // --------------------------------------------------------------------------- |
|
847 // Handle environment changes (Screensaver, Telephony, etc.) |
|
848 // --------------------------------------------------------------------------- |
|
849 void CLockAppDevicelockControl::HandleEnvironmentChange( TUint aEnvMask, TUint aEventMask ) |
|
850 { |
|
851 RDebug::Printf( "%s %s (%u) aEnvMask=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aEnvMask ); |
|
852 RDebug::Printf( "%s %s (%u) aEventMask=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aEventMask ); |
|
853 |
|
854 if ( IsBitFieldSet( aEventMask, KLockAppEnvScreenSaverOn ) ) |
|
855 { |
|
856 // screen saver state changed |
|
857 CapturePrimaryKeys( IsBitFieldSet( aEnvMask, KLockAppEnvScreenSaverOn ) ); |
|
858 } |
|
859 if ( IsBitFieldSet( aEventMask, KLockAppEnvFPS ) ) |
|
860 { |
|
861 TInt lockValue=0; |
|
862 iPSAutolockState->GetKeyValue( lockValue ); |
|
863 RDebug::Printf( "%s %s (%u) lockValue=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, lockValue ); |
|
864 if(lockValue>EAutolockOff) // device is locked and query is not open |
|
865 { |
|
866 // indicate to TARM that it should not ask for password |
|
867 TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized); |
|
868 RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); |
|
869 RDebug::Printf( "%s %s (%u) secUiOriginatedQuery=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, secUiOriginatedQuery ); |
|
870 RProperty::Set( KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsFpsOriginated ); |
|
871 |
|
872 HandleUnlockCommandL( ); |
|
873 RProperty::Set( KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery ); // reset to initial |
|
874 } |
|
875 else // device needs to be locked. Same happens in keyguard control becasue probably this is never called |
|
876 iStateControl.EnableDevicelockL( EDevicelockManual ); |
|
877 } |
|
878 if ( IsBitFieldSet( aEnvMask, KLockAppEnvGrip ) ) |
|
879 { |
|
880 RDebug::Printf( "%s %s (%u) iShowingSecCodeQuery=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iShowingSecCodeQuery ); |
|
881 if ( IsBitFieldSet( aEventMask, KLockAppEnvGrip ) ) //Grip opened |
|
882 { |
|
883 if(iShowingSecCodeQuery==EFalse) |
|
884 { |
|
885 TInt lockValue=0; |
|
886 iPSAutolockState->GetKeyValue( lockValue ); |
|
887 RDebug::Printf( "%s %s (%u) lockValue=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, lockValue ); |
|
888 if(lockValue>EAutolockOff) |
|
889 { |
|
890 // ask unlock code by sending the menu key. This works on touch? |
|
891 TApaTaskList tasklist( iEikonEnv->WsSession() ); |
|
892 #define KAknCapServerUid TUid::Uid( 0x10207218 ) |
|
893 TApaTask capserver = tasklist.FindApp( KAknCapServerUid ); |
|
894 RDebug::Printf( "%s %s (%u) KAknCapServerUid=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, KAknCapServerUid ); |
|
895 if( capserver.Exists() ) |
|
896 { |
|
897 RDebug::Printf( "%s %s (%u) capserver.Exists() EStdKeyDevice0=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EStdKeyDevice0 ); |
|
898 TKeyEvent key; |
|
899 key.iCode = EKeyDevice0; |
|
900 key.iModifiers = 0; |
|
901 key.iRepeats = 0; |
|
902 key.iScanCode = EStdKeyDevice0; |
|
903 capserver.SendKey( key ); |
|
904 } |
|
905 } |
|
906 } |
|
907 } |
|
908 else |
|
909 { |
|
910 if(iShowingSecCodeQuery==EFalse) |
|
911 { |
|
912 //the device lock query is on top |
|
913 //generate cancel key event |
|
914 const TInt KCancelKeyCode( 165 ); |
|
915 RDebug::Printf( "%s %s (%u) KCancelKeyCode=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, KCancelKeyCode ); |
|
916 |
|
917 TRawEvent rawEvent; |
|
918 rawEvent.Set( TRawEvent::EKeyDown, KCancelKeyCode ); |
|
919 iEikonEnv->WsSession().SimulateRawEvent( rawEvent ); |
|
920 } |
|
921 } |
|
922 } |
|
923 } |
|
924 |
|
925 // --------------------------------------------------------------------------- |
|
926 // Handle all Central Repository observer callbacks. |
|
927 // --------------------------------------------------------------------------- |
|
928 void CLockAppDevicelockControl::HandleCenRepNotify(TUid /*aCenRepUid*/, TUint32 aKeyId, TInt aValue ) |
|
929 { |
|
930 RDebug::Printf( "%s %s (%u) aKeyId=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aKeyId ); |
|
931 RDebug::Printf( "%s %s (%u) aValue=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aValue ); |
|
932 switch ( aKeyId ) |
|
933 { |
|
934 case KSettingsAutoLockTime: |
|
935 { |
|
936 INFO_1( "CLockAppDevicelockControl::HandleCenRepNotify - KSettingsAutoLockTime = %d", aValue ); |
|
937 ResetInactivityTimeout( ); |
|
938 } |
|
939 break; |
|
940 default: |
|
941 break; |
|
942 } |
|
943 } |
|
944 |
|
945 // --------------------------------------------------------------------------- |
|
946 // Handle all Publish & Subscribe observer callbacks. |
|
947 // --------------------------------------------------------------------------- |
|
948 void CLockAppDevicelockControl::HandlePubSubNotify(TUid aPubSubUid, TUint aKeyId, TInt aValue ) |
|
949 { |
|
950 RDebug::Printf( "%s %s (%u) KPSUidCoreApplicationUIs=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, KPSUidCoreApplicationUIs ); |
|
951 RDebug::Printf( "%s %s (%u) aKeyId=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aKeyId ); |
|
952 RDebug::Printf( "%s %s (%u) aValue=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aValue ); |
|
953 if ( aPubSubUid == KPSUidCoreApplicationUIs ) |
|
954 { |
|
955 switch ( aKeyId ) |
|
956 { |
|
957 case KCoreAppUIsAutolockStatus: |
|
958 { |
|
959 INFO_1( "CLockAppDevicelockControl::HandlePubSubNotify - KCoreAppUIsAutolockStatus = %d", aValue ); |
|
960 // Autolock used to react to this PubSub key - but its unsafe and |
|
961 // in future API will be used, and the key will be published by Lockapp |
|
962 INFO_1( "CLockAppDevicelockControl::HandlePubSubNotify - nothing done. LockApp reacts only to API = %d", aValue ); |
|
963 } |
|
964 break; |
|
965 default: |
|
966 break; |
|
967 } |
|
968 } |
|
969 } |
|
970 |
|
971 // --------------------------------------------------------------------------- |
|
972 // Devicelock UI key events are handled trough here. |
|
973 // --------------------------------------------------------------------------- |
|
974 TKeyResponse CLockAppDevicelockControl::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
975 { |
|
976 RDebug::Printf( "%s %s (%u) aKeyEvent.iCode=%x aType=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aKeyEvent.iCode, aType ); |
|
977 RDebug::Printf( "%s %s (%u) iActive=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, iActive ); |
|
978 if ( iActive ) |
|
979 { |
|
980 if(AknLayoutUtils::PenEnabled()) |
|
981 { |
|
982 if(aKeyEvent.iCode == EKeyDeviceF) // any Type |
|
983 { |
|
984 HandleUnlockCommandL( ); |
|
985 } |
|
986 } |
|
987 if ( aType == EEventKeyDown ) |
|
988 { |
|
989 if ( !iShowingSecCodeQuery ) |
|
990 { |
|
991 switch ( iKeyPattern->HandleKeyEvent( aKeyEvent.iScanCode ) ) |
|
992 { |
|
993 case EPatternPrimaryMatch: |
|
994 HandleUnlockCommandL( ); |
|
995 break; |
|
996 default: |
|
997 break; |
|
998 } |
|
999 } |
|
1000 } |
|
1001 } |
|
1002 return EKeyWasConsumed; |
|
1003 } |
|
1004 |
|
1005 // --------------------------------------------------------------------------- |
|
1006 // Handle unlock command |
|
1007 // --------------------------------------------------------------------------- |
|
1008 void CLockAppDevicelockControl::HandleUnlockCommandL( ) |
|
1009 { |
|
1010 INFO( "CLockAppDevicelockControl::HandleUnlockCommandL" ); |
|
1011 // inform sysap to put lights on left soft key press |
|
1012 SendMessageToSysAp( EEikKeyLockLightsOnRequest ); |
|
1013 RDebug::Printf( "%s %s (%u) iPhoneInitialized=%x -> 10 ", __FILE__, __PRETTY_FUNCTION__, __LINE__, iPhoneInitialized ); |
|
1014 iPhoneInitialized=10; |
|
1015 CSecurityHandler* handler = new (ELeave) CSecurityHandler( iPhone ); |
|
1016 RDebug::Printf( "%s %s (%u) got handler=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
1017 CleanupStack::PushL( handler ); |
|
1018 TSecUi::InitializeLibL( ); |
|
1019 RDebug::Printf( "%s %s (%u) got TSecUi::InitializeLibL=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
1020 iShowingSecCodeQuery = ETrue; |
|
1021 TRAPD(err, { |
|
1022 RDebug::Printf( "%s %s (%u) before AskSecCodeInAutoLockL=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 ); |
|
1023 TBool ret = handler->AskSecCodeInAutoLockL(); |
|
1024 RDebug::Printf( "%s %s (%u) after AskSecCodeInAutoLockL=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ret ); |
|
1025 INFO_1( "CLockAppDevicelockControl::HandleUnlockCommandL - AskSecCodeInAutoLockL = %d", ret ); |
|
1026 if ( ret ) |
|
1027 { |
|
1028 iStateControl.DisableDevicelockL(); |
|
1029 } |
|
1030 }) |
|
1031 ERROR(err, "CLockAppDevicelockControl::HandleUnlockCommandL - AskSecCodeInAutoLockL"); |
|
1032 iShowingSecCodeQuery = EFalse; |
|
1033 TSecUi::UnInitializeLib( ); |
|
1034 CleanupStack::PopAndDestroy( handler ); |
|
1035 } |
|
1036 |
|
1037 // --------------------------------------------------------------------------- |
|
1038 // Get autolock timeout (in seconds) |
|
1039 // --------------------------------------------------------------------------- |
|
1040 TInt CLockAppDevicelockControl::GetAutoLockTimeout( ) |
|
1041 { |
|
1042 TInt timeoutInMinutes = 0; |
|
1043 iCRAutoLockTime->GetValue( timeoutInMinutes ); |
|
1044 return timeoutInMinutes * 60; |
|
1045 } |
|
1046 |
|
1047 // ---------------------------------------------------------- |
|
1048 // Starts monitoring user activity |
|
1049 // ---------------------------------------------------------- |
|
1050 void CLockAppDevicelockControl::StartActivityMonitoringL( ) |
|
1051 { |
|
1052 __ASSERT_DEBUG( iActivityManager, DoPanic(ELockIllegalState)); |
|
1053 if ( iActivityManager && !iActivityManager->IsActive() ) |
|
1054 { |
|
1055 TInt value = GetAutoLockTimeout( ); |
|
1056 INFO_1( "CLockAppDevicelockControl::StartActivityMonitoringL - %d sec", value); |
|
1057 if ( value ) |
|
1058 { |
|
1059 iActivityManager->Start( value, |
|
1060 TCallBack( HandleInactiveEventL, this ), |
|
1061 TCallBack( HandleActiveEventL, this ) ); |
|
1062 } |
|
1063 else |
|
1064 { |
|
1065 iActivityManager->Start( KAutoDeviceLockOff, |
|
1066 TCallBack(HandleInactiveEventL, this ), |
|
1067 TCallBack(HandleActiveEventL, this ) ); |
|
1068 } |
|
1069 } |
|
1070 } |
|
1071 |
|
1072 // ---------------------------------------------------------- |
|
1073 // Gets autolock period and starts monitoring user activity |
|
1074 // ---------------------------------------------------------- |
|
1075 void CLockAppDevicelockControl::ResetInactivityTimeout( ) |
|
1076 { |
|
1077 __ASSERT_DEBUG( iActivityManager, DoPanic(ELockIllegalState)); |
|
1078 if ( iActivityManager ) |
|
1079 { |
|
1080 TInt value = GetAutoLockTimeout( ); |
|
1081 INFO_1( "CLockAppDevicelockControl::ResetInactivityTimeout - %d sec", value); |
|
1082 if ( value ) |
|
1083 { |
|
1084 iActivityManager->SetInactivityTimeout( value ); |
|
1085 } |
|
1086 else |
|
1087 { |
|
1088 iActivityManager->SetInactivityTimeout( KAutoDeviceLockOff ); |
|
1089 } |
|
1090 } |
|
1091 } |
|
1092 |
|
1093 // ---------------------------------------------------------- |
|
1094 // Stop monitoring user activity. |
|
1095 // ---------------------------------------------------------- |
|
1096 void CLockAppDevicelockControl::StopActivityMonitoring( ) |
|
1097 { |
|
1098 __ASSERT_DEBUG( iActivityManager, DoPanic(ELockIllegalState)); |
|
1099 if ( iActivityManager ) |
|
1100 { |
|
1101 iActivityManager->Cancel( ); |
|
1102 } |
|
1103 } |
|
1104 |
|
1105 // ---------------------------------------------------------- |
|
1106 // Handle Active event. Called by ActivityManager |
|
1107 // ---------------------------------------------------------- |
|
1108 TInt CLockAppDevicelockControl::HandleActiveEventL(TAny* /*aPtr*/) |
|
1109 { |
|
1110 return KErrNone; |
|
1111 } |
|
1112 |
|
1113 // ---------------------------------------------------------- |
|
1114 // Handles InActive event. Called by ActivityManager |
|
1115 // ---------------------------------------------------------- |
|
1116 TInt CLockAppDevicelockControl::HandleInactiveEventL(TAny* aPtr ) |
|
1117 { |
|
1118 CLockAppDevicelockControl* devicelock = STATIC_CAST(CLockAppDevicelockControl*, aPtr); |
|
1119 if ( devicelock->GetAutoLockTimeout( ) ) |
|
1120 { |
|
1121 devicelock->iStateControl.EnableDevicelockL( EDevicelockTimer ); |
|
1122 } |
|
1123 return KErrNone; |
|
1124 } |
|
1125 |
|
1126 // --------------------------------------------------------------------------- |
|
1127 // Set custom status pane visible |
|
1128 // --------------------------------------------------------------------------- |
|
1129 void CLockAppDevicelockControl::ShowStatusPane( const TBool aVisible ) |
|
1130 { |
|
1131 CEikStatusPane* statuspane = iAvkonAppUi->StatusPane(); |
|
1132 if ( statuspane ) |
|
1133 { |
|
1134 statuspane->MakeVisible( aVisible ); |
|
1135 } |
|
1136 } |
|
1137 |
|
1138 // --------------------------------------------------------------------------- |
|
1139 // Handle UI commands received from the child controls |
|
1140 // --------------------------------------------------------------------------- |
|
1141 void CLockAppDevicelockControl::ProcessCommandL(TInt aCommandId) |
|
1142 { |
|
1143 INFO_1("CLockAppDevicelockControl::ProcessCommandL : %d ", aCommandId ); |
|
1144 } |
|
1145 |
|
1146 TInt CLockAppDevicelockControl::CountComponentControls() const |
|
1147 { |
|
1148 return 2; |
|
1149 } |
|
1150 |
|
1151 CCoeControl* CLockAppDevicelockControl::ComponentControl(TInt aIndex ) const |
|
1152 { |
|
1153 switch ( aIndex ) |
|
1154 { |
|
1155 case 0: |
|
1156 return iCba; |
|
1157 case 1: |
|
1158 return iContainer; |
|
1159 default: |
|
1160 return NULL; |
|
1161 } |
|
1162 } |
|
1163 |
|
1164 // --------------------------------------------------------------------------- |
|
1165 // Notification if layout changes. |
|
1166 // --------------------------------------------------------------------------- |
|
1167 void CLockAppDevicelockControl::HandleResourceChange(TInt aType ) |
|
1168 { |
|
1169 if ( aType == KEikDynamicLayoutVariantSwitch && iCba ) |
|
1170 { |
|
1171 TRect screenRect; |
|
1172 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
1173 iCba->SetBoundingRect( screenRect ); |
|
1174 } |
|
1175 CCoeControl::HandleResourceChange( aType ); |
|
1176 } |
|
1177 |
|
1178 // END OF FILE |
|