|
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 // |
|
15 |
|
16 //************************************************************************************************************ |
|
17 // System |
|
18 #include <bacline.h> |
|
19 #include <e32cons.h> |
|
20 #include <ecom/ecom.h> |
|
21 |
|
22 // Project |
|
23 #include "lbsmanagermainlogic.h" |
|
24 #include "lbstimer.h" |
|
25 #include <lbs.h> |
|
26 #include <lbs/lbsassistancedatabase.h> |
|
27 #include <lbs/lbslocdatasourcegpsbase.h> |
|
28 #include "LbsInternalInterface.h" |
|
29 #include "lbsnetworkgatewayhandler.h" |
|
30 #include "lbsautoclockadjust.h" |
|
31 #include "lbsprocessuiddefs.h" |
|
32 #include "utilfunctions.h" |
|
33 #include <lbs/lbsextendedsatellite.h> |
|
34 #include <lbs/lbsgpsmeasurement.h> |
|
35 #include "lbsdevloggermacros.h" |
|
36 #include <lbs/lbslocerrors.h> |
|
37 #include <lbs/lbsgpsmeasurement.h> |
|
38 #include "lbsqualityprofile.h" |
|
39 #include <lbs/lbslocdatasourceclasstypes.h> |
|
40 #include <lbs/epos_intgpshwstatus.h> |
|
41 #include "lbscommoninternaldatatypes.h" |
|
42 #include "lbsreffnpint.h" |
|
43 #include "lbsnetregstatusint.h" |
|
44 |
|
45 #ifdef AGPS_MODULE_TESTING |
|
46 #include "lbslocsourcegps.h" |
|
47 #endif |
|
48 |
|
49 #ifdef AGPS_MANAGER_TESTING |
|
50 #include "ctestgpsmodule.h" |
|
51 #endif |
|
52 |
|
53 class RLbsPositionUpdates; |
|
54 |
|
55 const TInt64 KTrackingOffTimeout = 30000000;//30s |
|
56 |
|
57 const RLbsPositionUpdateRequests::TChannelIdentifer KChannelIdentifierLS = |
|
58 { |
|
59 {KLbsGpsLocManagerUidValue},{KLbsLocServerUidValue} |
|
60 }; |
|
61 const RLbsPositionUpdateRequests::TChannelIdentifer KChannelIdentifierNRH = |
|
62 { |
|
63 {KLbsGpsLocManagerUidValue},{KLbsNetRequestHandlerUidValue} |
|
64 }; |
|
65 |
|
66 |
|
67 #include "LbsAssistanceDataLogEvent.h" |
|
68 |
|
69 const TInt KLbsLogQueueSize = 10; |
|
70 |
|
71 |
|
72 // Definitions of constants to represent positioning methods (definitions are local |
|
73 // to this file, not LBS-wide) |
|
74 static const TPositionModuleInfo::TTechnologyType KLbsMethodNone = |
|
75 TPositionModuleInfo::ETechnologyUnknown; |
|
76 |
|
77 static const TPositionModuleInfo::TTechnologyType KLbsMethodAutonomous = |
|
78 TPositionModuleInfo::ETechnologyTerminal; |
|
79 |
|
80 static const TPositionModuleInfo::TTechnologyType KLbsMethodTerminalBased = |
|
81 TPositionModuleInfo::ETechnologyTerminal | |
|
82 TPositionModuleInfo::ETechnologyAssisted; |
|
83 |
|
84 static const TPositionModuleInfo::TTechnologyType KLbsMethodTerminalAssisted = |
|
85 TPositionModuleInfo::ETechnologyNetwork | |
|
86 TPositionModuleInfo::ETechnologyAssisted; |
|
87 |
|
88 static const TPositionModuleInfo::TTechnologyType KLbsMethodDual = |
|
89 TPositionModuleInfo::ETechnologyNetwork | |
|
90 TPositionModuleInfo::ETechnologyTerminal | |
|
91 TPositionModuleInfo::ETechnologyAssisted; |
|
92 |
|
93 // Gps Options Combination Table entry |
|
94 struct TLbsGpsCombinedModeTableEntry |
|
95 { |
|
96 TPositionModuleInfo::TTechnologyType iLSPreferredMode; |
|
97 TPositionModuleInfo::TTechnologyType iLSAlternativeMode; |
|
98 TPositionModuleInfo::TTechnologyType iNRHPreferredMode; |
|
99 TPositionModuleInfo::TTechnologyType iNRHAlternativeMode; |
|
100 TPositionModuleInfo::TTechnologyType iResultingMode; |
|
101 }; |
|
102 |
|
103 // Module supports Autonomous only. |
|
104 static const TLbsGpsCombinedModeTableEntry KLbsAutonomousTable[] = |
|
105 { |
|
106 //LS Preferred //LS Altenative //NRH Preferred //NRH Alternative // Result |
|
107 {KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodAutonomous} |
|
108 }; |
|
109 static const TInt KLbsAutonomousTableCount(sizeof(KLbsAutonomousTable) / sizeof(TLbsGpsCombinedModeTableEntry)); |
|
110 |
|
111 // Module supports Terminal-Based only. |
|
112 static const TLbsGpsCombinedModeTableEntry KLbsTBTable[] = |
|
113 { |
|
114 //LS Preferred //LS Altenative //NRH Preferred //NRH Alternative // Result |
|
115 {KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodAutonomous}, |
|
116 {KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalBased}, |
|
117 |
|
118 {KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodTerminalBased}, |
|
119 {KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalBased}, |
|
120 }; |
|
121 static const TInt KLbsTBTableCount(sizeof(KLbsTBTable) / sizeof(TLbsGpsCombinedModeTableEntry)); |
|
122 |
|
123 // Module supports Terminal-Assisted only. |
|
124 static const TLbsGpsCombinedModeTableEntry KLbsTATable[] = |
|
125 { |
|
126 //LS Preferred //LS Altenative //NRH Preferred // NRH Alternative // Result |
|
127 {KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodTerminalAssisted}, |
|
128 }; |
|
129 static const TInt KLbsTATableCount(sizeof(KLbsTATable) / sizeof(TLbsGpsCombinedModeTableEntry)); |
|
130 |
|
131 // Module supports either Terminal-Assisted or Terminal-Based (but not both at the same time). |
|
132 static const TLbsGpsCombinedModeTableEntry KLbsTBOrTATable[] = |
|
133 { |
|
134 //LS Preferred //LS Altenative //NRH Preferred //NRH Alternative // Result |
|
135 {KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodAutonomous}, |
|
136 {KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalBased}, |
|
137 {KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodTerminalAssisted}, |
|
138 |
|
139 {KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodTerminalBased}, |
|
140 {KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalBased}, |
|
141 {KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodTerminalAssisted}, |
|
142 |
|
143 {KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodAutonomous}, |
|
144 {KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalBased}, |
|
145 {KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodTerminalAssisted}, |
|
146 }; |
|
147 static const TInt KLbsTBOrTATableCount(sizeof(KLbsTBOrTATable) / sizeof(TLbsGpsCombinedModeTableEntry)); |
|
148 |
|
149 // Module supports Terminal-Assisted and Terminal-Base simultaneously. |
|
150 static const TLbsGpsCombinedModeTableEntry KLbsTBAndTATable[] = |
|
151 { |
|
152 //LS Preferred //LS Altenative //NRH Preferred //NRH Alternative // Result |
|
153 {KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodAutonomous}, |
|
154 {KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalBased}, |
|
155 {KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodDual}, |
|
156 {KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodTerminalAssisted, KLbsMethodAutonomous, KLbsMethodDual}, |
|
157 {KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodAutonomous, KLbsMethodTerminalAssisted, KLbsMethodDual}, |
|
158 {KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodTerminalBased, KLbsMethodTerminalAssisted, KLbsMethodDual}, |
|
159 {KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodTerminalAssisted, KLbsMethodTerminalBased, KLbsMethodDual}, |
|
160 |
|
161 |
|
162 {KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodTerminalBased}, |
|
163 {KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalBased}, |
|
164 {KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodDual}, |
|
165 {KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalAssisted, KLbsMethodAutonomous, KLbsMethodDual}, |
|
166 {KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodAutonomous, KLbsMethodTerminalAssisted, KLbsMethodDual}, |
|
167 {KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalBased, KLbsMethodTerminalAssisted, KLbsMethodDual}, |
|
168 {KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodTerminalAssisted, KLbsMethodTerminalBased , KLbsMethodDual}, |
|
169 |
|
170 {KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodAutonomous, KLbsMethodNone, KLbsMethodDual}, |
|
171 {KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodTerminalBased, KLbsMethodNone, KLbsMethodDual}, |
|
172 {KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodTerminalAssisted}, |
|
173 {KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodTerminalAssisted, KLbsMethodAutonomous, KLbsMethodDual}, |
|
174 {KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodAutonomous, KLbsMethodTerminalAssisted, KLbsMethodDual}, |
|
175 {KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodTerminalBased, KLbsMethodTerminalAssisted, KLbsMethodDual}, |
|
176 {KLbsMethodTerminalAssisted, KLbsMethodNone, KLbsMethodTerminalAssisted, KLbsMethodTerminalBased, KLbsMethodDual}, |
|
177 }; |
|
178 static const TInt KLbsTBAndTATableCount(sizeof(KLbsTBAndTATable)/sizeof(TLbsGpsCombinedModeTableEntry)); |
|
179 |
|
180 //************************************************************************************************************ |
|
181 // CManagerMainLogic |
|
182 //************************************************************************************************************ |
|
183 |
|
184 #define __ASSERT_ALWAYSX(c,p) (void)((c)||(RDebug::Printf("Assert at line %d in file %s ",__LINE__,__FILE__),p,0)); |
|
185 |
|
186 CManagerMainLogic* CManagerMainLogic::NewL() |
|
187 { |
|
188 LBSLOG(ELogP1, "CManagerMainLogic::NewL() Begin\n"); |
|
189 CManagerMainLogic* self = new(ELeave) CManagerMainLogic; |
|
190 CleanupStack::PushL(self); |
|
191 self->ConstructL(); |
|
192 |
|
193 CleanupStack::Pop(self); |
|
194 LBSLOG(ELogP1, "CManagerMainLogic::NewL() End\n"); |
|
195 return self; |
|
196 } |
|
197 |
|
198 //------------------------------------------------------------------------------------------------------------ |
|
199 CManagerMainLogic::CManagerMainLogic() : |
|
200 iClosingDown(EFalse), |
|
201 iLSReqState(EReqNone), |
|
202 iSessionId(KLbsGpsLocManagerUid, 0), |
|
203 iLastTrackingFlagSentToNG(EFalse), |
|
204 iTrackingStateUnknown(ETrue), |
|
205 iPowerModeLS(CLbsLocationSourceGpsBase::EPowerModeUnknown), |
|
206 iPowerModeNRH(CLbsLocationSourceGpsBase::EPowerModeUnknown) |
|
207 { |
|
208 LBSLOG(ELogP1, "CManagerMainLogic::CManagerMainLogic()\n"); |
|
209 } |
|
210 |
|
211 //------------------------------------------------------------------------------------------------------------ |
|
212 void CManagerMainLogic::ConstructL() |
|
213 { |
|
214 LBSLOG(ELogP1, "CManagerMainLogic::ConstructL() Begin\n"); |
|
215 iQuietus = CQuietus::NewL(); |
|
216 |
|
217 // Create the monitor which detects a closedown signal from |
|
218 // the LBS Root Process. |
|
219 iCloseDownRequestDetector = CLbsCloseDownRequestDetector::NewL(this, KLbsGpsLocManagerUid); |
|
220 |
|
221 iPositionUpdates.OpenL(KLbsGpsLocManagerUid); |
|
222 iMeasurementUpdates.OpenL(); |
|
223 iModuleStatus.OpenL(KLbsGpsLocManagerUid); |
|
224 |
|
225 iNetworkGatewayHandler = CNetworkGatewayHandler::NewL(this); |
|
226 |
|
227 iNRHLocationRequestHandler = CLocationRequestHandler::NewL(*this,KChannelIdentifierNRH); |
|
228 iLocSvrLocationRequestHandler = CLocationRequestHandler::NewL(*this,KChannelIdentifierLS); |
|
229 |
|
230 iEarlyCompletionUpdateHandler = CEarlyCompletionUpdateHandler::NewL(this); |
|
231 iEarlyCompletionUpdateHandler->ListenForEarlyCompletionUpdates(); |
|
232 |
|
233 TPositionModuleStatus moduleStatus; |
|
234 // set initial dynamic module status and tell interested parties |
|
235 moduleStatus.SetDeviceStatus(TPositionModuleStatus::EDeviceInactive); |
|
236 moduleStatus.SetDataQualityStatus(TPositionModuleStatus::EDataQualityUnknown); |
|
237 |
|
238 TPositionModuleStatusEventBase::TModuleEvent occurredEventsSinceLastSet = |
|
239 TPositionModuleStatusEventBase::EEventDeviceStatus | TPositionModuleStatusEventBase::EEventDataQualityStatus; |
|
240 iModuleStatus.SetModuleStatus(&moduleStatus,sizeof(moduleStatus),occurredEventsSinceLastSet); |
|
241 |
|
242 LBSLOG(ELogP9, "->S CLbsLocationSourceGpsBase::NewL() AGPSModule\n"); |
|
243 LBSLOG2(ELogP9, " > CManagerMainLogic this = 0x%08X\n", this); |
|
244 |
|
245 iPosIntGpsHwStatus = CPosIntGpsHwStatus::NewL(); |
|
246 |
|
247 #ifdef AGPS_MODULE_TESTING |
|
248 // ECOM plug-in not used in unit test |
|
249 iLocationSource = CLbsLocationSourceGps::NewL(*this); |
|
250 |
|
251 // When module testing there is no root process so the device capabilities |
|
252 // are not available from LbsModuleInfo |
|
253 iCapabilities = TPositionModuleInfoExtended::EDeviceGpsModeSimultaneousTATB; |
|
254 |
|
255 #elif defined(AGPS_MANAGER_TESTING) |
|
256 // ECOM plug-in not used in unit test |
|
257 iLocationSource = CTestGpsModule::NewL(*this); |
|
258 |
|
259 // When unit-testing there is no root process so the device capabilities |
|
260 // are not available from LbsModuleInfo...read capabilities from the |
|
261 // corresponding test property |
|
262 TInt capabilities = 0; |
|
263 TUid KSuiteExeUid = {0x102869CB}; |
|
264 TUint KGpsModeCapabilities = 0; |
|
265 TInt err = RProperty::Get(KSuiteExeUid, KGpsModeCapabilities, capabilities); |
|
266 ASSERT(err == KErrNone); |
|
267 iCapabilities = capabilities; |
|
268 #else |
|
269 // Instantiate Ecom plugin |
|
270 TUid dataSourceId; |
|
271 TInt result = LbsModuleInfo::GetDataSourceId(KLbsGpsLocManagerUid, dataSourceId); |
|
272 LBSLOG2(ELogP9, " > TUid dataSourceId = 0x%08X\n", dataSourceId.iUid); |
|
273 iLocationSource = CLbsLocationSourceGpsBase::NewL(*this, dataSourceId); |
|
274 |
|
275 // Get capabilities from module info |
|
276 User::LeaveIfError(LbsModuleInfo::GetDeviceCapabilities(KLbsGpsLocManagerUid, iCapabilities)); |
|
277 #endif |
|
278 |
|
279 iAutoClockAdjust = CAutoClockAdjust::NewL(); |
|
280 |
|
281 // Used to send Tracking Off if the Loc Server doesn't keep sending location requests. |
|
282 iTimer = CLbsCallbackTimer::NewL(*this); |
|
283 |
|
284 // Disable tracking if no messages received from the Loc Server before timeout |
|
285 RestartTimerIfTracking(); |
|
286 |
|
287 // Open logger |
|
288 iLogger.Open(KLbsLogQueueSize); |
|
289 |
|
290 iSessionClosureData.iNotify = EFalse; |
|
291 |
|
292 // Read the admin setting for the lag timer |
|
293 iAdmin = CLbsAdmin::NewL(); |
|
294 GetFinalNetPositionLagFromAdminProfileL(); |
|
295 |
|
296 iNetRegStatus.OpenL(); |
|
297 |
|
298 #if defined(_DEBUG) |
|
299 // For OOM testing. The listener will force an error on the next heap |
|
300 // allocation when it is kicked by test code. |
|
301 iOomListener = CLbsOomListener::NewL(); |
|
302 iOomListener->StartGettingRequests(); |
|
303 #endif |
|
304 |
|
305 |
|
306 |
|
307 LBSLOG(ELogP1, "CManagerMainLogic::ConstructL() End\n"); |
|
308 } |
|
309 |
|
310 |
|
311 //------------------------------------------------------------------------------------------------------------ |
|
312 CManagerMainLogic::~CManagerMainLogic() |
|
313 { |
|
314 LBSLOG(ELogP1, "CManagerMainLogic::~CManagerMainLogic() Begin\n"); |
|
315 |
|
316 LBSLOG(ELogP9, "->S CLbsLocationSourceGpsBase::~CLbsLocationSourceGpsBase() AGPSModule\n"); |
|
317 delete iLocationSource; |
|
318 #ifndef AGPS_MODULE_TESTING |
|
319 REComSession::FinalClose(); |
|
320 #endif |
|
321 |
|
322 delete iPosIntGpsHwStatus; |
|
323 delete iCloseDownRequestDetector; |
|
324 |
|
325 iLocationSource = NULL; |
|
326 |
|
327 delete iQuietus; |
|
328 iQuietus = NULL; |
|
329 |
|
330 iLocSvrLocationRequestHandler->Cancel(); |
|
331 delete iLocSvrLocationRequestHandler; |
|
332 iLocSvrLocationRequestHandler = NULL; |
|
333 |
|
334 |
|
335 iEarlyCompletionUpdateHandler->Cancel(); |
|
336 delete iEarlyCompletionUpdateHandler; |
|
337 iEarlyCompletionUpdateHandler = NULL; |
|
338 |
|
339 iNetworkGatewayHandler->Cancel(); |
|
340 delete iNetworkGatewayHandler; |
|
341 iNetworkGatewayHandler = NULL; |
|
342 |
|
343 iNRHLocationRequestHandler->Cancel(); |
|
344 delete iNRHLocationRequestHandler; |
|
345 iNRHLocationRequestHandler = NULL; |
|
346 |
|
347 delete iAutoClockAdjust; |
|
348 iAutoClockAdjust = NULL; |
|
349 |
|
350 if (iTimer) |
|
351 { |
|
352 iTimer->Cancel(); |
|
353 } |
|
354 |
|
355 delete iTimer; |
|
356 delete iAdmin; |
|
357 |
|
358 // Close logger |
|
359 iLogger.Close(); |
|
360 #if defined(_DEBUG) |
|
361 if(iOomListener) |
|
362 { |
|
363 iOomListener->Cancel(); |
|
364 delete iOomListener; |
|
365 } |
|
366 #endif |
|
367 |
|
368 LBSLOG(ELogP1, "CManagerMainLogic::~CManagerMainLogic() End\n"); |
|
369 } |
|
370 |
|
371 |
|
372 void CManagerMainLogic::GetFinalNetPositionLagFromAdminProfileL() |
|
373 { |
|
374 |
|
375 // Get the profile Id for self locate requests |
|
376 TLbsQualityProfileId profileId; |
|
377 TInt err = iAdmin->Get(KLbsSettingQualityProfileSelfLocate, profileId); |
|
378 if (err == KErrNone) |
|
379 { |
|
380 // Retrieve the quality profile that belongs to the given Id |
|
381 TQualityProfile quality; |
|
382 err = LbsQualityProfile::GetQualityProfileById(profileId, quality); |
|
383 if (err == KErrNone) |
|
384 { |
|
385 iFinalNetPositionLag = quality.FinalNetPositionLag(); |
|
386 } |
|
387 else |
|
388 { |
|
389 iFinalNetPositionLag = 0; |
|
390 } |
|
391 } |
|
392 |
|
393 } |
|
394 |
|
395 /* |
|
396 * Publish a dummy position on the position bus for the Loc Server, |
|
397 * note that the NRH will ignore this update since the 'conflict control' flag (overloaded for this purpose) is set to TRUE |
|
398 */ |
|
399 void CManagerMainLogic::PublishDummyPosition(TInt aReason) |
|
400 { |
|
401 TPositionExtendedSatelliteInfo dummySatInfo; |
|
402 TTime dummyTime = 0; |
|
403 iPositionUpdates.SetPositionInfo(aReason, ETrue, &dummySatInfo, sizeof(TPositionExtendedSatelliteInfo), dummyTime, dummyTime); |
|
404 } |
|
405 |
|
406 /* |
|
407 * Publish a dummy Assistance Data Event with the given error, for the integration module. |
|
408 * Note: we use 0xFFFFFFFF when informing the module of an error |
|
409 */ |
|
410 void CManagerMainLogic::PublishDummyAssistDataEvent(TInt aError) |
|
411 { |
|
412 iLocationSource->AssistanceDataEvent(aError, KLbsDummyAssistanceDataMaskWithError); |
|
413 } |
|
414 |
|
415 //----------------------------------------------------------------------------- |
|
416 |
|
417 TVersion CManagerMainLogic::Version() |
|
418 { |
|
419 LBSLOG(ELogP1, "CManagerMainLogic::Version()\n"); |
|
420 LBSLOG(ELogP9, "<-S MLbsLocationSourceGpsObserver::Version() AGPSModule\n"); |
|
421 LBSLOG(ELogP9, " Return TVersion = 1, 0, 0\n"); |
|
422 return TVersion(1,0,0); |
|
423 } |
|
424 |
|
425 |
|
426 //----------------------------------------------------------------------------- |
|
427 |
|
428 // New location arrives from integration module ... |
|
429 // from MLbsLocationSourceGpsObserver |
|
430 // |
|
431 void CManagerMainLogic::UpdateLocation |
|
432 ( |
|
433 TInt aStatus, |
|
434 const TPositionInfoBase* aPosInfoArray[], |
|
435 TInt aNumItems, |
|
436 const TTime& aTargetTime |
|
437 ) |
|
438 { |
|
439 LBSLOG(ELogP1, "CManagerMainLogic::UpdateLocation() Begin\n"); |
|
440 LBSLOG(ELogP9, "<-A MLbsLocationSourceGpsObserver::UpdateLocation() AGPSModule\n"); |
|
441 LBSLOG2(ELogP9, " > TInt aStatus = %d\n", aStatus); |
|
442 LBSLOG2(ELogP9, " > TInt aNumItems = %d\n", aNumItems); |
|
443 LBSLOG5(ELogP9, " > TTime TargetTime = %02d:%02d:%02d.%06d\n", aTargetTime.DateTime().Hour(), |
|
444 aTargetTime.DateTime().Minute(), |
|
445 aTargetTime.DateTime().Second(), |
|
446 aTargetTime.DateTime().MicroSecond()); |
|
447 LBS_RDEBUG_ARGINT("AGPSMod", "LBS", "UpdateLocation", aStatus); |
|
448 |
|
449 #ifdef ENABLE_LBS_DEV_LOGGER |
|
450 //Loop through the PositionInfoArray |
|
451 if(aPosInfoArray != NULL) |
|
452 { |
|
453 for(TInt posNum=0; posNum<aNumItems; posNum++) |
|
454 { |
|
455 const TPositionInfoBase& positionPtrTemp = (reinterpret_cast<const TPositionInfoBase&>(*(aPosInfoArray[posNum]))); |
|
456 LBSLOG2(ELogP9, " > TPositionInfoBase aPosInfoArray[%d] =\n", posNum); |
|
457 LBSLOG_TPOSITIONINFOBASE(positionPtrTemp); |
|
458 (void) positionPtrTemp; // avoid a compiler warning |
|
459 } |
|
460 } |
|
461 #endif |
|
462 |
|
463 (void)aNumItems; |
|
464 __ASSERT_ALWAYSX(aPosInfoArray != NULL,User::Panic(KLbsAGPSManFault, KErrArgument)); |
|
465 TInt positionCalculationIndex; // index where the position calculation is in the array |
|
466 TInt measurementIndex; // index where the satellite measurement is in the array |
|
467 TBool positionCalculationPossible = EFalse; |
|
468 TTime timeNow; |
|
469 timeNow.UniversalTime(); //done here so that position and measurement are published with same time. |
|
470 |
|
471 // If the update contains an error then this error will be passed on the location bus, |
|
472 // and if it's the case it will be sent with the measurements as well |
|
473 if(aStatus < 0) |
|
474 { |
|
475 LBSLOG(ELogP1,"There was an error returned"); |
|
476 |
|
477 GetGpsUpdateIndexes(aPosInfoArray, aNumItems, positionCalculationIndex, measurementIndex); |
|
478 if(measurementIndex >= 0) |
|
479 { |
|
480 // There is some measurement information so publish it together with the error |
|
481 const TPositionGpsMeasurementInfo* measurementPtr = (reinterpret_cast<const TPositionGpsMeasurementInfo*>(aPosInfoArray[measurementIndex])); |
|
482 |
|
483 iMeasurementUpdates.SetGpsMeasurementInfo(aStatus, measurementPtr, sizeof(TPositionGpsMeasurementInfo), timeNow); |
|
484 |
|
485 // Note: currently only doing this for any GPS mode except hybrid, so as not to adversely affect existing hybrid customers |
|
486 // Since there's an error in the measurement, and if there is no position returned, publish it in a dummy position for the LS since he doesn't monitor measurement bus: |
|
487 if((positionCalculationIndex < 0) && (iCurrentPositioningMethod != KLbsMethodDual)) |
|
488 { |
|
489 LBSLOG(ELogP1, "Publishing dummy position"); |
|
490 PublishDummyPosition(aStatus); |
|
491 |
|
492 iLocSvrLocationRequestHandler->InvalidateRequest(); |
|
493 iLSReqState = EReqNone; |
|
494 iNRHLocationRequestHandler->InvalidateRequest(); |
|
495 RestartTimerIfTracking(); |
|
496 } |
|
497 } |
|
498 |
|
499 if (positionCalculationIndex >= 0) |
|
500 { |
|
501 const TPositionModuleId id = {KLbsGpsLocManagerUidValue}; |
|
502 TPosition pos; |
|
503 TUint attributes = 0; // only relevant when aStatus == KPositionCalculationFutile (>0). |
|
504 const TPositionExtendedSatelliteInfo* satPositionPtr = |
|
505 (reinterpret_cast<const TPositionExtendedSatelliteInfo*>(aPosInfoArray[positionCalculationIndex])); |
|
506 TPositionExtendedSatelliteInfo position(*satPositionPtr); |
|
507 position.GetPosition(pos); |
|
508 LBSLOG3(ELogP2, "Lat=%3.4g. Long=%3.4g.\n", pos.Latitude(), pos.Longitude()); |
|
509 position.SetModuleId(id); |
|
510 |
|
511 // Invalidate all the requests. No need to call CombineLocationRequests(). |
|
512 iLocSvrLocationRequestHandler->InvalidateRequest(); |
|
513 iLSReqState = EReqNone; |
|
514 iNRHLocationRequestHandler->InvalidateRequest(); |
|
515 |
|
516 // If the network did not request ETechnologyTerminal then it doesn't need to know about |
|
517 // position updates. Set the 'conflict flag' to make the NRH ignore the position update. |
|
518 // |
|
519 TBool nrhToIgnoreUpdate = EFalse; |
|
520 if (iNRHLocationRequestHandler->IsRequestActive() && |
|
521 !(GetTechnologyTypeFromNrhRequest(0) & TPositionModuleInfo::ETechnologyTerminal) && |
|
522 !(GetTechnologyTypeFromNrhRequest(1) & TPositionModuleInfo::ETechnologyTerminal)) |
|
523 { |
|
524 nrhToIgnoreUpdate = ETrue; |
|
525 } |
|
526 |
|
527 // The position update is about to be published for the Location Server... |
|
528 // ...here we take the opportunity to let the LS know if we are collecting |
|
529 // measurements and sending them to the network (so the LS can apply a network lag timer |
|
530 // for waiting for the final network position after he client timer has expired). |
|
531 // The LS will watch out for transitions in the mode from non-TA mode to a TA mode. |
|
532 TUint gpsModeForLocationServer = RLbsPositionUpdates::EGpsModeTerminalBased; // default value |
|
533 if (iCurrentPositioningMethod & TPositionModuleInfo::ETechnologyNetwork) |
|
534 { |
|
535 gpsModeForLocationServer = RLbsPositionUpdates::EGpsModeTerminalAssisted; |
|
536 } |
|
537 |
|
538 LBSLOG(ELogP1, "CManagerMainLogic::UpdateLocation() Set position info\n"); |
|
539 LBSLOG2(ELogP1, "\t aStatus = %d\n", aStatus); |
|
540 iPositionUpdates.SetPositionInfo(aStatus, nrhToIgnoreUpdate, &position, sizeof(TPositionExtendedSatelliteInfo),aTargetTime, timeNow, attributes, gpsModeForLocationServer); |
|
541 RestartTimerIfTracking(); |
|
542 } |
|
543 } |
|
544 else if(IsUpdateAsExpected(aPosInfoArray, aNumItems, positionCalculationIndex, measurementIndex)) |
|
545 // The update will be ignored if it is of an unexpected type |
|
546 { |
|
547 LBSLOG(ELogP1,"Update is valid"); |
|
548 |
|
549 if (measurementIndex >= 0 && |
|
550 (iCurrentPositioningMethod & TPositionModuleInfo::ETechnologyNetwork) ) |
|
551 { |
|
552 LBSLOG(ELogP1, "Measurement index is positive; network expects measurements"); |
|
553 // There is a new Measurement data update when the network is expecting measurements. Publish it. |
|
554 const TPositionGpsMeasurementInfo* measurementPtr = (reinterpret_cast<const TPositionGpsMeasurementInfo*>(aPosInfoArray[measurementIndex])); |
|
555 positionCalculationPossible = measurementPtr->PositionCalculationPossible(); |
|
556 iMeasurementUpdates.SetGpsMeasurementInfo(aStatus, measurementPtr, sizeof(TPositionGpsMeasurementInfo), timeNow); |
|
557 } |
|
558 |
|
559 if (positionCalculationPossible && positionCalculationIndex < 0) |
|
560 { |
|
561 // here, we have had a measurement good enough for the network to calculate a position of |
|
562 // the required accuracy and also we have NOT had a agps position |
|
563 LBSLOG(ELogP2, "Invalidating NRG request and re-combining requests\n"); |
|
564 |
|
565 iNRHLocationRequestHandler->InvalidateRequest(); |
|
566 TUid dummyUid = {0}; |
|
567 CombineLocationRequests(dummyUid); |
|
568 } |
|
569 else if ((positionCalculationIndex >= 0 && |
|
570 (iCurrentPositioningMethod & TPositionModuleInfo::ETechnologyTerminal || iFallbackFromPTAToAutonomousPossible))) |
|
571 { |
|
572 LBSLOG(ELogP1, "Position index is positive"); |
|
573 const TPositionModuleId id = {KLbsGpsLocManagerUidValue}; |
|
574 TPosition pos; |
|
575 TReal32 horAccuracy; |
|
576 TReal32 verAccuracy; |
|
577 TBool updateCorrect = EFalse; |
|
578 TUint attributes = 0; // only relevant when aStatus == KPositionCalculationFutile (>0). |
|
579 const TPositionExtendedSatelliteInfo* satPositionPtr = |
|
580 (reinterpret_cast<const TPositionExtendedSatelliteInfo*>(aPosInfoArray[positionCalculationIndex])); |
|
581 TPositionExtendedSatelliteInfo position(*satPositionPtr); |
|
582 position.GetPosition(pos); |
|
583 horAccuracy = pos.HorizontalAccuracy(); |
|
584 verAccuracy = pos.VerticalAccuracy(); |
|
585 LBSLOG5(ELogP2, "Lat=%3.4g. Long=%3.4g. HorAcc=%3.4g. VerAcc=%3.4g.\n", pos.Latitude(), pos.Longitude(), horAccuracy, verAccuracy); |
|
586 position.SetModuleId(id); |
|
587 if (aStatus == 0) |
|
588 { |
|
589 LBSLOG(ELogP1, "Status is 0"); |
|
590 if ((horAccuracy != 0.0) && (verAccuracy != 0.0)) //IF3 |
|
591 { |
|
592 LBSLOG(ELogP1, "Update is correct for status 0"); |
|
593 |
|
594 updateCorrect = ETrue; |
|
595 |
|
596 // Both handler's IsAccuracyRequirementMet() MUST be called to ensure both handlers change state |
|
597 // if required. |
|
598 TBool isLSSatisfied = iLocSvrLocationRequestHandler->IsAccuracyRequirementMet(horAccuracy,verAccuracy); |
|
599 TBool isNRHSatisfied = iNRHLocationRequestHandler->IsAccuracyRequirementMet(horAccuracy,verAccuracy); |
|
600 |
|
601 if (positionCalculationPossible) |
|
602 { |
|
603 // we have had a measurement from which the network can |
|
604 // calculate an accurate enough position |
|
605 // so, now in Hybrid mode (we have just recieved both a measuremnt and position!) |
|
606 // the request from the NRH is now deemed over. |
|
607 iNRHLocationRequestHandler->InvalidateRequest(); |
|
608 isNRHSatisfied = ETrue; |
|
609 } |
|
610 |
|
611 if (isLSSatisfied || isNRHSatisfied) |
|
612 { |
|
613 LBSLOG(ELogP2, "NRH and/or LS satisfied with update\n"); |
|
614 // Recombine requests without specifying an originating |
|
615 // channel or reason since we are not recombining after a change |
|
616 // in the LS or NRH request handlers. |
|
617 TUid dummyUid = {0}; |
|
618 CombineLocationRequests(dummyUid); |
|
619 } |
|
620 |
|
621 if ((iLSReqState != EReqSessionStarted) && (iLSReqState != EReqReceivedDuringSession) && |
|
622 !iLocSvrLocationRequestHandler->IsRequestActive()) |
|
623 { |
|
624 LBSLOG(ELogP2, "Reseting session status\n"); |
|
625 iLSReqState = EReqNone; |
|
626 } |
|
627 |
|
628 // Pass the update to the clock adjuster. |
|
629 // It will adjust the system clock and update the TPosition::iTime if required. |
|
630 iAutoClockAdjust->LocationUpdate(aStatus, position); |
|
631 } |
|
632 } |
|
633 |
|
634 else if (aStatus > 0) |
|
635 { |
|
636 LBSLOG(ELogP1, "Status is greater than 0"); |
|
637 updateCorrect = ETrue; |
|
638 |
|
639 if (iLSReqState == EReqSessionStarted || iLSReqState == EReqReceivedDuringSession) |
|
640 { |
|
641 attributes |= RLbsPositionUpdates::ESelfLocateSessionInProgress; |
|
642 } |
|
643 |
|
644 // Check if we have to remember this position update for re-publishing it on the |
|
645 // GPS Location Bus when the session is closed. Currently this is only true |
|
646 // for KPositionCalculationFutile. |
|
647 if ((KPositionCalculationFutile == aStatus) && (attributes & RLbsPositionUpdates::ESelfLocateSessionInProgress)) |
|
648 { |
|
649 iSessionClosureData.iNotify = ETrue; |
|
650 iSessionClosureData.iLastPosInfo = position; |
|
651 iSessionClosureData.iLastStatus = aStatus; |
|
652 iSessionClosureData.iLastTargetTime = aTargetTime; |
|
653 } |
|
654 } |
|
655 |
|
656 if (updateCorrect) |
|
657 { |
|
658 LBSLOG(ELogP1, "Update is correct"); |
|
659 |
|
660 // If the network did not request Terminal Based or Autonomous positioning modes, |
|
661 // it doesn't need to know about positions. If that is the case, set the |
|
662 // 'conflict/ignore-update flag' to true so that the NRH ignores the position update. |
|
663 // (Note: Terminal Based and Autonomous are the only two positioning methods with the bit |
|
664 // TPositionModuleInfo::ETechnologyTerminal set to 1. |
|
665 // Terminal Based is "TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted"; |
|
666 // Autonomous mode is just "TPositionModuleInfo::ETechnologyTerminal"). |
|
667 TBool nrhToIgnoreUpdate = EFalse; |
|
668 if (iNRHLocationRequestHandler->IsRequestActive() && |
|
669 !(GetTechnologyTypeFromNrhRequest(0) & TPositionModuleInfo::ETechnologyTerminal) && |
|
670 !(GetTechnologyTypeFromNrhRequest(1) & TPositionModuleInfo::ETechnologyTerminal)) |
|
671 { |
|
672 nrhToIgnoreUpdate = ETrue; |
|
673 } |
|
674 |
|
675 // The position update is about to be published for the Location Server... |
|
676 // ...here we take the opportunity to let the LS know if we are collecting |
|
677 // measurements and sending them to the network (so the LS can apply a network lag timer |
|
678 // for waiting for the final network position after he client timer has expired). |
|
679 // The LS will watch out for transitions in the mode from non-TA mode to a TA mode. |
|
680 TUint gpsModeForLocationServer = RLbsPositionUpdates::EGpsModeTerminalBased; // default value |
|
681 if (iCurrentPositioningMethod & TPositionModuleInfo::ETechnologyNetwork) |
|
682 { |
|
683 gpsModeForLocationServer = RLbsPositionUpdates::EGpsModeTerminalAssisted; |
|
684 } |
|
685 |
|
686 LBSLOG(ELogP1, "CManagerMainLogic::UpdateLocation() Set position info\n"); |
|
687 LBSLOG2(ELogP1, "\t aStatus = %d\n", aStatus); |
|
688 iPositionUpdates.SetPositionInfo(aStatus, nrhToIgnoreUpdate, &position, sizeof(TPositionExtendedSatelliteInfo),aTargetTime, timeNow, attributes, gpsModeForLocationServer); |
|
689 RestartTimerIfTracking(); |
|
690 } |
|
691 } |
|
692 } |
|
693 LBSLOG(ELogP1, "CManagerMainLogic::UpdateLocation() End\n"); |
|
694 } |
|
695 |
|
696 |
|
697 // This private method checks the correctness of an update from GPS Module. |
|
698 // The method returns ETrue if the array with the updates reported by the GPS Module |
|
699 // contains at least one of the types of updates (positions or measurements) expected |
|
700 // according to the current positioning method. |
|
701 // This method returns in aPositionCalculationIndex the index of the array where the |
|
702 // position calculation is (it is set to -1 if there is none). |
|
703 // It returns in aMeasurementIndex the index of the array where the |
|
704 // position calculation is (it is set to -1 if there is none). |
|
705 // |
|
706 TBool CManagerMainLogic::IsUpdateAsExpected(const TPositionInfoBase* aPosInfoArray[],const TInt& aNumItems, TInt& aPositionCalculationIndex, TInt& aMeasurementIndex) |
|
707 { |
|
708 TBool posInfoArrayIsValid = ETrue; |
|
709 aPositionCalculationIndex = -1; |
|
710 aMeasurementIndex = -1; |
|
711 |
|
712 LBSLOG(ELogP1, "CManagerMainLogic::IsUpdateAsExpected() Begin"); |
|
713 // Check if positions and/or measurements are present in the array and record the indexes |
|
714 GetGpsUpdateIndexes(aPosInfoArray, aNumItems, aPositionCalculationIndex, aMeasurementIndex); |
|
715 |
|
716 switch (iCurrentPositioningMethod) |
|
717 { |
|
718 case KLbsMethodAutonomous: |
|
719 case KLbsMethodTerminalBased: |
|
720 // If positions were received then the update is valid. |
|
721 posInfoArrayIsValid = (aPositionCalculationIndex >= 0); |
|
722 break; |
|
723 |
|
724 case KLbsMethodTerminalAssisted: |
|
725 posInfoArrayIsValid = (aMeasurementIndex >= 0) || |
|
726 (iFallbackFromPTAToAutonomousPossible && aPositionCalculationIndex >= 0); |
|
727 break; |
|
728 |
|
729 case KLbsMethodDual: |
|
730 // Both positions and/or measurements are valid updates |
|
731 posInfoArrayIsValid = ETrue; |
|
732 break; |
|
733 |
|
734 case KLbsMethodNone: |
|
735 // No request is any longer expecting this update |
|
736 posInfoArrayIsValid = EFalse; |
|
737 break; |
|
738 |
|
739 default: |
|
740 ASSERT(EFalse); |
|
741 break; |
|
742 } |
|
743 |
|
744 LBSLOG2(ELogP1, "CManagerMainLogic::IsUpdateAsExpected() End with %d", posInfoArrayIsValid); |
|
745 return posInfoArrayIsValid; |
|
746 } |
|
747 |
|
748 |
|
749 /** |
|
750 This method returns where in the array the positions are stored and where the measurements. |
|
751 |
|
752 @aPosInfoArray The array with information sent from the GPS module |
|
753 @aNumItems The number of items in the array |
|
754 @aPositionCalculationIndex Used to return the index where positions are stored |
|
755 @aMeasurementIndex Used to return the index where measurements are stored |
|
756 */ |
|
757 void CManagerMainLogic::GetGpsUpdateIndexes(const TPositionInfoBase* aPosInfoArray[], const TInt& aNumItems, TInt& aPositionCalculationIndex, TInt& aMeasurementIndex) |
|
758 { |
|
759 aPositionCalculationIndex = -1; |
|
760 aMeasurementIndex = -1; |
|
761 |
|
762 LBSLOG(ELogP1, "CGPSModeHandlerBase::GetGpsUpdateIndexes() Begin"); |
|
763 |
|
764 // Check if positions and/or measurements are present in the array |
|
765 for (TInt index = 0; index < aNumItems; index++) |
|
766 { |
|
767 if ((aPosInfoArray[index]->PositionClassType() & EPositionSatelliteInfoClass) == EPositionSatelliteInfoClass) |
|
768 { |
|
769 LBSLOG2(ELogP1, "position present at index %d", index); |
|
770 aPositionCalculationIndex = index; |
|
771 } |
|
772 else if ((aPosInfoArray[index]->PositionClassType() & EPositionGpsMeasurementInfoClass) == EPositionGpsMeasurementInfoClass) |
|
773 { |
|
774 LBSLOG2(ELogP1, "measurement present at index %d", index); |
|
775 aMeasurementIndex = index; |
|
776 } |
|
777 } |
|
778 LBSLOG(ELogP1, "CGPSModeHandlerBase::GetGpsUpdateIndexes() End"); |
|
779 } |
|
780 |
|
781 //----------------------------------------------------------------------------- |
|
782 |
|
783 // convert TDeviceStatus to TIntGpsHwStatus |
|
784 // indexed with TPositionModuleStatus::TDeviceStatus |
|
785 // returns one of the four values: |
|
786 // EStatusUnknown, EStatusOff, EStatusOn, EStatusActive |
|
787 static const CPosIntGpsHwStatus::TIntGpsHwStatus KConvertStatusTable[8] = |
|
788 { |
|
789 CPosIntGpsHwStatus::EStatusUnknown, // EDeviceUnknown, |
|
790 CPosIntGpsHwStatus::EStatusOff, // EDeviceError -> EStatusOff |
|
791 CPosIntGpsHwStatus::EStatusOff, // EDeviceDisabled -> EStatusOff |
|
792 CPosIntGpsHwStatus::EStatusOff, // EDeviceInactive -> EStatusOff |
|
793 CPosIntGpsHwStatus::EStatusOn, // EDeviceInitialising -> EStatusOn |
|
794 CPosIntGpsHwStatus::EStatusOn, // EDeviceStandBy -> EStatusOn |
|
795 CPosIntGpsHwStatus::EStatusOn, // EDeviceReady -> EStatusOn |
|
796 CPosIntGpsHwStatus::EStatusActive // EDeviceActive |
|
797 }; |
|
798 |
|
799 //----------------------------------------------------------------------------- |
|
800 |
|
801 // from MLbsLocationSourceGpsObserver |
|
802 // from the module |
|
803 void CManagerMainLogic::UpdateDeviceStatus |
|
804 ( |
|
805 TPositionModuleStatus::TDeviceStatus aDeviceStatus |
|
806 ) |
|
807 { |
|
808 LBSLOG(ELogP1, "CManagerMainLogic::UpdateDeviceStatus() Begin\n"); |
|
809 LBSLOG(ELogP9, "<-A MLbsLocationSourceGpsObserver::UpdateDeviceStatus() AGPSModule\n"); |
|
810 LBSLOG2(ELogP9, " > TPositionModuleStatus::TDeviceStatus aDeviceStatus = %d\n", aDeviceStatus); |
|
811 LBS_RDEBUG_ARGINT("AGPSMod", "LBS", "UpdateDeviceStatus", aDeviceStatus); |
|
812 TPositionModuleStatus moduleStatus; |
|
813 |
|
814 // publish the HW status |
|
815 CPosIntGpsHwStatus::TIntGpsHwStatus hwStatus = CPosIntGpsHwStatus::EStatusUnknown; |
|
816 hwStatus = KConvertStatusTable[aDeviceStatus]; |
|
817 |
|
818 TRAPD(error, iPosIntGpsHwStatus->SetStatusL(hwStatus)); |
|
819 if(error != KErrNone) |
|
820 { |
|
821 User::Panic(KLbsAGPSManFault, error); |
|
822 } |
|
823 |
|
824 iModuleStatus.GetModuleStatus(&moduleStatus,sizeof(moduleStatus),KLbsGpsLocManagerUid); |
|
825 |
|
826 moduleStatus.SetDeviceStatus(aDeviceStatus); |
|
827 |
|
828 TPositionModuleStatusEventBase::TModuleEvent occurredEventsSinceLastSet = |
|
829 TPositionModuleStatusEventBase::EEventDeviceStatus; |
|
830 |
|
831 iModuleStatus.SetModuleStatus(&moduleStatus,sizeof(moduleStatus),occurredEventsSinceLastSet); |
|
832 |
|
833 LBSLOG(ELogP1, "CManagerMainLogic::UpdateDeviceStatus() End\n"); |
|
834 } |
|
835 |
|
836 // from MLbsLocationSourceGpsObserver |
|
837 void CManagerMainLogic::UpdateDataQualityStatus |
|
838 ( |
|
839 TPositionModuleStatus::TDataQualityStatus aDataQuality |
|
840 ) |
|
841 { |
|
842 LBSLOG(ELogP1, "CManagerMainLogic::UpdateDataQualityStatus() Begin\n"); |
|
843 LBSLOG(ELogP9, "<-A MLbsLocationSourceGpsObserver::UpdateDataQualityStatus() AGPSModule\n"); |
|
844 LBSLOG2(ELogP9, " > TPositionModuleStatus::TDataQualityStatus aDataQuality = %d\n", aDataQuality); |
|
845 LBS_RDEBUG_ARGINT("AGPSMod", "LBS", "UpdateDataQualityStatus", aDataQuality); |
|
846 |
|
847 TPositionModuleStatus moduleStatus; |
|
848 iModuleStatus.GetModuleStatus(&moduleStatus,sizeof(moduleStatus),KLbsGpsLocManagerUid); |
|
849 |
|
850 moduleStatus.SetDataQualityStatus(aDataQuality); |
|
851 |
|
852 TPositionModuleStatusEventBase::TModuleEvent occurredEventsSinceLastSet = |
|
853 TPositionModuleStatusEventBase::EEventDataQualityStatus; |
|
854 |
|
855 iModuleStatus.SetModuleStatus(&moduleStatus,sizeof(moduleStatus),occurredEventsSinceLastSet); |
|
856 LBSLOG(ELogP1, "CManagerMainLogic::UpdateDataQualityStatus() End\n"); |
|
857 } |
|
858 |
|
859 // from MLbsLocationSourceGpsObserver |
|
860 // Integration module informs us that we may now delete it |
|
861 void CManagerMainLogic::Shutdown() |
|
862 { |
|
863 LBSLOG(ELogP1, "CManagerMainLogic::Shutdown() Begin\n"); |
|
864 LBSLOG(ELogP9, "<-A MLbsLocationSourceGpsObserver::Shutdown() AGPSModule\n"); |
|
865 LBS_RDEBUG("AGPSMod", "LBS", "Shutdown"); |
|
866 |
|
867 // tell the Root Process we are closed. |
|
868 __ASSERT_ALWAYSX(iClosingDown,User::Panic(KLbsAGPSManFault, KErrArgument)); |
|
869 |
|
870 iQuietus->CoupDeGrace(); |
|
871 LBSLOG(ELogP1, "CManagerMainLogic::Shutdown() End\n"); |
|
872 } |
|
873 |
|
874 // New assistnce data has arrived from network. |
|
875 //Pass mask dowm to integration module |
|
876 void CManagerMainLogic::OnAssistanceDataResponse(TInt aError, TLbsAsistanceDataGroup aMask) |
|
877 { |
|
878 LBSLOG(ELogP1, "CManagerMainLogic::OnAssistanceDataResponse() Begin\n"); |
|
879 LBSLOG(ELogP9, "->S CLbsLocationSourceGpsBase::AssistanceDataEvent() AGPSModule\n"); |
|
880 LBSLOG2(ELogP9, " > TInt aError = %d\n", aError); |
|
881 LBSLOG2(ELogP9, " > TLbsAsistanceDataGroup aMask = 0x%08X\n", aMask); |
|
882 |
|
883 // assistance data received from network - // pass mask onto integration module |
|
884 iLocationSource->AssistanceDataEvent(aError,aMask); |
|
885 |
|
886 if ((iCurrentPositioningMethod == KLbsMethodTerminalAssisted) && (aError < 0)) |
|
887 { |
|
888 CLbsAdmin::TGpsMode gpsMode; |
|
889 // Get from Admin the flavour ("Preferred" or "Always") of Terminal Assisted |
|
890 // that is in progress |
|
891 GetTaGpsModeFromAdmin(gpsMode); |
|
892 if(gpsMode == CLbsAdmin::EGpsPreferTerminalAssisted) |
|
893 { |
|
894 // In PTA we send the module a dummy assistance data event to tell him to switch to autonomous if he can (or fail if not) |
|
895 iFallbackFromPTAToAutonomousPossible = ETrue; |
|
896 } |
|
897 } |
|
898 |
|
899 /** LBSLOGGER - Start Logging */ |
|
900 // ------------------------------------------------------------------------- |
|
901 CLbsAssistanceDataLogEvent* logEvent = NULL; |
|
902 TRAPD(err, logEvent = CLbsAssistanceDataLogEvent::NewL(iLogAssitaceDataGroup, aMask)); |
|
903 if (err == KErrNone) |
|
904 { |
|
905 iLogger.AddEvent(*logEvent); |
|
906 |
|
907 delete logEvent; |
|
908 } |
|
909 // ------------------------------------------------------------------------- |
|
910 /** LBSLOGGER - End Logging */ |
|
911 |
|
912 LBSLOG(ELogP1, "CManagerMainLogic::OnAssistanceDataResponse() End\n"); |
|
913 } |
|
914 |
|
915 /** |
|
916 Add handling other errors when implementing Always Assisted modes. |
|
917 */ |
|
918 void CManagerMainLogic::OnSessionComplete(TInt aReason, const TLbsNetSessionIdInt& aSessionId) |
|
919 { |
|
920 LBSLOG(ELogP1, "CManagerMainLogic::OnSessionComplete() Begin\n"); |
|
921 CLbsAdmin::TGpsMode gpsMode = CLbsAdmin::EGpsModeUnknown; |
|
922 |
|
923 iCurrentNetworkMode = KLbsMethodNone; |
|
924 |
|
925 // only do this when get explicit cancel from NRH iActiveLSMode = KLbsMethodNone; |
|
926 |
|
927 if ((iCurrentPositioningMethod == KLbsMethodTerminalAssisted) && (aReason < 0)) |
|
928 { |
|
929 // Get from Admin the flavour ("Preferred" or "Always") of Terminal Assisted |
|
930 // that is in progress |
|
931 GetTaGpsModeFromAdmin(gpsMode); |
|
932 } |
|
933 |
|
934 // These two errors (KErrServerBusy, KErrPositionHighPriorityReceive) have a special meaning |
|
935 // and cancel any outstanding Self Location request from the Location Server |
|
936 // Similarly if we're in Terminal Assisted mode (expecting the network to calculate the position), |
|
937 // any outstanding Loc Server request will need to be cancelled |
|
938 if ((aReason == KErrServerBusy) || |
|
939 (aReason == KErrPositionHighPriorityReceive) || |
|
940 ((aReason < 0) && (gpsMode == CLbsAdmin::EGpsAlwaysTerminalAssisted))) |
|
941 { |
|
942 iLocSvrLocationRequestHandler->InvalidateRequest(); |
|
943 iLSReqState = EReqNone; |
|
944 |
|
945 RestartTimerIfTracking(); |
|
946 |
|
947 PublishDummyPosition(aReason); |
|
948 |
|
949 // Recombine requests as if the NRH had cancelled to allow |
|
950 // a cancel sent to the module (if there are no more requests left). |
|
951 CombineLocationRequests(KLbsNetRequestHandlerUid, EReasonCancel); |
|
952 iIsNrhCancelDue = EFalse; |
|
953 } |
|
954 else if(((aReason < 0) && (gpsMode == CLbsAdmin::EGpsPreferTerminalAssisted))) |
|
955 { |
|
956 // In PTA we send the module a dummy assistance data event to tell him to switch to autonomous if he can (or fail if not) |
|
957 PublishDummyAssistDataEvent(aReason); |
|
958 iFallbackFromPTAToAutonomousPossible = ETrue; |
|
959 } |
|
960 else |
|
961 { |
|
962 // Other errors do not cancel LS requests. |
|
963 // NRH Location requests should get cancelled by NRH. |
|
964 switch (iLSReqState) |
|
965 { |
|
966 case EReqNone: |
|
967 case EReqReceived: |
|
968 case EReqSessionCompleted: |
|
969 // Ignore |
|
970 break; |
|
971 |
|
972 case EReqSessionStarted: |
|
973 case EReqReceivedDuringSession: |
|
974 if ((iSessionId.SessionOwner() == aSessionId.SessionOwner()) && |
|
975 (iSessionId.SessionNum() == aSessionId.SessionNum())) |
|
976 { |
|
977 // In HYBRID and TAP modes we may need to initiate a new request for a FNP |
|
978 // This would happen if a request was received from LS during the current ongoing session |
|
979 // and it hadn't been satisfied by any arrival of a FNP or AGPS position |
|
980 // We need to do this to instruct the network to start calculating a FNP. |
|
981 // Note that, If its Futile then we dont re-issue a new request |
|
982 if( (iCurrentPositioningMethod & TPositionModuleInfo::ETechnologyNetwork) |
|
983 && (iLSReqState == EReqReceivedDuringSession) |
|
984 && (iLocSvrLocationRequestHandler->IsRequestActive()) |
|
985 && (!iSessionClosureData.iNotify)) |
|
986 { |
|
987 RLbsNetworkPositionUpdates netPosUpdates; |
|
988 |
|
989 TRAPD(error, netPosUpdates.OpenL(RLbsNetworkPositionUpdates::ENetworkPositionFinal)); |
|
990 if (error!=KErrNone) |
|
991 { |
|
992 User::Panic(KLbsAGPSManFault, error); |
|
993 } |
|
994 |
|
995 TLbsNetSessionIdInt sessionId; |
|
996 TPositionInfo netPosInfo; |
|
997 TTime targetTime; |
|
998 TTime actualTime; |
|
999 TInt err = netPosUpdates.GetPositionInfo(sessionId, netPosInfo, targetTime, actualTime); |
|
1000 // Make sure we passed in the right position class type |
|
1001 __ASSERT_ALWAYSX(err != KErrNotSupported, User::Invariant()); |
|
1002 if((err != KErrNone) || |
|
1003 ((netPosInfo.PositionMode() & TPositionModuleInfo::ETechnologyNetwork) != TPositionModuleInfo::ETechnologyNetwork) || |
|
1004 (actualTime < iLocSvrLocationRequestHandler->GetTimeActivated())) |
|
1005 { // if either there is no FNP, or the FNP didn't originate from the network, |
|
1006 // or the activation time of the request is after the FNP was returned |
|
1007 // then re-issue the request |
|
1008 iLSReqState = EReqReceived; |
|
1009 CombineLocationRequests(KLbsLocServerUid, MLocationRequestHandlerObserver::EReasonRequest); |
|
1010 } |
|
1011 |
|
1012 |
|
1013 } |
|
1014 |
|
1015 if(iLSReqState != EReqReceived) |
|
1016 { |
|
1017 iLSReqState = EReqSessionCompleted; |
|
1018 } |
|
1019 |
|
1020 // Check if we need to re-publish the cached position update when |
|
1021 // completing the session (currently this should only happen if an |
|
1022 // update with KPositionCalculationFutile was received). |
|
1023 // Also invalidate Loc Server's request in this case. |
|
1024 if(iSessionClosureData.iNotify) |
|
1025 { |
|
1026 TTime timeNow; |
|
1027 timeNow.UniversalTime(); |
|
1028 iLocSvrLocationRequestHandler->InvalidateRequest(); |
|
1029 |
|
1030 // The position update is about to be re-published for the Location Server... |
|
1031 // ...here we take the opportunity to let the LS know if we are collecting |
|
1032 // measurements and sending them to the network (so the LS can apply a network lag timer |
|
1033 // for waiting for the final network position after he client timer has expired). |
|
1034 // The LS will watch out for transitions in the mode from non-TA mode to a TA mode. |
|
1035 TUint gpsModeForLocationServer = RLbsPositionUpdates::EGpsModeTerminalBased; // default value |
|
1036 if (iCurrentPositioningMethod & TPositionModuleInfo::ETechnologyNetwork) |
|
1037 { |
|
1038 gpsModeForLocationServer = RLbsPositionUpdates::EGpsModeTerminalAssisted; |
|
1039 } |
|
1040 |
|
1041 iPositionUpdates.SetPositionInfo(iSessionClosureData.iLastStatus, |
|
1042 EFalse, |
|
1043 &iSessionClosureData.iLastPosInfo, |
|
1044 sizeof(TPositionExtendedSatelliteInfo), |
|
1045 iSessionClosureData.iLastTargetTime, |
|
1046 timeNow, |
|
1047 RLbsPositionUpdates::ESelfLocateSessionClosed, |
|
1048 gpsModeForLocationServer); |
|
1049 iSessionClosureData.iNotify = EFalse; |
|
1050 } |
|
1051 } |
|
1052 else |
|
1053 { |
|
1054 LBSLOG_WARN(ELogP2, "SessionNum or SessionOwner does not match\n"); |
|
1055 } |
|
1056 break; |
|
1057 |
|
1058 default: |
|
1059 User::Panic(KLbsAGPSManFault, EAGPSManUnknownFSMState); |
|
1060 break; |
|
1061 } |
|
1062 |
|
1063 } |
|
1064 LBSLOG(ELogP1, "CManagerMainLogic::OnSessionComplete() End\n"); |
|
1065 } |
|
1066 |
|
1067 |
|
1068 // from MLbsLocationSourceGpsObserver |
|
1069 // request from integration module |
|
1070 TInt CManagerMainLogic::GetAssistanceDataItem |
|
1071 ( |
|
1072 TLbsAssistanceDataItem aItem, |
|
1073 RDataReaderRootBase& aDataRoot, |
|
1074 TTime& aTimeStamp |
|
1075 ) |
|
1076 { |
|
1077 LBSLOG(ELogP1, "CManagerMainLogic::GetAssistanceDataItem() Begin\n"); |
|
1078 LBSLOG(ELogP9, "<-A MLbsLocationSourceGpsObserver::GetAssistanceDataItem() AGPSModule\n"); |
|
1079 LBSLOG2(ELogP9, " > TLbsAssistanceDataItem aItem = 0x%08X\n", aItem); |
|
1080 |
|
1081 TInt err = iNetworkGatewayHandler->GetAssistanceDataItem(aItem,aDataRoot,aTimeStamp); |
|
1082 |
|
1083 LBSLOG5(ELogP9, " < TTime aTimeStamp = %02d:%02d:%02d.%06d\n", aTimeStamp.DateTime().Hour(), |
|
1084 aTimeStamp.DateTime().Minute(), |
|
1085 aTimeStamp.DateTime().Second(), |
|
1086 aTimeStamp.DateTime().MicroSecond()); |
|
1087 LBSLOG2(ELogP9, " Return = %d", err); |
|
1088 return err; |
|
1089 } |
|
1090 |
|
1091 |
|
1092 // from MLbsLocationSourceGpsObserver |
|
1093 // request from integration module |
|
1094 TInt CManagerMainLogic::GetAssistanceDataItemTimeStamp(TLbsAssistanceDataItem aItem, TTime& aTimeStamp) |
|
1095 { |
|
1096 LBSLOG(ELogP1, "CManagerMainLogic::GetAssistanceDataItemTimeStamp() Begin\n"); |
|
1097 LBSLOG(ELogP9, "<-A MLbsLocationSourceGpsObserver::GetAssistanceDataItemTimeStamp() AGPSModule"); |
|
1098 LBSLOG2(ELogP9, " > TLbsAssistanceDataItem aItem = 0x%08X\n", aItem); |
|
1099 |
|
1100 TInt err = iNetworkGatewayHandler->GetAssistanceDataItemTimeStamp(aItem, aTimeStamp); |
|
1101 |
|
1102 LBSLOG5(ELogP9, " < TTime aTimeStamp = %02d:%02d:%02d.%06d\n", aTimeStamp.DateTime().Hour(), |
|
1103 aTimeStamp.DateTime().Minute(), |
|
1104 aTimeStamp.DateTime().Second(), |
|
1105 aTimeStamp.DateTime().MicroSecond()); |
|
1106 LBSLOG2(ELogP9, " Return = %d", err); |
|
1107 return err; |
|
1108 } |
|
1109 |
|
1110 |
|
1111 // from MLbsLocationSourceGpsObserver |
|
1112 // Integration module requests assistance data from network |
|
1113 void CManagerMainLogic::RequestAssistanceData |
|
1114 ( |
|
1115 TLbsAsistanceDataGroup aDataItemMask |
|
1116 ) |
|
1117 { |
|
1118 LBSLOG(ELogP1, "CManagerMainLogic::RequestAssistanceData() Begin\n"); |
|
1119 LBSLOG(ELogP9, "<-A MLbsLocationSourceGpsObserver::RequestAssistanceData() AGPSModule\n"); |
|
1120 LBSLOG2(ELogP9, " > TLbsAsistanceDataGroup aDataItemMask = 0x%08X\n", aDataItemMask); |
|
1121 LBS_RDEBUG_ARGINT("AGPSMod", "LBS", "RequestAssistanceData", aDataItemMask); |
|
1122 |
|
1123 // LBSLOGGER - Store for later |
|
1124 iLogAssitaceDataGroup = aDataItemMask; |
|
1125 |
|
1126 if(iLSReqState == EReqReceived) |
|
1127 { |
|
1128 TTime now; |
|
1129 now.UniversalTime(); |
|
1130 |
|
1131 //If there is a NRH request outstanding and the LocSrv request is in the future we do not start |
|
1132 //the self-locate session. Instead of that, we send the assistance data request and start the timer |
|
1133 //for the LocSrv. When the timer fires, the LocSrv handler will reissue the request, the request will |
|
1134 //be reissued to the Integration Module, it will call RequestAssistanceData again, and then we start |
|
1135 //the self-locate session. |
|
1136 //This functionality is to prevent early self-locate requests when there are both NRH and LocSrv |
|
1137 //requests outstanding and the LocSrv request TT is in the future. |
|
1138 if(iNRHLocationRequestHandler->IsRequestActive() && iLocSvrLocationRequestHandler->GetStartTime() > now) |
|
1139 { |
|
1140 iLocSvrLocationRequestHandler->RestartOnTargetTime(); |
|
1141 iNetworkGatewayHandler->SendAssistanceDataRequest(aDataItemMask); |
|
1142 } |
|
1143 else |
|
1144 { |
|
1145 iLocSvrLocationRequestHandler->CancelRestartOnTargetTime(); |
|
1146 // Build Self Location Request |
|
1147 TLbsLocRequestQualityInt reqQuality = iLocSvrLocationRequestHandler->GetQuality(); |
|
1148 |
|
1149 TLbsNetPosRequestQualityInt ngQuality; |
|
1150 ngQuality.SetMaxFixAge(0); |
|
1151 ngQuality.SetMaxFixTime(reqQuality.MaxFixTime()); |
|
1152 ngQuality.SetMinHorizontalAccuracy(reqQuality.MinHorizontalAccuracy()); |
|
1153 ngQuality.SetMinVerticalAccuracy(reqQuality.MinVerticalAccuracy()); |
|
1154 |
|
1155 TLbsNetPosRequestOptionsAssistanceInt options; |
|
1156 options.SetRequestQuality(ngQuality); |
|
1157 options.SetDataRequestMask(aDataItemMask); |
|
1158 |
|
1159 switch (iActiveLSMode) |
|
1160 { |
|
1161 case KLbsMethodNone: |
|
1162 options.SetPosMode(TPositionModuleInfo::ETechnologyUnknown); |
|
1163 break; |
|
1164 |
|
1165 case KLbsMethodAutonomous: |
|
1166 options.SetPosMode(TPositionModuleInfo::ETechnologyTerminal); |
|
1167 break; |
|
1168 |
|
1169 case KLbsMethodTerminalBased: |
|
1170 case KLbsMethodDual: |
|
1171 options.SetPosMode(TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted); |
|
1172 break; |
|
1173 |
|
1174 case KLbsMethodTerminalAssisted: |
|
1175 options.SetPosMode(TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted); |
|
1176 break; |
|
1177 |
|
1178 default: |
|
1179 options.SetPosMode(TPositionModuleInfo::ETechnologyUnknown); |
|
1180 __ASSERT_ALWAYSX(EFalse,User::Panic(KLbsAGPSManFault, KErrArgument)); |
|
1181 break; |
|
1182 } |
|
1183 |
|
1184 options.SetNewClientConnected(iLocSvrLocationRequestHandler->GetNewClient()); |
|
1185 iSessionId.IncrSession(); |
|
1186 iCurrentNetworkMode = iCurrentPositioningMethod; |
|
1187 iNetworkGatewayHandler->SendSelfLocationRequest(iSessionId, options); |
|
1188 iLSReqState = EReqSessionStarted; |
|
1189 } |
|
1190 } |
|
1191 else //iLSReqState != EReqReceive |
|
1192 { |
|
1193 iNetworkGatewayHandler->SendAssistanceDataRequest(aDataItemMask); |
|
1194 } |
|
1195 |
|
1196 LBSLOG(ELogP1, "CManagerMainLogic::RequestAssistanceData() End\n"); |
|
1197 } |
|
1198 |
|
1199 |
|
1200 void CManagerMainLogic::GetTimeAndQuality(const CLocationRequestHandler& aRequestHandler, |
|
1201 TTime& aTargetTime, TLbsLocRequestQualityInt& aQuality) |
|
1202 { |
|
1203 LBSLOG(ELogP1, "CManagerMainLogic::GetTimeAndQuality() Begin\n"); |
|
1204 aTargetTime = aRequestHandler.GetStartTime(); |
|
1205 aQuality= aRequestHandler.GetQuality(); |
|
1206 LBSLOG(ELogP1, "CManagerMainLogic::GetTimeAndQuality() End\n"); |
|
1207 } |
|
1208 |
|
1209 TPositionModuleInfo::TTechnologyType CManagerMainLogic::GetTechnologyTypeFromNrhRequest(const TInt& aIndex) |
|
1210 { |
|
1211 LBSLOG(ELogP1, "CManagerMainLogic::GetTechnologyTypeFromNrhRequest() Begin\n"); |
|
1212 LBSLOG(ELogP1, "CManagerMainLogic::GetTechnologyTypeFromNrhRequest() End\n"); |
|
1213 return iNRHLocationRequestHandler->GetTechnologyTypeFromRequest(aIndex); |
|
1214 } |
|
1215 |
|
1216 TPositionModuleInfo::TTechnologyType CManagerMainLogic::GetTechnologyTypeFromLsRequest(const TInt& aIndex) |
|
1217 { |
|
1218 LBSLOG(ELogP1, "CManagerMainLogic::GetTechnologyTypeFromLsRequest() Begin\n"); |
|
1219 LBSLOG(ELogP1, "CManagerMainLogic::GetTechnologyTypeFromLsRequest() End\n"); |
|
1220 return iLocSvrLocationRequestHandler->GetTechnologyTypeFromRequest(aIndex); |
|
1221 } |
|
1222 |
|
1223 /** This method implements the logic for combining location requests from the LS and NRH |
|
1224 request handlers following a change in the status of either. That logic combines the |
|
1225 quality and start and end times of both requests. |
|
1226 |
|
1227 Before sending a new combined request to the GPS Module, this method invokes ConfigureGpsMode() |
|
1228 to ensure that the GPS module is configured to operate in a positioning method that suites |
|
1229 both the LS and NRH requests. |
|
1230 |
|
1231 @aChannelId The channel (LS or NRH) whose status last changed (to active or inactive) |
|
1232 @aReason The reason of the change in the channel status (new request, cancel or timeout) |
|
1233 */ |
|
1234 void CManagerMainLogic::CombineLocationRequests(const TUid& aChannelId, const TRequestStateChangeReason& aReason) |
|
1235 { |
|
1236 LBSLOG(ELogP1, "CManagerMainLogic::CombineLocationRequests() Begin\n"); |
|
1237 TTime targetTime; |
|
1238 TLbsLocRequestQuality quality; |
|
1239 TTimeIntervalMicroSeconds maxFixTime = 0; |
|
1240 // If in Futile case and GPS producing measurements, |
|
1241 // do not send a further request to data source to stop AGPS |
|
1242 // manager re-issuing a request after Futile. |
|
1243 if (iSessionClosureData.iNotify && |
|
1244 (iCurrentPositioningMethod & TPositionModuleInfo::ETechnologyNetwork)) |
|
1245 { |
|
1246 LBSLOG(ELogP1, "Invalidating request from LS to avoid reissue after futile measurement received\n"); |
|
1247 iLocSvrLocationRequestHandler->InvalidateRequest(); |
|
1248 } |
|
1249 |
|
1250 // The fix here to get the start time for LS requests, of using the activation time if |
|
1251 // the target time is 0, otherwise the target time, might not be needed when DEF117381 gets fixed |
|
1252 if (!iLocSvrLocationRequestHandler->IsRequestActive() && |
|
1253 !iNRHLocationRequestHandler->IsRequestActive() ) |
|
1254 { |
|
1255 if (aReason == EReasonCancel && !iLastTrackingFlagSentToNG) |
|
1256 { |
|
1257 LBSLOG(ELogP9, "->S CLbsLocationSourceGpsBase::CancelLocationRequest() AGPSModule"); |
|
1258 LBS_RDEBUG("LBS", "AGPSMod", "CancelLocationRequest"); |
|
1259 iLocationSource->CancelLocationRequest(); |
|
1260 } |
|
1261 } |
|
1262 else |
|
1263 if (iLocSvrLocationRequestHandler->IsRequestActive() && |
|
1264 iNRHLocationRequestHandler->IsRequestActive()) |
|
1265 |
|
1266 { |
|
1267 TTime targetTimeNRH; |
|
1268 TLbsLocRequestQualityInt qualityNRH; |
|
1269 TTime targetTimeLS; |
|
1270 TLbsLocRequestQualityInt qualityLS; |
|
1271 GetTimeAndQuality(*iNRHLocationRequestHandler,targetTimeNRH,qualityNRH); |
|
1272 GetTimeAndQuality(*iLocSvrLocationRequestHandler,targetTimeLS,qualityLS); |
|
1273 |
|
1274 TTime startTimeNRH = iNRHLocationRequestHandler->GetTimeActivated(); |
|
1275 TTimeIntervalMicroSeconds fixTimeNRH = qualityNRH.MaxFixTime(); |
|
1276 TTime endTimeNRH; |
|
1277 if (targetTimeNRH == 0) |
|
1278 { |
|
1279 endTimeNRH = LbsTimerUtils::AddUpInt64TimersWithOverflowCheck(startTimeNRH,fixTimeNRH); |
|
1280 } |
|
1281 else |
|
1282 { |
|
1283 endTimeNRH = LbsTimerUtils::AddUpInt64TimersWithOverflowCheck(targetTimeNRH,fixTimeNRH); |
|
1284 } |
|
1285 |
|
1286 if (targetTimeLS > endTimeNRH) // no overlap |
|
1287 { |
|
1288 // if no overlap then issue earlier one (the NRH request) |
|
1289 // This could be optimised and only send NRH request once |
|
1290 targetTime = targetTimeNRH; |
|
1291 maxFixTime = fixTimeNRH; |
|
1292 ConvertToTLbsLocRequestQuality(qualityNRH, quality); |
|
1293 |
|
1294 // the request is entirely from NRH, so set the flag to false |
|
1295 quality.SetAssistedClientRequestPresent(EFalse); |
|
1296 |
|
1297 } |
|
1298 else |
|
1299 { |
|
1300 // requests overlap since NRH always starts now instead of in the future! so issue a combined request |
|
1301 targetTime = targetTimeNRH; // NRH requests are always "NOW" |
|
1302 // For a combined request, need to take account of the time the |
|
1303 // initial request has been active |
|
1304 TTime startTimeLS = targetTimeLS.Int64() == 0 ? iLocSvrLocationRequestHandler->GetTimeActivated() : targetTimeLS; |
|
1305 TTime endTimeLS = LbsTimerUtils::AddUpInt64TimersWithOverflowCheck(startTimeLS, qualityLS.MaxFixTime()); |
|
1306 TTime endTime = (endTimeNRH >= endTimeLS) ? endTimeNRH : endTimeLS; |
|
1307 // now have an end time. Convert it to a max fix time |
|
1308 TTime timeNow; |
|
1309 timeNow.UniversalTime(); |
|
1310 // since at least NRH request is being processed now modify the max fix time |
|
1311 maxFixTime = LbsTimerUtils::SubtractInt64TimersWithUnderflowCheck(endTime, timeNow); |
|
1312 |
|
1313 // set Quality to most stringent |
|
1314 TReal32 minHorizontalAccuracy; |
|
1315 TReal32 minVerticalAccuracy; |
|
1316 |
|
1317 TReal32 minHorizontalAccuracyNRH = qualityNRH.MinHorizontalAccuracy(); |
|
1318 TReal32 minVerticalAccuracyNRH = qualityNRH.MinVerticalAccuracy(); |
|
1319 |
|
1320 TReal32 minHorizontalAccuracyLS = qualityLS.MinHorizontalAccuracy(); |
|
1321 TReal32 minVerticalAccuracyLS = qualityLS.MinVerticalAccuracy(); |
|
1322 |
|
1323 minHorizontalAccuracy = (minHorizontalAccuracyNRH >= minHorizontalAccuracyLS) |
|
1324 ?minHorizontalAccuracyLS:minHorizontalAccuracyNRH; |
|
1325 |
|
1326 minVerticalAccuracy = (minVerticalAccuracyNRH >= minVerticalAccuracyLS) |
|
1327 ?minVerticalAccuracyLS:minVerticalAccuracyNRH; |
|
1328 |
|
1329 quality.SetMinHorizontalAccuracy(minHorizontalAccuracy); |
|
1330 quality.SetMinVerticalAccuracy(minVerticalAccuracy); |
|
1331 if(GetTechnologyTypeFromLsRequest(0) != KLbsMethodAutonomous) |
|
1332 { |
|
1333 // this request is partially from the client and the client didn't request |
|
1334 // Autonomous, so set the flag to true |
|
1335 quality.SetAssistedClientRequestPresent(ETrue); |
|
1336 } |
|
1337 else |
|
1338 { |
|
1339 // client requested Autonomous |
|
1340 quality.SetAssistedClientRequestPresent(EFalse); |
|
1341 } |
|
1342 } |
|
1343 |
|
1344 } |
|
1345 else |
|
1346 if (iLocSvrLocationRequestHandler->IsRequestActive()) |
|
1347 { |
|
1348 // only a Location Server request is active |
|
1349 TLbsLocRequestQualityInt qualityInt; |
|
1350 GetTimeAndQuality(*iLocSvrLocationRequestHandler,targetTime,qualityInt); |
|
1351 ConvertToTLbsLocRequestQuality(qualityInt, quality); |
|
1352 // At this point, this could be just a standard LS Request. |
|
1353 // However, it could also be a resend of an older request after a |
|
1354 // combined request was issued and the NRH request timed out. |
|
1355 // So, we have to calculate the fix time remaining rather than using |
|
1356 // the fix time from the original request |
|
1357 TTime startTime = targetTime.Int64() == 0 ? iLocSvrLocationRequestHandler->GetTimeActivated() : targetTime; |
|
1358 TTime endTime = LbsTimerUtils::AddUpInt64TimersWithOverflowCheck(startTime, quality.MaxFixTime()); |
|
1359 |
|
1360 TTime timeNow; |
|
1361 timeNow.UniversalTime(); |
|
1362 if(targetTime < timeNow) |
|
1363 { // if the request is being processed then readjust the max fix time |
|
1364 maxFixTime = LbsTimerUtils::SubtractInt64TimersWithUnderflowCheck(endTime, timeNow); |
|
1365 } |
|
1366 else |
|
1367 { // otherwise leave it as it was |
|
1368 maxFixTime = quality.MaxFixTime(); |
|
1369 } |
|
1370 if(GetTechnologyTypeFromLsRequest(0) != KLbsMethodAutonomous) |
|
1371 { |
|
1372 // this request is entirely from the client API and the client didn't request |
|
1373 // Autonomous, so set the flag to true |
|
1374 quality.SetAssistedClientRequestPresent(ETrue); |
|
1375 } |
|
1376 else |
|
1377 { |
|
1378 // client requested Autonomous |
|
1379 quality.SetAssistedClientRequestPresent(EFalse); |
|
1380 } |
|
1381 } |
|
1382 else |
|
1383 { |
|
1384 // only an NRH request is active |
|
1385 TLbsLocRequestQualityInt qualityInt; |
|
1386 GetTimeAndQuality(*iNRHLocationRequestHandler,targetTime,qualityInt); |
|
1387 ConvertToTLbsLocRequestQuality(qualityInt, quality); |
|
1388 // At this point, this could be just a standard NRH Request. |
|
1389 // However, it could also be a resend of an older request after a |
|
1390 // combined request was issued and the LS request timed out. |
|
1391 // So, we have to calculate the fix time remaining rather than using |
|
1392 // the fix time from the original request |
|
1393 TTime startTime = targetTime.Int64() == 0 ? iNRHLocationRequestHandler->GetTimeActivated() : targetTime; |
|
1394 TTime endTime = LbsTimerUtils::AddUpInt64TimersWithOverflowCheck(startTime,quality.MaxFixTime()); |
|
1395 TTime timeNow; |
|
1396 timeNow.UniversalTime(); |
|
1397 if(targetTime < timeNow) |
|
1398 { // if the request is being processed then readjust the max fix time |
|
1399 maxFixTime = LbsTimerUtils::SubtractInt64TimersWithUnderflowCheck(endTime, timeNow); |
|
1400 } |
|
1401 else |
|
1402 { // otherwise leave it as it was |
|
1403 maxFixTime = quality.MaxFixTime(); |
|
1404 } |
|
1405 |
|
1406 // the request is entirely from NRH, so set the flag to false |
|
1407 quality.SetAssistedClientRequestPresent(EFalse); |
|
1408 } |
|
1409 |
|
1410 // Check if GPS module's mode needs reconfiguring |
|
1411 ConfigureGpsMode(aChannelId, aReason); |
|
1412 |
|
1413 if (maxFixTime != 0) // if we need to send a new request |
|
1414 { |
|
1415 // If we are in a GPS mode that sends measurements to the network |
|
1416 // and a LocServer request is active then add on the |
|
1417 // lag time to allow the loc server to receive GPS positions from the |
|
1418 // integration module until the session complete comes in. |
|
1419 if ((iCurrentPositioningMethod & TPositionModuleInfo::ETechnologyNetwork) && |
|
1420 (!iSessionClosureData.iNotify) && |
|
1421 (iLocSvrLocationRequestHandler->IsRequestActive() || iLSReqState == EReqSessionStarted |
|
1422 || iLSReqState == EReqReceivedDuringSession)) |
|
1423 { |
|
1424 TTime extendedMaxFixTime = maxFixTime.Int64(); |
|
1425 extendedMaxFixTime = LbsTimerUtils::AddUpInt64TimersWithOverflowCheck(extendedMaxFixTime, iFinalNetPositionLag); |
|
1426 maxFixTime = extendedMaxFixTime.Int64(); |
|
1427 } |
|
1428 |
|
1429 quality.SetMaxFixTime(maxFixTime); |
|
1430 LBSLOG(ELogP9, "->A CLbsLocationSourceGpsBase::RequestLocationUpdate() AGPSModule\n"); |
|
1431 LBSLOG5(ELogP9, " > TargetTime = %02d:%02d:%02d.%06d\n", targetTime.DateTime().Hour(), |
|
1432 targetTime.DateTime().Minute(), |
|
1433 targetTime.DateTime().Second(), |
|
1434 targetTime.DateTime().MicroSecond()); |
|
1435 LBSLOG(ELogP9, " > TLbsLocRequestQuality quality =\n"); |
|
1436 LBSLOG2(ELogP9, " - Max Fix Time = %ld\n", quality.MaxFixTime().Int64()); |
|
1437 LBSLOG2(ELogP9, " - Horizontal Accuracy = %f\n", quality.MinHorizontalAccuracy()); |
|
1438 LBSLOG2(ELogP9, " - Vertical Accuracy = %f\n", quality.MinVerticalAccuracy()); |
|
1439 LBS_RDEBUG("LBS", "AGPSMod", "RequestLocationUpdate"); |
|
1440 |
|
1441 iLocationSource->RequestLocationUpdate(targetTime, quality); |
|
1442 } |
|
1443 } |
|
1444 |
|
1445 /** |
|
1446 This method works out if a new GPS Options message has to be sent to the GPS module to request |
|
1447 a new positioning method to be used. |
|
1448 |
|
1449 The method must first call CalculateActiveLSMode to calculate the contribution of the Location |
|
1450 Server request to the desired GPS mode. |
|
1451 |
|
1452 */ |
|
1453 void CManagerMainLogic::ConfigureGpsMode(const TUid& aChannelId, const TRequestStateChangeReason& aReason) |
|
1454 { |
|
1455 TBool forcedSelfLocate; |
|
1456 |
|
1457 CalculateActiveLSMode(aChannelId, aReason, forcedSelfLocate); |
|
1458 |
|
1459 if(KLbsNetRequestHandlerUid == aChannelId) |
|
1460 { |
|
1461 if(MLocationRequestHandlerObserver::EReasonCancel == aReason) |
|
1462 { |
|
1463 iIsNrhCancelDue = EFalse; |
|
1464 } |
|
1465 else if(MLocationRequestHandlerObserver::EReasonRequest == aReason) |
|
1466 { |
|
1467 iIsNrhCancelDue = ETrue; |
|
1468 } |
|
1469 } |
|
1470 |
|
1471 |
|
1472 TPositionModuleInfo::TTechnologyType newPositioningMethod = KLbsMethodNone; |
|
1473 newPositioningMethod = CalculatePositioningMethod(); |
|
1474 |
|
1475 // A change in the combined GPS mode implies a new configuration |
|
1476 // message has to be sent to the module |
|
1477 if (newPositioningMethod != iCurrentPositioningMethod |
|
1478 || (!iCurrentGpsTimingOfCellFramesRequested != !iNRHLocationRequestHandler->GpsTimingOfCellFramesRequested())) |
|
1479 { |
|
1480 SetGpsOptions(newPositioningMethod); |
|
1481 iCurrentPositioningMethod = newPositioningMethod; |
|
1482 iCurrentGpsTimingOfCellFramesRequested = iNRHLocationRequestHandler->GpsTimingOfCellFramesRequested(); |
|
1483 |
|
1484 // The GPS module has been configured with a new mode... |
|
1485 // check if a SelfLocate has to be sent to the NG next time |
|
1486 // the GPM module requests assistance data. |
|
1487 if (forcedSelfLocate) |
|
1488 { |
|
1489 iLSReqState = EReqReceived; |
|
1490 } |
|
1491 } |
|
1492 |
|
1493 } |
|
1494 |
|
1495 |
|
1496 /* This method determines whether the GPS mode received in a Location Request from the Location |
|
1497 Server should be considered to configure the GPS mode or if the currently active mode provided |
|
1498 by an outstanding Location Server request must continue. |
|
1499 The method also determines whether a new selflocation request is to be sent to the Network Gateway |
|
1500 (only necessary when the request has not originated in a new client and a session is already in progress) |
|
1501 */ |
|
1502 void CManagerMainLogic::CalculateActiveLSMode(const TUid& aChannelId, const TRequestStateChangeReason& aReason, TBool& aForceSelfLocate) |
|
1503 { |
|
1504 aForceSelfLocate = EFalse; |
|
1505 |
|
1506 if (KLbsLocServerUid == aChannelId && MLocationRequestHandlerObserver::EReasonRequest == aReason) |
|
1507 { |
|
1508 //The Location Server sent a location request (only one posmethod allowed in the request) |
|
1509 __ASSERT_ALWAYSX(GetTechnologyTypeFromLsRequest(1) == KLbsMethodNone, User::Invariant()); |
|
1510 __ASSERT_ALWAYSX((GetTechnologyTypeFromLsRequest(0) == KLbsMethodAutonomous || |
|
1511 GetTechnologyTypeFromLsRequest(0) == KLbsMethodTerminalBased || |
|
1512 GetTechnologyTypeFromLsRequest(0) == KLbsMethodTerminalAssisted), |
|
1513 User::Invariant()); |
|
1514 |
|
1515 // The GPS mode in new clients' requests is always used |
|
1516 if (iLocSvrLocationRequestHandler->GetNewClient()) |
|
1517 { |
|
1518 iActiveLSMode = GetTechnologyTypeFromLsRequest(0); |
|
1519 // No need to force a new self-locate request as one will be sent |
|
1520 // by the usual means due to this being a new-client request. |
|
1521 } |
|
1522 else |
|
1523 { |
|
1524 // For "old" clients, the mode in the new LS request is always used when |
|
1525 // it is NOT autonomous. |
|
1526 TPositionModuleInfo::TTechnologyType oldActiveLSMode = iActiveLSMode; |
|
1527 if((KLbsMethodAutonomous != GetTechnologyTypeFromLsRequest(0))) |
|
1528 { |
|
1529 iActiveLSMode = GetTechnologyTypeFromLsRequest(0); |
|
1530 |
|
1531 // If the active LS mode has changed AND a self-location session is in progress, |
|
1532 // a new session has to be forced to start (if it is not in progress already |
|
1533 // it will start by the usual means) |
|
1534 aForceSelfLocate = ((oldActiveLSMode != iActiveLSMode) && (KLbsMethodNone != iCurrentNetworkMode)); |
|
1535 } |
|
1536 else |
|
1537 { |
|
1538 // For "old" Autonomous clients, set them to Autonomous if there is no network method |
|
1539 if(KLbsMethodNone == iCurrentNetworkMode) |
|
1540 { |
|
1541 iActiveLSMode = KLbsMethodAutonomous; |
|
1542 } |
|
1543 // Otherwise set them to the network method |
|
1544 else |
|
1545 { |
|
1546 iActiveLSMode = iCurrentNetworkMode; |
|
1547 } |
|
1548 |
|
1549 } |
|
1550 } |
|
1551 } |
|
1552 } |
|
1553 |
|
1554 |
|
1555 TPositionModuleInfo::TTechnologyType CManagerMainLogic::LookUpPositioningMethodInCombinationTables() |
|
1556 { |
|
1557 // Look up positioning method in combination tables |
|
1558 const TLbsGpsCombinedModeTableEntry* ptrToTableEntry = NULL; |
|
1559 TInt entryCount = 0; |
|
1560 |
|
1561 // Select the correct table according to h/w capabilities |
|
1562 switch (iCapabilities) |
|
1563 { |
|
1564 case TPositionModuleInfoExtended::EDeviceGpsModeTerminalBased: |
|
1565 ptrToTableEntry = KLbsTBTable; |
|
1566 entryCount = KLbsTBTableCount; |
|
1567 break; |
|
1568 |
|
1569 case TPositionModuleInfoExtended::EDeviceGpsModeTerminalAssisted: |
|
1570 ptrToTableEntry = KLbsTATable; |
|
1571 entryCount = KLbsTATableCount; |
|
1572 break; |
|
1573 |
|
1574 case (TPositionModuleInfoExtended::EDeviceGpsModeTerminalBased| |
|
1575 TPositionModuleInfoExtended::EDeviceGpsModeTerminalAssisted): |
|
1576 ptrToTableEntry = KLbsTBOrTATable; |
|
1577 entryCount = KLbsTBOrTATableCount; |
|
1578 break; |
|
1579 |
|
1580 case TPositionModuleInfoExtended::EDeviceGpsModeSimultaneousTATB: |
|
1581 ptrToTableEntry = KLbsTBAndTATable; |
|
1582 entryCount = KLbsTBAndTATableCount; |
|
1583 break; |
|
1584 |
|
1585 case TPositionModuleInfoExtended::EDeviceGpsModeAutonomous: |
|
1586 ptrToTableEntry = KLbsAutonomousTable; |
|
1587 entryCount = KLbsAutonomousTableCount; |
|
1588 break; |
|
1589 |
|
1590 default: |
|
1591 ASSERT(EFalse); // incorrect capabilities set |
|
1592 break; |
|
1593 } |
|
1594 |
|
1595 // Find an entry of the table matching the positioning methods |
|
1596 // requested by LS and NRH |
|
1597 TPositionModuleInfo::TTechnologyType newPositioningMethod = KLbsMethodNone; |
|
1598 |
|
1599 for (TInt index = 0; index < entryCount; index++) |
|
1600 { |
|
1601 if (ptrToTableEntry->iLSPreferredMode == iActiveLSMode && |
|
1602 ptrToTableEntry->iLSAlternativeMode == KLbsMethodNone && |
|
1603 ptrToTableEntry->iNRHPreferredMode == GetTechnologyTypeFromNrhRequest(0) && |
|
1604 ptrToTableEntry->iNRHAlternativeMode == GetTechnologyTypeFromNrhRequest (1)) |
|
1605 { |
|
1606 newPositioningMethod = ptrToTableEntry->iResultingMode; |
|
1607 break; |
|
1608 } |
|
1609 ptrToTableEntry++; |
|
1610 } |
|
1611 |
|
1612 __ASSERT_ALWAYSX(KLbsMethodNone != newPositioningMethod, User::Invariant()); // no match found in combination table |
|
1613 return newPositioningMethod; |
|
1614 } |
|
1615 |
|
1616 /* This method determines the positioning method that would be sent in a GPS Options |
|
1617 message to the GPS module. It takes into account the positioning methods requested by |
|
1618 both Location Server and NRH. |
|
1619 */ |
|
1620 TPositionModuleInfo::TTechnologyType CManagerMainLogic::CalculatePositioningMethod() |
|
1621 { |
|
1622 |
|
1623 #if defined(AGPS_MANAGER_TESTING) |
|
1624 TInt capabilities; |
|
1625 TUid KSuiteExeUid = {0x102869CB}; |
|
1626 TUint KGpsModeCapabilities = 0; |
|
1627 TInt error; |
|
1628 error = RProperty::Get(KSuiteExeUid, KGpsModeCapabilities, capabilities); |
|
1629 if(error != KErrNone) |
|
1630 { |
|
1631 User::Panic(KLbsAGPSManFault, error); |
|
1632 } |
|
1633 iCapabilities = capabilities; |
|
1634 #endif |
|
1635 |
|
1636 TPositionModuleInfo::TTechnologyType newPositioningMethod = KLbsMethodNone; |
|
1637 // Calculate positioning method when there are both |
|
1638 // LS and NRH requests active |
|
1639 if(iLocSvrLocationRequestHandler->IsRequestActive() && iIsNrhCancelDue) |
|
1640 { |
|
1641 newPositioningMethod = LookUpPositioningMethodInCombinationTables(); |
|
1642 } |
|
1643 // Positioning method when only the LS has an active request |
|
1644 else if(iLocSvrLocationRequestHandler->IsRequestActive()) |
|
1645 { |
|
1646 if (KLbsMethodNone == iActiveLSMode) |
|
1647 { |
|
1648 // leave mode as it was - cancel after session comepletes |
|
1649 newPositioningMethod = iCurrentPositioningMethod; |
|
1650 } |
|
1651 else |
|
1652 switch (iCapabilities) |
|
1653 { |
|
1654 case TPositionModuleInfoExtended::EDeviceGpsModeTerminalBased: |
|
1655 __ASSERT_ALWAYSX((iActiveLSMode == KLbsMethodAutonomous || |
|
1656 iActiveLSMode == KLbsMethodTerminalBased), User::Invariant()); |
|
1657 newPositioningMethod = iActiveLSMode; |
|
1658 break; |
|
1659 |
|
1660 case TPositionModuleInfoExtended::EDeviceGpsModeTerminalAssisted: |
|
1661 __ASSERT_ALWAYSX(iActiveLSMode == KLbsMethodTerminalAssisted, User::Invariant()); |
|
1662 newPositioningMethod = iActiveLSMode; |
|
1663 break; |
|
1664 |
|
1665 case TPositionModuleInfoExtended::EDeviceGpsModeAutonomous: |
|
1666 __ASSERT_ALWAYSX(iActiveLSMode == KLbsMethodAutonomous, User::Invariant()); |
|
1667 newPositioningMethod = iActiveLSMode; |
|
1668 break; |
|
1669 |
|
1670 case TPositionModuleInfoExtended::EDeviceGpsModeSimultaneousTATB: |
|
1671 case (TPositionModuleInfoExtended::EDeviceGpsModeTerminalBased| |
|
1672 TPositionModuleInfoExtended::EDeviceGpsModeTerminalAssisted): |
|
1673 __ASSERT_ALWAYSX((iActiveLSMode == KLbsMethodAutonomous || |
|
1674 iActiveLSMode == KLbsMethodTerminalBased || |
|
1675 iActiveLSMode == KLbsMethodTerminalAssisted), User::Invariant()); |
|
1676 newPositioningMethod = iActiveLSMode; |
|
1677 break; |
|
1678 |
|
1679 default: |
|
1680 ASSERT(EFalse); // incorrect capabilities set |
|
1681 break; |
|
1682 } |
|
1683 } |
|
1684 // Positioning method when only the NRH has an active request |
|
1685 else if (iIsNrhCancelDue) |
|
1686 { |
|
1687 if (iActiveLSMode ==KLbsMethodNone) |
|
1688 { |
|
1689 switch (iCapabilities) |
|
1690 { |
|
1691 case TPositionModuleInfoExtended::EDeviceGpsModeTerminalBased: |
|
1692 __ASSERT_ALWAYSX(GetTechnologyTypeFromNrhRequest(1) == KLbsMethodNone, |
|
1693 User::Invariant()); |
|
1694 newPositioningMethod = GetTechnologyTypeFromNrhRequest(0); |
|
1695 __ASSERT_ALWAYSX(newPositioningMethod & TPositionModuleInfo::ETechnologyTerminal, |
|
1696 User::Invariant()); |
|
1697 break; |
|
1698 |
|
1699 case TPositionModuleInfoExtended::EDeviceGpsModeTerminalAssisted: |
|
1700 __ASSERT_ALWAYSX(GetTechnologyTypeFromNrhRequest(1) == KLbsMethodNone, |
|
1701 User::Invariant()); |
|
1702 newPositioningMethod = GetTechnologyTypeFromNrhRequest(0); |
|
1703 __ASSERT_ALWAYSX(newPositioningMethod == KLbsMethodTerminalAssisted, |
|
1704 User::Invariant()); |
|
1705 break; |
|
1706 |
|
1707 case (TPositionModuleInfoExtended::EDeviceGpsModeTerminalBased| |
|
1708 TPositionModuleInfoExtended::EDeviceGpsModeTerminalAssisted): |
|
1709 __ASSERT_ALWAYSX(GetTechnologyTypeFromNrhRequest(1) == KLbsMethodNone, |
|
1710 User::Invariant()); |
|
1711 newPositioningMethod = GetTechnologyTypeFromNrhRequest(0); |
|
1712 __ASSERT_ALWAYSX((newPositioningMethod == KLbsMethodAutonomous || |
|
1713 newPositioningMethod == KLbsMethodTerminalBased || |
|
1714 newPositioningMethod == KLbsMethodTerminalAssisted), |
|
1715 User::Invariant()); |
|
1716 |
|
1717 break; |
|
1718 |
|
1719 case TPositionModuleInfoExtended::EDeviceGpsModeSimultaneousTATB: |
|
1720 if (GetTechnologyTypeFromNrhRequest(1) != KLbsMethodNone) |
|
1721 { |
|
1722 __ASSERT_ALWAYSX(( |
|
1723 (GetTechnologyTypeFromNrhRequest(0) == KLbsMethodTerminalAssisted && GetTechnologyTypeFromNrhRequest(1) == KLbsMethodAutonomous) || |
|
1724 (GetTechnologyTypeFromNrhRequest(0) == KLbsMethodAutonomous && GetTechnologyTypeFromNrhRequest(1) == KLbsMethodTerminalAssisted) || |
|
1725 (GetTechnologyTypeFromNrhRequest(0) == KLbsMethodTerminalBased && GetTechnologyTypeFromNrhRequest(1) == KLbsMethodTerminalAssisted) || |
|
1726 (GetTechnologyTypeFromNrhRequest(0) == KLbsMethodTerminalAssisted && GetTechnologyTypeFromNrhRequest(1) == KLbsMethodTerminalBased)), |
|
1727 User::Invariant()); |
|
1728 |
|
1729 newPositioningMethod = KLbsMethodDual; |
|
1730 } |
|
1731 else |
|
1732 { |
|
1733 newPositioningMethod = GetTechnologyTypeFromNrhRequest(0); |
|
1734 __ASSERT_ALWAYSX((newPositioningMethod == KLbsMethodAutonomous || |
|
1735 newPositioningMethod == KLbsMethodTerminalBased || |
|
1736 newPositioningMethod == KLbsMethodTerminalAssisted), |
|
1737 User::Invariant()); |
|
1738 } |
|
1739 break; |
|
1740 |
|
1741 case TPositionModuleInfoExtended::EDeviceGpsModeAutonomous: |
|
1742 __ASSERT_ALWAYSX(GetTechnologyTypeFromNrhRequest(1) == KLbsMethodNone, |
|
1743 User::Invariant()); |
|
1744 newPositioningMethod = GetTechnologyTypeFromNrhRequest(0); |
|
1745 __ASSERT_ALWAYSX(newPositioningMethod == KLbsMethodAutonomous, |
|
1746 User::Invariant()); |
|
1747 break; |
|
1748 |
|
1749 default: |
|
1750 ASSERT(EFalse); // incorrect capabilities set |
|
1751 break; |
|
1752 } |
|
1753 } |
|
1754 else |
|
1755 { |
|
1756 newPositioningMethod = LookUpPositioningMethodInCombinationTables(); |
|
1757 } |
|
1758 } |
|
1759 else |
|
1760 { |
|
1761 // No activity. Make newPositioningMethod equal to current |
|
1762 // positioning method so that GPS Options are not set. |
|
1763 newPositioningMethod = iCurrentPositioningMethod; |
|
1764 } |
|
1765 |
|
1766 return newPositioningMethod; |
|
1767 } |
|
1768 |
|
1769 |
|
1770 /* |
|
1771 This method sends a GPS Options configuration message to the GPS module |
|
1772 */ |
|
1773 void CManagerMainLogic::SetGpsOptions(const TPositionModuleInfo::TTechnologyType aNewPositioningMethod) |
|
1774 { |
|
1775 if (aNewPositioningMethod == KLbsMethodDual) |
|
1776 { |
|
1777 // Use an object of class class TLbsGpsOptionsArray |
|
1778 // to set gps options to Terminal Based and request |
|
1779 // that both measurements and position calcuations |
|
1780 // are returned by the GPS module. |
|
1781 TLbsGpsOptionsArray optionsArray; |
|
1782 optionsArray.ClearOptionItems(); |
|
1783 optionsArray.SetGpsMode(CLbsAdmin::EGpsPreferTerminalBased); |
|
1784 |
|
1785 TLbsGpsOptionsItem optionsItem; |
|
1786 optionsItem.SetLocUpdateType(TLbsGpsOptionsItem::EPosUpdateCalculation); |
|
1787 optionsArray.AppendOptionItem(optionsItem); |
|
1788 optionsItem.SetLocUpdateType(TLbsGpsOptionsItem::EPosUpdateMeasurement); |
|
1789 optionsArray.AppendOptionItem(optionsItem); |
|
1790 optionsArray.SetGpsTimeRelationReq(iNRHLocationRequestHandler->GpsTimingOfCellFramesRequested()); |
|
1791 |
|
1792 LBSLOG(ELogP9, "->S CLbsLocationSourceGpsBase::SetGpsOptions() AGPSModule\n"); |
|
1793 LBSLOG(ELogP9, " > TLbsGpsOptions gpsOptions =\n"); |
|
1794 LBSLOG_TLBSGPSOPTIONS(optionsArray); |
|
1795 iLocationSource->SetGpsOptions(optionsArray); |
|
1796 iFallbackFromPTAToAutonomousPossible = EFalse; |
|
1797 } |
|
1798 else |
|
1799 { |
|
1800 // Use an object of class TLbsGpsOptions |
|
1801 // to set gps options (an object of class |
|
1802 // TLbsGpsOptionsArray could also be used, but |
|
1803 // using the base class TLbsGpsOptions ensures |
|
1804 // minimum impact on GPS Integration Modules |
|
1805 // already getting the base class when there is |
|
1806 // only one item in the array) |
|
1807 TLbsGpsOptions options; |
|
1808 |
|
1809 switch (aNewPositioningMethod) |
|
1810 { |
|
1811 case KLbsMethodTerminalBased: |
|
1812 options.SetGpsMode(CLbsAdmin::EGpsPreferTerminalBased); |
|
1813 break; |
|
1814 |
|
1815 case KLbsMethodTerminalAssisted: |
|
1816 CLbsAdmin::TGpsMode mode; |
|
1817 GetTaGpsModeFromAdmin(mode); // Prefer or Always Terminal Assisted |
|
1818 options.SetGpsMode(mode); |
|
1819 break; |
|
1820 |
|
1821 case KLbsMethodAutonomous: |
|
1822 options.SetGpsMode(CLbsAdmin::EGpsAutonomous); |
|
1823 break; |
|
1824 } |
|
1825 options.SetGpsTimeRelationReq(iNRHLocationRequestHandler->GpsTimingOfCellFramesRequested()); |
|
1826 |
|
1827 LBSLOG(ELogP9, "->S CLbsLocationSourceGpsBase::SetGpsOptions() AGPSModule\n"); |
|
1828 LBSLOG(ELogP9, " > TLbsGpsOptions gpsOptions =\n"); |
|
1829 LBSLOG_TLBSGPSOPTIONS(options); |
|
1830 iLocationSource->SetGpsOptions(options); |
|
1831 iFallbackFromPTAToAutonomousPossible = EFalse; |
|
1832 } |
|
1833 } |
|
1834 |
|
1835 |
|
1836 // from Mixin class MUpdateRequestObserver |
|
1837 // Manager receives request for a position update (or cancel) |
|
1838 // from either NRH or location server |
|
1839 // or, on manager startup, this is called whenever there is an outstanding request |
|
1840 void CManagerMainLogic::OnLocationRequestStateChanged |
|
1841 ( |
|
1842 const RLbsPositionUpdateRequests::TChannelIdentifer& aChannel, |
|
1843 const TRequestStateChangeReason& aReason |
|
1844 ) |
|
1845 { |
|
1846 LBSLOG(ELogP1, "CManagerMainLogic::OnLocationRequestStateChanged()\n"); |
|
1847 |
|
1848 if (!iClosingDown) |
|
1849 { |
|
1850 if (aChannel.iClientId == KLbsLocServerUid) |
|
1851 { |
|
1852 LBSLOG(ELogP2, " LS Location Request, Cancel or Timeout\n"); |
|
1853 |
|
1854 if (iLocSvrLocationRequestHandler->IsRequestActive()) |
|
1855 { |
|
1856 // New request received from the Location Server. |
|
1857 // Always switch to EReqReceived state if the request has come from a new client. |
|
1858 // If it hasn't, never leave a EReqSessionStarted or EReqReceivedDuringSession state. |
|
1859 if ((iLocSvrLocationRequestHandler->GetNewClient()) || |
|
1860 (iLSReqState != EReqSessionStarted && iLSReqState != EReqReceivedDuringSession)) |
|
1861 { |
|
1862 iLSReqState = EReqReceived; |
|
1863 } |
|
1864 if(iLSReqState == EReqSessionStarted) |
|
1865 { |
|
1866 iLSReqState = EReqReceivedDuringSession; |
|
1867 } |
|
1868 } |
|
1869 else |
|
1870 { |
|
1871 if (iLSReqState == EReqSessionStarted || iLSReqState == EReqReceivedDuringSession) |
|
1872 { |
|
1873 // if we are in the process of cancelling then don't issue another! |
|
1874 // stay in EReqSessionStarted state! |
|
1875 __ASSERT_ALWAYSX(((aReason == MLocationRequestHandlerObserver::EReasonTimeout) || (aReason == MLocationRequestHandlerObserver::EReasonCancel)),User::Panic(KLbsAGPSManFault, KErrArgument)); |
|
1876 TInt reason; |
|
1877 switch (aReason) |
|
1878 { |
|
1879 case MLocationRequestHandlerObserver::EReasonTimeout: |
|
1880 reason = KErrTimedOut; |
|
1881 break; |
|
1882 |
|
1883 case MLocationRequestHandlerObserver::EReasonCancel: |
|
1884 reason = KErrCancel; |
|
1885 break; |
|
1886 |
|
1887 default: |
|
1888 // Change this to a big scream after beta2 release of PREQ1624 |
|
1889 reason = KErrCancel; |
|
1890 break; |
|
1891 } |
|
1892 iNetworkGatewayHandler->SendSelfLocationCancel(iSessionId, reason); |
|
1893 } |
|
1894 else |
|
1895 { |
|
1896 // leave any state except EReqSessionStarted |
|
1897 iLSReqState = EReqNone; |
|
1898 } |
|
1899 } |
|
1900 |
|
1901 RestartTimerIfTracking(); |
|
1902 } |
|
1903 else |
|
1904 { |
|
1905 __ASSERT_ALWAYSX(aChannel.iClientId == KLbsNetRequestHandlerUid, User::Panic(KLbsAGPSManFault, KErrArgument)); |
|
1906 |
|
1907 if (aReason == MLocationRequestHandlerObserver::EReasonCancel) |
|
1908 { |
|
1909 iIsNrhCancelDue = EFalse; // only an explicit cancel can do this. |
|
1910 //iActiveLSMode = KLbsMethodNone; |
|
1911 } |
|
1912 |
|
1913 LBSLOG(ELogP2, " NRH Location Request, Cancel or Timeout\n"); |
|
1914 } |
|
1915 |
|
1916 // Combine LS and NRH requests and send a request to GPS module |
|
1917 // after setting the correct GPS options. |
|
1918 CombineLocationRequests(aChannel.iClientId, aReason); |
|
1919 } |
|
1920 else |
|
1921 { |
|
1922 LBSLOG_WARN(ELogP2, " Location Request ignored because closing down"); |
|
1923 } |
|
1924 } |
|
1925 |
|
1926 /** Pass the status to the NG */ |
|
1927 void CManagerMainLogic::OnSystemStatusAdvice(const RLbsPositionUpdateRequests::TChannelIdentifer& aChannel, TBool aTracking) |
|
1928 { |
|
1929 LBSLOG(ELogP1, "CManagerMainLogic::OnSystemStatusAdvice() Begin\n"); |
|
1930 if (aChannel.iClientId == KLbsLocServerUid) |
|
1931 { |
|
1932 SendSystemStatusAdvice(aTracking); |
|
1933 } |
|
1934 LBSLOG(ELogP1, "CManagerMainLogic::OnSystemStatusAdvice() End\n"); |
|
1935 } |
|
1936 |
|
1937 // power mode advice arrives from location server via a loc request |
|
1938 void CManagerMainLogic::OnPowerModeAdvice(const RLbsPositionUpdateRequests::TChannelIdentifer& aChannel, CLbsLocationSourceGpsBase::TPowerMode& aPowerMode) |
|
1939 { |
|
1940 LBSLOG(ELogP1, "CManagerMainLogic::PowerModeAdvice() Begin\n"); |
|
1941 LBSLOG(ELogP9, "->S CLbsLocationSourceGpsBase::AdvisePowerMode() AGPSModule\n"); |
|
1942 LBSLOG2(ELogP9, " > CLbsLocationSourceGpsBase::TPowerMode aMode = %d\n", aPowerMode); |
|
1943 LBSLOG2(ELogP9, " > RLbsPositionUpdateRequests::TChannelIdentifer aChannel = 0x%08X\n", aChannel.iClientId); |
|
1944 |
|
1945 if (!iClosingDown) |
|
1946 { |
|
1947 CLbsLocationSourceGpsBase::TPowerMode powerMode = CLbsLocationSourceGpsBase::EPowerModeUnknown; |
|
1948 CLbsLocationSourceGpsBase::TPowerMode otherChannelPowerMode = CLbsLocationSourceGpsBase::EPowerModeUnknown; |
|
1949 |
|
1950 //Find out who is sending the power advice and update the correct memory variable |
|
1951 if(aChannel.iClientId == KLbsLocServerUid) |
|
1952 { |
|
1953 //Power Advice from LocServer |
|
1954 iPowerModeLS = aPowerMode; |
|
1955 otherChannelPowerMode = iPowerModeNRH; |
|
1956 } |
|
1957 else |
|
1958 { |
|
1959 //Power Advice from NRH |
|
1960 iPowerModeNRH = aPowerMode; |
|
1961 otherChannelPowerMode = iPowerModeLS; |
|
1962 } |
|
1963 |
|
1964 //Need to decide what powerMode to send to the module. We need to ensure that we are not |
|
1965 // overwriting a "higher" priority power advice from the other channel |
|
1966 //(i.e. If the NRH previously sent an ON and the LS is now sending an OFF, we should not send |
|
1967 // the OFF, since the NRH still requires the hardware to be on, so the LS power mode is ignored) |
|
1968 switch(aPowerMode) |
|
1969 { |
|
1970 case CLbsLocationSourceGpsBase::EPowerModeOn: |
|
1971 { |
|
1972 //Always send an ON power advice irrespective of what the other advice is saying |
|
1973 powerMode = aPowerMode; |
|
1974 break; |
|
1975 } |
|
1976 |
|
1977 case CLbsLocationSourceGpsBase::EPowerModeStandby: |
|
1978 { |
|
1979 //Send standby Power mode only if the other channel is not currently "sending" On |
|
1980 if(otherChannelPowerMode != CLbsLocationSourceGpsBase::EPowerModeOn) |
|
1981 { |
|
1982 powerMode = aPowerMode; |
|
1983 } |
|
1984 break; |
|
1985 } |
|
1986 |
|
1987 case CLbsLocationSourceGpsBase::EPowerModeOff: |
|
1988 { |
|
1989 //Send Off power mode only if the other channel is not "sending" On or Standby |
|
1990 if((otherChannelPowerMode != CLbsLocationSourceGpsBase::EPowerModeOn) && |
|
1991 (otherChannelPowerMode != CLbsLocationSourceGpsBase::EPowerModeStandby)) |
|
1992 { |
|
1993 powerMode = aPowerMode; |
|
1994 } |
|
1995 break; |
|
1996 } |
|
1997 |
|
1998 case CLbsLocationSourceGpsBase::EPowerModeClose: |
|
1999 { |
|
2000 //Send Off power mode only if the other channel is not "sending" On, Standby or Off |
|
2001 if((otherChannelPowerMode != CLbsLocationSourceGpsBase::EPowerModeOn) && |
|
2002 (otherChannelPowerMode != CLbsLocationSourceGpsBase::EPowerModeStandby) && |
|
2003 (otherChannelPowerMode != CLbsLocationSourceGpsBase::EPowerModeOff)) |
|
2004 { |
|
2005 powerMode = aPowerMode; |
|
2006 } |
|
2007 break; |
|
2008 } |
|
2009 |
|
2010 case CLbsLocationSourceGpsBase::EPowerModeUnknown: |
|
2011 default: |
|
2012 { |
|
2013 //Do nothing, will send no powerMode to the module |
|
2014 break; |
|
2015 } |
|
2016 } |
|
2017 |
|
2018 //Check to see whether we actually made a decision about which powerMode to send |
|
2019 if(powerMode != CLbsLocationSourceGpsBase::EPowerModeUnknown) |
|
2020 { |
|
2021 LBSLOG(ELogP1, "PowerAdvice sent to Module\n"); |
|
2022 iLocationSource->AdvisePowerMode(powerMode); // inform integration module |
|
2023 } |
|
2024 |
|
2025 } |
|
2026 else |
|
2027 { |
|
2028 LBSLOG_WARN(ELogP2, " Power advice ignored because closing down"); |
|
2029 } |
|
2030 |
|
2031 |
|
2032 LBSLOG(ELogP1, "CManagerMainLogic::OnPowerModeAdvice() End\n"); |
|
2033 } |
|
2034 |
|
2035 // from MLbsCloseDownObserver |
|
2036 void CManagerMainLogic::OnProcessCloseDown() |
|
2037 { |
|
2038 LBSLOG(ELogP1, "CManagerMainLogic::OnProcessCloseDown() Begin\n"); |
|
2039 iClosingDown = ETrue; |
|
2040 |
|
2041 // Cancel any outstanding request |
|
2042 LBSLOG(ELogP9, "->S CLbsLocationSourceGpsBase::CancelLocationRequest() AGPSModule\n"); |
|
2043 LBS_RDEBUG("LBS", "AGPSMod", "CancelLocationRequest"); |
|
2044 iLocationSource->CancelLocationRequest(); |
|
2045 |
|
2046 // instruct integration module to shutdown by sending it Power Mode Advise |
|
2047 LBSLOG(ELogP9, "->S CLbsLocationSourceGpsBase::AdvisePowerMode() AGPSModule\n"); |
|
2048 LBSLOG(ELogP9, " > CLbsLocationSourceGpsBase::TPowerMode aMode = EPowerModeClose\n"); |
|
2049 LBS_RDEBUG_ARGINT("LBS", "AGPSMod", "AdvisePowerMode", CLbsLocationSourceGpsBase::EPowerModeClose); |
|
2050 iLocationSource->AdvisePowerMode(CLbsLocationSourceGpsBase::EPowerModeClose); |
|
2051 delete iCloseDownRequestDetector; |
|
2052 iCloseDownRequestDetector = NULL; |
|
2053 |
|
2054 LBSLOG(ELogP1, "CManagerMainLogic::OnProcessCloseDown() End\n"); |
|
2055 } |
|
2056 |
|
2057 |
|
2058 /** Disables tracking if the Loc Server stopps reissuing requests */ |
|
2059 void CManagerMainLogic::OnTimerEventL(TInt /*aTimerId*/) |
|
2060 { |
|
2061 LBSLOG(ELogP1, "CManagerMainLogic::OnTimerEventL() Begin\n"); |
|
2062 SendSystemStatusAdvice(EFalse); |
|
2063 LBSLOG(ELogP1, "CManagerMainLogic::OnTimerEventL() End\n"); |
|
2064 } |
|
2065 |
|
2066 TInt CManagerMainLogic::OnTimerError(TInt /*aTimerId*/, TInt aError) |
|
2067 { |
|
2068 LBSLOG(ELogP1, "CManagerMainLogic::OnTimerError() Begin\n"); |
|
2069 User::Panic(KLbsAGPSManFault, aError); |
|
2070 LBSLOG(ELogP1, "CManagerMainLogic::OnTimerError() End\n"); |
|
2071 return aError; |
|
2072 } |
|
2073 |
|
2074 void CManagerMainLogic::SendSystemStatusAdvice(TBool aTracking) |
|
2075 { |
|
2076 // if we are sending the state for the first time then just send it |
|
2077 // if it's not the first time then only send the state when it changes |
|
2078 if ((iTrackingStateUnknown) || (iLastTrackingFlagSentToNG != aTracking)) |
|
2079 { |
|
2080 iLastTrackingFlagSentToNG = aTracking; |
|
2081 iNetworkGatewayHandler->SendSystemStatusAdvice(iLastTrackingFlagSentToNG); |
|
2082 } |
|
2083 |
|
2084 iTrackingStateUnknown = EFalse; // the tracking state is now known! |
|
2085 |
|
2086 RestartTimerIfTracking(); |
|
2087 } |
|
2088 |
|
2089 void CManagerMainLogic::RestartTimerIfTracking() |
|
2090 { |
|
2091 LBSLOG(ELogP1, "CManagerMainLogic::RestartTimerIfTracking() Begin\n"); |
|
2092 |
|
2093 iTimer->Cancel(); |
|
2094 |
|
2095 // If tracking is on the location server must send another message before the timeout |
|
2096 // Failing to do so will send a Tracking Off message to the NG |
|
2097 if ( (iTrackingStateUnknown) || ((iLastTrackingFlagSentToNG == TRUE) && !iLocSvrLocationRequestHandler->IsRequestActive())) |
|
2098 { |
|
2099 iTimer->EventAfter(static_cast<TTimeIntervalMicroSeconds>(KTrackingOffTimeout), 0); |
|
2100 } |
|
2101 LBSLOG(ELogP1, "CManagerMainLogic::RestartTimerIfTracking() End\n"); |
|
2102 } |
|
2103 |
|
2104 |
|
2105 void CManagerMainLogic::EarlyCompletionUpdate(TPositionInfo& aEarlyCompletionUpdate, TTime& aTargetTime, TTime& aActualTime) |
|
2106 { |
|
2107 // Cancel the location request with the integration module if the MO-LR (selflocate session) is still in progress. |
|
2108 // If the MO-LR (selflocate session) is no longer in progress (EReqSessionCompleted or EReqNone) then only |
|
2109 // cancel the location request if there isn't an MT-LR in progress (inactive NRH request) to prevent cancelling a |
|
2110 // potential emergency request. |
|
2111 if ((iLSReqState == EReqSessionStarted) || (iLSReqState == EReqReceivedDuringSession) || |
|
2112 (((iLSReqState == EReqSessionCompleted)||(iLSReqState == EReqNone)) && (!iNRHLocationRequestHandler->IsRequestActive()))) |
|
2113 { |
|
2114 TInt posSize = aEarlyCompletionUpdate.PositionClassSize(); |
|
2115 // Just publish this position for the NRH (since it is published with KPositionEarlyComplete code |
|
2116 // the LocServer will ignore it). The position is of TPositionExtendedSatelliteInfo type. |
|
2117 // iPositionUpdates.SetPositionInfo(KPositionEarlyComplete, EFalse, &aEarlyCompletionUpdate, sizeof(TPositionExtendedSatelliteInfo), aTargetTime, aActualTime); |
|
2118 iPositionUpdates.SetPositionInfo(KPositionEarlyComplete, EFalse, &aEarlyCompletionUpdate, sizeof(TPositionExtendedSatelliteInfo), aTargetTime, aActualTime); |
|
2119 |
|
2120 // invalidate requests |
|
2121 iLocSvrLocationRequestHandler->InvalidateRequest(); |
|
2122 iNRHLocationRequestHandler->InvalidateRequest(); |
|
2123 |
|
2124 // cancel the location request |
|
2125 LBSLOG(ELogP9, "->S CLbsLocationSourceGpsBase::CancelLocationRequest() AGPSModule\n"); |
|
2126 LBS_RDEBUG("LBS", "AGPSMod", "CancelLocationRequest"); |
|
2127 iLocationSource->CancelLocationRequest(); |
|
2128 } |
|
2129 } |
|
2130 |
|
2131 |
|
2132 /* |
|
2133 This method is only called when it is expected (for consistency with the |
|
2134 hardware capabilities) that a Terminal Assisted positioning method is set |
|
2135 in Admin DB. The reason this method is called is to determine what variety |
|
2136 of Terminal Assisted ("Prefer" or "Always") was set. |
|
2137 */ |
|
2138 void CManagerMainLogic::GetTaGpsModeFromAdmin(CLbsAdmin::TGpsMode& aGpsMode) |
|
2139 { |
|
2140 LBSLOG(ELogP1, "CManagerMainLogic::GetTaGpsModeFromAdmin() Begin\n"); |
|
2141 TLbsAdminSetting adminSetting; |
|
2142 TInt err; |
|
2143 RLbsNetworkRegistrationStatus::TLbsNetworkRegistrationStatus netRegStatus; |
|
2144 |
|
2145 // Read the current network registration status |
|
2146 err = iNetRegStatus.GetNetworkRegistrationStatus(netRegStatus); |
|
2147 |
|
2148 if (err != KErrNone) |
|
2149 { |
|
2150 ASSERT(EFalse); |
|
2151 // Assume roaming network to err on the safe side as nothing better can be done |
|
2152 netRegStatus = RLbsNetworkRegistrationStatus::ERegisteredRoamingNetwork; |
|
2153 } |
|
2154 |
|
2155 // Determine precise admin setting to be read (home or roaming gps mode) |
|
2156 switch (netRegStatus) |
|
2157 { |
|
2158 case RLbsNetworkRegistrationStatus::ERegisteredHomeNetwork: |
|
2159 adminSetting = KLbsSettingRoamingGpsMode; |
|
2160 break; |
|
2161 |
|
2162 default: // roaming and unknown (assume roaming) |
|
2163 adminSetting = KLbsSettingRoamingGpsMode; |
|
2164 break; |
|
2165 } |
|
2166 |
|
2167 // Read value of admin setting |
|
2168 if (KErrNone != iAdmin->Get(adminSetting, aGpsMode)) |
|
2169 { |
|
2170 // Assume PreferTerminalAssisted |
|
2171 ASSERT(EFalse); |
|
2172 aGpsMode = CLbsAdmin::EGpsPreferTerminalAssisted; |
|
2173 } |
|
2174 else |
|
2175 { |
|
2176 // Verify that the mode is truly a TA variety |
|
2177 if ( (aGpsMode != CLbsAdmin::EGpsAlwaysTerminalAssisted) && |
|
2178 (aGpsMode != CLbsAdmin::EGpsPreferTerminalAssisted)) |
|
2179 { |
|
2180 // Assume PreferTerminalAssisted (nothing else can be done) |
|
2181 aGpsMode = CLbsAdmin::EGpsPreferTerminalAssisted; |
|
2182 } |
|
2183 } |
|
2184 |
|
2185 LBSLOG(ELogP1, "CManagerMainLogic::GetTaGpsModeFromAdmin() End\n"); |
|
2186 } |
|
2187 |
|
2188 void CManagerMainLogic::ConvertToTLbsLocRequestQuality(const TLbsLocRequestQualityInt& aSource, |
|
2189 TLbsLocRequestQuality& aDest) const |
|
2190 { |
|
2191 aDest.SetMaxFixTime(aSource.MaxFixTime()); |
|
2192 aDest.SetMinHorizontalAccuracy(aSource.MinHorizontalAccuracy()); |
|
2193 aDest.SetMinVerticalAccuracy(aSource.MinVerticalAccuracy()); |
|
2194 } |
|
2195 |
|
2196 |
|
2197 |
|
2198 |