|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Definition of main logoc of agps manager |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 #ifndef MAINLOGIC_H |
|
24 #define MAINLOGIC_H |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <lbs.h> |
|
28 #include <lbs/lbsextendedsatellite.h> |
|
29 #include <lbs/lbsassistancedatabase.h> |
|
30 #include <lbs/lbslocdatasourcegpsbase.h> |
|
31 #include <lbs/epos_intgpshwstatus.h> |
|
32 |
|
33 #include "LbsInternalInterface.h" |
|
34 #include "lbscommoninternaldatatypes.h" |
|
35 #include "lbsrootapi.h" |
|
36 |
|
37 #include "lbsprocesssupervisor.h" |
|
38 #include "lbstimer.h" |
|
39 #include "lbslocationrequesthandler.h" |
|
40 #include "lbsassistancedatacacheapi.h" |
|
41 #include "lbsnetworkgatewayhandler.h" |
|
42 #include "cquietus.h" |
|
43 #include "lbsautoclockadjust.h" |
|
44 #include "lbsearlycompletionupdatehandler.h" |
|
45 #include "LbsLogger.h" |
|
46 #include "lbsnetregstatusint.h" |
|
47 #if defined(_DEBUG) |
|
48 #include "LbsOomListener.h" |
|
49 #endif |
|
50 |
|
51 class CLbsAdmin; |
|
52 |
|
53 |
|
54 const TPositionModuleId KSirfModuleId= {0x10282249}; // Ecom plugin implementation Id |
|
55 |
|
56 |
|
57 //************************************************************************************************************ |
|
58 // CManagerMainLogic |
|
59 //************************************************************************************************************ |
|
60 class CManagerMainLogic : public CBase, |
|
61 public MLbsLocationSourceGpsObserver, |
|
62 public MLbsCallbackTimerObserver, |
|
63 public MLocationRequestHandlerObserver, |
|
64 public MNetworkGatewayHandlerObserver, |
|
65 public MLbsProcessCloseDown, |
|
66 public MLbsEarlyCompletionUpdateObserver |
|
67 { |
|
68 public: |
|
69 static CManagerMainLogic* NewL(); |
|
70 ~CManagerMainLogic(); |
|
71 public: |
|
72 |
|
73 enum TLocReqStatus |
|
74 { |
|
75 EReqNone = 0, |
|
76 EReqReceived = 1, |
|
77 EReqSessionStarted = 2, |
|
78 EReqReceivedDuringSession = 3, |
|
79 EReqSessionCompleted = 4 |
|
80 }; |
|
81 |
|
82 class TSessionClosureData |
|
83 { |
|
84 public: |
|
85 TInt iLastStatus; |
|
86 TPositionExtendedSatelliteInfo iLastPosInfo; |
|
87 TTime iLastTargetTime; |
|
88 TBool iNotify; |
|
89 }; |
|
90 |
|
91 public: |
|
92 // from MLbsLocationSourceGpsObserver |
|
93 TVersion Version(); |
|
94 void UpdateLocation(TInt aStatus, const TPositionInfoBase* aPosition[], TInt aNumItems, const TTime& aTargetTime); |
|
95 void UpdateDeviceStatus(TPositionModuleStatus::TDeviceStatus aDeviceStatus); |
|
96 void UpdateDataQualityStatus(TPositionModuleStatus::TDataQualityStatus aDataQuality); |
|
97 TInt GetAssistanceDataItem(TLbsAssistanceDataItem aItem, RDataReaderRootBase& aDataRoot, TTime& aTimeStamp); |
|
98 TInt GetAssistanceDataItemTimeStamp(TLbsAssistanceDataItem aItem, TTime& aTimeStamp); |
|
99 void RequestAssistanceData(TLbsAsistanceDataGroup aDataItemMask); |
|
100 void Shutdown(); |
|
101 |
|
102 void NotifyServiceToClose(TRequestStatus* aStatus); |
|
103 |
|
104 // from MLocationRequestHandlerObserver |
|
105 void OnLocationRequestStateChanged(const RLbsPositionUpdateRequests::TChannelIdentifer& aChannel,const TRequestStateChangeReason& aReason); |
|
106 void OnSystemStatusAdvice(const RLbsPositionUpdateRequests::TChannelIdentifer& aChannel, TBool aTracking); |
|
107 void OnPowerModeAdvice(const RLbsPositionUpdateRequests::TChannelIdentifer& aChannel, CLbsLocationSourceGpsBase::TPowerMode& aPowerMode); |
|
108 // from MNetworkGatewayHandlerObserver |
|
109 void OnAssistanceDataResponse(TInt aError, TLbsAsistanceDataGroup aMask); |
|
110 void OnSessionComplete(TInt aReason, const TLbsNetSessionIdInt& aSessionId); |
|
111 // from MLbsCloseDownObserver |
|
112 void OnProcessCloseDown(); |
|
113 |
|
114 // from MLbsCallbackTimerObserver |
|
115 virtual void OnTimerEventL(TInt aTimerId); |
|
116 virtual TInt OnTimerError(TInt aTimerId, TInt aError); |
|
117 |
|
118 // from MLbsEarlyCompletionUpdateObserver |
|
119 virtual void EarlyCompletionUpdate(TPositionInfo& aEarlyCompletionUpdate, TTime& aTargetTime, TTime& aActualTime); |
|
120 |
|
121 |
|
122 private: |
|
123 |
|
124 CManagerMainLogic(); |
|
125 void ConstructL(); |
|
126 void CombineLocationRequests(const TUid& aOriginatingChannel, const TRequestStateChangeReason& aOriginatorReason = EReasonNone); |
|
127 void ConfigureGpsMode(const TUid& aChannelId, const TRequestStateChangeReason& aReason); |
|
128 |
|
129 void GetTimeAndQuality(const CLocationRequestHandler& aRequestHandler, TTime& aStartTime, TLbsLocRequestQualityInt& aQuality); |
|
130 TPositionModuleInfo::TTechnologyType GetTechnologyTypeFromNrhRequest(const TInt& aIndex); |
|
131 TPositionModuleInfo::TTechnologyType GetTechnologyTypeFromLsRequest(const TInt& aIndex); |
|
132 |
|
133 void RestartTimerIfTracking(); |
|
134 void SendSystemStatusAdvice(TBool aTracking); |
|
135 void GetFinalNetPositionLagFromAdminProfileL(); |
|
136 void SetGpsOptions(const TPositionModuleInfo::TTechnologyType aNewPositioningMethod); |
|
137 TBool IsUpdateAsExpected(const TPositionInfoBase* aPosInfoArray[],const TInt& aNumItems, TInt& aPositionCalculationIndex, TInt& aMeasurementIndex); |
|
138 void GetGpsUpdateIndexes(const TPositionInfoBase* aPosInfoArray[], const TInt& aNumItems, TInt& aPositionCalculationIndex, TInt& aMeasurementIndex); |
|
139 void PublishDummyPosition(TInt aReason); |
|
140 void PublishDummyAssistDataEvent(TInt aReason); |
|
141 void ConvertToTLbsLocRequestQuality(const TLbsLocRequestQualityInt& aSource, TLbsLocRequestQuality& aDest) const; |
|
142 void GetTaGpsModeFromAdmin(CLbsAdmin::TGpsMode& aGpsMode); |
|
143 TPositionModuleInfo::TTechnologyType CalculatePositioningMethod(); |
|
144 TPositionModuleInfo::TTechnologyType LookUpPositioningMethodInCombinationTables(); |
|
145 |
|
146 void CalculateActiveLSMode(const TUid& aChannelId, const TRequestStateChangeReason& aReason, TBool& aForceSelfLocate); |
|
147 |
|
148 private: |
|
149 TBool iClosingDown; |
|
150 CLbsCloseDownRequestDetector* iCloseDownRequestDetector; |
|
151 CQuietus* iQuietus; |
|
152 |
|
153 CLbsLocationSourceGpsBase* iLocationSource; |
|
154 CNetworkGatewayHandler* iNetworkGatewayHandler; |
|
155 CLocationRequestHandler* iNRHLocationRequestHandler; |
|
156 CLocationRequestHandler* iLocSvrLocationRequestHandler; |
|
157 CEarlyCompletionUpdateHandler* iEarlyCompletionUpdateHandler; |
|
158 |
|
159 CLbsCallbackTimer* iTimer; |
|
160 |
|
161 |
|
162 CAutoClockAdjust* iAutoClockAdjust; |
|
163 RLbsPositionUpdates iPositionUpdates;// For publishing position updates for Loc Server and NRH. |
|
164 RLbsGpsMeasurementUpdates iMeasurementUpdates; |
|
165 RLbsModuleStatus iModuleStatus; |
|
166 |
|
167 TLocReqStatus iLSReqState; |
|
168 TBool iIsNrhCancelDue; // A NRH request must be cancelled even if it has timed out |
|
169 TLbsNetSessionIdInt iSessionId; |
|
170 TBool iLastTrackingFlagSentToNG; |
|
171 TBool iTrackingStateUnknown; |
|
172 // LBSLogging |
|
173 RLbsLogger iLogger; |
|
174 TLbsAsistanceDataGroup iLogAssitaceDataGroup; |
|
175 |
|
176 |
|
177 // Position update cache (for republishing in some scenarios only) |
|
178 TSessionClosureData iSessionClosureData; |
|
179 |
|
180 TTimeIntervalMicroSeconds iFinalNetPositionLag; |
|
181 CLbsAdmin* iAdmin; |
|
182 |
|
183 //Stores the last power advice recieved |
|
184 CLbsLocationSourceGpsBase::TPowerMode iPowerModeLS; |
|
185 CLbsLocationSourceGpsBase::TPowerMode iPowerModeNRH; |
|
186 |
|
187 // the current behaviour mode of Lbs |
|
188 CLbsAdmin::TLbsBehaviourMode iLbsBehaviourMode; |
|
189 |
|
190 // Capabilities of underlying GPS hardware regarding |
|
191 // positioning methods it supports |
|
192 TPositionModuleInfoExtended::TDeviceGpsModeCapabilities iCapabilities; |
|
193 |
|
194 RLbsNetworkRegistrationStatus iNetRegStatus; |
|
195 |
|
196 // Positioning method used last to configure GPS options |
|
197 TPositionModuleInfo::TTechnologyType iCurrentPositioningMethod; |
|
198 |
|
199 // Positioning method last used to configure the GPS module |
|
200 // options due to a Location Request from the Location server. |
|
201 // It is set to KLbsMethodNone when the Location server reques goes inactive. |
|
202 TPositionModuleInfo::TTechnologyType iActiveLSMode; |
|
203 |
|
204 // Positioning method last sent to the Network Gateway in |
|
205 // a SelfLocateRequest. It is set to KLbsMethodNone |
|
206 // when self location session terminates. |
|
207 TPositionModuleInfo::TTechnologyType iCurrentNetworkMode; |
|
208 |
|
209 #if defined(_DEBUG) |
|
210 CLbsOomListener* iOomListener; |
|
211 #endif |
|
212 |
|
213 // Flag which gets set when in Prefer Terminal Assisted and there is |
|
214 // an error from the network. This flag is needed because the AGPS manager |
|
215 // always ensures positions/measurements are returned correctly. So it |
|
216 // would typically wait for measurements when in PTA. But in the case |
|
217 // of a fatal network error the module can fall-back to Autonomous. In that |
|
218 // case the PTA mode is set and positions are returned. So we need this |
|
219 // flag to know when we can accept positions in PTA. |
|
220 TBool iFallbackFromPTAToAutonomousPossible; |
|
221 // Flag that specifies if currently gps timing of cell frames is requested |
|
222 TBool iCurrentGpsTimingOfCellFramesRequested; |
|
223 |
|
224 CPosIntGpsHwStatus* iPosIntGpsHwStatus; |
|
225 |
|
226 }; |
|
227 |
|
228 |
|
229 #endif //MAINLOGIC_H |
|
230 |