|
1 /* |
|
2 * Copyright (c) 2009 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: HtiStartupWait implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "HtiStartupWait.h" |
|
21 #include <HtiLogging.h> |
|
22 #include <e32property.h> |
|
23 #include <hal.h> |
|
24 #include <startupdomainpskeys.h> |
|
25 |
|
26 // CONSTANTS |
|
27 const TInt KStateCheckInterval = 3000000; // microseconds |
|
28 |
|
29 // LOCAL CONSTANTS AND MACROS |
|
30 |
|
31 // MODULE DATA STRUCTURES |
|
32 |
|
33 // LOCAL FUNCTION PROTOTYPES |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 |
|
37 |
|
38 // ============================= LOCAL FUNCTIONS =============================== |
|
39 |
|
40 // ---------------------------------------------------------------------------- |
|
41 EXPORT_C CHtiStartupWait* NewStartupWait() |
|
42 { |
|
43 return new ( ELeave ) CHtiStartupWait(); |
|
44 |
|
45 } |
|
46 |
|
47 // ============================ MEMBER FUNCTIONS =============================== |
|
48 |
|
49 // ---------------------------------------------------------------------------- |
|
50 TInt CHtiStartupWait::WaitForStartup( TInt aMaxWaitTime ) |
|
51 { |
|
52 TInt err = KErrNone; |
|
53 |
|
54 // Not relying on TTime as the time might change during OS startup. |
|
55 // Counting the time from nano ticks. |
|
56 TInt nTickPeriod; |
|
57 HAL::Get( HAL::ENanoTickPeriod, nTickPeriod ); |
|
58 HTI_LOG_FORMAT( "ENanoTickPeriod = %d", nTickPeriod ); |
|
59 |
|
60 TUint32 startTime = User::NTickCount(); |
|
61 TInt secsFromStart = 0; |
|
62 |
|
63 TInt state = ESwStateStartingUiServices; // TPSGlobalSystemState |
|
64 RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state ); |
|
65 while ( state != ESwStateNormalRfOn && state != ESwStateNormalRfOff && |
|
66 secsFromStart < aMaxWaitTime ) |
|
67 { |
|
68 HTI_LOG_FORMAT( |
|
69 "HTI waiting for device to start: TPSGlobalSystemState = %d", |
|
70 state ); |
|
71 User::After( KStateCheckInterval ); |
|
72 secsFromStart = |
|
73 ( User::NTickCount() - startTime ) * nTickPeriod / 1000000; |
|
74 HTI_LOG_FORMAT( "Seconds from start %d", secsFromStart ); |
|
75 RProperty::Get( KPSUidStartup, KPSGlobalSystemState, state ); |
|
76 } |
|
77 |
|
78 if ( secsFromStart >= aMaxWaitTime ) |
|
79 { |
|
80 HTI_LOG_TEXT( "Max wait time exceeded" ); |
|
81 err = KErrTimedOut; |
|
82 } |
|
83 |
|
84 return err; |
|
85 } |
|
86 |
|
87 |
|
88 // End of File |