author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 17 Sep 2010 08:37:32 +0300 | |
changeset 60 | 9a7e3d5f461a |
parent 51 | 95c570bf4a05 |
permissions | -rw-r--r-- |
36 | 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 |
#include <e32std.h> |
|
17 |
#include <e32property.h> |
|
18 |
#include <centralrepository.h> |
|
19 |
||
20 |
#ifdef SYMBIAN_FEATURE_MANAGER |
|
21 |
#include <featdiscovery.h> |
|
22 |
#include <featureuids.h> |
|
23 |
#endif |
|
24 |
||
25 |
// LBS-specific |
|
26 |
#include <lbs.h> |
|
27 |
#include <lbs/lbsadmin.h> |
|
28 |
#include <lbs/lbslocerrors.h> |
|
29 |
#include <lbs/lbslocclasstypes.h> |
|
30 |
||
31 |
#include "nrhpanic.h" |
|
32 |
#include "lbsdevloggermacros.h" |
|
33 |
#include "lbsqualityprofile.h" |
|
34 |
#include "lbsrootcenrepdefs.h" |
|
35 |
#include "lbspositioningstatusprops.h" |
|
36 |
||
37 |
#include "privacyandlocationrequesthandler.h" |
|
38 |
||
39 |
// Special 'invalid session' SessionId. |
|
40 |
const TLbsNetSessionIdInt KInvalidSessionId(TUid::Uid(0), 0); |
|
41 |
||
42 |
const TPositionModuleInfo::TTechnologyType KTerminalAssistedMode = (TPositionModuleInfo::ETechnologyNetwork | |
|
43 |
TPositionModuleInfo::ETechnologyAssisted); |
|
44 |
||
45 |
// ----------------------------------------------------------------------------- |
|
46 |
// |
|
47 |
// ----------------------- Class CPrivacyAndLocationHandler -------------------- |
|
48 |
// |
|
49 |
// State Machine class which owns the states of the Privacy and Location Handler |
|
50 |
// |
|
51 |
// ----------------------------------------------------------------------------- |
|
52 |
// |
|
53 |
||
54 |
// ----------------------------------------------------------------------------- |
|
55 |
// CPrivacyAndLocationHandler::NewL |
|
56 |
// Description: CPrivacyAndLocationHandler static constructor |
|
57 |
// ----------------------------------------------------------------------------- |
|
58 |
// |
|
59 |
CPrivacyAndLocationHandler* CPrivacyAndLocationHandler::NewL(CNGMessageSwitch& aMessageSwitch, |
|
60 |
CLbsAdmin& aLbsAdmin, |
|
61 |
RLbsNetworkRegistrationStatus& aNetRegStatus) |
|
62 |
{ |
|
63 |
CPrivacyAndLocationHandler* self; |
|
64 |
self = new (ELeave) CPrivacyAndLocationHandler(aMessageSwitch, aNetRegStatus); |
|
65 |
CleanupStack::PushL(self); |
|
66 |
self->ConstructL(&aLbsAdmin); |
|
67 |
CleanupStack::Pop(self); |
|
68 |
return(self); |
|
69 |
} |
|
70 |
||
71 |
// ----------------------------------------------------------------------------- |
|
72 |
// CPrivacyAndLocationHandler::CPrivacyAndLocationHandler |
|
73 |
// Description: CPrivacyAndLocationHandler constructor |
|
74 |
// ----------------------------------------------------------------------------- |
|
75 |
// |
|
76 |
CPrivacyAndLocationHandler::CPrivacyAndLocationHandler(CNGMessageSwitch& aMessageSwitch, |
|
77 |
RLbsNetworkRegistrationStatus& aNetRegStatus) |
|
78 |
: iNetRegStatus(aNetRegStatus), |
|
79 |
iMessageSwitch(&aMessageSwitch), |
|
80 |
iNumActiveSessions(0) |
|
81 |
{ |
|
82 |
} |
|
83 |
||
84 |
// ----------------------------------------------------------------------------- |
|
85 |
// CPrivacyAndLocationHandler::~CPrivacyAndLocationHandler |
|
86 |
// Description: CPrivacyAndLocationHandler destructor |
|
87 |
// ----------------------------------------------------------------------------- |
|
88 |
// |
|
89 |
CPrivacyAndLocationHandler::~CPrivacyAndLocationHandler() |
|
90 |
{ |
|
91 |
// If iEmergencyFsm has been used by any outstanding request, |
|
92 |
// it needs to be removed before calling ResetAndDestroy(), |
|
93 |
// otherwise it will get double-deleted when delete iEmergencyFsm |
|
94 |
// is called. |
|
95 |
||
96 |
TInt index = iFsmArray.Find(iEmergencyFsm); |
|
97 |
if (index >= 0) |
|
98 |
{ |
|
99 |
iFsmArray.Remove(index); |
|
100 |
} |
|
101 |
||
102 |
iFsmArray.ResetAndDestroy(); |
|
103 |
||
104 |
// force the count of active network initiated positioning sessions to 0 |
|
105 |
// this supports the pre-APE centric architecture wherein the NRH is |
|
106 |
// destroyed on completion of network initiated positioning. |
|
107 |
RProperty::Set(iPosStatusCategory, KLbsNiPositioningStatusKey, 0); |
|
108 |
||
109 |
delete iEmergencyFsm; |
|
110 |
delete iAgpsInterface; |
|
111 |
delete iPrivacyHandler; |
|
112 |
} |
|
113 |
||
114 |
// ----------------------------------------------------------------------------- |
|
115 |
// CPrivacyAndLocationHandler::ConstructL |
|
116 |
// Description: CPrivacyAndLocationHandler second-phase constructor. |
|
117 |
// Creates the states of the system and the Privacy Handler. |
|
118 |
// ----------------------------------------------------------------------------- |
|
119 |
// |
|
120 |
||
121 |
const TInt KLbsDefaultMaxNumLocationRequests = 4; |
|
122 |
||
123 |
void CPrivacyAndLocationHandler::ConstructL(CLbsAdmin* aLbsAdmin) |
|
124 |
{ |
|
125 |
iLbsAdmin = aLbsAdmin; |
|
126 |
||
127 |
iPrivacyHandler = CPrivacyHandler::CreateL(this, *iLbsAdmin, iNetRegStatus); |
|
128 |
iMessageSwitch->RegisterObserver(this); |
|
129 |
||
130 |
// Get the behaviour mode and device gps mode capabilities |
|
131 |
TInt err = iLbsAdmin->Get(KLbsSettingBehaviourMode, iLbsBehaviourMode); |
|
132 |
if (err != KErrNone) |
|
133 |
{ |
|
134 |
iLbsBehaviourMode = CLbsAdmin::ELbsBehaviourCustom1; |
|
135 |
} |
|
136 |
// get device mode capabilities: |
|
137 |
err = LbsModuleInfo::GetDeviceCapabilities(KLbsGpsLocManagerUid, iDeviceGpsModeCaps); |
|
138 |
if(err != KErrNone || (iDeviceGpsModeCaps==TPositionModuleInfoExtended::EDeviceGpsModeNone)) |
|
139 |
{ |
|
140 |
// Assume module supports hybrid if it has not reported its capabilities in module info file |
|
141 |
iDeviceGpsModeCaps = TPositionModuleInfoExtended::EDeviceGpsModeSimultaneousTATB; |
|
142 |
} |
|
143 |
||
144 |
||
145 |
err = iLbsAdmin->Get(KLbsSettingMaximumExternalLocateRequests, iMaxNumSessions); |
|
146 |
if (err != KErrNone) |
|
147 |
{ |
|
148 |
iMaxNumSessions = KLbsDefaultMaxNumLocationRequests; |
|
149 |
} |
|
150 |
||
151 |
iAgpsInterface = CAgpsInterfaceHandler::NewL(*this, *iLbsAdmin, iNetRegStatus); |
|
152 |
||
153 |
||
154 |
#ifdef NRH_UNIT_TEST |
|
155 |
// For testing use the Uid of the dummy NG |
|
156 |
const TInt KTestNgUidInt = 0x1028226B; |
|
157 |
const TUid KTestNgUid = {KTestNgUidInt}; |
|
158 |
iProtocolModuleUid = KTestNgUid; |
|
159 |
#else |
|
160 |
ReadProtocolModuleAdminSetting(); |
|
161 |
#endif |
|
162 |
||
163 |
iEmergencyFsm = CLbsPrivLocFsm::NewL(*this, KInvalidSessionId); |
|
164 |
||
165 |
// Reserve space for FSMs. Note "+1" because a pointer to the emergency Fsm gets added to this array |
|
166 |
iFsmArray.ReserveL(iMaxNumSessions+1); |
|
167 |
||
168 |
CLbsAdmin::TSpecialFeature specialFeature(CLbsAdmin::ESpecialFeatureOff); |
|
169 |
err = iLbsAdmin->Get(KLbsSpecialFeatureIntermediateFutileUpdate, specialFeature); |
|
170 |
if (err != KErrNone) |
|
171 |
{ |
|
172 |
LBSLOG_ERR2(ELogP3, "Failed to get KLbsSpecialFeatureIntermediateFutileUpdate (err %d)", err); |
|
173 |
} |
|
174 |
LBSLOG2(ELogP3, "Using KLbsSpecialFeatureIntermediateFutileUpdate = %d", specialFeature); |
|
175 |
iSpecialFeatureIntermediateFutileUpdate = (specialFeature == CLbsAdmin::ESpecialFeatureOn) ? ETrue : EFalse; |
|
51
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
176 |
|
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
177 |
#if defined __WINSCW__ && defined SYMBIAN_CELLMO_CENTRIC |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
178 |
iLocationManagementSupported = EFalse; |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
179 |
#else |
36 | 180 |
#ifdef SYMBIAN_FEATURE_MANAGER |
181 |
iLocationManagementSupported = CFeatureDiscovery::IsFeatureSupportedL(NFeature::KLocationManagement); |
|
182 |
#else |
|
183 |
__ASSERT_ALWAYS(EFalse, User::Invariant()); // Would happen on older versions of symbian OS if this code ever backported |
|
51
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
184 |
#endif // SYMBIAN_FEATURE_MANAGER |
95c570bf4a05
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
36
diff
changeset
|
185 |
#endif // __WINSCW__ && defined SYMBIAN_CELLMO_CENTRIC |
36 | 186 |
|
187 |
// Get the CategoryUid from the cenrep file owned by LbsRoot for accessing Positioning Status P&S Keys |
|
188 |
CRepository* rep = CRepository::NewLC(KLbsCenRepUid); |
|
189 |
TInt posStatusCategory; |
|
190 |
err = rep->Get(KNiPositioningStatusAPIKey, posStatusCategory); |
|
191 |
User::LeaveIfError(err); |
|
192 |
CleanupStack::PopAndDestroy(rep); |
|
193 |
iPosStatusCategory = TUid::Uid(posStatusCategory); |
|
194 |
} |
|
195 |
||
196 |
||
197 |
||
198 |
/** |
|
199 |
Reads the Uid of a current Protocol Module from the Admin Settings. |
|
200 |
*/ |
|
201 |
void CPrivacyAndLocationHandler::ReadProtocolModuleAdminSetting() |
|
202 |
{ |
|
203 |
LBSLOG(ELogP1, "CPrivacyAndLocationHandler::ReadProtocolModuleAdminSetting()"); |
|
204 |
TLbsProtocolModuleId protUid(KLbsProtocolNullModuleId); |
|
205 |
||
206 |
TInt err = iLbsAdmin->Get(KLbsSettingHomeProtocolModule, protUid); |
|
207 |
if (err != KErrNone) |
|
208 |
{ |
|
209 |
LBSLOG_ERR2(ELogP4, "Failed to get KLbsSettingHomeProtocolModule (err %d)", err); |
|
210 |
} |
|
211 |
||
212 |
iProtocolModuleUid = protUid; |
|
213 |
} |
|
214 |
||
215 |
/** Compares sessionId for RPointerArray::Find(). |
|
216 |
*/ |
|
217 |
TBool CPrivacyAndLocationHandler::IsSessionIdEqual( |
|
218 |
const TLbsNetSessionIdInt* aSessionId, |
|
219 |
const CLbsPrivLocFsm& aFsm) |
|
220 |
{ |
|
221 |
return (*aSessionId == aFsm.SessionId()); |
|
222 |
} |
|
223 |
||
224 |
/** Compares session type for RPointerArray::Find(). |
|
225 |
*/ |
|
226 |
TBool CPrivacyAndLocationHandler::IsSessionTypeEqual( |
|
227 |
const TLbsNetworkEnumInt::TLbsNetProtocolServiceInt* aSessionType, |
|
228 |
const CLbsPrivLocFsm& aFsm) |
|
229 |
{ |
|
230 |
return (*aSessionType == const_cast<CLbsPrivLocFsm&>(aFsm).SessionType()); |
|
231 |
} |
|
232 |
||
233 |
// ----------------------------------------------------------------------------- |
|
234 |
// CPrivacyAndLocationHandler::LookupFsm |
|
235 |
// Description: Lookup CLbsPrivLocFsm object by session ID. |
|
236 |
// ----------------------------------------------------------------------------- |
|
237 |
// |
|
238 |
CLbsPrivLocFsm* CPrivacyAndLocationHandler::LookupFsm(const TLbsNetSessionIdInt& aSessionId) |
|
239 |
{ |
|
240 |
LBSLOG2(ELogP3, "LookupFsm session=%d", aSessionId.SessionNum()); |
|
241 |
||
242 |
// Standard sessions always use the standard state machines. |
|
243 |
TInt index = iFsmArray.Find(aSessionId, IsSessionIdEqual); |
|
244 |
if (index >= 0) |
|
245 |
{ |
|
246 |
LBSLOG(ELogP3, "LookupFsm: Existing standard FSM found"); |
|
247 |
return iFsmArray[index]; |
|
248 |
} |
|
249 |
else |
|
250 |
{ |
|
251 |
LBSLOG(ELogP3, "LookupFsm: No standard FSM found"); |
|
252 |
return NULL; |
|
253 |
} |
|
254 |
} |
|
255 |
||
256 |
/** Get a new state machine to use for a new request. |
|
257 |
||
258 |
The state machine can either be re-using an existing FSM, |
|
259 |
or allocating a new one from the heap or, for emergencies one thats was prepared earlier is used. |
|
260 |
*/ |
|
261 |
CLbsPrivLocFsm* CPrivacyAndLocationHandler::GetNewFsm( |
|
262 |
const TLbsNetSessionIdInt& aSessionId, |
|
263 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
264 |
TBool aEmergency) |
|
265 |
{ |
|
266 |
LBSLOG2(ELogP3, "LookupFsm session=%d", aSessionId.SessionNum()); |
|
267 |
||
268 |
CLbsPrivLocFsm* fsm(NULL); |
|
269 |
||
270 |
// If this is an emergency request, use the emergency FSM |
|
271 |
// Note, we only have to support ONE emergency at a time |
|
272 |
// this implies that only one Protcol module may deal with emergencies |
|
273 |
// So we do NOT support TWO emergencies .. one from each of the PMs |
|
274 |
// Note: only MT-LR or NI-LR requests can be emergency requests. |
|
275 |
if (aEmergency |
|
276 |
&& (aSessionType == MLbsNetworkProtocolObserver::EServiceMobileTerminated |
|
277 |
|| aSessionType == MLbsNetworkProtocolObserver::EServiceNetworkInduced)) |
|
278 |
{ |
|
279 |
TInt index = iFsmArray.Find(iEmergencyFsm); |
|
280 |
if (index >= 0) |
|
281 |
{ |
|
282 |
iFsmArray.Remove(index); |
|
283 |
iNumActiveSessions--; |
|
284 |
} |
|
285 |
// clean out Fsm |
|
286 |
iEmergencyFsm->RefPosProcessed() = EFalse; |
|
287 |
iEmergencyFsm->LocReqReceived() = EFalse; |
|
288 |
iEmergencyFsm->LocationFixReceived()= EFalse; |
|
289 |
iEmergencyFsm->TapMode() = EFalse; |
|
290 |
iEmergencyFsm->WasPrivacyResponseReceivedStateExited() = EFalse; |
|
291 |
iEmergencyFsm->NetSessionId()= aSessionId; |
|
292 |
fsm = iEmergencyFsm; |
|
293 |
} |
|
294 |
else |
|
295 |
{ |
|
296 |
if (iNumActiveSessions <= iMaxNumSessions) |
|
297 |
{ |
|
298 |
// Create a new session to handle this privacy request |
|
299 |
LBSLOG2(ELogP3, "Creating FSM for new standard request %d",aSessionId.SessionNum()); |
|
300 |
TRAPD(err, fsm = CLbsPrivLocFsm::NewL(*this, aSessionId)); |
|
301 |
if (err != KErrNone) |
|
302 |
{ |
|
303 |
LBSLOG_ERR2(ELogP3, "Failed to create new FSM, error code : %d", err); |
|
304 |
} |
|
305 |
} |
|
306 |
else |
|
307 |
{ |
|
308 |
LBSLOG_ERR3(ELogP3, "Session start rejected! iNumActiveSessions=%d > iMaxNumSessions=%d", iNumActiveSessions, iMaxNumSessions); |
|
309 |
} |
|
310 |
} |
|
311 |
||
312 |
if (fsm) |
|
313 |
{ |
|
314 |
// Add the state machine to the buffer. |
|
60
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
315 |
TInt err = iFsmArray.Append(fsm); |
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
316 |
if( err != KErrNone ) |
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
317 |
{ |
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
318 |
delete fsm; |
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
319 |
return NULL; |
9a7e3d5f461a
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
51
diff
changeset
|
320 |
} |
36 | 321 |
|
322 |
iNumActiveSessions++; // conceptually, a session starts when a Fsm is created for it |
|
323 |
||
324 |
} |
|
325 |
||
326 |
return fsm; |
|
327 |
} |
|
328 |
||
329 |
||
330 |
// ----------------------------------------------------------------------------- |
|
331 |
// CPrivacyAndLocationHandler::PrivacyHandler |
|
332 |
// Description: Return a pointer to the privacy handler implementation |
|
333 |
// (controller or notifier). |
|
334 |
// ----------------------------------------------------------------------------- |
|
335 |
// |
|
336 |
CPrivacyHandler* CPrivacyAndLocationHandler::PrivacyHandler() |
|
337 |
{ |
|
338 |
return iPrivacyHandler; |
|
339 |
} |
|
340 |
||
341 |
// ----------------------------------------------------------------------------- |
|
342 |
// CPrivacyAndLocationHandler::MessageSwitch |
|
343 |
// Description: Return a pointer to the Network Gateway Message Switch |
|
344 |
// ----------------------------------------------------------------------------- |
|
345 |
// |
|
346 |
CNGMessageSwitch* CPrivacyAndLocationHandler::MessageSwitch() |
|
347 |
{ |
|
348 |
return iMessageSwitch; |
|
349 |
} |
|
350 |
||
351 |
// ----------------------------------------------------------------------------- |
|
352 |
// CPrivacyAndLocationHandler::LbsAdmin |
|
353 |
// Description: Return a pointer to the Admin settings database |
|
354 |
// ----------------------------------------------------------------------------- |
|
355 |
// |
|
356 |
CLbsAdmin* CPrivacyAndLocationHandler::LbsAdmin() |
|
357 |
{ |
|
358 |
return iLbsAdmin; |
|
359 |
} |
|
360 |
||
361 |
// ----------------------------------------------------------------------------- |
|
362 |
// CPrivacyAndLocationHandler::SetServerObserver |
|
363 |
// Description: Store a pointer to the NRH server which comunicates with the |
|
364 |
// Privacy Controller. |
|
365 |
// ----------------------------------------------------------------------------- |
|
366 |
// |
|
367 |
void CPrivacyAndLocationHandler::SetServerObserver(MLbsSessionObserver* aNrhServer) |
|
368 |
{ |
|
369 |
PrivacyHandler()->SetServerObserver(aNrhServer); |
|
370 |
} |
|
371 |
||
372 |
// ----------------------------------------------------------------------------- |
|
373 |
// CPrivacyAndLocationHandler::OnRespondNetworkLocationRequest |
|
374 |
// Description: Called by the Privacy Handler to report the result of a privacy |
|
375 |
// check. Handling of the response is delegated to the current state. |
|
376 |
// ----------------------------------------------------------------------------- |
|
377 |
// |
|
378 |
void CPrivacyAndLocationHandler::OnRespondNetworkLocationRequest(const TLbsNetSessionIdInt& aRequestId, |
|
379 |
TLbsNetworkEnumInt::TLbsPrivacyResponseInt aRequestResult, |
|
380 |
TInt aResponseReason) |
|
381 |
{ |
|
382 |
LBSLOG2(ELogP3, "Received response %d to privacy request", aRequestResult); |
|
383 |
CLbsPrivLocFsm* fsm = LookupFsm(aRequestId); |
|
384 |
||
385 |
if (NULL != fsm) |
|
386 |
{ |
|
387 |
fsm->OnRespondNetworkLocationRequest(aRequestId, aRequestResult, aResponseReason); |
|
388 |
} |
|
389 |
else |
|
390 |
{ |
|
391 |
LBSLOG_WARN(ELogP3, "Couldn't find a FSM with matching session Id"); |
|
392 |
} |
|
393 |
} |
|
394 |
||
395 |
// ----------------------------------------------------------------------------- |
|
396 |
// CPrivacyAndLocationHandler::OnCancelNetworkLocationRequest |
|
397 |
// Description: Called by the Privacy Handler to report that a privacy check |
|
398 |
// has been rejected. This may occur after it has already been accepted. |
|
399 |
// Handling of the response is delegated to the current state. |
|
400 |
// ----------------------------------------------------------------------------- |
|
401 |
// |
|
402 |
void CPrivacyAndLocationHandler::OnCancelNetworkLocationRequest(const TLbsNetSessionIdInt& aRequestId) |
|
403 |
{ |
|
404 |
LBSLOG2(ELogP3, "Received cancellation to privacy request %d", aRequestId.SessionNum()); |
|
405 |
CLbsPrivLocFsm* fsm = LookupFsm(aRequestId); |
|
406 |
||
407 |
if (NULL != fsm) |
|
408 |
{ |
|
409 |
fsm->OnCancelNetworkLocationRequest(aRequestId); |
|
410 |
} |
|
411 |
else |
|
412 |
{ |
|
413 |
LBSLOG_WARN(ELogP3, "Couldn't find a FSM with matching session Id"); |
|
414 |
} |
|
415 |
} |
|
416 |
||
417 |
// ----------------------------------------------------------------------------- |
|
418 |
// CPrivacyAndLocationHandler::OnMTLRRequest |
|
419 |
// Description: The Message Switch has forwarded a request to start an MTLR |
|
420 |
// session. |
|
421 |
// Handling of the request is delegated to the current state. |
|
422 |
// ----------------------------------------------------------------------------- |
|
423 |
// |
|
424 |
void CPrivacyAndLocationHandler::OnMTLRRequest(const TLbsNetSessionIdInt& aSessionId, |
|
425 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
426 |
TBool aIsEmergency, |
|
427 |
const TLbsExternalRequestInfo& aExternalRequestInfo, |
|
428 |
const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy) |
|
429 |
{ |
|
430 |
LBSLOG2(ELogP3, "Received privacy request with id %d", aSessionId.SessionNum()); |
|
431 |
CLbsPrivLocFsm* fsm = LookupFsm(aSessionId); |
|
432 |
||
433 |
if (fsm==NULL) |
|
434 |
{ |
|
435 |
fsm = GetNewFsm(aSessionId, aSessionType, aIsEmergency); |
|
436 |
} |
|
437 |
||
438 |
if (NULL != fsm) |
|
439 |
{ |
|
440 |
fsm->OnMTLRRequest(aSessionId, |
|
441 |
aSessionType, |
|
442 |
aIsEmergency, |
|
443 |
aExternalRequestInfo, |
|
444 |
aNetPosRequestPrivacy); |
|
445 |
} |
|
446 |
else |
|
447 |
{ |
|
448 |
// Failed to create a state machine for this request, |
|
449 |
// so simply reply with a privacy rejection. |
|
450 |
iMessageSwitch->SendMTLRResponse(aSessionId, |
|
451 |
TLbsNetworkEnumInt::EPrivacyResponseRejected, |
|
452 |
KErrGeneral, EFalse); // can't be an emergency cuase we know we have a Fsm for these! |
|
453 |
} |
|
454 |
} |
|
455 |
||
456 |
// ----------------------------------------------------------------------------- |
|
457 |
// CPrivacyAndLocationHandler::OnSessionComplete |
|
458 |
// Description: The Message Switch has reported that the session is |
|
459 |
// over (complete or aborted due to some error). |
|
460 |
// Handling of the message is delegated to the current state. |
|
461 |
// ----------------------------------------------------------------------------- |
|
462 |
// |
|
463 |
void CPrivacyAndLocationHandler::OnSessionComplete( |
|
464 |
const TLbsNetSessionIdInt& aSessionId, |
|
465 |
TInt aReason) |
|
466 |
{ |
|
467 |
LBSLOG3(ELogP3, "Received Session Complete for id %d, reason %d", aSessionId.SessionNum(), aReason); |
|
468 |
CLbsPrivLocFsm* fsm = LookupFsm(aSessionId); |
|
469 |
||
470 |
if (NULL != fsm) |
|
471 |
{ |
|
472 |
fsm->OnSessionComplete(aSessionId, aReason); |
|
473 |
||
474 |
// The session complete marks the end of a session. |
|
475 |
TInt index = iFsmArray.Find(fsm); |
|
476 |
if (index != KErrNotFound) |
|
477 |
{ |
|
478 |
||
479 |
if (fsm->SessionType()== TLbsNetworkEnumInt::EServiceSelfLocation) |
|
480 |
{ |
|
481 |
iMolRFsm = NULL; |
|
482 |
} |
|
483 |
else if (fsm->SessionType()== TLbsNetworkEnumInt::EServiceTransmitThirdParty) |
|
484 |
{ |
|
485 |
iX3pFsm = NULL; |
|
486 |
} |
|
487 |
||
488 |
// We should never delete the emergency FSM. |
|
489 |
iFsmArray.Remove(index); |
|
490 |
iNumActiveSessions--; |
|
491 |
||
492 |
if (fsm != iEmergencyFsm) |
|
493 |
{ |
|
494 |
delete fsm; |
|
495 |
} |
|
496 |
} |
|
497 |
} |
|
498 |
else |
|
499 |
{ |
|
500 |
LBSLOG_WARN(ELogP3, "Couldn't find a FSM with matching session Id"); |
|
501 |
} |
|
502 |
} |
|
503 |
||
504 |
// ----------------------------------------------------------------------------- |
|
505 |
// CPrivacyAndLocationHandler::OnNetLocRequest |
|
506 |
// Description: The Message Switch has passed on a request for a position update |
|
507 |
// Handling of the request is delegated to the current state. |
|
508 |
// ----------------------------------------------------------------------------- |
|
509 |
// |
|
510 |
void CPrivacyAndLocationHandler::OnNetLocRequest( |
|
511 |
const TLbsNetSessionIdInt& aSessionId, |
|
512 |
const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
513 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
514 |
TBool aIsEmergency, |
|
515 |
const TLbsNetPosRequestQualityInt& aQuality) |
|
516 |
{ |
|
517 |
LBSLOG2(ELogP3, "Received position update request for id %d", aSessionId.SessionNum()); |
|
518 |
||
519 |
TLbsNetSessionIdInt sessionId; |
|
520 |
TPositionInfo posInfo; |
|
521 |
TPosition pos; |
|
522 |
TTime timeStamp; |
|
523 |
TInt err; |
|
524 |
||
525 |
TBool tapMode = EFalse; |
|
526 |
TInt numMethods = aPosRequestMethod.NumPosMethods(); |
|
527 |
if (numMethods==1) |
|
528 |
{ |
|
529 |
TLbsNetPosMethodInt netPosMethod; |
|
530 |
aPosRequestMethod.GetPosMethod(0,netPosMethod); |
|
531 |
||
532 |
if (netPosMethod.PosMode()== (TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted)) |
|
533 |
{ |
|
534 |
tapMode = ETrue; |
|
535 |
} |
|
536 |
} |
|
537 |
||
538 |
// This filtering used to be in the NG Message Switch, but has been moved |
|
539 |
// here to get an access to the ref position bus |
|
540 |
||
541 |
if( (aSessionType == TLbsNetworkEnumInt::EServiceNetworkLocation) && !tapMode) |
|
542 |
{ |
|
543 |
// A Network-based location request generates a location |
|
544 |
// request to the network request handler, but there's no point |
|
545 |
// passing it any further - the AGPS manager & privacy |
|
546 |
// controller aren't interested. |
|
547 |
// Simply return the saved reference location |
|
548 |
err = iMessageSwitch->GetNetworkReferencePosition(aSessionId, posInfo); |
|
549 |
posInfo.GetPosition(pos); |
|
550 |
timeStamp = pos.Time(); |
|
551 |
TLbsNetPosRequestQualityInt dummyQuality; |
|
552 |
MessageSwitch()->SendNetLocResponse(aSessionId, err, dummyQuality, posInfo, timeStamp, EFalse); |
|
553 |
} |
|
554 |
else |
|
555 |
{ |
|
556 |
// we note that a self locate MoLr session can be implicitly |
|
557 |
// cancelled by the start of a new session for a new client. |
|
558 |
// In this case we complete the session before creating a new |
|
559 |
// fsm for the new client |
|
560 |
CLbsPrivLocFsm* fsm = LookupFsm(aSessionId); |
|
561 |
if (!fsm) |
|
562 |
{ |
|
563 |
// here, we need to create a new fsm |
|
564 |
// We note that only one self locate MolR (or X3p) is supported |
|
565 |
// a new one will implicitly cancel any ongoing |
|
566 |
if(aSessionType == TLbsNetworkEnumInt::EServiceSelfLocation) |
|
567 |
{ |
|
568 |
if (iMolRFsm) |
|
569 |
{ |
|
570 |
TInt index = iFsmArray.Find(iMolRFsm); |
|
571 |
if (index != KErrNotFound) |
|
572 |
{ |
|
573 |
iFsmArray.Remove(index); |
|
574 |
iNumActiveSessions--; |
|
575 |
delete iMolRFsm; |
|
576 |
iMolRFsm = NULL; |
|
577 |
} |
|
578 |
} |
|
579 |
||
580 |
} |
|
581 |
else if(aSessionType == TLbsNetworkEnumInt::EServiceTransmitThirdParty) |
|
582 |
{ |
|
583 |
if (iX3pFsm) |
|
584 |
{ |
|
585 |
TInt index = iFsmArray.Find(iX3pFsm); |
|
586 |
if (index != KErrNotFound) |
|
587 |
{ |
|
588 |
iFsmArray.Remove(index); |
|
589 |
iNumActiveSessions--; |
|
590 |
delete iX3pFsm; |
|
591 |
iX3pFsm = NULL; |
|
592 |
} |
|
593 |
} |
|
594 |
} |
|
595 |
||
596 |
fsm = GetNewFsm(aSessionId, aSessionType, aIsEmergency); |
|
597 |
} |
|
598 |
||
599 |
if (NULL != fsm) |
|
600 |
{ |
|
601 |
if(aSessionType == TLbsNetworkEnumInt::EServiceSelfLocation) |
|
602 |
{ |
|
603 |
iMolRFsm = fsm; |
|
604 |
} |
|
605 |
else if(aSessionType == TLbsNetworkEnumInt::EServiceTransmitThirdParty) |
|
606 |
{ |
|
607 |
iX3pFsm = fsm; |
|
608 |
} |
|
609 |
||
610 |
fsm->OnNetLocRequest(aSessionId, |
|
611 |
aPosRequestMethod, |
|
612 |
aSessionType, |
|
613 |
aIsEmergency, |
|
614 |
aQuality); |
|
615 |
} |
|
616 |
else |
|
617 |
{ |
|
618 |
// TODO: Return a dummy loc response with error code? |
|
619 |
LBSLOG_WARN(ELogP3, "Couldn't find a FSM with matching session Id"); |
|
620 |
} |
|
621 |
} |
|
622 |
} |
|
623 |
||
624 |
/** Called when a reference position arrives from the network. |
|
625 |
*/ |
|
626 |
void CPrivacyAndLocationHandler::OnNetLocReferenceUpdate( |
|
627 |
const TLbsNetSessionIdInt& aSessionId, |
|
628 |
const TPositionInfoBase& aPosInfo) |
|
629 |
{ |
|
630 |
LBSLOG2(ELogP3, "Received reference position update for id %d", aSessionId.SessionNum()); |
|
631 |
CLbsPrivLocFsm* fsm = LookupFsm(aSessionId); |
|
632 |
||
633 |
if (NULL != fsm) |
|
634 |
{ |
|
635 |
fsm->OnNetLocReferenceUpdate(aSessionId, aPosInfo); |
|
636 |
} |
|
637 |
else |
|
638 |
{ |
|
639 |
LBSLOG_WARN(ELogP3, "Couldn't find a FSM with matching session Id"); |
|
640 |
} |
|
641 |
} |
|
642 |
||
643 |
/** Callend when a final location arrives from the network. |
|
644 |
*/ |
|
645 |
void CPrivacyAndLocationHandler::OnNetLocFinalUpdate( |
|
646 |
const TLbsNetSessionIdInt& aSessionId, |
|
647 |
const TPositionInfoBase& aPosInfo) |
|
648 |
{ |
|
649 |
LBSLOG2(ELogP3, "Received final network position update for id %d", aSessionId.SessionNum()); |
|
650 |
CLbsPrivLocFsm* fsm = LookupFsm(aSessionId); |
|
651 |
||
652 |
if (NULL != fsm) |
|
653 |
{ |
|
654 |
fsm->OnNetLocFinalUpdate(aSessionId, aPosInfo); |
|
655 |
} |
|
656 |
else |
|
657 |
{ |
|
658 |
LBSLOG_WARN(ELogP3, "Couldn't find a FSM with matching session Id"); |
|
659 |
} |
|
660 |
} |
|
661 |
||
662 |
/** Callback when a GPS position update arrives from AGPS manager. |
|
663 |
*/ |
|
664 |
void CPrivacyAndLocationHandler::OnAgpsPositionUpdate( |
|
665 |
TInt aReason, |
|
666 |
const TPositionExtendedSatelliteInfo& aPosInfo, |
|
667 |
const TTime& aTimeStamp) |
|
668 |
{ |
|
669 |
// Broadcast the update to all state machines. |
|
670 |
const TInt count = iFsmArray.Count(); |
|
671 |
for (TInt i = 0; i < count; i++) |
|
672 |
{ |
|
673 |
iFsmArray[i]->OnAgpsPositionUpdate(aReason, aPosInfo, aTimeStamp); |
|
674 |
} |
|
675 |
} |
|
676 |
||
677 |
/** Callback when a GPS measurement results update arrives from AGPS manager. |
|
678 |
*/ |
|
679 |
void CPrivacyAndLocationHandler::OnAgpsMeasurementUpdate( |
|
680 |
TInt aReason, |
|
681 |
const TPositionGpsMeasurementInfo& aPosInfo, |
|
682 |
const TTime& aTimeStamp) |
|
683 |
{ |
|
684 |
// Broadcast the update to all state machines |
|
685 |
const TInt count = iFsmArray.Count(); |
|
686 |
for (TInt i = 0; i < count; i++) |
|
687 |
{ |
|
688 |
iFsmArray[i]->OnAgpsMeasurementUpdate(aReason, aPosInfo, aTimeStamp); |
|
689 |
} |
|
690 |
} |
|
691 |
||
692 |
/** |
|
693 |
*/ |
|
694 |
CAgpsInterfaceHandler* CPrivacyAndLocationHandler::AgpsHandler() |
|
695 |
{ |
|
696 |
return iAgpsInterface; |
|
697 |
} |
|
698 |
||
699 |
// ----------------------------------------------------------------------------- |
|
700 |
// CPrivacyAndLocationHandler::DeviceGpsModeCaps |
|
701 |
// Description: Return the device mode capabilities |
|
702 |
// ----------------------------------------------------------------------------- |
|
703 |
// |
|
704 |
TPositionModuleInfoExtended::TDeviceGpsModeCapabilities CPrivacyAndLocationHandler::DeviceGpsModeCaps() |
|
705 |
{ |
|
706 |
return iDeviceGpsModeCaps; |
|
707 |
} |
|
708 |
||
709 |
// ----------------------------------------------------------------------------- |
|
710 |
// CPrivacyAndLocationHandler::BehaviourMode |
|
711 |
// Description: Return the behaviour mode setting |
|
712 |
// ----------------------------------------------------------------------------- |
|
713 |
// |
|
714 |
CLbsAdmin::TLbsBehaviourMode CPrivacyAndLocationHandler::BehaviourMode() |
|
715 |
{ |
|
716 |
return iLbsBehaviourMode; |
|
717 |
} |
|
718 |
||
719 |
RLbsNetworkRegistrationStatus& CPrivacyAndLocationHandler::NetworkRegistrationStatus() |
|
720 |
{ |
|
721 |
return iNetRegStatus; |
|
722 |
} |
|
723 |
||
724 |
// increments the P&S key tracking mobile terminated positioning requests |
|
725 |
void CPrivacyAndLocationHandler::IncrementPositioningStatus() |
|
726 |
{ |
|
727 |
TInt count; |
|
728 |
RProperty::Get(iPosStatusCategory, KLbsNiPositioningStatusKey, count); |
|
729 |
RProperty::Set(iPosStatusCategory, KLbsNiPositioningStatusKey, count+1); |
|
730 |
} |
|
731 |
||
732 |
// decrements the P&S key tracking mobile terminated positioning requests |
|
733 |
// if location management is supported. In the alternative architecture, |
|
734 |
// the NRH is not aware of the positioning session's progress, but is |
|
735 |
// transient. Therefore the positioning status is set to zero in the |
|
736 |
// class destructor. |
|
737 |
void CPrivacyAndLocationHandler::DecrementPositioningStatus() |
|
738 |
{ |
|
739 |
if (iLocationManagementSupported) |
|
740 |
{ |
|
741 |
TInt count; |
|
742 |
RProperty::Get(iPosStatusCategory, KLbsNiPositioningStatusKey, count); |
|
743 |
if(count>0) |
|
744 |
{ |
|
745 |
RProperty::Set(iPosStatusCategory, KLbsNiPositioningStatusKey, count-1); |
|
746 |
} |
|
747 |
else |
|
748 |
{ |
|
749 |
LBSLOG_ERR(ELogP3, "CPrivacyAndLocationHandler::DecrementPositioningStatus() - Incorrect Positioning Status count\n"); |
|
750 |
} |
|
751 |
} |
|
752 |
} |
|
753 |
||
754 |
||
755 |
/** |
|
756 |
*/ |
|
757 |
MX3pStatusHandler& CPrivacyAndLocationHandler::X3pStatusHandler() |
|
758 |
{ |
|
759 |
return *iAgpsInterface; |
|
760 |
} |
|
761 |
||
762 |
/** Returns ETrue if KLbsSpecialFeatureIntermediateFutileUpdate is on. |
|
763 |
@return ETrue if the special feature is on, EFalse otherwise. |
|
764 |
*/ |
|
765 |
TBool CPrivacyAndLocationHandler::IsSpecialFeatureIntermediateFutileUpdateOn() |
|
766 |
{ |
|
767 |
return iSpecialFeatureIntermediateFutileUpdate; |
|
768 |
} |
|
769 |
||
770 |
// ----------------------------------------------------------------------------- |
|
771 |
// |
|
772 |
// ----------------------- Class CLbsPrivLocStateBase -------------------- |
|
773 |
// |
|
774 |
// This class is not intended for instantiation. Implemented functions are |
|
775 |
// those common to multiple derived states |
|
776 |
// |
|
777 |
// ----------------------------------------------------------------------------- |
|
778 |
// |
|
779 |
||
780 |
// ----------------------------------------------------------------------------- |
|
781 |
// CLbsPrivLocStateBase::OnCancelNetworkLocationRequest |
|
782 |
// Description: Pass on a received privacy request cancel to the network gateway, |
|
783 |
// if it relates to the current session. |
|
784 |
// This behaviour is common to states EStateWaitLocationRequest, |
|
785 |
// EStateWaitLocationUpdate and EStateWaitPrivacyResponse. |
|
786 |
// Other states ignore the event. |
|
787 |
// ----------------------------------------------------------------------------- |
|
788 |
// |
|
789 |
void CLbsPrivLocStateBase::OnCancelNetworkLocationRequest(const TLbsNetSessionIdInt& aSessionId) |
|
790 |
{ |
|
791 |
/* Ignore the cancel if this is an emergency request */ |
|
792 |
if(!iFsm->IsEmergency()) |
|
793 |
{ |
|
794 |
// Also ignore it if the cancel doesn't relate to this session. |
|
795 |
if(aSessionId == iFsm->SessionId()) |
|
796 |
{ |
|
797 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitCancelledByPrivacyController, KErrCancel); |
|
798 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, aSessionId); |
|
799 |
} |
|
800 |
} |
|
801 |
} |
|
802 |
||
803 |
// ----------------------------------------------------------------------------- |
|
804 |
// CLbsPrivLocStateBase::OnEntry |
|
805 |
// Description: Handles initialisation actions which are common to multiple states. |
|
806 |
// ----------------------------------------------------------------------------- |
|
807 |
// |
|
808 |
void CLbsPrivLocStateBase::OnEntry(const TPrivLocCommonParams& /* aStateParams */) |
|
809 |
{ |
|
810 |
// Exit reason should always be explicitly set by a state, |
|
811 |
// otherwise OnExit() will panic |
|
812 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitReasonNone, KErrNone); |
|
813 |
} |
|
814 |
||
815 |
||
816 |
// ----------------------------------------------------------------------------- |
|
817 |
// CLbsPrivLocStateBase::OnExit |
|
818 |
// Description: Handles exit actions which are common to multiple states. |
|
819 |
// Any exit reason not handled here is delegated to the current state. |
|
820 |
// ----------------------------------------------------------------------------- |
|
821 |
// |
|
822 |
TBool CLbsPrivLocStateBase::OnExit() |
|
823 |
{ |
|
824 |
TBool consumed = ETrue; |
|
825 |
switch(iFsm->iExitData.iExitReason) |
|
826 |
{ |
|
827 |
case TPrivLocStateExitData::EExitSessionComplete: |
|
828 |
{ |
|
829 |
// Tell the AGPS interface handle this location request has finished. |
|
830 |
AgpsInterface()->StopPositioning(iFsm->SessionId()); |
|
831 |
||
832 |
// Tell the privacy controller this session is finished. |
|
833 |
PrivacyHandler()->ProcessRequestComplete(iFsm->SessionId(), |
|
834 |
iFsm->ExitData().iExitInfo); |
|
835 |
break; |
|
836 |
} |
|
837 |
||
838 |
case TPrivLocStateExitData::EExitCancelledByPrivacyController: |
|
839 |
{ |
|
840 |
// Send a cancel to the network gateway |
|
841 |
TPositionInfo dummyPosInfo; |
|
842 |
TTime dummyTime; |
|
843 |
TLbsNetPosRequestQualityInt dummyQuality; |
|
844 |
MessageSwitch()->SendNetLocResponse(iFsm->SessionId(), |
|
845 |
iFsm->ExitData().iExitInfo, |
|
846 |
dummyQuality, |
|
847 |
dummyPosInfo, |
|
848 |
dummyTime, |
|
849 |
iFsm->IsEmergency()); |
|
850 |
} |
|
851 |
break; |
|
852 |
||
853 |
case TPrivLocStateExitData::EExitLocReqReceived: |
|
854 |
// No action required - request is issued on entry to next state. |
|
855 |
case TPrivLocStateExitData::EExitPrivacyRequestReceived: |
|
856 |
// No action required, state moves to waiting for loc request. |
|
857 |
{ |
|
858 |
consumed = ETrue; |
|
859 |
break; |
|
860 |
} |
|
861 |
||
862 |
default: |
|
863 |
{ |
|
864 |
// Don't know what to do with it. |
|
865 |
consumed = EFalse; |
|
866 |
break; |
|
867 |
} |
|
868 |
} |
|
869 |
return(consumed); |
|
870 |
} |
|
871 |
||
872 |
// ----------------------------------------------------------------------------- |
|
873 |
// CLbsPrivLocStateBase::HandleLocRequest |
|
874 |
// Description: Common handling of a location request received while the |
|
875 |
// Privacy and Location Handler is dealing with a session. |
|
876 |
// |
|
877 |
// If the session type is anything but MTLR, then it is processed, otherwise |
|
878 |
// a privacy request is generated |
|
879 |
// ----------------------------------------------------------------------------- |
|
880 |
// |
|
881 |
void CLbsPrivLocStateBase::HandleLocRequest(const TLbsNetSessionIdInt& aSessionId, |
|
882 |
const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
883 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
884 |
TBool aIsEmergency, |
|
885 |
const TLbsNetPosRequestQualityInt& aQuality) |
|
886 |
{ |
|
887 |
// MTLR. |
|
888 |
if (aSessionType == TLbsNetworkEnumInt::EServiceMobileTerminated) |
|
889 |
{ |
|
890 |
// An MTLR with out a prior privacy request is not supported, report error via |
|
891 |
// RespondLocationRequest(dummy position). |
|
892 |
TPositionInfo dummyPosInfo; |
|
893 |
TTime dummyTime; |
|
894 |
TLbsNetPosRequestQualityInt dummyQuality; |
|
895 |
||
896 |
MessageSwitch()->SendNetLocResponse(aSessionId, |
|
897 |
KErrNotSupported, |
|
898 |
dummyQuality, |
|
899 |
dummyPosInfo, |
|
900 |
dummyTime, aIsEmergency); |
|
901 |
} |
|
902 |
||
903 |
// Network Induced. |
|
904 |
else if (aSessionType == TLbsNetworkEnumInt::EServiceNetworkInduced) |
|
905 |
{ |
|
906 |
// If a request for a position update has been received without |
|
907 |
// a privacy request, then there's nothing to say how the user |
|
908 |
// should be informed or what do do if there is no response. |
|
909 |
// The safest thing is to get the user to confirm (verify) |
|
910 |
// the request, and in the absence of confirmation to reject the |
|
911 |
// request. For emergency requests we notify and accept. |
|
912 |
||
913 |
// Store the loc req. |
|
914 |
iFsm->LocReqReceived() = ETrue; |
|
915 |
||
916 |
iFsm->IsEmergency() = aIsEmergency; |
|
917 |
iFsm->NetRequestQuality() = aQuality; |
|
918 |
iFsm->PosRequestMethod() = aPosRequestMethod; |
|
919 |
||
920 |
||
921 |
// The following notification types are chosen based on the emergency and network requests admin status. |
|
922 |
// |
|
923 |
// Emergency = On, Admin = Any, gives ENotifyLocationAccepted |
|
924 |
// Emergency = Off, Admin = On, gives ENotifyLocationAccepted |
|
925 |
// Emergency = Off, Admin = OnButAlwayVerify, gives ENotifyAndVerifyLocationRejectedIfNoResponse |
|
926 |
// Emergency = Off, Admin = Off, N/A the notifier or controller will not be called |
|
927 |
// Emergency = Off, Admin = OffButNotify, gives ENotifyLocationRejected |
|
928 |
TLbsNetPosRequestPrivacyInt requestPrivacy; |
|
929 |
||
930 |
requestPrivacy.SetRequestAdvice(TLbsNetPosRequestPrivacyInt::ERequestAdviceNotify); |
|
931 |
requestPrivacy.SetRequestAction(TLbsNetPosRequestPrivacyInt::ERequestActionAllow); |
|
932 |
||
933 |
// Verifications are rejected after timeout. |
|
934 |
CLbsAdmin::TExternalLocateService externalLocate(CLbsAdmin::EExternalLocateOff); |
|
935 |
||
936 |
ReadNetworkInducedAdminSetting(externalLocate); |
|
937 |
if ((externalLocate == CLbsAdmin::EExternalLocateOnButAlwaysVerify) && (!aIsEmergency)) |
|
938 |
{ |
|
939 |
requestPrivacy.SetRequestAdvice(TLbsNetPosRequestPrivacyInt::ERequestAdviceVerify); |
|
940 |
requestPrivacy.SetRequestAction(TLbsNetPosRequestPrivacyInt::ERequestActionReject); |
|
941 |
} |
|
942 |
||
943 |
// Similarly, default values have to be assigned to the external request info. |
|
944 |
TLbsExternalRequestInfo requestInfo; |
|
945 |
_LIT8(KUnknownExternalReqInfoField, ""); |
|
946 |
requestInfo.SetRequesterId(KUnknownExternalReqInfoField); |
|
947 |
requestInfo.SetClientName(KUnknownExternalReqInfoField); |
|
948 |
requestInfo.SetClientExternalId(KUnknownExternalReqInfoField); |
|
949 |
||
950 |
||
951 |
// Process the privacy request. |
|
952 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitLocReqReceived, KErrNone); |
|
953 |
||
954 |
TPrivLocWaitPrivResponseParams privacyRequestParams(aSessionId, aSessionType, requestInfo, requestPrivacy, aIsEmergency); |
|
955 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateWaitPrivacyResponse, privacyRequestParams); |
|
956 |
} |
|
957 |
||
958 |
// All other location requests. |
|
959 |
else |
|
960 |
{ |
|
961 |
TPrivLocWaitLocationUpdateParams updateRequestParams(aSessionId, |
|
962 |
aPosRequestMethod, |
|
963 |
aSessionType, |
|
964 |
aIsEmergency, |
|
965 |
aQuality); |
|
966 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitSessionComplete, KErrCancel); |
|
967 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateWaitLocationUpdate, updateRequestParams); |
|
968 |
} |
|
969 |
} |
|
970 |
||
971 |
// ----------------------------------------------------------------------------- |
|
972 |
// CLbsPrivLocStateBase::OnSessionComplete |
|
973 |
// Description: Common handling of a session complete message received other |
|
974 |
// than when it is expected as normal session completion. |
|
975 |
// ----------------------------------------------------------------------------- |
|
976 |
// |
|
977 |
void CLbsPrivLocStateBase::OnSessionComplete(const TLbsNetSessionIdInt& aSessionId, |
|
978 |
TInt aReason) |
|
979 |
{ |
|
980 |
if(aSessionId == iFsm->SessionId()) |
|
981 |
{ |
|
982 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitSessionComplete, aReason); |
|
983 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, aSessionId); |
|
984 |
} |
|
985 |
} |
|
986 |
||
987 |
/** Called when a reference position arrives from the network. |
|
988 |
*/ |
|
989 |
void CLbsPrivLocStateBase::OnNetLocReferenceUpdate( |
|
990 |
const TLbsNetSessionIdInt& /*aSessionId*/ , |
|
991 |
const TPositionInfoBase& aPosInfo) |
|
992 |
{ |
|
993 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt sessionType = iFsm->SessionType(); |
|
994 |
__ASSERT_DEBUG((sessionType != MLbsNetworkProtocolObserver::EServiceNone), Panic(ENrhPanicBadParamType)); |
|
995 |
||
996 |
if( ((sessionType == MLbsNetworkProtocolObserver::EServiceNetworkInduced) || |
|
997 |
(sessionType == MLbsNetworkProtocolObserver::EServiceMobileTerminated))) |
|
998 |
{ |
|
999 |
TPositionInfo posInfo = static_cast<const TPositionInfo&>(aPosInfo); |
|
1000 |
||
1001 |
// Set the module Id and position mode for the reference position. |
|
1002 |
// These values are not 'real' values, since this position |
|
1003 |
// came directly from the network and not one of the location |
|
1004 |
// managers within LBS. |
|
1005 |
posInfo.SetModuleId(KLbsGpsLocManagerUid); |
|
1006 |
posInfo.SetPositionMode(TPositionModuleInfo::ETechnologyNetwork); |
|
1007 |
posInfo.SetPositionModeReason(EPositionModeReasonNone); |
|
1008 |
posInfo.SetUpdateType(EPositionUpdateGeneral); |
|
1009 |
||
1010 |
if (!iFsm->RefPosProcessed()) |
|
1011 |
{ |
|
1012 |
iFsm->RefPosProcessed() = ETrue; |
|
1013 |
PrivacyHandler()->ProcessNetworkPositionUpdate(iFsm->SessionId(), posInfo); |
|
1014 |
} |
|
1015 |
||
1016 |
} |
|
1017 |
} |
|
1018 |
||
1019 |
/* Timer callback called when the MaxFixTime for a gps location update request has expired. |
|
1020 |
||
1021 |
The default action is to ignore this callback. Any state interested in it must |
|
1022 |
implement its own version. |
|
1023 |
*/ |
|
1024 |
void CLbsPrivLocStateBase::OnTimerEventL(TInt /*aTimerId*/) |
|
1025 |
{ |
|
1026 |
} |
|
1027 |
||
1028 |
||
1029 |
// ----------------------------------------------------------------------------- |
|
1030 |
// CLbsPrivLocStateBase::ReadNetworkInducedAdminSetting |
|
1031 |
// Description: Determine the external location value from the admin settings for network induced location requests. |
|
1032 |
// ----------------------------------------------------------------------------- |
|
1033 |
// |
|
1034 |
void CLbsPrivLocStateBase::ReadNetworkInducedAdminSetting(CLbsAdmin::TExternalLocateService& aExternalLocateService) |
|
1035 |
{ |
|
1036 |
CLbsAdmin::TExternalLocateService serviceStatus(CLbsAdmin::EExternalLocateOff); |
|
1037 |
RLbsNetworkRegistrationStatus::TLbsNetworkRegistrationStatus netRegStatus(RLbsNetworkRegistrationStatus::ENetworkRegistrationUnknown); |
|
1038 |
TInt err = LbsNetworkRegistrationStatus().GetNetworkRegistrationStatus(netRegStatus); |
|
1039 |
if (err == KErrNone) |
|
1040 |
{ |
|
1041 |
switch (netRegStatus) |
|
1042 |
{ |
|
1043 |
case RLbsNetworkRegistrationStatus::ERegisteredHomeNetwork: |
|
1044 |
{ |
|
1045 |
err = LbsAdmin()->Get(KLbsSettingHomeNetworkInducedLocate, serviceStatus); |
|
1046 |
break; |
|
1047 |
} |
|
1048 |
case RLbsNetworkRegistrationStatus::ERegisteredRoamingNetwork: |
|
1049 |
case RLbsNetworkRegistrationStatus::ENotRegistered: |
|
1050 |
{ |
|
1051 |
err = LbsAdmin()->Get(KLbsSettingRoamingNetworkInducedLocate, serviceStatus); |
|
1052 |
break; |
|
1053 |
} |
|
1054 |
case RLbsNetworkRegistrationStatus::ENetworkRegistrationUnknown: |
|
1055 |
default: |
|
1056 |
{ |
|
1057 |
LBSLOG_WARN2(ELogP4, "Unrecognised TLbsNetworkRegistrationStatus (%d), defaulting to EExternalLocateOff", |
|
1058 |
netRegStatus); |
|
1059 |
serviceStatus = CLbsAdmin::EExternalLocateOff; |
|
1060 |
break; |
|
1061 |
} |
|
1062 |
} |
|
1063 |
} |
|
1064 |
else |
|
1065 |
{ |
|
1066 |
LBSLOG_WARN2(ELogP4, "Failed to get TExternalLocateService, couldn't read roaming status (err %d), defaulting to EExternalLocateOff", |
|
1067 |
err); |
|
1068 |
} |
|
1069 |
||
1070 |
aExternalLocateService = serviceStatus; |
|
1071 |
} |
|
1072 |
||
1073 |
// ----------------------------------------------------------------------------- |
|
1074 |
// CLbsPrivLocStateBase::CLbsPrivLocStateBase |
|
1075 |
// Description: Constructor |
|
1076 |
// ----------------------------------------------------------------------------- |
|
1077 |
// |
|
1078 |
CLbsPrivLocStateBase::CLbsPrivLocStateBase(CLbsPrivLocFsm* aFsm) |
|
1079 |
: iFsm(aFsm) |
|
1080 |
{ |
|
1081 |
} |
|
1082 |
// ----------------------------------------------------------------------------- |
|
1083 |
// CLbsPrivLocStateBase::PrivacyHandler, MessageSwitch, LbsAdmin |
|
1084 |
// Description: Allows concrete states access to NRH resources passed to |
|
1085 |
// the FSM |
|
1086 |
// Returns: pointers. |
|
1087 |
// ----------------------------------------------------------------------------- |
|
1088 |
// |
|
1089 |
CPrivacyHandler* CLbsPrivLocStateBase::PrivacyHandler() |
|
1090 |
{ |
|
1091 |
return iFsm->PrivLocHandler().PrivacyHandler(); |
|
1092 |
} |
|
1093 |
CNGMessageSwitch* CLbsPrivLocStateBase::MessageSwitch() |
|
1094 |
{ |
|
1095 |
return iFsm->PrivLocHandler().MessageSwitch(); |
|
1096 |
} |
|
1097 |
CLbsAdmin* CLbsPrivLocStateBase::LbsAdmin() |
|
1098 |
{ |
|
1099 |
return iFsm->PrivLocHandler().LbsAdmin(); |
|
1100 |
} |
|
1101 |
CAgpsInterfaceHandler* CLbsPrivLocStateBase::AgpsInterface() |
|
1102 |
{ |
|
1103 |
return iFsm->PrivLocHandler().AgpsHandler(); |
|
1104 |
} |
|
1105 |
||
1106 |
||
1107 |
TPositionModuleInfoExtended::TDeviceGpsModeCapabilities CLbsPrivLocStateBase::DeviceGpsModeCaps() |
|
1108 |
{ |
|
1109 |
return iFsm->PrivLocHandler().DeviceGpsModeCaps(); |
|
1110 |
} |
|
1111 |
||
1112 |
CLbsAdmin::TLbsBehaviourMode CLbsPrivLocStateBase::BehaviourMode() |
|
1113 |
{ |
|
1114 |
return iFsm->PrivLocHandler().BehaviourMode(); |
|
1115 |
} |
|
1116 |
||
1117 |
RLbsNetworkRegistrationStatus& CLbsPrivLocStateBase::LbsNetworkRegistrationStatus() |
|
1118 |
{ |
|
1119 |
return iFsm->PrivLocHandler().NetworkRegistrationStatus(); |
|
1120 |
} |
|
1121 |
||
1122 |
/* |
|
1123 |
* increments the network initiated positioning status count |
|
1124 |
* and remembers that it has done |
|
1125 |
*/ |
|
1126 |
void CLbsPrivLocStateBase::IncrementPositioningStatus() |
|
1127 |
{ |
|
1128 |
iFsm->PrivLocHandler().IncrementPositioningStatus(); |
|
1129 |
iFsm->WasPositioningStatusIncremented() = ETrue; |
|
1130 |
} |
|
1131 |
||
1132 |
||
1133 |
// ----------------------------------------------------------------------------- |
|
1134 |
// |
|
1135 |
// ----------------------- Class CLbsPrivLocIdleState -------------------- |
|
1136 |
// |
|
1137 |
// Implements the Idle state of the Privacy and Location Request Handler |
|
1138 |
// |
|
1139 |
// ----------------------------------------------------------------------------- |
|
1140 |
// |
|
1141 |
||
1142 |
// ----------------------------------------------------------------------------- |
|
1143 |
// CLbsPrivLocIdleState::NewL |
|
1144 |
// Description: CLbsPrivLocIdleState static constructor |
|
1145 |
// ----------------------------------------------------------------------------- |
|
1146 |
// |
|
1147 |
CLbsPrivLocIdleState* CLbsPrivLocIdleState::NewL(CLbsPrivLocFsm* aFsm) |
|
1148 |
{ |
|
1149 |
return new (ELeave) CLbsPrivLocIdleState(aFsm); |
|
1150 |
} |
|
1151 |
||
1152 |
// ----------------------------------------------------------------------------- |
|
1153 |
// CLbsPrivLocIdleState::CLbsPrivLocIdleState |
|
1154 |
// Description: CLbsPrivLocIdleState constructor. |
|
1155 |
// ----------------------------------------------------------------------------- |
|
1156 |
// |
|
1157 |
CLbsPrivLocIdleState::CLbsPrivLocIdleState(CLbsPrivLocFsm* aFsm) |
|
1158 |
: CLbsPrivLocStateBase(aFsm) |
|
1159 |
{ |
|
1160 |
} |
|
1161 |
||
1162 |
// ----------------------------------------------------------------------------- |
|
1163 |
// CLbsPrivLocIdleState::OnEntry |
|
1164 |
// Description: Carries out tasks required on entry to the state. |
|
1165 |
// ----------------------------------------------------------------------------- |
|
1166 |
// |
|
1167 |
void CLbsPrivLocIdleState::OnEntry(const TPrivLocCommonParams& aStateParams) |
|
1168 |
{ |
|
1169 |
CLbsPrivLocStateBase::OnEntry(aStateParams); |
|
1170 |
} |
|
1171 |
||
1172 |
// ----------------------------------------------------------------------------- |
|
1173 |
// CLbsPrivLocIdleState::OnExit |
|
1174 |
// Description: Carries out tasks required on exit from the state. |
|
1175 |
// Panics if the exit reason is not handled by the base state exit |
|
1176 |
// ----------------------------------------------------------------------------- |
|
1177 |
// |
|
1178 |
TBool CLbsPrivLocIdleState::OnExit() |
|
1179 |
{ |
|
1180 |
TBool consumed = CLbsPrivLocStateBase::OnExit(); |
|
1181 |
// If the exit reason wasn't handled, panic (should only happen in development) |
|
1182 |
__ASSERT_DEBUG(consumed, Panic(ENrhPanicIdleUnknownExitReason)); |
|
1183 |
||
1184 |
return(consumed); |
|
1185 |
} |
|
1186 |
||
1187 |
// ----------------------------------------------------------------------------- |
|
1188 |
// CLbsPrivLocIdleState::OnNetLocRequest |
|
1189 |
// Description: The Message Switch has forwarded a request for a control |
|
1190 |
// measurement. |
|
1191 |
// If the session type is anything but MTLR, then it is processed, otherwise |
|
1192 |
// a privacy request is generated |
|
1193 |
// ----------------------------------------------------------------------------- |
|
1194 |
// |
|
1195 |
void CLbsPrivLocIdleState::OnNetLocRequest( |
|
1196 |
const TLbsNetSessionIdInt& aSessionId, |
|
1197 |
const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
1198 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
1199 |
TBool aIsEmergency, |
|
1200 |
const TLbsNetPosRequestQualityInt& aQuality) |
|
1201 |
{ |
|
1202 |
iFsm->SessionType() = aSessionType; |
|
1203 |
if(iFsm->WasPrivacyResponseReceivedStateExited()) |
|
1204 |
{ |
|
1205 |
// The request relates to a rejected privacy request |
|
1206 |
// or a request for this session which has already been answered. |
|
1207 |
// In either case, it should be refused. The message is sent to the |
|
1208 |
// network gateway as a part of exit from the state, but we want to |
|
1209 |
// remain in Idle state. |
|
1210 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitCancelledByPrivacyController, KErrAccessDenied); |
|
1211 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, aSessionId); |
|
1212 |
} |
|
1213 |
else |
|
1214 |
{ |
|
1215 |
TInt numMethods = aPosRequestMethod.NumPosMethods(); |
|
1216 |
if (numMethods==1) |
|
1217 |
{ |
|
1218 |
TLbsNetPosMethodInt netPosMethod; |
|
1219 |
aPosRequestMethod.GetPosMethod(0,netPosMethod); |
|
1220 |
||
1221 |
if (netPosMethod.PosMode()== (TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted)) |
|
1222 |
{ |
|
1223 |
iFsm->TapMode() = ETrue; |
|
1224 |
} |
|
1225 |
} |
|
1226 |
||
1227 |
||
1228 |
if ((aSessionType != MLbsNetworkProtocolObserver::EServiceMobileTerminated) && |
|
1229 |
(aSessionType != MLbsNetworkProtocolObserver::EServiceNetworkInduced)) |
|
1230 |
{ |
|
1231 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitLocReqReceived, KErrNone); |
|
1232 |
TPrivLocWaitLocationUpdateParams updateRequestParams(aSessionId, |
|
1233 |
aPosRequestMethod, |
|
1234 |
aSessionType, |
|
1235 |
aIsEmergency, |
|
1236 |
aQuality); |
|
1237 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateWaitLocationUpdate, updateRequestParams); |
|
1238 |
} |
|
1239 |
else |
|
1240 |
{ |
|
1241 |
// It's a request for a different session. Need to find out what to do with it. |
|
1242 |
HandleLocRequest(aSessionId, aPosRequestMethod, |
|
1243 |
aSessionType,aIsEmergency, |
|
1244 |
aQuality); |
|
1245 |
} |
|
1246 |
} |
|
1247 |
} |
|
1248 |
||
1249 |
// ----------------------------------------------------------------------------- |
|
1250 |
// CLbsPrivLocIdleState::OnMTLRRequest |
|
1251 |
// Description: The Message Switch has forwarded a request for a location update |
|
1252 |
// (a privacy request) |
|
1253 |
// ----------------------------------------------------------------------------- |
|
1254 |
// |
|
1255 |
void CLbsPrivLocIdleState::OnMTLRRequest(const TLbsNetSessionIdInt& aSessionId, |
|
1256 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
1257 |
TBool aIsEmergency, |
|
1258 |
const TLbsExternalRequestInfo& aExternalRequestInfo, |
|
1259 |
const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy) |
|
1260 |
{ |
|
1261 |
iFsm->SessionType() = aSessionType; |
|
1262 |
iFsm->ExternalRequestType() = aExternalRequestInfo.RequestType(); |
|
1263 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitPrivacyRequestReceived, KErrNone); |
|
1264 |
TPrivLocWaitPrivResponseParams privacyRequestParams( aSessionId, |
|
1265 |
aSessionType, |
|
1266 |
aExternalRequestInfo, |
|
1267 |
aNetPosRequestPrivacy, |
|
1268 |
aIsEmergency); |
|
1269 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateWaitPrivacyResponse, privacyRequestParams); |
|
1270 |
} |
|
1271 |
||
1272 |
/** Called when a reference position arrives from the network. |
|
1273 |
* |
|
1274 |
*/ |
|
1275 |
void CLbsPrivLocIdleState::OnNetLocReferenceUpdate( |
|
1276 |
const TLbsNetSessionIdInt& /*aSessionId*/, |
|
1277 |
const TPositionInfoBase& /* aPosInfo */) |
|
1278 |
{ |
|
1279 |
// note that the reference postion is stored by the message switch |
|
1280 |
// so here we don't need to save it again! |
|
1281 |
} |
|
1282 |
||
1283 |
// ----------------------------------------------------------------------------- |
|
1284 |
// |
|
1285 |
// ----------------------- Class CLbsPrivLocWaitPrivRespState -------------------- |
|
1286 |
// |
|
1287 |
// Implements the Idle state of the Privacy and Location Request Handler |
|
1288 |
// |
|
1289 |
// ----------------------------------------------------------------------------- |
|
1290 |
// |
|
1291 |
||
1292 |
// ----------------------------------------------------------------------------- |
|
1293 |
// CLbsPrivLocWaitPrivRespState::NewL |
|
1294 |
// Description: CLbsPrivLocIdleState static constructor |
|
1295 |
// ----------------------------------------------------------------------------- |
|
1296 |
// |
|
1297 |
CLbsPrivLocWaitPrivRespState* CLbsPrivLocWaitPrivRespState::NewL(CLbsPrivLocFsm* aFsm) |
|
1298 |
{ |
|
1299 |
return new (ELeave) CLbsPrivLocWaitPrivRespState(aFsm); |
|
1300 |
} |
|
1301 |
||
1302 |
// ----------------------------------------------------------------------------- |
|
1303 |
// CLbsPrivLocWaitPrivRespState::CLbsPrivLocWaitPrivRespState |
|
1304 |
// Description: CLbsPrivLocWaitPrivRespState constructor. |
|
1305 |
// ----------------------------------------------------------------------------- |
|
1306 |
// |
|
1307 |
CLbsPrivLocWaitPrivRespState::CLbsPrivLocWaitPrivRespState(CLbsPrivLocFsm* aFsm) |
|
1308 |
: CLbsPrivLocStateBase(aFsm) |
|
1309 |
{ |
|
1310 |
} |
|
1311 |
||
1312 |
// ----------------------------------------------------------------------------- |
|
1313 |
// CLbsPrivLocWaitPrivRespState::OnEntry |
|
1314 |
// Description: Actions performed when the state is entered. |
|
1315 |
// Unpack the parameters and issue the privacy request. |
|
1316 |
// ----------------------------------------------------------------------------- |
|
1317 |
// |
|
1318 |
void CLbsPrivLocWaitPrivRespState::OnEntry(const TPrivLocCommonParams& aStateParams) |
|
1319 |
{ |
|
1320 |
CLbsPrivLocStateBase::OnEntry(aStateParams); |
|
1321 |
const TPrivLocWaitPrivResponseParams& params = TPrivLocWaitPrivResponseParams::Cast(const_cast<TPrivLocCommonParams&>(aStateParams)); |
|
1322 |
iFsm->SessionType() = params.iSessionType; |
|
1323 |
iFsm->IsEmergency() = params.iIsEmergency; |
|
1324 |
||
1325 |
PrivacyHandler()->ProcessNetworkLocationRequest(iFsm->SessionId(), |
|
1326 |
iFsm->SessionType(), |
|
1327 |
params.iExternalRequestInfo, |
|
1328 |
params.iNetPosRequestPrivacy, |
|
1329 |
iFsm->IsEmergency()); |
|
1330 |
} |
|
1331 |
||
1332 |
// ----------------------------------------------------------------------------- |
|
1333 |
// CLbsPrivLocWaitPrivRespState::OnExit |
|
1334 |
// Description: Actions performed on leaving the state. |
|
1335 |
// ----------------------------------------------------------------------------- |
|
1336 |
// |
|
1337 |
TBool CLbsPrivLocWaitPrivRespState::OnExit() |
|
1338 |
{ |
|
1339 |
TInt consumed = EFalse; |
|
1340 |
switch(iFsm->ExitData().iExitReason) |
|
1341 |
{ |
|
1342 |
case TPrivLocStateExitData::EExitPrivacyResponseReceived: |
|
1343 |
{ |
|
1344 |
// Remember that we exited the privacy response received state |
|
1345 |
// so that we can deny the network location requests in the idle staet. |
|
1346 |
||
1347 |
iFsm->WasPrivacyResponseReceivedStateExited() = ETrue; |
|
1348 |
||
1349 |
||
1350 |
// For the NI case a Reference position may have arrived by now |
|
1351 |
// So we must pass this onto the privacy handler. |
|
1352 |
||
1353 |
if (iFsm->SessionType() == MLbsNetworkProtocolObserver::EServiceNetworkInduced) |
|
1354 |
{ |
|
1355 |
if (iFsm->PrivacyResponse() == CLbsNetworkProtocolBase::EPrivacyResponseAccepted) |
|
1356 |
{ |
|
1357 |
TPositionInfo posInfo; |
|
1358 |
TInt err = MessageSwitch()->GetNetworkReferencePosition(iFsm->SessionId(), posInfo); |
|
1359 |
if (KErrNone == err) |
|
1360 |
{ |
|
1361 |
if (!iFsm->RefPosProcessed()) |
|
1362 |
{ |
|
1363 |
iFsm->RefPosProcessed() = ETrue; |
|
1364 |
PrivacyHandler()->ProcessNetworkPositionUpdate(iFsm->SessionId(), posInfo); |
|
1365 |
} |
|
1366 |
||
1367 |
} |
|
1368 |
||
1369 |
} |
|
1370 |
} |
|
1371 |
||
1372 |
// For MtLrs the Protocol module should not |
|
1373 |
// send a REF position until after we have sent the Priv response to the PM |
|
1374 |
||
1375 |
// Inform network of the privacy response for normal privacy requests. |
|
1376 |
if (iFsm->SessionType() == TLbsNetworkEnumInt::EServiceMobileTerminated) |
|
1377 |
{ |
|
1378 |
MessageSwitch()->SendMTLRResponse(iFsm->SessionId(), iFsm->PrivacyResponse(), iFsm->PrivacyResponseReason(), iFsm->IsEmergency()); |
|
1379 |
} |
|
1380 |
||
1381 |
// Inform network of a rejected privacy response via a "RespondLocationRequest" for faked privacy requests (generated internaly). |
|
1382 |
else if ((iFsm->SessionType() == TLbsNetworkEnumInt::EServiceNetworkInduced) && (iFsm->PrivacyResponse() == TLbsNetworkEnumInt::EPrivacyResponseRejected)) |
|
1383 |
{ |
|
1384 |
// The faked privacy request was rejected, so reject the location request. |
|
1385 |
TPositionInfo dummyPosInfo; |
|
1386 |
TTime dummyTime; |
|
1387 |
TLbsNetPosRequestQualityInt dummyQuality; |
|
1388 |
||
1389 |
MessageSwitch()->SendNetLocResponse(iFsm->SessionId(), |
|
1390 |
KErrAccessDenied, |
|
1391 |
dummyQuality, |
|
1392 |
dummyPosInfo, |
|
1393 |
dummyTime, |
|
1394 |
iFsm->IsEmergency()); |
|
1395 |
} |
|
1396 |
||
1397 |
consumed = ETrue; |
|
1398 |
break; |
|
1399 |
} |
|
1400 |
||
1401 |
case TPrivLocStateExitData::EExitCancelledByPrivacyController: |
|
1402 |
{ |
|
1403 |
// Send a cancel to the network gateway |
|
1404 |
iFsm->PrivacyResponse() = TLbsNetworkEnumInt::EPrivacyResponseRejected; |
|
1405 |
iFsm->PrivacyResponseReason() = KErrCancel; |
|
1406 |
MessageSwitch()->SendMTLRResponse(iFsm->SessionId(), iFsm->PrivacyResponse(), iFsm->PrivacyResponseReason(), iFsm->IsEmergency()); |
|
1407 |
consumed = ETrue; |
|
1408 |
} |
|
1409 |
break; |
|
1410 |
||
1411 |
default: |
|
1412 |
{ |
|
1413 |
consumed = CLbsPrivLocStateBase::OnExit(); |
|
1414 |
// If the exit reason wasn't handled, panic (should only happen in development) |
|
1415 |
__ASSERT_DEBUG(consumed, Panic(ENrhPanicWaitPrivRespUnknownExitReason)); |
|
1416 |
break; |
|
1417 |
} |
|
1418 |
} |
|
1419 |
||
1420 |
iFsm->LocReqReceived() = EFalse; |
|
1421 |
||
1422 |
return(consumed); |
|
1423 |
} |
|
1424 |
||
1425 |
// ----------------------------------------------------------------------------- |
|
1426 |
// CLbsPrivLocWaitPrivRespState::OnRespondNetworkLocationRequest |
|
1427 |
// Description: Pass on a received privacy response to the network gateway, if |
|
1428 |
// it relates to the current session. |
|
1429 |
// ----------------------------------------------------------------------------- |
|
1430 |
// |
|
1431 |
void CLbsPrivLocWaitPrivRespState::OnRespondNetworkLocationRequest( |
|
1432 |
const TLbsNetSessionIdInt& aSessionId, |
|
1433 |
TLbsNetworkEnumInt::TLbsPrivacyResponseInt aRequestResult, |
|
1434 |
TInt /* aResponseReason*/) |
|
1435 |
{ |
|
1436 |
||
1437 |
if(aSessionId == iFsm->SessionId()) |
|
1438 |
{ |
|
1439 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitPrivacyResponseReceived, KErrNone); |
|
1440 |
iFsm->PrivacyResponse() = aRequestResult; |
|
1441 |
if(iFsm->PrivacyResponse() == TLbsNetworkEnumInt::EPrivacyResponseAccepted) |
|
1442 |
{ |
|
1443 |
// Tell the AGPS handler that we are going to start a location request soon. |
|
1444 |
AgpsInterface()->PreStartPositioning(iFsm->SessionId(), iFsm->IsEmergency()); |
|
1445 |
||
1446 |
// Set the Positioning Status for the UI indicator. |
|
1447 |
// Not done for silent requests. |
|
1448 |
if (iFsm->ExternalRequestType() < TLbsExternalRequestInfo::ERequestSingleShotSilent) |
|
1449 |
{ |
|
1450 |
IncrementPositioningStatus(); |
|
1451 |
} |
|
1452 |
||
1453 |
if(iFsm->LocReqReceived()) |
|
1454 |
{ |
|
1455 |
TPrivLocWaitLocationUpdateParams updateRequestParams(iFsm->SessionId(), |
|
1456 |
iFsm->PosRequestMethod(), |
|
1457 |
iFsm->SessionType(), |
|
1458 |
iFsm->IsEmergency(), |
|
1459 |
iFsm->NetRequestQuality()); |
|
1460 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateWaitLocationUpdate, updateRequestParams); |
|
1461 |
} |
|
1462 |
else |
|
1463 |
{ |
|
1464 |
TPrivLocWaitLocationRequestParams locationRequestParams(iFsm->SessionId(), |
|
1465 |
iFsm->IsEmergency(), |
|
1466 |
EFalse); |
|
1467 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateWaitLocationRequest, locationRequestParams); |
|
1468 |
} |
|
1469 |
} |
|
1470 |
else |
|
1471 |
{ |
|
1472 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, aSessionId); |
|
1473 |
} |
|
1474 |
} |
|
1475 |
} |
|
1476 |
||
1477 |
// ----------------------------------------------------------------------------- |
|
1478 |
// CLbsPrivLocWaitPrivRespState::OnNetLocRequest |
|
1479 |
// Description: The Message Switch has forwarded a request for a control |
|
1480 |
// measurement. |
|
1481 |
// If the session Id is the same as the current one, then save the parameters |
|
1482 |
// so that the request can be issued when privacy is accepted. |
|
1483 |
// Otherwise (the session Id is different) a cancel is implied and we cancel |
|
1484 |
// the current session and start another, which may or may not require a new |
|
1485 |
// privacy query. |
|
1486 |
// ----------------------------------------------------------------------------- |
|
1487 |
// |
|
1488 |
void CLbsPrivLocWaitPrivRespState::OnNetLocRequest( |
|
1489 |
const TLbsNetSessionIdInt& aSessionId, |
|
1490 |
const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
1491 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
1492 |
TBool aIsEmergency, |
|
1493 |
const TLbsNetPosRequestQualityInt& aQuality) |
|
1494 |
{ |
|
1495 |
TInt numMethods = aPosRequestMethod.NumPosMethods(); |
|
1496 |
if (numMethods==1) |
|
1497 |
{ |
|
1498 |
TLbsNetPosMethodInt netPosMethod; |
|
1499 |
aPosRequestMethod.GetPosMethod(0,netPosMethod); |
|
1500 |
||
1501 |
if (netPosMethod.PosMode()== (TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted)) |
|
1502 |
{ |
|
1503 |
iFsm->TapMode() = ETrue; |
|
1504 |
} |
|
1505 |
} |
|
1506 |
if(aSessionId == iFsm->SessionId() && |
|
1507 |
aIsEmergency == iFsm->IsEmergency() && |
|
1508 |
aSessionType == iFsm->SessionType()) |
|
1509 |
{ |
|
1510 |
iFsm->PosRequestMethod() = aPosRequestMethod; |
|
1511 |
iFsm->NetRequestQuality() = aQuality; |
|
1512 |
iFsm->LocReqReceived() = ETrue; |
|
1513 |
} |
|
1514 |
else |
|
1515 |
{ |
|
1516 |
// It's a request for different session. Need to find out what to do with it. |
|
1517 |
HandleLocRequest(aSessionId,aPosRequestMethod, |
|
1518 |
aSessionType,aIsEmergency, |
|
1519 |
aQuality); |
|
1520 |
} |
|
1521 |
} |
|
1522 |
||
1523 |
||
1524 |
void CLbsPrivLocWaitPrivRespState::OnMTLRRequest(const TLbsNetSessionIdInt& /*aSessionId*/, |
|
1525 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt /*aSessionType*/, |
|
1526 |
TBool /*aIsEmergency*/, |
|
1527 |
const TLbsExternalRequestInfo& /*aExternalRequestInfo*/, |
|
1528 |
const TLbsNetPosRequestPrivacyInt& /*aNetPosRequestPrivacy*/) |
|
1529 |
{ |
|
1530 |
// this can never happen. If the Fsm is in the WaitPrivRespState then |
|
1531 |
// any arrival of a MTLR request would start a new session (no implicit cancel!) |
|
1532 |
// and the OnMTLRRequest()would be directed to that session not this one |
|
1533 |
__ASSERT_DEBUG(EFalse, Panic(ENrhPanicBadParamType)); |
|
1534 |
} |
|
1535 |
||
1536 |
/** Called when a reference position arrives from the network. |
|
1537 |
* |
|
1538 |
*/ |
|
1539 |
void CLbsPrivLocWaitPrivRespState::OnNetLocReferenceUpdate( |
|
1540 |
const TLbsNetSessionIdInt& /*aSessionId*/, |
|
1541 |
const TPositionInfoBase& /*aPosInfo*/) |
|
1542 |
{ |
|
1543 |
// note that the reference postion is stored by the message switch |
|
1544 |
// so here we don't need to save it again! |
|
1545 |
} |
|
1546 |
||
1547 |
||
1548 |
// ----------------------------------------------------------------------------- |
|
1549 |
// |
|
1550 |
// ----------------------- Class CLbsPrivLocWaitLocUpdateState -------------------- |
|
1551 |
// |
|
1552 |
// Implements the Wait For Location Update state of the Privacy and Location |
|
1553 |
// Request Handler |
|
1554 |
// |
|
1555 |
// On entry, issues a location update request then starts a timer and waits for |
|
1556 |
// a response. |
|
1557 |
// |
|
1558 |
// ----------------------------------------------------------------------------- |
|
1559 |
// |
|
1560 |
||
1561 |
// ----------------------------------------------------------------------------- |
|
1562 |
// CLbsPrivLocWaitLocUpdateState::NewL |
|
1563 |
// Description: CLbsPrivLocWaitLocUpdateState static constructor |
|
1564 |
// ----------------------------------------------------------------------------- |
|
1565 |
// |
|
1566 |
CLbsPrivLocWaitLocUpdateState* CLbsPrivLocWaitLocUpdateState::NewL(CLbsPrivLocFsm* aFsm) |
|
1567 |
{ |
|
1568 |
CLbsPrivLocWaitLocUpdateState* self; |
|
1569 |
self = new (ELeave) CLbsPrivLocWaitLocUpdateState(aFsm); |
|
1570 |
CleanupStack::PushL(self); |
|
1571 |
self->ConstructL(); |
|
1572 |
CleanupStack::Pop(self); |
|
1573 |
return(self); |
|
1574 |
} |
|
1575 |
||
1576 |
// ----------------------------------------------------------------------------- |
|
1577 |
// CLbsPrivLocWaitLocUpdateState::CLbsPrivLocWaitLocUpdateState |
|
1578 |
// Description: CLbsPrivLocWaitLocUpdateState constructor. |
|
1579 |
// ----------------------------------------------------------------------------- |
|
1580 |
// |
|
1581 |
CLbsPrivLocWaitLocUpdateState::CLbsPrivLocWaitLocUpdateState(CLbsPrivLocFsm* aFsm) |
|
1582 |
: CLbsPrivLocStateBase(aFsm) |
|
1583 |
{ |
|
1584 |
} |
|
1585 |
||
1586 |
// ----------------------------------------------------------------------------- |
|
1587 |
// CLbsPrivLocWaitLocUpdateState::~CLbsPrivLocWaitLocUpdateState |
|
1588 |
// Description: CLbsPrivLocWaitLocUpdateState destructor. |
|
1589 |
// ----------------------------------------------------------------------------- |
|
1590 |
// |
|
1591 |
CLbsPrivLocWaitLocUpdateState::~CLbsPrivLocWaitLocUpdateState() |
|
1592 |
{ |
|
1593 |
} |
|
1594 |
||
1595 |
// ----------------------------------------------------------------------------- |
|
1596 |
// CLbsPrivLocIdleState::ConstructL |
|
1597 |
// Description: CLbsPrivLocIdleState second-phase constructor. |
|
1598 |
// ----------------------------------------------------------------------------- |
|
1599 |
// |
|
1600 |
void CLbsPrivLocWaitLocUpdateState::ConstructL() |
|
1601 |
{ |
|
1602 |
} |
|
1603 |
||
1604 |
||
1605 |
// ----------------------------------------------------------------------------- |
|
1606 |
// CLbsPrivLocWaitLocUpdateState::OnEntry |
|
1607 |
// Description: Carries out tasks required on entry to the state. |
|
1608 |
// Issues the location update request and starts a timer. |
|
1609 |
// ----------------------------------------------------------------------------- |
|
1610 |
// |
|
1611 |
void CLbsPrivLocWaitLocUpdateState::OnEntry(const TPrivLocCommonParams& aStateParams) |
|
1612 |
{ |
|
1613 |
TInt err(KErrNone); |
|
1614 |
||
1615 |
CLbsPrivLocStateBase::OnEntry(aStateParams); |
|
1616 |
const TPrivLocWaitLocationUpdateParams& params = TPrivLocWaitLocationUpdateParams::Cast(aStateParams); |
|
1617 |
iFsm->IsEmergency() = params.iIsEmergency; |
|
1618 |
iFsm->SessionType() = params.iSessionType; |
|
1619 |
iFsm->PosRequestMethod() = params.iPosRequestMethod; |
|
1620 |
||
1621 |
// If the network has not specified a positioning method, get the default |
|
1622 |
// one from the admin settings. |
|
1623 |
TLbsNetPosMethodInt netReqMethod; |
|
1624 |
iFsm->PosRequestMethod().GetPosMethod(0, netReqMethod); |
|
1625 |
if (iFsm->PosRequestMethod().NumPosMethods() == 1 |
|
1626 |
&& (netReqMethod.PosMode() == TPositionModuleInfo::ETechnologyUnknown)) |
|
1627 |
{ |
|
1628 |
AgpsInterface()->GetDefaultPosMethod(iFsm->PosRequestMethod()); |
|
1629 |
} |
|
1630 |
||
1631 |
// We may use two sources for the required quality for the |
|
1632 |
// new location request, either: |
|
1633 |
// 1) The quality from the network (aQuality) |
|
1634 |
// 2) The quality defined in a quality profile (which profile to |
|
1635 |
// use depends on the service type, e.g. MT-LR or X3P) |
|
1636 |
// |
|
1637 |
// We decide which to use based on the required quality from the network. |
|
1638 |
// Any invalid/unsupplied parameter is read from the quality profile |
|
1639 |
// for the ocation request type. |
|
1640 |
TBool maxFixTimeRequired = params.iQuality.MaxFixTime() == 0; |
|
1641 |
TBool minVerticalAccuracyRequired = |
|
1642 |
Math::IsNaN(params.iQuality.MinVerticalAccuracy()); |
|
1643 |
TBool minHorizontalAccuracyRequired = |
|
1644 |
Math::IsNaN(params.iQuality.MinHorizontalAccuracy()); |
|
1645 |
||
1646 |
if (maxFixTimeRequired || minVerticalAccuracyRequired || minHorizontalAccuracyRequired) |
|
1647 |
{ |
|
1648 |
// Select which LbsAdmin setting to use for the |
|
1649 |
// quality profile Id based on the type of location |
|
1650 |
// request. |
|
1651 |
TLbsAdminSetting adminSetting(KLbsSettingNone); |
|
1652 |
switch (iFsm->SessionType()) |
|
1653 |
{ |
|
1654 |
case TLbsNetworkEnumInt::EServiceMobileTerminated: |
|
1655 |
case TLbsNetworkEnumInt::EServiceNetworkInduced: |
|
1656 |
{ |
|
1657 |
adminSetting = KLbsSettingQualityProfileExternalLocate; |
|
1658 |
break; |
|
1659 |
} |
|
1660 |
case TLbsNetworkEnumInt::EServiceTransmitThirdParty: |
|
1661 |
{ |
|
1662 |
adminSetting = KLbsSettingQualityProfileTransmitLocate; |
|
1663 |
break; |
|
1664 |
} |
|
1665 |
case TLbsNetworkEnumInt::EServiceTriggeredMolr: |
|
1666 |
// SUPL 2.0 "Triggered MOLR" request uses Self Locate Quality Profile |
|
1667 |
case TLbsNetworkEnumInt::EServiceNetworkLocation: |
|
1668 |
// This type of request should only get here in the case of a TA MOLR. Treat as Self-Locate |
|
1669 |
case TLbsNetworkEnumInt::EServiceSelfLocation: |
|
1670 |
{ |
|
1671 |
adminSetting = KLbsSettingQualityProfileSelfLocate; |
|
1672 |
break; |
|
1673 |
} |
|
1674 |
default: |
|
1675 |
{ |
|
1676 |
// We must not fail if it is an emergency request |
|
1677 |
if (!iFsm->IsEmergency()) |
|
1678 |
{ |
|
1679 |
LBSLOG2(ELogP3, |
|
1680 |
"Unable to select quality profile for TLbsNetProtocolService (%d), using quality data from network instead.", |
|
1681 |
iFsm->SessionType()); |
|
1682 |
__ASSERT_DEBUG(EFalse, Panic(ENrhPanicNoQualityProfile)); |
|
1683 |
} |
|
1684 |
else |
|
1685 |
{ |
|
1686 |
adminSetting = KLbsSettingQualityProfileExternalLocate; |
|
1687 |
} |
|
1688 |
} |
|
1689 |
} |
|
1690 |
||
1691 |
// Retrieve the Id of the quality profile to use |
|
1692 |
TLbsQualityProfileId profileId(KLbsNullQualityProfileId); |
|
1693 |
if (adminSetting != KLbsSettingNone) |
|
1694 |
{ |
|
1695 |
LbsAdmin()->Get(adminSetting, profileId); |
|
1696 |
} |
|
1697 |
||
1698 |
// Retrieve the data for the quality profile |
|
1699 |
TQualityProfile qualityProfile; |
|
1700 |
err = LbsQualityProfile::GetQualityProfileById(profileId, qualityProfile); |
|
1701 |
if (err == KErrNone) |
|
1702 |
{ |
|
1703 |
// Use the quality data from the quality profile for any missing/invalid data |
|
1704 |
if(maxFixTimeRequired) |
|
1705 |
{ |
|
1706 |
iFsm->GpsRequestQuality().SetMaxFixTime(qualityProfile.MaxFixTime()); |
|
1707 |
} |
|
1708 |
else |
|
1709 |
{ |
|
1710 |
iFsm->GpsRequestQuality().SetMaxFixTime(params.iQuality.MaxFixTime()); |
|
1711 |
} |
|
1712 |
if(minHorizontalAccuracyRequired) |
|
1713 |
{ |
|
1714 |
iFsm->GpsRequestQuality().SetMinHorizontalAccuracy(qualityProfile.MinHorizontalAccuracy()); |
|
1715 |
} |
|
1716 |
else |
|
1717 |
{ |
|
1718 |
iFsm->GpsRequestQuality().SetMinHorizontalAccuracy(params.iQuality.MinHorizontalAccuracy()); |
|
1719 |
} |
|
1720 |
if(minVerticalAccuracyRequired) |
|
1721 |
{ |
|
1722 |
iFsm->GpsRequestQuality().SetMinVerticalAccuracy(qualityProfile.MinVerticalAccuracy()); |
|
1723 |
} |
|
1724 |
else |
|
1725 |
{ |
|
1726 |
iFsm->GpsRequestQuality().SetMinVerticalAccuracy(params.iQuality.MinVerticalAccuracy()); |
|
1727 |
} |
|
1728 |
} |
|
1729 |
else |
|
1730 |
{ |
|
1731 |
// We should not fail if we are emergency |
|
1732 |
if (!iFsm->IsEmergency()) |
|
1733 |
{ |
|
1734 |
// We couldn't find the quality profile with the given Id. |
|
1735 |
// This is an error, so reject the location request. |
|
1736 |
TPositionInfo dummyPosInfo; |
|
1737 |
TTime dummyTime; |
|
1738 |
TLbsNetPosRequestQualityInt dummyQuality; |
|
1739 |
MessageSwitch()->SendNetLocResponse(iFsm->SessionId(), |
|
1740 |
KErrAccessDenied, |
|
1741 |
dummyQuality, |
|
1742 |
dummyPosInfo, |
|
1743 |
dummyTime, |
|
1744 |
iFsm->IsEmergency()); |
|
1745 |
||
1746 |
// if this location request is the result of a privacy request, |
|
1747 |
// then notify the privacy handler of the error |
|
1748 |
if ((params.iSessionType == TLbsNetworkEnumInt::EServiceMobileTerminated) || |
|
1749 |
(params.iSessionType == TLbsNetworkEnumInt::EServiceNetworkInduced)) |
|
1750 |
{ |
|
1751 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitSessionComplete, KErrAccessDenied); |
|
1752 |
} |
|
1753 |
else |
|
1754 |
{ |
|
1755 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitBadQualityProfile, KErrNone); |
|
1756 |
} |
|
1757 |
||
1758 |
// Whatever the result, this session is finished, so return to idle. |
|
1759 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, iFsm->SessionId()); |
|
1760 |
return; |
|
1761 |
} // if (!iIsEmergency) |
|
1762 |
else |
|
1763 |
{ |
|
1764 |
// Just set some defaults |
|
1765 |
TTimeIntervalMicroSeconds timeout(30000000); |
|
1766 |
iFsm->GpsRequestQuality().SetMinHorizontalAccuracy(50); |
|
1767 |
iFsm->GpsRequestQuality().SetMinVerticalAccuracy(1000); |
|
1768 |
iFsm->GpsRequestQuality().SetMaxFixTime(timeout); |
|
1769 |
} |
|
1770 |
} |
|
1771 |
} |
|
1772 |
else |
|
1773 |
{ |
|
1774 |
// Use the quality parameters supplied with the request. |
|
1775 |
iFsm->GpsRequestQuality().SetMinHorizontalAccuracy(params.iQuality.MinHorizontalAccuracy()); |
|
1776 |
iFsm->GpsRequestQuality().SetMinVerticalAccuracy(params.iQuality.MinVerticalAccuracy()); |
|
1777 |
iFsm->GpsRequestQuality().SetMaxFixTime(params.iQuality.MaxFixTime()); |
|
1778 |
} |
|
1779 |
||
1780 |
||
1781 |
// Check for any existing position updates in case they meet the |
|
1782 |
// MaxFixAge and quality requirements for this request. |
|
1783 |
TInt updateReason; |
|
1784 |
err = AgpsInterface()->GetPosition(updateReason, |
|
1785 |
iFsm->GpsPosition(), |
|
1786 |
iFsm->ActualTime()); |
|
1787 |
if (err == KErrNone) |
|
1788 |
{ |
|
1789 |
TPrivLocWaitLocationRequestParams locationRequestParams(iFsm->SessionId(), |
|
1790 |
iFsm->IsEmergency(), |
|
1791 |
EFalse, |
|
1792 |
updateReason); |
|
1793 |
||
1794 |
// Check the existing update in case it meets the MaxFixAge and quality requirements for this request. |
|
1795 |
if (params.iQuality.MaxFixAge() > 0) |
|
1796 |
{ |
|
1797 |
TTime now; |
|
1798 |
now.UniversalTime(); |
|
1799 |
TTimeIntervalMicroSeconds age(Max((now.Int64() - iFsm->ActualTime().Int64()), TInt64(0))); |
|
1800 |
if (updateReason == KErrNone |
|
1801 |
&& (age <= params.iQuality.MaxFixAge()) |
|
1802 |
&& ReceivedFixIsAccurate()) |
|
1803 |
{ |
|
1804 |
// Accurate update that is within the MaxFixAge time limit, |
|
1805 |
// so return it straight away. |
|
1806 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitLocFixReceived, updateReason); |
|
1807 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateWaitLocationRequest, locationRequestParams); |
|
1808 |
return; |
|
1809 |
} |
|
1810 |
} |
|
1811 |
||
1812 |
||
1813 |
// Special feature behaviour! |
|
1814 |
// If the admin setting KLbsSpecialFeatureIntermediateFutileUpdate is on, |
|
1815 |
// it means that we should check to see if a futile update has happened |
|
1816 |
// since the first location request of this session. This might happen |
|
1817 |
// in a hybrid session, if the GPS module sends a futile update when there |
|
1818 |
// is no outstanding location request in the NRH. E.g. in the gap between |
|
1819 |
// sending the response for one hybrid loc request and getting the next |
|
1820 |
// loc request from the network. |
|
1821 |
// |
|
1822 |
// Note: This only really applies to hybrid of TA position modes, because |
|
1823 |
// in TB or autonomous you only have one location request per |
|
1824 |
// session. |
|
1825 |
else if (iFsm->IsSpecialFeatureIntermediateFutileUpdateOn()) |
|
1826 |
{ |
|
1827 |
// If this is the first request for a new sessionId, record the current session id. |
|
1828 |
// We need to know this for terminal assisted or hybrid requests, in case |
|
1829 |
// we need to check for a futile update that has happened in the gap between |
|
1830 |
// one location response and the next location update request. |
|
1831 |
if (iFsm->LastLocReqSessionId() != iFsm->SessionId()) |
|
1832 |
{ |
|
1833 |
iFsm->LastLocReqSessionId() = iFsm->SessionId(); |
|
1834 |
} |
|
1835 |
else |
|
1836 |
{ |
|
1837 |
// Before sending the location request, see if a futile update has |
|
1838 |
// happened since the start of the session (in general only terminal-assisted |
|
1839 |
// and hybrid requests should have more than one location request |
|
1840 |
// per session, however the SUPL PM will have more than one for all request modes). |
|
1841 |
TGpsRequestMode gpsMode = AgpsInterface()->ConvertPosMethodToGpsRequestMode(iFsm->PosRequestMethod()); |
|
1842 |
if ((updateReason == KPositionCalculationFutile) && |
|
1843 |
((gpsMode == EGpsRequestModeTerminalAssisted) || (gpsMode == EGpsRequestModeHybrid))) |
|
1844 |
{ |
|
1845 |
// Return last measurement straight away. |
|
1846 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitLocMeasurementResultsReceived, updateReason); |
|
1847 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateWaitLocationRequest, locationRequestParams); |
|
1848 |
return; |
|
1849 |
} |
|
1850 |
} |
|
1851 |
} |
|
1852 |
} |
|
1853 |
||
1854 |
||
1855 |
// Issue the request and supply pointers to the data to be updated |
|
1856 |
iFsm->LocationFixReceived() = EFalse; |
|
1857 |
iFsm->MeasurementInfoReceived() = EFalse; |
|
1858 |
err = AgpsInterface()->StartPositioning(iFsm->SessionId(), |
|
1859 |
iFsm->PosRequestMethod(), |
|
1860 |
iFsm->GpsRequestQuality(), |
|
1861 |
iFsm->IsEmergency()); |
|
1862 |
if (KErrNone == err) |
|
1863 |
{ |
|
1864 |
iFsm->LocationUpdateTimer().EventAfter(iFsm->GpsRequestQuality().MaxFixTime(), 1); |
|
1865 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitReasonNone, KErrNone); |
|
1866 |
} |
|
1867 |
else |
|
1868 |
{ |
|
1869 |
// Error sending the location request, send a location response |
|
1870 |
// with the error and go to Idle state. |
|
1871 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitBadLocationRequest, err); |
|
1872 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, iFsm->SessionId()); |
|
1873 |
} |
|
1874 |
} |
|
1875 |
||
1876 |
// ----------------------------------------------------------------------------- |
|
1877 |
// CLbsPrivLocWaitLocUpdateState::OnExit |
|
1878 |
// Description: Carries out tasks required on exit from the state. |
|
1879 |
// Cancels the location update request and stops the timer. |
|
1880 |
// ----------------------------------------------------------------------------- |
|
1881 |
// |
|
1882 |
TBool CLbsPrivLocWaitLocUpdateState::OnExit() |
|
1883 |
{ |
|
1884 |
// Cancel the update timer. |
|
1885 |
iFsm->LocationUpdateTimer().Cancel(); |
|
1886 |
||
1887 |
TInt consumed = EFalse; |
|
1888 |
switch(iFsm->ExitData().iExitReason) |
|
1889 |
{ |
|
1890 |
case TPrivLocStateExitData::EExitLocFixReceived: |
|
1891 |
{ |
|
1892 |
// Don't cancel the location request yet, but tell the AGPS interface |
|
1893 |
// handler to put it on 'hold'. If we are in a hybrid or terminal-assisted |
|
1894 |
// request then we are going to get another location request very shortly |
|
1895 |
// anyway... |
|
1896 |
AgpsInterface()->HoldPositioning(iFsm->SessionId(), KErrNone); |
|
1897 |
||
1898 |
// Report the position to the message switch |
|
1899 |
MessageSwitch()->SendNetLocResponse(iFsm->SessionId(), |
|
1900 |
iFsm->ExitData().iExitInfo, |
|
1901 |
iFsm->GpsRequestQuality(), |
|
1902 |
iFsm->GpsPosition(), |
|
1903 |
iFsm->ActualTime(), |
|
1904 |
iFsm->IsEmergency()); |
|
1905 |
||
1906 |
// For MTLR pass the data to the privacy handler |
|
1907 |
// in case the Privacy Controller wants it. |
|
1908 |
if ((iFsm->ExitData().iExitInfo >= KErrNone) && |
|
1909 |
(iFsm->ExitData().iExitInfo != KPositionCalculationFutile) && |
|
1910 |
((iFsm->SessionType() == TLbsNetworkEnumInt::EServiceMobileTerminated) || |
|
1911 |
(iFsm->SessionType() == TLbsNetworkEnumInt::EServiceNetworkInduced))) |
|
1912 |
{ |
|
1913 |
PrivacyHandler()->ProcessNetworkPositionUpdate(iFsm->SessionId(), |
|
1914 |
iFsm->GpsPosition()); |
|
1915 |
} |
|
1916 |
||
1917 |
consumed = ETrue; |
|
1918 |
break; |
|
1919 |
} |
|
1920 |
||
1921 |
case TPrivLocStateExitData::EExitLocMeasurementResultsReceived: |
|
1922 |
{ |
|
1923 |
// Don't cancel the location request yet, but tell the AGPS interface |
|
1924 |
// handler to put it on 'hold'. If we are in a hybrid or terminal-assisted |
|
1925 |
// request then we are going to get another location request very shortly |
|
1926 |
// anyway... |
|
1927 |
AgpsInterface()->HoldPositioning(iFsm->SessionId(), KErrNone); |
|
1928 |
||
1929 |
// Report the measurement data to the message switch, even if we |
|
1930 |
// didn't get any. The error code will indicate that the data |
|
1931 |
// is rubbish in that case. |
|
1932 |
LBSLOG2(ELogP3, "CLbsPrivLocWaitLocUpdateState:returning with reason %d", iFsm->MeasurementInfoError()); |
|
1933 |
||
1934 |
MessageSwitch()->SendNetLocResponse(iFsm->SessionId(), |
|
1935 |
iFsm->ExitData().iExitInfo, |
|
1936 |
iFsm->GpsRequestQuality(), |
|
1937 |
iFsm->GpsMeasurementInfo(), |
|
1938 |
iFsm->ActualTime(), |
|
1939 |
iFsm->IsEmergency()); |
|
1940 |
break; |
|
1941 |
} |
|
1942 |
||
1943 |
case TPrivLocStateExitData::EExitTimedOut: |
|
1944 |
{ |
|
1945 |
// Don't cancel the location request yet, but tell the AGPS interface |
|
1946 |
// handler to put it on 'hold'. If we are in a hybrid or terminal-assisted |
|
1947 |
// request then we are going to get another location request very shortly |
|
1948 |
// anyway... |
|
1949 |
AgpsInterface()->HoldPositioning(iFsm->SessionId(), KErrNone); |
|
1950 |
||
1951 |
// If the request has timed out, then return whatever position |
|
1952 |
// data we have, but make it clear it's not what was requested. |
|
1953 |
// If there's an error (probably KErrTimedOut) there's |
|
1954 |
// nothing to report, so send dummy data with the error. |
|
1955 |
MessageSwitch()->SendNetLocResponse(iFsm->SessionId(), |
|
1956 |
iFsm->ExitData().iExitInfo, |
|
1957 |
iFsm->GpsRequestQuality(), |
|
1958 |
iFsm->GpsPosition(), |
|
1959 |
iFsm->ActualTime(), |
|
1960 |
iFsm->IsEmergency()); |
|
1961 |
||
1962 |
// For MTLR, pass the data to the privacy handler in case the Privacy |
|
1963 |
// Controller wants it. |
|
1964 |
// NB Don't send the update if the error is KErrTimedOut, as that means there's |
|
1965 |
// nothing to report. |
|
1966 |
if((iFsm->SessionType() == TLbsNetworkEnumInt::EServiceMobileTerminated) && |
|
1967 |
(iFsm->ExitData().iExitInfo == KPositionQualityLoss)) |
|
1968 |
{ |
|
1969 |
PrivacyHandler()->ProcessNetworkPositionUpdate(iFsm->SessionId(), |
|
1970 |
iFsm->GpsPosition()); |
|
1971 |
} |
|
1972 |
||
1973 |
consumed = ETrue; |
|
1974 |
break; |
|
1975 |
} |
|
1976 |
||
1977 |
case TPrivLocStateExitData::EExitCancelledByPrivacyController: |
|
1978 |
{ |
|
1979 |
// Stop the location request immediately. |
|
1980 |
AgpsInterface()->StopPositioning(iFsm->SessionId()); |
|
1981 |
||
1982 |
// Send a SendExternalLocateCancel to NetGateWay- if the protcol module does not support this then |
|
1983 |
// the Gateway will do nothing |
|
1984 |
MessageSwitch()->SendExternalLocateCancel(iFsm->SessionId(), KErrCancel); |
|
1985 |
||
1986 |
// Send a location response with 'cancel' set to the network |
|
1987 |
TPositionInfo dummyPosInfo; |
|
1988 |
TTime dummyTime; |
|
1989 |
TLbsNetPosRequestQualityInt dummyQuality; |
|
1990 |
MessageSwitch()->SendNetLocResponse(iFsm->SessionId(), |
|
1991 |
iFsm->ExitData().iExitInfo, |
|
1992 |
dummyQuality, |
|
1993 |
dummyPosInfo, |
|
1994 |
dummyTime, |
|
1995 |
iFsm->IsEmergency()); |
|
1996 |
||
1997 |
consumed = ETrue; |
|
1998 |
} |
|
1999 |
break; |
|
2000 |
||
2001 |
case TPrivLocStateExitData::EExitBadQualityProfile: |
|
2002 |
{ |
|
2003 |
// Do nothing; we're just going back to Idle state |
|
2004 |
consumed = ETrue; |
|
2005 |
break; |
|
2006 |
} |
|
2007 |
||
2008 |
case TPrivLocStateExitData::EExitBadLocationRequest: |
|
2009 |
{ |
|
2010 |
// Error processing the location request - |
|
2011 |
// send a dummy response with an error code. |
|
2012 |
TPositionInfo dummyPosInfo; |
|
2013 |
TTime dummyTime; |
|
2014 |
TLbsNetPosRequestQualityInt dummyQuality; |
|
2015 |
MessageSwitch()->SendNetLocResponse(iFsm->SessionId(), |
|
2016 |
iFsm->ExitData().iExitInfo, |
|
2017 |
dummyQuality, |
|
2018 |
dummyPosInfo, |
|
2019 |
dummyTime, |
|
2020 |
iFsm->IsEmergency()); |
|
2021 |
||
2022 |
consumed = ETrue; |
|
2023 |
break; |
|
2024 |
} |
|
2025 |
||
2026 |
default: |
|
2027 |
{ |
|
2028 |
consumed = CLbsPrivLocStateBase::OnExit(); |
|
2029 |
// If the exit reason wasn't handled, panic (should only happen in development) |
|
2030 |
__ASSERT_DEBUG(consumed, Panic(ENrhPanicWaitLocUpdateUnknownExitReason)); |
|
2031 |
} |
|
2032 |
} |
|
2033 |
return(consumed); |
|
2034 |
} |
|
2035 |
||
2036 |
// ----------------------------------------------------------------------------- |
|
2037 |
// CLbsPrivLocIdleState::OnNetLocRequest |
|
2038 |
// Description: The Message Switch has forwarded a request for a network |
|
2039 |
// location. |
|
2040 |
// ----------------------------------------------------------------------------- |
|
2041 |
// |
|
2042 |
void CLbsPrivLocWaitLocUpdateState::OnNetLocRequest(const TLbsNetSessionIdInt& aSessionId, |
|
2043 |
const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
2044 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
2045 |
TBool aIsEmergency, |
|
2046 |
const TLbsNetPosRequestQualityInt& aQuality) |
|
2047 |
{ |
|
2048 |
TInt numMethods = aPosRequestMethod.NumPosMethods(); |
|
2049 |
if (numMethods==1) |
|
2050 |
{ |
|
2051 |
TLbsNetPosMethodInt netPosMethod; |
|
2052 |
aPosRequestMethod.GetPosMethod(0,netPosMethod); |
|
2053 |
||
2054 |
if (netPosMethod.PosMode()== (TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted)) |
|
2055 |
{ |
|
2056 |
iFsm->TapMode() = ETrue; |
|
2057 |
} |
|
2058 |
} |
|
2059 |
if(aSessionId != iFsm->SessionId()) |
|
2060 |
{ |
|
2061 |
/* This request is for a different session. Cancel the current one |
|
2062 |
* and start a new one. |
|
2063 |
*/ |
|
2064 |
HandleLocRequest(aSessionId,aPosRequestMethod, |
|
2065 |
aSessionType,aIsEmergency, |
|
2066 |
aQuality); |
|
2067 |
} |
|
2068 |
else |
|
2069 |
{ |
|
2070 |
LBSLOG(ELogP3, "CLbsPrivLocWaitLocUpdateState::OnNetLocRequest: Matching SessionId."); |
|
2071 |
TPrivLocWaitLocationUpdateParams updateRequestParams(aSessionId, |
|
2072 |
aPosRequestMethod, |
|
2073 |
aSessionType, |
|
2074 |
aIsEmergency, |
|
2075 |
aQuality); |
|
2076 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitLocReqReceived, KErrNone); |
|
2077 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateWaitLocationUpdate, updateRequestParams); |
|
2078 |
} |
|
2079 |
} |
|
2080 |
||
2081 |
||
2082 |
void CLbsPrivLocWaitLocUpdateState::OnMTLRRequest(const TLbsNetSessionIdInt& /*aSessionId*/, |
|
2083 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt /*aSessionType*/, |
|
2084 |
TBool /*aIsEmergency*/, |
|
2085 |
const TLbsExternalRequestInfo& /*aExternalRequestInfo*/, |
|
2086 |
const TLbsNetPosRequestPrivacyInt& /*aNetPosRequestPrivacy*/) |
|
2087 |
{ |
|
2088 |
// this can never happen. If the Fsm is in the WaitLocUpdateState then |
|
2089 |
// any arrival of a MTLR request would start a new session and not |
|
2090 |
// implicitly cancel the ongoing MTLR and the OnMTLRRequest() |
|
2091 |
// would be directed to that session not this one |
|
2092 |
||
2093 |
} |
|
2094 |
||
2095 |
// ----------------------------------------------------------------------------- |
|
2096 |
// CLbsPrivLocWaitLocUpdateState::OnTimerEventL |
|
2097 |
// Description: The Location Update timer has expired. |
|
2098 |
// Cancel the request, and pass on the response if any has been received, |
|
2099 |
// otherwise report failure. |
|
2100 |
// ----------------------------------------------------------------------------- |
|
2101 |
// |
|
2102 |
void CLbsPrivLocWaitLocUpdateState::OnTimerEventL(TInt /*aTimerId*/) |
|
2103 |
{ |
|
2104 |
LBSLOG(ELogP3, "CLbsPrivLocWaitLocUpdateState::OnTimerEventL"); |
|
2105 |
||
2106 |
if(iFsm->MeasurementInfoReceived()) |
|
2107 |
{ |
|
2108 |
// A position fix may have been received, but it can't be accurate enough |
|
2109 |
// (otherwise the request would have been completed before timeout), so |
|
2110 |
// return the most recent measurement info |
|
2111 |
LBSLOG(ELogP3, "OnTimerEventL, measurement data received"); |
|
2112 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitLocMeasurementResultsReceived, |
|
2113 |
iFsm->MeasurementInfoError()); |
|
2114 |
} |
|
2115 |
else if(iFsm->LocationFixReceived()) |
|
2116 |
{ |
|
2117 |
// position received, but not accurate enough (or request would already have been completed) |
|
2118 |
LBSLOG(ELogP3, "OnTimerEventL, inaccurate location data received"); |
|
2119 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitTimedOut, |
|
2120 |
KPositionQualityLoss); |
|
2121 |
} |
|
2122 |
else |
|
2123 |
{ |
|
2124 |
// we've received no update (position / measurements) |
|
2125 |
LBSLOG(ELogP3, "OnTimerEventL, NO measurement data received"); |
|
2126 |
LBSLOG(ELogP3, "(Setting exit info KErrPositionNoGpsUpdate"); |
|
2127 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitTimedOut, |
|
2128 |
KErrPositionNoGpsUpdate); |
|
2129 |
} |
|
2130 |
||
2131 |
SetExitState(); |
|
2132 |
} |
|
2133 |
||
2134 |
// ----------------------------------------------------------------------------- |
|
2135 |
// CLbsPrivLocWaitLocUpdateState::SetExitState |
|
2136 |
// Description: Works out the next state on the basis of the current session |
|
2137 |
// type and whether any update has been received. |
|
2138 |
// ----------------------------------------------------------------------------- |
|
2139 |
// |
|
2140 |
void CLbsPrivLocWaitLocUpdateState::SetExitState() |
|
2141 |
{ |
|
2142 |
TPrivLocWaitLocationRequestParams locationRequestParams(iFsm->SessionId(), |
|
2143 |
iFsm->IsEmergency(), |
|
2144 |
EFalse, |
|
2145 |
iFsm->ExitData().iExitInfo); |
|
2146 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateWaitLocationRequest, |
|
2147 |
locationRequestParams); |
|
2148 |
} |
|
2149 |
||
2150 |
TBool CLbsPrivLocWaitLocUpdateState::ReceivedFixIsAccurate() |
|
2151 |
{ |
|
2152 |
TBool fixIsAccurate = EFalse; |
|
2153 |
||
2154 |
// Compare the accuracy to the request values. |
|
2155 |
// Make sure the location update is (A)GPS and not Network based. |
|
2156 |
TPosition latestPosition; |
|
2157 |
iFsm->GpsPosition().GetPosition(latestPosition); |
|
2158 |
||
2159 |
if ((latestPosition.HorizontalAccuracy() <= iFsm->GpsRequestQuality().MinHorizontalAccuracy()) && |
|
2160 |
(latestPosition.VerticalAccuracy() <= iFsm->GpsRequestQuality().MinVerticalAccuracy()) && |
|
2161 |
(iFsm->GpsPosition().PositionMode() != TPositionModuleInfo::ETechnologyNetwork))//Pure Reference Location |
|
2162 |
{ |
|
2163 |
fixIsAccurate = ETrue; |
|
2164 |
} |
|
2165 |
||
2166 |
return(fixIsAccurate); |
|
2167 |
} |
|
2168 |
||
2169 |
/** Callback when a GPS position update arrives from AGPS manager. |
|
2170 |
*/ |
|
2171 |
void CLbsPrivLocWaitLocUpdateState::OnAgpsPositionUpdate( |
|
2172 |
TInt aReason, |
|
2173 |
const TPositionExtendedSatelliteInfo& aPosInfo, |
|
2174 |
const TTime& aTimeStamp) |
|
2175 |
{ |
|
2176 |
iFsm->GpsPosition() = aPosInfo; |
|
2177 |
iFsm->ActualTime() = aTimeStamp; |
|
2178 |
iFsm->LocationFixReceived() = ETrue; |
|
2179 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitLocFixReceived, aReason); |
|
2180 |
||
2181 |
if (KErrNone == aReason) |
|
2182 |
{ |
|
2183 |
if (iFsm->TapMode()) |
|
2184 |
{ |
|
2185 |
LBSLOG(ELogP1,"TAP mode) - NOT sending position to network"); |
|
2186 |
return; // do NOT return AGPS postions to TAP mode sessions |
|
2187 |
} |
|
2188 |
// See if the reported accuracy matches the specified quality. |
|
2189 |
// If the accuracy is good enough, report the position |
|
2190 |
||
2191 |
// if this session is TAP then discard the position |
|
2192 |
||
2193 |
if(ReceivedFixIsAccurate()) |
|
2194 |
{ |
|
2195 |
SetExitState(); |
|
2196 |
} |
|
2197 |
} |
|
2198 |
else if ((aReason <= KErrNone) || (KPositionCalculationFutile == aReason)) |
|
2199 |
{ |
|
2200 |
// GPS Manager can't provide a location update. return what we do have. |
|
2201 |
if(iFsm->MeasurementInfoReceived()) |
|
2202 |
{ |
|
2203 |
LBSLOG(ELogP1,"CLbsPrivLocWaitLocUpdateState::OnPositionUpdate() - measurement received"); |
|
2204 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitLocMeasurementResultsReceived, aReason); |
|
2205 |
} |
|
2206 |
else |
|
2207 |
{ |
|
2208 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitLocFixReceived, aReason); |
|
2209 |
} |
|
2210 |
SetExitState(); |
|
2211 |
} |
|
2212 |
else if (KPositionEarlyComplete == aReason) |
|
2213 |
{ |
|
2214 |
// Not an error. Report back what was accepted. |
|
2215 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitLocFixReceived, KErrNone); |
|
2216 |
SetExitState(); |
|
2217 |
} |
|
2218 |
else |
|
2219 |
{ |
|
2220 |
// A real error |
|
2221 |
SetExitState(); |
|
2222 |
} |
|
2223 |
} |
|
2224 |
||
2225 |
/** Callback when a GPS measurement results update arrives from AGPS manager. |
|
2226 |
||
2227 |
Only location requests that are 'hybrid' or 'terminal assisted' should record |
|
2228 |
the measurement results. Other types of request (autonomous, terminal based) |
|
2229 |
are only interested in the GPS position update. |
|
2230 |
*/ |
|
2231 |
void CLbsPrivLocWaitLocUpdateState::OnAgpsMeasurementUpdate( |
|
2232 |
TInt aReason, |
|
2233 |
const TPositionGpsMeasurementInfo& aPosInfo, |
|
2234 |
const TTime& /*aTimeStamp*/) |
|
2235 |
{ |
|
2236 |
// Check that we should be listening for measurement updates. |
|
2237 |
||
2238 |
TBool positionCalculationPossible = aPosInfo.PositionCalculationPossible(); |
|
2239 |
||
2240 |
const TInt methodCount = iFsm->PosRequestMethod().NumPosMethods(); |
|
2241 |
for(TInt i = 0; i < methodCount; ++i) |
|
2242 |
{ |
|
2243 |
TLbsNetPosMethodInt posMethod; |
|
2244 |
iFsm->PosRequestMethod().GetPosMethod(i, posMethod); |
|
2245 |
if((posMethod.PosMode() & KTerminalAssistedMode) == KTerminalAssistedMode) |
|
2246 |
{ |
|
2247 |
iFsm->MeasurementInfoReceived() = ETrue; |
|
2248 |
iFsm->MeasurementInfoError() = aReason; |
|
2249 |
iFsm->GpsMeasurementInfo() = aPosInfo; |
|
2250 |
||
2251 |
// don't wait until alpha2 time expires, instead |
|
2252 |
// return measuremnts now |
|
2253 |
if (positionCalculationPossible) |
|
2254 |
{ |
|
2255 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitLocMeasurementResultsReceived, |
|
2256 |
iFsm->MeasurementInfoError()); |
|
2257 |
SetExitState(); |
|
2258 |
} |
|
2259 |
break; |
|
2260 |
} |
|
2261 |
} |
|
2262 |
} |
|
2263 |
||
2264 |
/** Callback when a GPS measurement results update arrives from AGPS manager. |
|
2265 |
||
2266 |
Only location requests that are 'hybrid' or 'terminal assisted' should record |
|
2267 |
the measurement results. Other types of request (autonomous, terminal based) |
|
2268 |
are only interested in the GPS position update. |
|
2269 |
*/ |
|
2270 |
void CLbsPrivLocWaitLocUpdateState::OnNetLocReferenceUpdate( |
|
2271 |
const TLbsNetSessionIdInt& aSessionId, |
|
2272 |
const TPositionInfoBase& aPosInfo) |
|
2273 |
{ |
|
2274 |
CLbsPrivLocStateBase::OnNetLocReferenceUpdate(aSessionId,aPosInfo); |
|
2275 |
} |
|
2276 |
||
2277 |
||
2278 |
// ----------------------------------------------------------------------------- |
|
2279 |
// |
|
2280 |
// ----------------------- Class CLbsPrivLocWaitLocReqState -------------------- |
|
2281 |
// |
|
2282 |
// Implements the Wait For Location Request state of the Privacy and Location |
|
2283 |
// Request Handler |
|
2284 |
// |
|
2285 |
// ----------------------------------------------------------------------------- |
|
2286 |
// |
|
2287 |
CLbsPrivLocWaitLocReqState* CLbsPrivLocWaitLocReqState::NewL(CLbsPrivLocFsm* aFsm) |
|
2288 |
{ |
|
2289 |
return new(ELeave)CLbsPrivLocWaitLocReqState(aFsm); |
|
2290 |
} |
|
2291 |
||
2292 |
CLbsPrivLocWaitLocReqState::CLbsPrivLocWaitLocReqState(CLbsPrivLocFsm* aFsm) |
|
2293 |
: CLbsPrivLocStateBase(aFsm) |
|
2294 |
{ |
|
2295 |
} |
|
2296 |
||
2297 |
// ----------------------------------------------------------------------------- |
|
2298 |
// CLbsPrivLocWaitLocReqState::OnEntry |
|
2299 |
// Description: Carries out tasks required on entry to the state. |
|
2300 |
// ----------------------------------------------------------------------------- |
|
2301 |
// |
|
2302 |
void CLbsPrivLocWaitLocReqState::OnEntry(const TPrivLocCommonParams& aStateParams) |
|
2303 |
{ |
|
2304 |
CLbsPrivLocStateBase::OnEntry(aStateParams); |
|
2305 |
const TPrivLocWaitLocationRequestParams& params = TPrivLocWaitLocationRequestParams::Cast(aStateParams); |
|
2306 |
iFsm->IsEmergency() = params.iIsEmergency; |
|
2307 |
iFsm->PrivacyRequestCancelled() = params.iReqCancelled; |
|
2308 |
iFsm->PreviousStateExitInfo() = params.iPreviousStateExitInfo; |
|
2309 |
} |
|
2310 |
||
2311 |
||
2312 |
// ----------------------------------------------------------------------------- |
|
2313 |
// CLbsPrivLocWaitLocReqState::OnExit |
|
2314 |
// Description: Carries out tasks required on exit from the state. |
|
2315 |
// Panics if the exit reason is not handled by the base state exit |
|
2316 |
// ----------------------------------------------------------------------------- |
|
2317 |
// |
|
2318 |
TBool CLbsPrivLocWaitLocReqState::OnExit() |
|
2319 |
{ |
|
2320 |
TBool consumed = CLbsPrivLocStateBase::OnExit(); |
|
2321 |
// If the exit reason wasn't handled, panic (should only happen in development) |
|
2322 |
__ASSERT_DEBUG(consumed, Panic(ENrhPanicWaitLocReqUnknownExitReason)); |
|
2323 |
return(consumed); |
|
2324 |
} |
|
2325 |
||
2326 |
void CLbsPrivLocWaitLocReqState::OnMTLRRequest(const TLbsNetSessionIdInt& /*aSessionId*/, |
|
2327 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt /*aSessionType*/, |
|
2328 |
TBool /*aIsEmergency*/, |
|
2329 |
const TLbsExternalRequestInfo& /*aExternalRequestInfo*/, |
|
2330 |
const TLbsNetPosRequestPrivacyInt& /*aNetPosRequestPrivacy*/) |
|
2331 |
{ |
|
2332 |
// this can never happen. If the Fsm is in the WaitLocReqState then |
|
2333 |
// any arrival of a MTLR request would start a new session and the OnMTLRRequest() |
|
2334 |
// would be directed to that session not this one |
|
2335 |
__ASSERT_DEBUG(EFalse, Panic(ENrhPanicBadParamType)); |
|
2336 |
} |
|
2337 |
||
2338 |
void CLbsPrivLocWaitLocReqState::OnNetLocRequest(const TLbsNetSessionIdInt& aSessionId, |
|
2339 |
const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
2340 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
2341 |
TBool aIsEmergency, |
|
2342 |
const TLbsNetPosRequestQualityInt& aQuality) |
|
2343 |
{ |
|
2344 |
TInt numMethods = aPosRequestMethod.NumPosMethods(); |
|
2345 |
if (numMethods==1) |
|
2346 |
{ |
|
2347 |
TLbsNetPosMethodInt netPosMethod; |
|
2348 |
aPosRequestMethod.GetPosMethod(0,netPosMethod); |
|
2349 |
||
2350 |
if (netPosMethod.PosMode()== (TPositionModuleInfo::ETechnologyNetwork | TPositionModuleInfo::ETechnologyAssisted)) |
|
2351 |
{ |
|
2352 |
iFsm->TapMode() = ETrue; |
|
2353 |
} |
|
2354 |
} |
|
2355 |
||
2356 |
||
2357 |
if(aSessionId == iFsm->SessionId()) |
|
2358 |
{ |
|
2359 |
if (iFsm->PrivacyRequestCancelled()) |
|
2360 |
{ |
|
2361 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitCancelledByPrivacyController, KErrCancel); |
|
2362 |
TPrivLocWaitLocationRequestParams locationRequestParams(iFsm->SessionId(), |
|
2363 |
iFsm->IsEmergency(), |
|
2364 |
iFsm->PrivacyRequestCancelled()); |
|
2365 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateWaitLocationRequest, locationRequestParams); |
|
2366 |
} |
|
2367 |
else |
|
2368 |
{ |
|
2369 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitLocReqReceived, KErrNone); |
|
2370 |
TPrivLocWaitLocationUpdateParams updateRequestParams(aSessionId, |
|
2371 |
aPosRequestMethod, |
|
2372 |
aSessionType, |
|
2373 |
aIsEmergency, |
|
2374 |
aQuality); |
|
2375 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateWaitLocationUpdate, updateRequestParams); |
|
2376 |
} |
|
2377 |
} |
|
2378 |
else |
|
2379 |
{ |
|
2380 |
HandleLocRequest(aSessionId,aPosRequestMethod, |
|
2381 |
aSessionType,aIsEmergency, |
|
2382 |
aQuality); |
|
2383 |
} |
|
2384 |
} |
|
2385 |
||
2386 |
void CLbsPrivLocWaitLocReqState::OnCancelNetworkLocationRequest(const TLbsNetSessionIdInt& aSessionId) |
|
2387 |
{ |
|
2388 |
if (!iFsm->IsEmergency() && (aSessionId == iFsm->SessionId())) |
|
2389 |
{ |
|
2390 |
if (!iFsm->PrivacyRequestCancelled() ) |
|
2391 |
{ |
|
2392 |
TLbsNetSessionIdInt sessionId = iFsm->SessionId(); |
|
2393 |
MessageSwitch()->SendExternalLocateCancel(sessionId,KErrCancel); |
|
2394 |
} |
|
2395 |
iFsm->PrivacyRequestCancelled() = ETrue; |
|
2396 |
} |
|
2397 |
} |
|
2398 |
||
2399 |
||
2400 |
/** Called when a reference position arrives from the network. |
|
2401 |
*/ |
|
2402 |
void CLbsPrivLocWaitLocReqState::OnNetLocReferenceUpdate( |
|
2403 |
const TLbsNetSessionIdInt& aSessionId, |
|
2404 |
const TPositionInfoBase& aPosInfo) |
|
2405 |
{ |
|
2406 |
// if the MTLR is still active (has not been cancelled by the privacy handler) |
|
2407 |
if (!iFsm->PrivacyRequestCancelled()) |
|
2408 |
{ |
|
2409 |
CLbsPrivLocStateBase::OnNetLocReferenceUpdate(aSessionId, aPosInfo); |
|
2410 |
} |
|
2411 |
} |
|
2412 |
||
2413 |
// ----------------------------------------------------------------------------- |
|
2414 |
// CLbsPrivLocWaitLocReqState::OnSessionComplete |
|
2415 |
// Description: handling of a session complete message |
|
2416 |
// ----------------------------------------------------------------------------- |
|
2417 |
// |
|
2418 |
void CLbsPrivLocWaitLocReqState::OnSessionComplete(const TLbsNetSessionIdInt& aSessionId, |
|
2419 |
TInt aReason) |
|
2420 |
{ |
|
2421 |
||
2422 |
||
2423 |
if(aSessionId == iFsm->SessionId()) |
|
2424 |
{ |
|
2425 |
// Make sure the reason passed with the Session Complete is sent to the |
|
2426 |
// Privacy Controller EXCEPT when the update previously passed to the |
|
2427 |
// network didn't meet the quality criteria. In this case use the |
|
2428 |
// KPositionQualityLoss status. |
|
2429 |
TInt completionReason = aReason; |
|
2430 |
if(aReason == KErrNone) |
|
2431 |
{ |
|
2432 |
if(KPositionQualityLoss == iFsm->PreviousStateExitInfo()) |
|
2433 |
{ |
|
2434 |
completionReason = KPositionQualityLoss; |
|
2435 |
} |
|
2436 |
} |
|
2437 |
||
2438 |
iFsm->ExitData().SetExitData(TPrivLocStateExitData::EExitSessionComplete, completionReason); |
|
2439 |
iFsm->ChangeState(CLbsPrivLocFsm::EStateIdle, aSessionId); |
|
2440 |
} |
|
2441 |
} |
|
2442 |
||
2443 |
// ----------------------------------------------------------------------------- |
|
2444 |
// |
|
2445 |
// Package classes |
|
2446 |
// |
|
2447 |
// ----------------------------------------------------------------------------- |
|
2448 |
// |
|
2449 |
TPrivLocCommonParams::TPrivLocCommonParams() |
|
2450 |
{ |
|
2451 |
} |
|
2452 |
TPrivLocCommonParams::TPrivLocCommonParams(TLbsNetSessionIdInt aSessionId) |
|
2453 |
{ |
|
2454 |
iSessionId = aSessionId; |
|
2455 |
} |
|
2456 |
||
2457 |
TPrivLocWaitLocationRequestParams::TPrivLocWaitLocationRequestParams() |
|
2458 |
{ |
|
2459 |
} |
|
2460 |
TPrivLocWaitLocationRequestParams::TPrivLocWaitLocationRequestParams( |
|
2461 |
const TLbsNetSessionIdInt& aSessionId, |
|
2462 |
TBool aIsEmergency, |
|
2463 |
TBool aReqCancelled, |
|
2464 |
TInt aPreviousStateExitInfo) : |
|
2465 |
TPrivLocCommonParams(aSessionId), |
|
2466 |
iIsEmergency(aIsEmergency), |
|
2467 |
iReqCancelled(aReqCancelled), |
|
2468 |
iPreviousStateExitInfo(aPreviousStateExitInfo) |
|
2469 |
{ |
|
2470 |
} |
|
2471 |
||
2472 |
TPrivLocWaitLocationUpdateParams::TPrivLocWaitLocationUpdateParams() |
|
2473 |
{ |
|
2474 |
} |
|
2475 |
TPrivLocWaitLocationUpdateParams::TPrivLocWaitLocationUpdateParams( |
|
2476 |
const TLbsNetSessionIdInt& aSessionId, |
|
2477 |
const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
2478 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
2479 |
TBool aIsEmergency, |
|
2480 |
const TLbsNetPosRequestQualityInt& aQuality) : |
|
2481 |
TPrivLocCommonParams(aSessionId), |
|
2482 |
iSessionType(aSessionType), |
|
2483 |
iIsEmergency(aIsEmergency), |
|
2484 |
iQuality(aQuality), |
|
2485 |
iPosRequestMethod(aPosRequestMethod) |
|
2486 |
{ |
|
2487 |
} |
|
2488 |
||
2489 |
TPrivLocWaitPrivResponseParams::TPrivLocWaitPrivResponseParams() |
|
2490 |
{ |
|
2491 |
||
2492 |
} |
|
2493 |
TPrivLocWaitPrivResponseParams::TPrivLocWaitPrivResponseParams( |
|
2494 |
const TLbsNetSessionIdInt& aSessionId, |
|
2495 |
const TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
2496 |
const TLbsExternalRequestInfo& aExternalRequestInfo, |
|
2497 |
const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy, |
|
2498 |
TBool aIsEmergency) : |
|
2499 |
TPrivLocCommonParams(aSessionId), |
|
2500 |
iNetPosRequestPrivacy(aNetPosRequestPrivacy), |
|
2501 |
iIsEmergency(aIsEmergency), |
|
2502 |
iSessionType(aSessionType) |
|
2503 |
{ |
|
2504 |
// Need to check the type of aExternalRequestInfo before |
|
2505 |
// copying it into this class. |
|
2506 |
if (aExternalRequestInfo.ClassType() == EExternalRequestInfoClass) |
|
2507 |
{ |
|
2508 |
__ASSERT_DEBUG(aExternalRequestInfo.ClassSize() == sizeof(TLbsExternalRequestInfo), |
|
2509 |
Panic(ENrhPanicInvalidExternalRequestInfoType)); |
|
2510 |
||
2511 |
Mem::Copy(&iExternalRequestInfo, |
|
2512 |
&aExternalRequestInfo, |
|
2513 |
sizeof(TLbsExternalRequestInfo)); |
|
2514 |
} |
|
2515 |
else |
|
2516 |
{ |
|
2517 |
if (aExternalRequestInfo.ClassType() == (EExternalRequestInfoClass | EExternalRequestInfoClass2)) |
|
2518 |
{ |
|
2519 |
__ASSERT_DEBUG(aExternalRequestInfo.ClassSize() == sizeof(TLbsExternalRequestInfo2), |
|
2520 |
Panic(ENrhPanicInvalidExternalRequestInfoType)); |
|
2521 |
||
2522 |
Mem::Copy(&iExternalRequestInfo, |
|
2523 |
&aExternalRequestInfo, |
|
2524 |
sizeof(TLbsExternalRequestInfo2)); |
|
2525 |
} |
|
2526 |
else |
|
2527 |
{ |
|
2528 |
Panic(ENrhPanicInvalidExternalRequestInfoType); |
|
2529 |
} |
|
2530 |
} |
|
2531 |
} |
|
2532 |
||
2533 |
// ----------------------------------------------------------------------------- |
|
2534 |
// |
|
2535 |
// ----------------------------- Class CLbsPrivLocFsm -------------------------- |
|
2536 |
// |
|
2537 |
// State Machine class which owns the states of the Privacy and Location Handler |
|
2538 |
// |
|
2539 |
// ----------------------------------------------------------------------------- |
|
2540 |
// |
|
2541 |
||
2542 |
// ----------------------------------------------------------------------------- |
|
2543 |
// CLbsPrivLocFsm::NewL |
|
2544 |
// Description: CLbsPrivLocFsm static constructor |
|
2545 |
// ----------------------------------------------------------------------------- |
|
2546 |
// |
|
2547 |
CLbsPrivLocFsm* CLbsPrivLocFsm::NewL( |
|
2548 |
CPrivacyAndLocationHandler& aPrivLocHandler, |
|
2549 |
const TLbsNetSessionIdInt& aSessionId) |
|
2550 |
{ |
|
2551 |
CLbsPrivLocFsm* self; |
|
2552 |
self = new (ELeave) CLbsPrivLocFsm(aPrivLocHandler, aSessionId); |
|
2553 |
CleanupStack::PushL(self); |
|
2554 |
self->ConstructL(); |
|
2555 |
CleanupStack::Pop(self); |
|
2556 |
return(self); |
|
2557 |
} |
|
2558 |
||
2559 |
// ----------------------------------------------------------------------------- |
|
2560 |
// CLbsPrivLocFsm::CLbsPrivLocFsm |
|
2561 |
// Description: CLbsPrivLocFsm constructor |
|
2562 |
// ----------------------------------------------------------------------------- |
|
2563 |
// |
|
2564 |
CLbsPrivLocFsm::CLbsPrivLocFsm( |
|
2565 |
CPrivacyAndLocationHandler& aPrivLocHandler, |
|
2566 |
const TLbsNetSessionIdInt& aSessionId) : |
|
2567 |
iPrivLocHandler(aPrivLocHandler), |
|
2568 |
iSessionId(aSessionId), |
|
2569 |
iIsEmergency(EFalse), |
|
2570 |
iSessionType(TLbsNetworkEnumInt::EServiceNone), |
|
2571 |
iRefPosProcessed(EFalse), |
|
2572 |
iLocReqReceived(EFalse), |
|
2573 |
iReqCancelled(EFalse), |
|
2574 |
iWasPrivacyResponseReceivedStateExited(EFalse), |
|
2575 |
iPositioningStatusIncremented(EFalse) |
|
2576 |
{ |
|
2577 |
} |
|
2578 |
||
2579 |
// ----------------------------------------------------------------------------- |
|
2580 |
// CLbsPrivLocFsm::~CLbsPrivLocFsm |
|
2581 |
// Description: CLbsPrivLocFsm destructor |
|
2582 |
// ----------------------------------------------------------------------------- |
|
2583 |
// |
|
2584 |
CLbsPrivLocFsm::~CLbsPrivLocFsm() |
|
2585 |
{ |
|
2586 |
delete iLocationUpdateTimer; |
|
2587 |
iStates.DeleteAll(); |
|
2588 |
iStates.Reset(); |
|
2589 |
} |
|
2590 |
||
2591 |
// ----------------------------------------------------------------------------- |
|
2592 |
// CLbsPrivLocFsm::SessionId |
|
2593 |
// Description: Get the current session Id for this FSM. |
|
2594 |
// ----------------------------------------------------------------------------- |
|
2595 |
// |
|
2596 |
const TLbsNetSessionIdInt& CLbsPrivLocFsm::SessionId() const |
|
2597 |
{ |
|
2598 |
return iSessionId; |
|
2599 |
} |
|
2600 |
||
2601 |
// ----------------------------------------------------------------------------- |
|
2602 |
// CLbsPrivLocFsm::ConstructL |
|
2603 |
// Description: CLbsPrivLocFsm second-phase constructor. |
|
2604 |
// Creates the states of the system and the Privacy Handler. |
|
2605 |
// ----------------------------------------------------------------------------- |
|
2606 |
// |
|
2607 |
void CLbsPrivLocFsm::ConstructL() |
|
2608 |
{ |
|
2609 |
// Create the states |
|
2610 |
iStates.At(EStateIdle) = CLbsPrivLocIdleState::NewL(this); |
|
2611 |
iStates.At(EStateWaitPrivacyResponse) = CLbsPrivLocWaitPrivRespState::NewL(this); |
|
2612 |
iStates.At(EStateWaitLocationRequest) = CLbsPrivLocWaitLocReqState::NewL(this); |
|
2613 |
iStates.At(EStateWaitLocationUpdate) = CLbsPrivLocWaitLocUpdateState::NewL(this); |
|
2614 |
||
2615 |
iCurrentState = iStates.At(EStateIdle); |
|
2616 |
// When waiting for an update, there is a maximum duration specified by the |
|
2617 |
// LBS admin data to avoid the risk of hanging around forever in the event of |
|
2618 |
// a problem with the A-GPS module. Create a timer to deal with this. |
|
2619 |
iLocationUpdateTimer = CLbsCallbackTimer::NewL(*this); |
|
2620 |
} |
|
2621 |
||
2622 |
||
2623 |
TBool CLbsPrivLocFsm::IsSpecialFeatureIntermediateFutileUpdateOn() |
|
2624 |
{ |
|
2625 |
return PrivLocHandler().IsSpecialFeatureIntermediateFutileUpdateOn(); |
|
2626 |
} |
|
2627 |
||
2628 |
// ----------------------------------------------------------------------------- |
|
2629 |
// CPrivacyAndLocationHandler::SetServerObserver |
|
2630 |
// Description: Store a pointer to the NRH server which comunicates with the |
|
2631 |
// Privacy Controller. |
|
2632 |
// ----------------------------------------------------------------------------- |
|
2633 |
// |
|
2634 |
void CLbsPrivLocFsm::SetServerObserver(MLbsSessionObserver* aNrhServer) |
|
2635 |
{ |
|
2636 |
PrivLocHandler().PrivacyHandler()->SetServerObserver(aNrhServer); |
|
2637 |
} |
|
2638 |
||
2639 |
// ----------------------------------------------------------------------------- |
|
2640 |
// CLbsPrivLocFsm::OnRespondNetworkLocationRequest |
|
2641 |
// Description: Called by the Privacy Handler to report the result of a privacy |
|
2642 |
// check. Handling of the response is delegated to the current state. |
|
2643 |
// ----------------------------------------------------------------------------- |
|
2644 |
// |
|
2645 |
void CLbsPrivLocFsm::OnRespondNetworkLocationRequest(const TLbsNetSessionIdInt& aRequestId, |
|
2646 |
TLbsNetworkEnumInt::TLbsPrivacyResponseInt aRequestResult, |
|
2647 |
TInt aResponseReason) |
|
2648 |
{ |
|
2649 |
LBSLOG3(ELogP3, "FSM(%d) OnRespondNetworkLocationRequest response=%d",iSessionId.SessionNum(),aRequestResult); |
|
2650 |
iCurrentState->OnRespondNetworkLocationRequest(aRequestId, aRequestResult, aResponseReason); |
|
2651 |
} |
|
2652 |
||
2653 |
// ----------------------------------------------------------------------------- |
|
2654 |
// CLbsPrivLocFsm::OnCancelNetworkLocationRequest |
|
2655 |
// Description: Called by the Privacy Handler to report that a privacy check |
|
2656 |
// has been rejected. This may occur after it has already been accepted. |
|
2657 |
// Handling of the response is delegated to the current state. |
|
2658 |
// ----------------------------------------------------------------------------- |
|
2659 |
// |
|
2660 |
void CLbsPrivLocFsm::OnCancelNetworkLocationRequest(const TLbsNetSessionIdInt& aRequestId) |
|
2661 |
{ |
|
2662 |
LBSLOG2(ELogP3, "FSM(%d) OnCancelNetworkLocationRequest",iSessionId.SessionNum()); |
|
2663 |
iCurrentState->OnCancelNetworkLocationRequest(aRequestId); |
|
2664 |
} |
|
2665 |
||
2666 |
// ----------------------------------------------------------------------------- |
|
2667 |
// CLbsPrivLocFsm::OnMTLRRequest |
|
2668 |
// Description: The Message Switch has forwarded a request to start an MTLR |
|
2669 |
// session. |
|
2670 |
// Handling of the request is delegated to the current state. |
|
2671 |
// ----------------------------------------------------------------------------- |
|
2672 |
// |
|
2673 |
void CLbsPrivLocFsm::OnMTLRRequest(const TLbsNetSessionIdInt& aSessionId, |
|
2674 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
2675 |
TBool aIsEmergency, |
|
2676 |
const TLbsExternalRequestInfo& aExternalRequestInfo, |
|
2677 |
const TLbsNetPosRequestPrivacyInt& aNetPosRequestPrivacy) |
|
2678 |
{ |
|
2679 |
LBSLOG2(ELogP3, "FSM(%d) OnMTLRRequest",iSessionId.SessionNum()); |
|
2680 |
iCurrentState->OnMTLRRequest(aSessionId, |
|
2681 |
aSessionType, |
|
2682 |
aIsEmergency, |
|
2683 |
aExternalRequestInfo, |
|
2684 |
aNetPosRequestPrivacy); |
|
2685 |
} |
|
2686 |
||
2687 |
// ----------------------------------------------------------------------------- |
|
2688 |
// CLbsPrivLocFsm::OnSessionComplete |
|
2689 |
// Description: The Message Switch has reported that the session is |
|
2690 |
// over (complete or aborted due to some error). |
|
2691 |
// Handling of the message is delegated to the current state. |
|
2692 |
// ----------------------------------------------------------------------------- |
|
2693 |
// |
|
2694 |
void CLbsPrivLocFsm::OnSessionComplete( |
|
2695 |
const TLbsNetSessionIdInt& aSessionId, |
|
2696 |
TInt aReason) |
|
2697 |
{ |
|
2698 |
LBSLOG3(ELogP3, "FSM(%d) OnSessionComplete reason=%d",iSessionId.SessionNum(),aReason); |
|
2699 |
iCurrentState->OnSessionComplete(aSessionId, aReason); |
|
2700 |
||
2701 |
// update the positioning status. Note this is updated only if it was previously |
|
2702 |
// incremented as a result of this session. |
|
2703 |
if (WasPositioningStatusIncremented()) |
|
2704 |
{ |
|
2705 |
PrivLocHandler().DecrementPositioningStatus(); |
|
2706 |
WasPositioningStatusIncremented() = EFalse; |
|
2707 |
} |
|
2708 |
} |
|
2709 |
||
2710 |
// ----------------------------------------------------------------------------- |
|
2711 |
// CLbsPrivLocFsm::OnNetLocRequest |
|
2712 |
// Description: The Message Switch has passed on a request for a position update |
|
2713 |
// Handling of the request is delegated to the current state. |
|
2714 |
// ----------------------------------------------------------------------------- |
|
2715 |
// |
|
2716 |
void CLbsPrivLocFsm::OnNetLocRequest( |
|
2717 |
const TLbsNetSessionIdInt& aSessionId, |
|
2718 |
const TLbsNetPosRequestMethodInt& aPosRequestMethod, |
|
2719 |
TLbsNetworkEnumInt::TLbsNetProtocolServiceInt aSessionType, |
|
2720 |
TBool aIsEmergency, |
|
2721 |
const TLbsNetPosRequestQualityInt& aQuality) |
|
2722 |
{ |
|
2723 |
LBSLOG2(ELogP3, "FSM(%d) OnNetLocRequest",iSessionId.SessionNum()); |
|
2724 |
iCurrentState->OnNetLocRequest(aSessionId, |
|
2725 |
aPosRequestMethod, |
|
2726 |
aSessionType, |
|
2727 |
aIsEmergency, |
|
2728 |
aQuality); |
|
2729 |
} |
|
2730 |
||
2731 |
/** Called when a reference position arrives from the network. |
|
2732 |
*/ |
|
2733 |
void CLbsPrivLocFsm::OnNetLocReferenceUpdate( |
|
2734 |
const TLbsNetSessionIdInt& aSessionId, |
|
2735 |
const TPositionInfoBase& aPosInfo) |
|
2736 |
{ |
|
2737 |
LBSLOG2(ELogP3, "FSM(%d) OnNetLocReferenceUpdate",iSessionId.SessionNum()); |
|
2738 |
iCurrentState->OnNetLocReferenceUpdate(aSessionId, aPosInfo); |
|
2739 |
} |
|
2740 |
||
2741 |
/** Callend when a final location arrives from the network. |
|
2742 |
||
2743 |
Currently the final network position is never used by the |
|
2744 |
state machine - it is only needed by the X3P handler. |
|
2745 |
So this function just ignores the update. |
|
2746 |
*/ |
|
2747 |
void CLbsPrivLocFsm::OnNetLocFinalUpdate( |
|
2748 |
const TLbsNetSessionIdInt& /*aSessionId*/, |
|
2749 |
const TPositionInfoBase& /*aPosInfo*/) |
|
2750 |
{ |
|
2751 |
// Final network position not used by CLbsPrivLocFsm, so ignore it. |
|
2752 |
} |
|
2753 |
||
2754 |
// ----------------------------------------------------------------------------- |
|
2755 |
// CLbsPrivLocFsm::ChangeState |
|
2756 |
// Description: Called by a state of the FSM when a transition is required. |
|
2757 |
// ----------------------------------------------------------------------------- |
|
2758 |
// |
|
2759 |
void CLbsPrivLocFsm::ChangeState(TLocPrivacyHandlerState aNewStateId,const TPrivLocCommonParams& aStateParams) |
|
2760 |
{ |
|
2761 |
// Tidy up the old state |
|
2762 |
if(iCurrentState) |
|
2763 |
{ |
|
2764 |
// coverity[unchecked_value] |
|
2765 |
// We're not interested in whether it was consumed here |
|
2766 |
iCurrentState->OnExit(); |
|
2767 |
} |
|
2768 |
||
2769 |
// Note, here the session ID has already being set when the Fsm was created (when session first came into being) |
|
2770 |
// so no need to do this ... iSessionId = aStateParams.iSessionId; |
|
2771 |
||
2772 |
// Set the new state |
|
2773 |
iCurrentState = iStates.At(aNewStateId); |
|
2774 |
||
2775 |
LBSLOG3(ELogP3, "FSM(%d) Entering state %d",iSessionId.SessionNum(), aNewStateId); |
|
2776 |
||
2777 |
// Do any initialisation for the new state. |
|
2778 |
iCurrentState->OnEntry(aStateParams); |
|
2779 |
} |
|
2780 |
||
2781 |
// ----------------------------------------------------------------------------- |
|
2782 |
// CLbsPrivLocFsm::ChangeState |
|
2783 |
// Description: Called by a state of the FSM when a transition is required to a |
|
2784 |
// state which only requires the session Id |
|
2785 |
// ----------------------------------------------------------------------------- |
|
2786 |
// |
|
2787 |
void CLbsPrivLocFsm::ChangeState(TLocPrivacyHandlerState aNewStateId, |
|
2788 |
const TLbsNetSessionIdInt& aSessionId) |
|
2789 |
{ |
|
2790 |
TPrivLocCommonParams commonParams(aSessionId); |
|
2791 |
ChangeState(aNewStateId, commonParams); |
|
2792 |
} |
|
2793 |
||
2794 |
// ----------------------------------------------------------------------------- |
|
2795 |
// CLbsPrivLocFsm::PrivLocHandler |
|
2796 |
// Description: Get the CPrivacyAndLocationHandler object |
|
2797 |
// ----------------------------------------------------------------------------- |
|
2798 |
// |
|
2799 |
CPrivacyAndLocationHandler& CLbsPrivLocFsm::PrivLocHandler() |
|
2800 |
{ |
|
2801 |
return iPrivLocHandler; |
|
2802 |
} |
|
2803 |
||
2804 |
// ----------------------------------------------------------------------------- |
|
2805 |
// CLbsPrivLocWaitLocUpdateState::OnTimerEventL |
|
2806 |
// Description: The Location Update timer has expired. |
|
2807 |
// Cancel the request, and pass on the response if any has been received, |
|
2808 |
// otherwise report failure. |
|
2809 |
// ----------------------------------------------------------------------------- |
|
2810 |
// |
|
2811 |
void CLbsPrivLocFsm::OnTimerEventL(TInt aTimerId) |
|
2812 |
{ |
|
2813 |
LBSLOG2(ELogP3, "FSM(%d) OnTimerEventL", iSessionId.SessionNum()); |
|
2814 |
iCurrentState->OnTimerEventL(aTimerId); |
|
2815 |
} |
|
2816 |
||
2817 |
/** Called if OnTimerEventL leaves */ |
|
2818 |
TInt CLbsPrivLocFsm::OnTimerError(TInt /*aTimerId*/, TInt aError) |
|
2819 |
{ |
|
2820 |
__ASSERT_DEBUG(EFalse, Panic(ENrhPanicLocationTimerError)); |
|
2821 |
return(aError); |
|
2822 |
} |
|
2823 |
||
2824 |
/** Callback when a GPS position update arrives from AGPS manager. |
|
2825 |
*/ |
|
2826 |
void CLbsPrivLocFsm::OnAgpsPositionUpdate( |
|
2827 |
TInt aReason, |
|
2828 |
const TPositionExtendedSatelliteInfo& aPosInfo, |
|
2829 |
const TTime& aTimeStamp) |
|
2830 |
{ |
|
2831 |
LBSLOG2(ELogP3, "FSM(%d) OnAgpsPositionUpdate", iSessionId.SessionNum()); |
|
2832 |
iCurrentState->OnAgpsPositionUpdate(aReason, aPosInfo, aTimeStamp); |
|
2833 |
} |
|
2834 |
||
2835 |
/** Callback when a GPS measurement results update arrives from AGPS manager. |
|
2836 |
*/ |
|
2837 |
void CLbsPrivLocFsm::OnAgpsMeasurementUpdate( |
|
2838 |
TInt aReason, |
|
2839 |
const TPositionGpsMeasurementInfo& aPosInfo, |
|
2840 |
const TTime& aTimeStamp) |
|
2841 |
{ |
|
2842 |
LBSLOG2(ELogP3, "FSM(%d) OnAgpsMeasurementUpdate", iSessionId.SessionNum()); |
|
2843 |
iCurrentState->OnAgpsMeasurementUpdate(aReason, aPosInfo, aTimeStamp); |
|
2844 |
} |