748
|
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
|
872
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
748
|
5 |
// which accompanies this distribution, and is available
|
872
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
748
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// @file CT_Utils.cpp
|
|
15 |
// This is the Cpp file which contains the utility functions common across the servers
|
|
16 |
//
|
|
17 |
//
|
|
18 |
|
|
19 |
// User includes
|
|
20 |
#include "tlbsutils.h"
|
|
21 |
#include "ctlbsconfigreader.h"
|
|
22 |
#include "ctlbsasyncwaiter.h"
|
|
23 |
#include "ctlbstestloggermacros.h"
|
|
24 |
|
|
25 |
// Epoc includes
|
|
26 |
#include <f32file.h>
|
|
27 |
#include <e32math.h>
|
|
28 |
#include <e32property.h>
|
|
29 |
|
|
30 |
// Lbs includes
|
|
31 |
#include <lbsclasstypes.h>
|
|
32 |
#include <lbssatellite.h>
|
|
33 |
|
|
34 |
|
|
35 |
// defines
|
|
36 |
#define BAD_MODULE_ID 0x87654321
|
|
37 |
|
|
38 |
|
|
39 |
/**
|
|
40 |
*/
|
|
41 |
EXPORT_C TLbsModuleUpdateItem::TLbsModuleUpdateItem()
|
|
42 |
{
|
|
43 |
}
|
|
44 |
|
|
45 |
|
|
46 |
/**
|
|
47 |
*/
|
|
48 |
EXPORT_C const TPositionSatelliteInfo& TLbsModuleUpdateItem::Position() const
|
|
49 |
{
|
|
50 |
return iPosition;
|
|
51 |
}
|
|
52 |
|
|
53 |
/**
|
|
54 |
*/
|
|
55 |
EXPORT_C void TLbsModuleUpdateItem::SetPosition(const TPositionSatelliteInfo& aPosition)
|
|
56 |
{
|
|
57 |
iPosition = aPosition;
|
|
58 |
}
|
|
59 |
|
|
60 |
|
|
61 |
/**
|
|
62 |
*/
|
|
63 |
EXPORT_C const TPositionGpsMeasurementInfo& TLbsModuleUpdateItem::Measurement() const
|
|
64 |
{
|
|
65 |
return iMeasurement;
|
|
66 |
}
|
|
67 |
|
|
68 |
/**
|
|
69 |
*/
|
|
70 |
EXPORT_C void TLbsModuleUpdateItem::SetMeasurement(const TPositionGpsMeasurementInfo& aMeasurement)
|
|
71 |
{
|
|
72 |
iMeasurement = aMeasurement;
|
|
73 |
}
|
|
74 |
|
|
75 |
|
|
76 |
/**
|
|
77 |
*/
|
|
78 |
EXPORT_C TInt TLbsModuleUpdateItem::Error() const
|
|
79 |
{
|
|
80 |
return iError;
|
|
81 |
}
|
|
82 |
|
|
83 |
/**
|
|
84 |
*/
|
|
85 |
EXPORT_C void TLbsModuleUpdateItem::SetDelay(TInt aDelay)
|
|
86 |
{
|
|
87 |
iDelay = aDelay;
|
|
88 |
}
|
|
89 |
|
|
90 |
/**
|
|
91 |
*/
|
|
92 |
EXPORT_C TInt TLbsModuleUpdateItem::Delay() const
|
|
93 |
{
|
|
94 |
return iDelay;
|
|
95 |
}
|
|
96 |
|
|
97 |
/**
|
|
98 |
*/
|
|
99 |
EXPORT_C void TLbsModuleUpdateItem::SetError(TInt aError)
|
|
100 |
{
|
|
101 |
iError = aError;
|
|
102 |
}
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
EXPORT_C T_LbsUtils::T_LbsUtils()
|
|
107 |
/** Constructor.
|
|
108 |
*/
|
|
109 |
{
|
|
110 |
}
|
|
111 |
|
|
112 |
|
|
113 |
EXPORT_C T_LbsUtils::~T_LbsUtils()
|
|
114 |
/** Destructor.
|
|
115 |
*/
|
|
116 |
{
|
|
117 |
}
|
|
118 |
|
|
119 |
|
|
120 |
/*EXPORT_C static*/ /*void GetDefault_ModuleStatusInfo(TModuleConfiguredStatus& aStatusInfo)
|
|
121 |
{
|
|
122 |
(void)aStatusInfo;
|
|
123 |
}
|
|
124 |
*/
|
|
125 |
|
|
126 |
|
|
127 |
EXPORT_C void T_LbsUtils::CreateTestPropertiesL()
|
|
128 |
/** Creates the test properties for the test module. To allow data to be passed between
|
|
129 |
test steps and the test module.
|
|
130 |
*/
|
|
131 |
{
|
|
132 |
const TSecurityPolicy KReadPolicy(ECapability_None);
|
|
133 |
const TSecurityPolicy KWritePolicy(ECapabilityWriteDeviceData);
|
|
134 |
|
|
135 |
|
|
136 |
// Create the test module data bus properties.
|
|
137 |
TInt err;
|
|
138 |
|
|
139 |
// Data to the test module.
|
|
140 |
err = RProperty::Define(KUidSystemCategory, ELbsTestAGpsModuleIn, RProperty::ELargeByteArray, KReadPolicy, KWritePolicy, sizeof(TModuleDataIn));
|
|
141 |
if ((KErrNone != err) && (KErrAlreadyExists != err))
|
|
142 |
{
|
|
143 |
User::LeaveIfError(err);
|
|
144 |
}
|
|
145 |
|
|
146 |
// Data from the test module.
|
|
147 |
err = RProperty::Define(KUidSystemCategory, ELbsTestAGpsModuleOut, RProperty::ELargeByteArray, KReadPolicy, KWritePolicy, sizeof(TModuleDataOut));
|
|
148 |
if ((KErrNone != err) && (KErrAlreadyExists != err))
|
|
149 |
{
|
|
150 |
User::LeaveIfError(err);
|
|
151 |
}
|
|
152 |
|
|
153 |
// Data from the test clock plugin.
|
|
154 |
err = RProperty::Define(KUidSystemCategory, ELbsTestClockPluginOut, RProperty::ELargeByteArray, KReadPolicy, KWritePolicy, sizeof(TClockPluginDataOut));
|
|
155 |
if ((KErrNone != err) && (KErrAlreadyExists != err))
|
|
156 |
{
|
|
157 |
User::LeaveIfError(err);
|
|
158 |
}
|
|
159 |
|
|
160 |
// Creating the property for allowing the AGPS module to report when the mode it's running in changes
|
|
161 |
err = RProperty::Define(KUidSystemCategory, ELbsTestAGpsModuleModeChanges, RProperty::ELargeByteArray, KReadPolicy, KWritePolicy, sizeof(TLbsGpsOptionsArray));
|
|
162 |
if ((KErrNone != err) && (KErrAlreadyExists != err))
|
|
163 |
{
|
|
164 |
User::LeaveIfError(err);
|
|
165 |
}
|
|
166 |
|
|
167 |
// Create other test properties here also - just update the TLbsTestPropertyKeys enum don't add extra Categories.
|
|
168 |
|
|
169 |
}
|
|
170 |
|
|
171 |
|
|
172 |
EXPORT_C void T_LbsUtils::GetConfigured_PosInfosL(const TDesC& aConfigFileName, const TDesC& aConfigSection, RPointerArray<TAny>& aPosInfoArr)
|
|
173 |
/** Fills a position info array with values read from a configuration ini file.
|
|
174 |
|
|
175 |
@param aConfigFileName The name of the ini file to read. If the file name is empty (0 length) then
|
|
176 |
the array will contain a single pos info item with default values.
|
|
177 |
@param aConfigSection The section within the ini file to read data from.
|
|
178 |
@param aPosInfoArr The pos info array to which the items are added. The array will cleared of
|
|
179 |
existing items.
|
|
180 |
*/
|
|
181 |
{
|
|
182 |
// Clear array.
|
|
183 |
ResetAndDestroy_PosInfoArr(aPosInfoArr);
|
|
184 |
|
|
185 |
// Check for config file, if not present create a single default TPositionInfo.
|
|
186 |
if (aConfigFileName.Length() == 0)
|
|
187 |
{
|
|
188 |
TPositionSatelliteInfo* posInfo = new(ELeave) TPositionSatelliteInfo();
|
|
189 |
TPosition position;
|
|
190 |
|
|
191 |
position.SetCoordinate(DEFAULT_NOTIFY_POS_UPDATE_LATITUDE, DEFAULT_NOTIFY_POS_UPDATE_LONGITUDE, DEFAULT_NOTIFY_POS_UPDATE_ALTITUDE);
|
|
192 |
position.SetAccuracy(DEFAULT_NOTIFY_POS_UPDATE_HORIZONTAL_ACCURACY, DEFAULT_NOTIFY_POS_UPDATE_VERTICAL_ACCURACY);
|
|
193 |
position.SetCurrentTime();
|
|
194 |
|
|
195 |
posInfo->SetPosition(position);
|
|
196 |
|
|
197 |
User::LeaveIfError(aPosInfoArr.Append(posInfo));
|
|
198 |
}
|
|
199 |
|
|
200 |
else
|
|
201 |
{
|
|
202 |
CPosInfoConfigReader* reader;
|
|
203 |
|
|
204 |
reader = CPosInfoConfigReader::NewL(aConfigFileName, aConfigSection, aPosInfoArr);
|
|
205 |
CleanupStack::PushL(reader);
|
|
206 |
|
|
207 |
reader->ProcessL();
|
|
208 |
|
|
209 |
CleanupStack::PopAndDestroy(reader);
|
|
210 |
}
|
|
211 |
}
|
|
212 |
|
|
213 |
EXPORT_C void T_LbsUtils::GetConfigured_UpdateArrayL(const TDesC& aConfigFileName, const TDesC& aConfigSection, RPointerArray<TLbsModuleUpdateItem>& aUpdateArr)
|
|
214 |
/** Fills an updata array structure with values read from a configuration ini file.
|
|
215 |
|
|
216 |
@param aConfigFileName The name of the ini file to read. If the file name is empty (0 length) then
|
|
217 |
default values will be used.
|
|
218 |
@param aConfigSection The section within the ini file to read data from.
|
|
219 |
@param aUpdateArr The update array to be populated.
|
|
220 |
*/
|
|
221 |
{
|
|
222 |
// Use default values if file name not given.
|
|
223 |
if (aConfigFileName.Length() == 0)
|
|
224 |
{
|
|
225 |
// I am not sure we want to fill in the array with default values - ??
|
|
226 |
}
|
|
227 |
|
|
228 |
else
|
|
229 |
{
|
|
230 |
CUpdateConfigReader* reader;
|
|
231 |
|
|
232 |
reader = CUpdateConfigReader::NewL(aConfigFileName, aConfigSection, aUpdateArr);
|
|
233 |
CleanupStack::PushL(reader);
|
|
234 |
|
|
235 |
reader->ProcessL();
|
|
236 |
|
|
237 |
CleanupStack::PopAndDestroy(reader);
|
|
238 |
}
|
|
239 |
}
|
|
240 |
|
|
241 |
|
|
242 |
// don't think we need this...
|
|
243 |
EXPORT_C void T_LbsUtils::GetConfigured_ModuleStatusL(const TDesC& aConfigFileName, const TDesC& aConfigSection, TPositionModuleStatus& aModuleStatus)
|
|
244 |
{
|
|
245 |
// Use default values if file name not given.
|
|
246 |
if (aConfigFileName.Length() == 0)
|
|
247 |
{
|
|
248 |
aModuleStatus.SetDeviceStatus(TPositionModuleStatus::EDeviceReady);
|
|
249 |
aModuleStatus.SetDataQualityStatus(TPositionModuleStatus::EDataQualityNormal);
|
|
250 |
}
|
|
251 |
else
|
|
252 |
{
|
|
253 |
CModuleStatusConfigReader* reader;
|
|
254 |
|
|
255 |
reader = CModuleStatusConfigReader::NewL(aConfigFileName, aConfigSection, aModuleStatus);
|
|
256 |
CleanupStack::PushL(reader);
|
|
257 |
|
|
258 |
reader->ProcessL();
|
|
259 |
|
|
260 |
CleanupStack::PopAndDestroy(reader);
|
|
261 |
}
|
|
262 |
}
|
|
263 |
|
|
264 |
|
|
265 |
EXPORT_C void T_LbsUtils::GetConfigured_ModuleUpdateOptionsL(const TDesC& aConfigFileName, const TDesC& aConfigSection, TPositionUpdateOptions& aUpdateOpts)
|
|
266 |
/** Fills a module updata options class/structure with values read from a configuration ini file.
|
|
267 |
|
|
268 |
@param aConfigFileName The name of the ini file to read. If the file name is empty (0 length) then
|
|
269 |
default values will be used.
|
|
270 |
@param aConfigSection The section within the ini file to read data from.
|
|
271 |
@param aUpdateOpts The modified update options structure.
|
|
272 |
*/
|
|
273 |
{
|
|
274 |
// Use default values if file name not given.
|
|
275 |
if (aConfigFileName.Length() == 0)
|
|
276 |
{
|
|
277 |
aUpdateOpts.SetUpdateInterval(0);
|
|
278 |
aUpdateOpts.SetUpdateTimeOut(0);
|
|
279 |
aUpdateOpts.SetMaxUpdateAge(0);
|
|
280 |
aUpdateOpts.SetAcceptPartialUpdates(EFalse);
|
|
281 |
}
|
|
282 |
|
|
283 |
else
|
|
284 |
{
|
|
285 |
CUpdateOptsConfigReader* reader;
|
|
286 |
|
|
287 |
reader = CUpdateOptsConfigReader::NewL(aConfigFileName, aConfigSection, aUpdateOpts);
|
|
288 |
CleanupStack::PushL(reader);
|
|
289 |
|
|
290 |
reader->ProcessL();
|
|
291 |
|
|
292 |
CleanupStack::PopAndDestroy(reader);
|
|
293 |
}
|
|
294 |
}
|
|
295 |
|
|
296 |
EXPORT_C void T_LbsUtils::GetConfigured_ClientDetailsL(const TDesC& aConfigFileName, const TDesC& aConfigSection,
|
|
297 |
RArray<TCTClientDetails>& aClientDetailsArray)
|
|
298 |
/** Gets the delays for each client with values read from a configuration ini file.
|
|
299 |
|
|
300 |
@param aConfigFileName The name of the ini file to read. If the file name is empty (0 length) then
|
|
301 |
default values will be used.
|
|
302 |
@param aConfigSection The section within the ini file to read data from.
|
|
303 |
@param aClientDelayArray The array of client delays.
|
|
304 |
*/
|
|
305 |
{
|
|
306 |
// Use default values if file name not given.
|
|
307 |
if (aConfigFileName.Length() == 0)
|
|
308 |
{ // by default have one client
|
|
309 |
TCTClientDetails client;
|
|
310 |
aClientDetailsArray.AppendL(client);
|
|
311 |
return;
|
|
312 |
}
|
|
313 |
|
|
314 |
else
|
|
315 |
{
|
|
316 |
CClientDetailsConfigReader* reader;
|
|
317 |
reader = CClientDetailsConfigReader::NewL(aConfigFileName, aConfigSection, aClientDetailsArray);
|
|
318 |
CleanupStack::PushL(reader);
|
|
319 |
|
|
320 |
reader->ProcessL();
|
|
321 |
|
|
322 |
CleanupStack::PopAndDestroy(reader);
|
|
323 |
if(aClientDetailsArray.Count() == 0)
|
|
324 |
{ // by default have one client
|
|
325 |
TCTClientDetails client;
|
|
326 |
aClientDetailsArray.AppendL(client);
|
|
327 |
}
|
|
328 |
}
|
|
329 |
}
|
|
330 |
|
|
331 |
EXPORT_C void T_LbsUtils::GetExpected_ModuleModes(const TDesC& aConfigFileName, const TDesC& aConfigSection, RPointerArray<TLbsGpsOptions>& aModuleModes)
|
|
332 |
{
|
|
333 |
if (aConfigFileName.Length() == 0)
|
|
334 |
{
|
|
335 |
return;
|
|
336 |
}
|
|
337 |
|
|
338 |
CAgpsModuleModesConfigReader* reader;
|
|
339 |
reader = CAgpsModuleModesConfigReader::NewL(aConfigFileName, aConfigSection, aModuleModes);
|
|
340 |
CleanupStack::PushL(reader);
|
|
341 |
reader->ProcessL();
|
|
342 |
CleanupStack::PopAndDestroy(reader);
|
|
343 |
}
|
|
344 |
|
|
345 |
|
|
346 |
EXPORT_C void T_LbsUtils::NotifyModuleOfConfigChangeL(const TModuleDataIn& aModuleDataIn)
|
|
347 |
/** Notify the module of a configuration change.
|
|
348 |
|
|
349 |
Used when the test harness has read a configuration file and wishes to notify the test module
|
|
350 |
that it should also do a read of the configuration file. To ensure both the test harness and
|
|
351 |
the test module are using the same reference data.
|
|
352 |
|
|
353 |
The ELbsTestAGpsModuleIn property is used to pass the ini file and section names to the
|
|
354 |
test module. The ELbsTestAGpsModuleOut is then used to receive an response from the test module.
|
|
355 |
|
|
356 |
@param aConfigFileName The file name string to send to the test mdoule.
|
|
357 |
@param aConfigSection The ini section name string to send to the test module.
|
|
358 |
*/
|
|
359 |
{
|
|
360 |
// Ask to be notified when the module receives the ini file re-read request.
|
|
361 |
|
|
362 |
// Attach and subscribe to listen for data bus updates. Use the async waiter to process
|
|
363 |
// the update.
|
|
364 |
RProperty modDataOutProperty;
|
|
365 |
User::LeaveIfError(modDataOutProperty.Attach(KUidSystemCategory, ELbsTestAGpsModuleOut));
|
|
366 |
|
|
367 |
CT_LbsAsyncWaiter* waiter = CT_LbsAsyncWaiter::NewL();
|
|
368 |
CleanupStack::PushL(waiter);
|
|
369 |
|
|
370 |
modDataOutProperty.Subscribe(waiter->iStatus);
|
|
371 |
|
|
372 |
|
|
373 |
// Publish the file and section names to the module, to inform the module it has to
|
|
374 |
// carry out a re-read of the ini file.
|
|
375 |
TPckgBuf<TModuleDataIn> modDataInBuf;
|
|
376 |
TModuleDataIn& modDataIn = modDataInBuf();
|
|
377 |
|
|
378 |
// Copy across all the data items.
|
|
379 |
modDataIn.iRequestType = aModuleDataIn.iRequestType;
|
|
380 |
modDataIn.iConfigFileName = aModuleDataIn.iConfigFileName;
|
|
381 |
modDataIn.iConfigSection = aModuleDataIn.iConfigSection;
|
|
382 |
modDataIn.iAssDataEventType = aModuleDataIn.iAssDataEventType;
|
|
383 |
modDataIn.iAssDataTestMode = aModuleDataIn.iAssDataTestMode;
|
|
384 |
modDataIn.iKickOffEventType = aModuleDataIn.iKickOffEventType;
|
|
385 |
modDataIn.iTimeOut = aModuleDataIn.iTimeOut;
|
|
386 |
modDataIn.iError = aModuleDataIn.iError;
|
|
387 |
modDataIn.iTimeStampOffset = aModuleDataIn.iTimeStampOffset;
|
|
388 |
modDataIn.iOptionsChangeReportMode = aModuleDataIn.iOptionsChangeReportMode;
|
|
389 |
|
|
390 |
User::LeaveIfError(RProperty::Set(KUidSystemCategory, ELbsTestAGpsModuleIn, modDataInBuf));
|
|
391 |
|
|
392 |
TBool noResponse = ETrue;
|
|
393 |
|
|
394 |
// Wait for the notification from the test module.
|
|
395 |
while(noResponse)
|
|
396 |
{
|
|
397 |
waiter->StartAndWait();
|
|
398 |
User::LeaveIfError(waiter->Result());
|
|
399 |
|
|
400 |
// Now ensure the notification response was good.
|
|
401 |
TModuleDataOut modDataOut;
|
|
402 |
TPckg<TModuleDataOut> modDataOutPckg(modDataOut);
|
|
403 |
|
|
404 |
User::LeaveIfError(modDataOutProperty.Get(modDataOutPckg));
|
|
405 |
|
|
406 |
if ((TModuleDataOut::EModuleResponse == modDataOut.iRequestType) && (TModuleDataOut::EModuleResponseOk == modDataOut.iResponse))
|
|
407 |
{
|
|
408 |
noResponse = EFalse;
|
|
409 |
}
|
|
410 |
}
|
|
411 |
|
|
412 |
CleanupStack::PopAndDestroy(waiter);
|
|
413 |
}
|
|
414 |
|
|
415 |
|
|
416 |
EXPORT_C void T_LbsUtils::WaitForModuleToRequestAssistanceDataL()
|
|
417 |
/** Wait for notification that the test AGPS module as requested assistance data.
|
|
418 |
|
|
419 |
Blocking function used to determine when the test module has requested assistance data as part of its location update.
|
|
420 |
*/
|
|
421 |
{
|
|
422 |
RProperty modDataOutProperty;
|
|
423 |
User::LeaveIfError(modDataOutProperty.Attach(KUidSystemCategory, ELbsTestAGpsModuleOut));
|
|
424 |
|
|
425 |
CT_LbsAsyncWaiter* waiter = CT_LbsAsyncWaiter::NewL();
|
|
426 |
CleanupStack::PushL(waiter);
|
|
427 |
|
|
428 |
modDataOutProperty.Subscribe(waiter->iStatus);
|
|
429 |
|
|
430 |
// Wait for the notification from the test module.
|
|
431 |
waiter->StartAndWait();
|
|
432 |
User::LeaveIfError(waiter->Result());
|
|
433 |
|
|
434 |
// Ensure the correct response is given.
|
|
435 |
TModuleDataOut modDataOut;
|
|
436 |
TPckg<TModuleDataOut> modDataOutPckg(modDataOut);
|
|
437 |
|
|
438 |
User::LeaveIfError(modDataOutProperty.Get(modDataOutPckg));
|
|
439 |
|
|
440 |
if (TModuleDataOut::EModuleAssDataRequestedOk != modDataOut.iResponse)
|
|
441 |
{
|
|
442 |
User::LeaveIfError(KErrArgument);
|
|
443 |
}
|
|
444 |
|
|
445 |
CleanupStack::PopAndDestroy(waiter);
|
|
446 |
}
|
|
447 |
|
|
448 |
EXPORT_C TBool T_LbsUtils::Compare_PosInfo(const TPositionInfoBase& aPosInfoSideA, const TPositionInfoBase& aPosInfoSideB)
|
|
449 |
/** Compare two position info structures. Ensure all fields match excatly.
|
|
450 |
|
|
451 |
@param aPosInfoSideA The first structure to compare.
|
|
452 |
@param aPosInfoSideB The second structure to compare.
|
|
453 |
@return ETrue if both structure match excatly else EFalse.
|
|
454 |
*/
|
|
455 |
{
|
|
456 |
return Compare_PosInfo(aPosInfoSideA, aPosInfoSideB, EExactAccuracy);
|
|
457 |
}
|
|
458 |
|
|
459 |
|
|
460 |
EXPORT_C TBool T_LbsUtils::Compare_PosInfo(const TPositionInfoBase& aPosInfoSideA, const TPositionInfoBase& aPosInfoSideB, TComparisonAccuracyType aCmpAccuracy)
|
|
461 |
{
|
|
462 |
// TODO compare base class items, such as module id, position mode, etc.
|
|
463 |
|
|
464 |
TUint32 typeA = aPosInfoSideA.PositionClassType();
|
|
465 |
TUint32 typeB = aPosInfoSideB.PositionClassType();
|
|
466 |
|
|
467 |
// Compare TPositionInfo type items.
|
|
468 |
if(typeA & typeB & EPositionInfoClass)
|
|
469 |
{
|
|
470 |
TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Both positions are of type EPositionInfoClass");
|
|
471 |
const TPositionInfo& posInfoSideA = reinterpret_cast<const TPositionInfo&>(aPosInfoSideA);
|
|
472 |
const TPositionInfo& posInfoSideB = reinterpret_cast<const TPositionInfo&>(aPosInfoSideB);
|
|
473 |
|
|
474 |
TPosition posSideA;
|
|
475 |
TPosition posSideB;
|
|
476 |
posInfoSideA.GetPosition(posSideA);
|
|
477 |
posInfoSideB.GetPosition(posSideB);
|
|
478 |
|
|
479 |
// Carry out an exact check when comparing items.
|
|
480 |
if (EExactAccuracy == aCmpAccuracy)
|
|
481 |
{
|
|
482 |
TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Comparing positions for exact match");
|
|
483 |
// Compare latitude.
|
|
484 |
if (Math::IsNaN(posSideA.Latitude()) && Math::IsNaN(posSideB.Latitude()))
|
|
485 |
;
|
|
486 |
else if (posSideA.Latitude() != posSideB.Latitude())
|
|
487 |
{
|
|
488 |
TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match!");
|
|
489 |
TESTLOG3(ELogP1, "Latitudes %d and %d respectively", posSideA.Latitude(), posSideB.Latitude());
|
|
490 |
return EFalse;
|
|
491 |
}
|
|
492 |
|
|
493 |
// Compare longitude.
|
|
494 |
if (Math::IsNaN(posSideA.Longitude()) && Math::IsNaN(posSideB.Longitude()))
|
|
495 |
;
|
|
496 |
else if (posSideA.Longitude() != posSideB.Longitude())
|
|
497 |
{
|
|
498 |
TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match!");
|
|
499 |
TESTLOG3(ELogP1, "Longitudes %d and %d respectively", posSideA.Longitude(), posSideB.Longitude());
|
|
500 |
return EFalse;
|
|
501 |
}
|
|
502 |
|
|
503 |
// Compare altitude.
|
|
504 |
if (Math::IsNaN(posSideA.Altitude()) && Math::IsNaN(posSideB.Altitude()))
|
|
505 |
;
|
|
506 |
else if (posSideA.Altitude() != posSideB.Altitude())
|
|
507 |
{
|
|
508 |
TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match!");
|
|
509 |
TESTLOG3(ELogP1, "Altitudes %d and %d respectively", posSideA.Altitude(), posSideB.Altitude());
|
|
510 |
return EFalse;
|
|
511 |
}
|
|
512 |
|
|
513 |
// Compare datum.
|
|
514 |
if (posSideA.Datum() != posSideB.Datum())
|
|
515 |
{
|
|
516 |
TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match!");
|
|
517 |
TESTLOG3(ELogP1, "Datums %d and %d respectively", posSideA.Datum(), posSideB.Datum());
|
|
518 |
return EFalse;
|
|
519 |
}
|
|
520 |
|
|
521 |
// Compare horizontal accuracy.
|
|
522 |
if (Math::IsNaN(posSideA.HorizontalAccuracy()) && Math::IsNaN(posSideB.HorizontalAccuracy()))
|
|
523 |
;
|
|
524 |
else if (posSideA.HorizontalAccuracy() != posSideB.HorizontalAccuracy())
|
|
525 |
{
|
|
526 |
TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match!");
|
|
527 |
TESTLOG3(ELogP1, "Horizontal Accuracies %d and %d respectively", posSideA.HorizontalAccuracy(), posSideB.HorizontalAccuracy());
|
|
528 |
return EFalse;
|
|
529 |
}
|
|
530 |
|
|
531 |
// Compare vertical accuracy.
|
|
532 |
if (Math::IsNaN(posSideA.VerticalAccuracy()) && Math::IsNaN(posSideB.VerticalAccuracy()))
|
|
533 |
;
|
|
534 |
else if (posSideA.VerticalAccuracy() != posSideB.VerticalAccuracy())
|
|
535 |
{
|
|
536 |
TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match!");
|
|
537 |
TESTLOG3(ELogP1, "Vertical Accuracies %d and %d respectively", posSideA.VerticalAccuracy(), posSideB.VerticalAccuracy());
|
|
538 |
return EFalse;
|
|
539 |
}
|
|
540 |
}
|
|
541 |
else
|
|
542 |
{
|
|
543 |
// Check latitude + longitude using horz accuracy.
|
|
544 |
TReal horzAct = posSideA.HorizontalAccuracy(); // Use the verify accuracy value (which is side A).
|
|
545 |
TReal distance ;
|
|
546 |
|
|
547 |
TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Comparing positions for 'rough' match");
|
|
548 |
// if(NAN != horzAct)
|
|
549 |
{
|
|
550 |
// The following is a temporary patch until TPositionInfo.Distance() is implemented:
|
|
551 |
/*
|
|
552 |
from http://www.movable-type.co.uk/scripts/GIS-FAQ-5.1.html
|
|
553 |
|
|
554 |
presuming a spherical Earth with radius R (see below), and the locations of the two points in spherical coordinates (longitude and latitude) are lon1,lat1 and lon2,lat2 then the
|
|
555 |
|
|
556 |
Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159):
|
|
557 |
|
|
558 |
dlon = lon2 - lon1
|
|
559 |
dlat = lat2 - lat1
|
|
560 |
a = sin^2(dlat/2) + cos(lat1) * cos(lat2) * sin^2(dlon/2)
|
|
561 |
c = 2 * arcsin(min(1,sqrt(a)))
|
|
562 |
d = R * c
|
|
563 |
|
|
564 |
will give mathematically and computationally exact results.
|
|
565 |
|
|
566 |
*/
|
|
567 |
const TReal pi = 3.141592653589793;
|
|
568 |
const TReal earthRadius = 6367 * 1000; // earth radius in metres
|
|
569 |
|
|
570 |
TReal32 latA = posSideA.Latitude() * (pi/180);
|
|
571 |
TReal32 latB = posSideB.Latitude() * (pi/180);
|
|
572 |
TReal32 lonA = posSideA.Longitude() * (pi/180);
|
|
573 |
TReal32 lonB = posSideB.Longitude() * (pi/180);
|
|
574 |
|
|
575 |
TReal dlon = (lonB - lonA);
|
|
576 |
TReal dlat = (latB - latA);
|
|
577 |
TReal sin_half_dlat, sin_half_dlon, coslatA, coslatB;
|
|
578 |
|
|
579 |
Math::Sin(sin_half_dlat, dlat/2);
|
|
580 |
Math::Sin(sin_half_dlon, dlon/2);
|
|
581 |
Math::Cos(coslatA, latA);
|
|
582 |
Math::Cos(coslatB, latB);
|
|
583 |
|
|
584 |
TReal a = (sin_half_dlat * sin_half_dlat) + (coslatA * coslatB * (sin_half_dlon * sin_half_dlon));
|
|
585 |
TReal sqrt_a;
|
|
586 |
Math::Sqrt(sqrt_a, a);
|
|
587 |
TReal arcsinmin;
|
|
588 |
|
|
589 |
TReal min = Min(static_cast<TReal>(1), sqrt_a);
|
|
590 |
Math::ASin(arcsinmin, min);
|
|
591 |
|
|
592 |
distance = earthRadius * (2 * arcsinmin);
|
|
593 |
|
|
594 |
//__ASSERT_ALWAYS(!Math::IsNaN(distance), User::Panic(_L("Lbs Test Utils"), KErrGeneral));
|
|
595 |
if(Math::IsNaN(latA) || Math::IsNaN(lonA) || Math::IsNaN(horzAct))
|
|
596 |
{
|
|
597 |
TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match because contains NaNs!");
|
|
598 |
return EFalse;
|
|
599 |
}
|
|
600 |
else if(distance > horzAct + 30) // lrm allow for 30m discrepency for now TO DO figure out whether we should be able to check finer accuracy
|
|
601 |
{
|
|
602 |
TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Positions don't match because distance greater than reported accuracy + margin!");
|
|
603 |
return EFalse;
|
|
604 |
}
|
|
605 |
}
|
|
606 |
|
|
607 |
/* put back later:
|
|
608 |
TReal32 horzAct = posSideA.HorizontalAccuracy(); // Use the verify accuracy value (which is side A).
|
|
609 |
TReal32 distance ;
|
|
610 |
|
|
611 |
posSideA.Distance(posSideB, distance);
|
|
612 |
if (distance > horzAct)
|
|
613 |
return EFalse;
|
|
614 |
|
|
615 |
// Check altitude using vert accuracy.
|
|
616 |
TReal32 vertAct = posSideA.VerticalAccuracy(); // Use the verify accuracy value (which is side A).
|
|
617 |
TReal32 height = Abs(posSideA.Altitude() - posSideB.Altitude());
|
|
618 |
if (height > vertAct)
|
|
619 |
return EFalse;
|
|
620 |
*/
|
|
621 |
|
|
622 |
}
|
|
623 |
|
|
624 |
// TODO, we don't compare times, not sure if this is something we would do later on
|
|
625 |
// if (posSideA.Time() != posSideB.Time())
|
|
626 |
// return EFalse;
|
|
627 |
|
|
628 |
return ETrue;
|
|
629 |
}
|
|
630 |
|
|
631 |
// Compare TPositionCourseInfo type items.
|
|
632 |
if (typeA & typeB & EPositionCourseInfoClass)
|
|
633 |
{
|
|
634 |
TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Both positions are of type EPositionCourseInfoClass");
|
|
635 |
// TODO
|
|
636 |
}
|
|
637 |
|
|
638 |
// Compare TPositionSatelliteInfo type items.
|
|
639 |
if (typeA & typeB & EPositionSatelliteInfoClass)
|
|
640 |
{
|
|
641 |
TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfo() Both positions are of type EPositionSatelliteInfoClass");
|
|
642 |
// TODO
|
|
643 |
}
|
|
644 |
|
|
645 |
/* For extended tests when we have them.
|
|
646 |
if (infoBase.PositionClassType() & EPositionClassTestExtension)
|
|
647 |
{
|
|
648 |
}
|
|
649 |
*/
|
|
650 |
return EFalse;
|
|
651 |
}
|
|
652 |
|
|
653 |
|
|
654 |
EXPORT_C TBool T_LbsUtils::Compare_PosInfoArr(RPointerArray<TAny>& aPosInfoArrSideA, RPointerArray<TAny>& aPosInfoArrSideB)
|
|
655 |
{
|
|
656 |
return Compare_PosInfoArr(aPosInfoArrSideA, aPosInfoArrSideB, EExactAccuracy);
|
|
657 |
}
|
|
658 |
|
|
659 |
EXPORT_C TBool T_LbsUtils::Compare_PosInfoArr(RPointerArray<TAny>& aPosInfoArrSideA, RPointerArray<TAny>& aPosInfoArrSideB, TComparisonAccuracyType aCmpAccuracy)
|
|
660 |
{
|
|
661 |
// Only compare items if the arrays are the same size.
|
|
662 |
if (aPosInfoArrSideA.Count() == aPosInfoArrSideB.Count())
|
|
663 |
{
|
|
664 |
TPositionInfoBase* posInfoA;
|
|
665 |
TPositionInfoBase* posInfoB;
|
|
666 |
TBool res;
|
|
667 |
|
|
668 |
for (TInt i = 0; i < aPosInfoArrSideA.Count(); ++i)
|
|
669 |
{
|
|
670 |
posInfoA = reinterpret_cast<TPositionInfoBase*>(aPosInfoArrSideA[i]);
|
|
671 |
posInfoB = reinterpret_cast<TPositionInfoBase*>(aPosInfoArrSideB[i]);
|
|
672 |
|
|
673 |
res = Compare_PosInfo(*posInfoA, *posInfoB, aCmpAccuracy);
|
|
674 |
if (!res)
|
|
675 |
return EFalse;
|
|
676 |
}
|
|
677 |
}
|
|
678 |
|
|
679 |
else
|
|
680 |
{
|
|
681 |
TESTLOG(ELogP1, "T_LbsUtils::Compare_PosInfoArr() Failed because different number of positions in arrays being compared!");
|
|
682 |
return EFalse;
|
|
683 |
}
|
|
684 |
return ETrue;
|
|
685 |
}
|
|
686 |
|
|
687 |
|
|
688 |
EXPORT_C void T_LbsUtils::ResetAndDestroy_PosInfoArr(RPointerArray<TAny>& aPosInfoArr)
|
|
689 |
{
|
|
690 |
for (TInt i = 0; i < aPosInfoArr.Count(); ++i)
|
|
691 |
delete aPosInfoArr[i];
|
|
692 |
aPosInfoArr.Reset();
|
|
693 |
}
|
|
694 |
|
|
695 |
|
|
696 |
EXPORT_C TPositionModuleId T_LbsUtils::GetNetworkModuleIdL(RPositionServer& aServer)
|
|
697 |
{
|
|
698 |
TPositionModuleId modId;
|
|
699 |
|
|
700 |
User::LeaveIfError(GetModIdByTechnology(aServer, TPositionModuleInfo::ETechnologyNetwork, modId));
|
|
701 |
|
|
702 |
return modId;
|
|
703 |
}
|
|
704 |
|
|
705 |
|
|
706 |
EXPORT_C TPositionModuleId T_LbsUtils::GetAGpsModuleIdL(RPositionServer& aServer)
|
|
707 |
{
|
|
708 |
TPositionModuleId modId;
|
|
709 |
|
|
710 |
User::LeaveIfError(GetModIdByTechnology(aServer, (TPositionModuleInfo::ETechnologyTerminal | TPositionModuleInfo::ETechnologyAssisted), modId));
|
|
711 |
|
|
712 |
return modId;
|
|
713 |
}
|
|
714 |
|
|
715 |
EXPORT_C TPositionModuleId T_LbsUtils::GetBadModuleId()
|
|
716 |
{
|
|
717 |
TPositionModuleId modId;
|
|
718 |
|
|
719 |
modId.iUid = BAD_MODULE_ID;
|
|
720 |
|
|
721 |
return modId;
|
|
722 |
}
|
|
723 |
|
|
724 |
|
|
725 |
EXPORT_C TBool T_LbsUtils::Compare_ModuleInfo(TPositionModuleInfo& aModInfoSideA, TPositionModuleInfo& aModInfoSideB)
|
|
726 |
{
|
|
727 |
// Compare all module information items and quality.
|
|
728 |
|
|
729 |
// Compare module id.
|
|
730 |
if (aModInfoSideA.ModuleId() != aModInfoSideB.ModuleId())
|
|
731 |
{
|
|
732 |
return EFalse;
|
|
733 |
}
|
|
734 |
|
|
735 |
// Compare is available flag.
|
|
736 |
if (aModInfoSideA.IsAvailable() != aModInfoSideB.IsAvailable())
|
|
737 |
{
|
|
738 |
return EFalse;
|
|
739 |
}
|
|
740 |
|
|
741 |
// Compare technology type.
|
|
742 |
if (aModInfoSideA.TechnologyType() != aModInfoSideB.TechnologyType())
|
|
743 |
{
|
|
744 |
return EFalse;
|
|
745 |
}
|
|
746 |
|
|
747 |
// Compare device location.
|
|
748 |
if (aModInfoSideA.DeviceLocation() != aModInfoSideB.DeviceLocation())
|
|
749 |
{
|
|
750 |
return EFalse;
|
|
751 |
}
|
|
752 |
|
|
753 |
// Compare capabilities.
|
|
754 |
if (aModInfoSideA.Capabilities() != aModInfoSideB.Capabilities())
|
|
755 |
{
|
|
756 |
return EFalse;
|
|
757 |
}
|
|
758 |
|
|
759 |
// Compare each of the family classes. Use min and max enum values.
|
|
760 |
for (TInt i = EPositionInfoFamily; i <= EPositionUpdateOptionsFamily; i++)
|
|
761 |
{
|
|
762 |
if (aModInfoSideA.ClassesSupported(static_cast<TPositionClassFamily>(i)) != aModInfoSideB.ClassesSupported(static_cast<TPositionClassFamily>(i)))
|
|
763 |
{
|
|
764 |
return EFalse;
|
|
765 |
}
|
|
766 |
}
|
|
767 |
|
|
768 |
// Compare version.
|
|
769 |
if ((aModInfoSideA.Version().iMajor != aModInfoSideB.Version().iMajor) ||
|
|
770 |
(aModInfoSideA.Version().iMinor != aModInfoSideB.Version().iMinor) ||
|
|
771 |
(aModInfoSideA.Version().iBuild != aModInfoSideB.Version().iBuild))
|
|
772 |
{
|
|
773 |
return EFalse;
|
|
774 |
}
|
|
775 |
|
|
776 |
// Compare module name.
|
|
777 |
TBuf<KPositionMaxModuleName> modNameSideA;
|
|
778 |
TBuf<KPositionMaxModuleName> modNameSideB;
|
|
779 |
|
|
780 |
aModInfoSideA.GetModuleName(modNameSideA);
|
|
781 |
aModInfoSideB.GetModuleName(modNameSideB);
|
|
782 |
if (0 != modNameSideA.Compare(modNameSideB))
|
|
783 |
{
|
|
784 |
return EFalse;
|
|
785 |
}
|
|
786 |
|
|
787 |
// Compare module quality.
|
|
788 |
TPositionQuality qualitySideA;
|
|
789 |
TPositionQuality qualitySideB;
|
|
790 |
|
|
791 |
aModInfoSideA.GetPositionQuality(qualitySideA);
|
|
792 |
aModInfoSideB.GetPositionQuality(qualitySideB);
|
|
793 |
|
|
794 |
return Compare_PositionQuality(qualitySideA, qualitySideB);
|
|
795 |
}
|
|
796 |
|
|
797 |
EXPORT_C TBool T_LbsUtils::Compare_ModuleStatus(TPositionModuleStatus& aModStatusSideA, TPositionModuleStatus& aModStatusSideB)
|
|
798 |
{
|
|
799 |
// Compare device status.
|
|
800 |
if (aModStatusSideA.DeviceStatus() != aModStatusSideB.DeviceStatus())
|
|
801 |
{
|
|
802 |
return EFalse;
|
|
803 |
}
|
|
804 |
|
|
805 |
// Compare quality status.
|
|
806 |
if (aModStatusSideA.DataQualityStatus() != aModStatusSideB.DataQualityStatus())
|
|
807 |
{
|
|
808 |
return EFalse;
|
|
809 |
}
|
|
810 |
|
|
811 |
return TRUE;
|
|
812 |
}
|
|
813 |
|
|
814 |
|
|
815 |
EXPORT_C TBool Compare_ModuleUpdateOptions(TPositionUpdateOptions& aModUpdateOptsSideA, TPositionUpdateOptions& aModUpdateOptsSideB)
|
|
816 |
{
|
|
817 |
// Compare base class items.
|
|
818 |
if(aModUpdateOptsSideA.PositionClassSize() != aModUpdateOptsSideB.PositionClassSize())
|
|
819 |
{
|
|
820 |
return EFalse;
|
|
821 |
}
|
|
822 |
|
|
823 |
if(aModUpdateOptsSideA.PositionClassType() != aModUpdateOptsSideB.PositionClassType())
|
|
824 |
{
|
|
825 |
return EFalse;
|
|
826 |
}
|
|
827 |
|
|
828 |
// Compare interval option.
|
|
829 |
if(aModUpdateOptsSideA.UpdateInterval() != aModUpdateOptsSideB.UpdateInterval())
|
|
830 |
{
|
|
831 |
return EFalse;
|
|
832 |
}
|
|
833 |
|
|
834 |
// Compare timeout option.
|
|
835 |
if(aModUpdateOptsSideA.UpdateTimeOut() != aModUpdateOptsSideB.UpdateTimeOut())
|
|
836 |
{
|
|
837 |
return EFalse;
|
|
838 |
}
|
|
839 |
|
|
840 |
// Compare maxage option.
|
|
841 |
if(aModUpdateOptsSideA.MaxUpdateAge() != aModUpdateOptsSideB.MaxUpdateAge())
|
|
842 |
{
|
|
843 |
return EFalse;
|
|
844 |
}
|
|
845 |
|
|
846 |
// Compare partial update option.
|
|
847 |
if(aModUpdateOptsSideA.AcceptPartialUpdates() != aModUpdateOptsSideB.AcceptPartialUpdates())
|
|
848 |
{
|
|
849 |
return EFalse;
|
|
850 |
}
|
|
851 |
|
|
852 |
return ETrue;
|
|
853 |
}
|
|
854 |
|
|
855 |
|
|
856 |
EXPORT_C TBool T_LbsUtils::Compare_PositionQuality(TPositionQuality& aQualitySideA, TPositionQuality& aQualitySideB)
|
|
857 |
/** Compare two position quality structures.
|
|
858 |
|
|
859 |
@param aQualitySideA
|
|
860 |
@param aQualitySideB
|
|
861 |
*/
|
|
862 |
{
|
|
863 |
// Check if each quality contains the same number of assigned quality items.
|
|
864 |
if (aQualitySideA.HighWaterMark() != aQualitySideB.HighWaterMark())
|
|
865 |
{
|
|
866 |
return EFalse;
|
|
867 |
}
|
|
868 |
|
|
869 |
// Compare each quality item.
|
|
870 |
TInt endId = aQualitySideA.HighWaterMark();
|
|
871 |
|
|
872 |
for (TInt i = 0; i <= endId; i++)
|
|
873 |
{
|
|
874 |
// Element for each side must be defined.
|
|
875 |
if (!aQualitySideA.IsDefined(i) || !aQualitySideB.IsDefined(i))
|
|
876 |
{
|
|
877 |
return EFalse;
|
|
878 |
}
|
|
879 |
|
|
880 |
// Now compare the actual element.
|
|
881 |
TPositionQualityItem::TResult res;
|
|
882 |
if (KErrNone != aQualitySideA.Compare(aQualitySideB, i, res))
|
|
883 |
{
|
|
884 |
return EFalse;
|
|
885 |
}
|
|
886 |
if (TPositionQualityItem::EIsEqual != res)
|
|
887 |
{
|
|
888 |
return EFalse;
|
|
889 |
}
|
|
890 |
}
|
|
891 |
|
|
892 |
return ETrue;
|
|
893 |
}
|
|
894 |
|
|
895 |
|
|
896 |
/**
|
|
897 |
* Verifies that the supplied position is 'reasonable'
|
|
898 |
*
|
|
899 |
*/
|
|
900 |
EXPORT_C TBool T_LbsUtils::Verify_PositionIsValid(TPositionInfo& aPosInfo)
|
|
901 |
{
|
|
902 |
TBool valid = TRUE;
|
|
903 |
TPosition pos;
|
|
904 |
TReal32 alt;
|
|
905 |
TReal64 lat, longt;
|
|
906 |
|
|
907 |
aPosInfo.GetPosition(pos);
|
|
908 |
|
|
909 |
alt = pos.Altitude();
|
|
910 |
lat = pos.Latitude();
|
|
911 |
longt = pos.Longitude();
|
|
912 |
|
|
913 |
// TO DO figure out what values are reasonable here (in Milton somewhere!?)
|
|
914 |
// We could use the normal verify posinfo stuff, and check to see if the values are roughly equal.
|
|
915 |
// Either update this func (add a parameter) or new func like the compare posinfo func we have
|
|
916 |
if(alt == 0 || lat == 0 || longt == 0)
|
|
917 |
{
|
|
918 |
valid = FALSE;
|
|
919 |
}
|
|
920 |
|
|
921 |
|
|
922 |
return valid;
|
|
923 |
}
|
|
924 |
|
|
925 |
|
|
926 |
// May not be required.
|
|
927 |
//EXPORT_C void T_LbsUtils::CreateSimpleAssistanceData(/*TLbsAssistanceDataGroup aDataMask, RDataReaderRootBase& aGpsRefTimeReader*/)
|
|
928 |
// {
|
|
929 |
|
|
930 |
// }
|
|
931 |
|
|
932 |
/** Ensure the simple assistance data is correct. Typically the data is given by the simple
|
|
933 |
assistance data provider module used by the Net Sim.
|
|
934 |
|
|
935 |
@param aRefTimeReader The assistance data reader which holds the reference time data, the
|
|
936 |
reader must be opened (use OpenL()) before calling this function.
|
|
937 |
*/
|
|
938 |
EXPORT_C TBool T_LbsUtils::VerifySimpleAssistanceData(RUEPositioningGpsReferenceTimeReader& aRefTimeReader)
|
|
939 |
{
|
|
940 |
TUint week;
|
|
941 |
TUint tow1MSec;
|
|
942 |
|
|
943 |
// Access the reference time values.
|
|
944 |
aRefTimeReader.GetField(TUEPositioningGpsReferenceTime::EGpsWeek, week);
|
|
945 |
aRefTimeReader.GetField(TUEPositioningGpsReferenceTime::EGpsTow1Msec, tow1MSec);
|
|
946 |
|
|
947 |
// Verify the reference time values.
|
|
948 |
TBool passed = ETrue;
|
|
949 |
|
|
950 |
passed &= (week == KAssistanceData_RefTime_Week);
|
|
951 |
passed &= (tow1MSec == KAssistanceData_RefTime_Tow1MSec);
|
|
952 |
|
|
953 |
return passed;
|
|
954 |
}
|
|
955 |
|
|
956 |
/** Create the module information depending on module id(i'e either agps_manager or network location manager)
|
|
957 |
Fills a module info class/structure with values depending on the module id.
|
|
958 |
|
|
959 |
@param aModuleId module id within the ini file
|
|
960 |
@param aModInfo The modified module info structure.
|
|
961 |
*/
|
|
962 |
EXPORT_C void T_LbsUtils::Create_ModuleInfoL(TPositionModuleId aModuleId, TPositionModuleInfo& aModInfo)
|
|
963 |
|
|
964 |
{
|
|
965 |
TPositionQuality posQuality;
|
|
966 |
|
|
967 |
// Use these values if the module is a-gps manager
|
|
968 |
if (aModuleId == (TUid::Uid(APGS_MODINFO_MODULE_ID)))
|
|
969 |
{
|
|
970 |
aModInfo.SetModuleId(TUid::Uid(APGS_MODINFO_MODULE_ID));
|
|
971 |
aModInfo.SetIsAvailable(AGPS_MODINFO_IS_AVAILABLE);
|
|
972 |
aModInfo.SetModuleName(AGPS_MODINFO_MOD_NAME);
|
|
973 |
aModInfo.SetTechnologyType(AGPS_MODINFO_TECHNOLOGY_TYPE);
|
|
974 |
aModInfo.SetDeviceLocation(AGPS_MODINFO_DEVICE_LOCATION);
|
|
975 |
aModInfo.SetCapabilities(AGPS_MODINFO_CAPABILITIES);
|
|
976 |
|
|
977 |
// Classes Supported - this is a binary bitmap, but support for each class
|
|
978 |
// has to be set individually.
|
|
979 |
|
|
980 |
TInt supportedClasses = AGPS_MODINFO_CLASSES_SUPPORTED_POSITION_FAMILY;
|
|
981 |
TPositionClassFamily currentClass = EPositionInfoFamily;
|
|
982 |
while(currentClass <= EPositionUpdateOptionsFamily)
|
|
983 |
{
|
|
984 |
aModInfo.SetClassesSupported(currentClass, supportedClasses & 1);
|
|
985 |
supportedClasses >>= 1;
|
|
986 |
currentClass = static_cast<TPositionClassFamily>(static_cast<TInt>(currentClass) + 1);
|
|
987 |
}
|
|
988 |
|
|
989 |
aModInfo.SetVersion(AGPS_MODINFO_VERSION);
|
|
990 |
posQuality.SetTimeToFirstFix(AGPS_MODINFO_TIME_TO_FIRST_FIX);
|
|
991 |
posQuality.SetTimeToNextFix(AGPS_MODINFO_TIME_TO_NEXT_FIX);
|
|
992 |
posQuality.SetHorizontalAccuracy(AGPS_MODINFO_HORIZONTAL_ACCURACY);
|
|
993 |
posQuality.SetVerticalAccuracy(AGPS_MODINFO_VERTICAL_ACCURACY);
|
|
994 |
posQuality.SetCostIndicator(AGPS_MODINFO_COST_INDICATOR);
|
|
995 |
posQuality.SetPowerConsumption(AGPS_MODINFO_POWER_CONSUMPTION);
|
|
996 |
aModInfo.SetPositionQuality(posQuality);
|
|
997 |
}
|
|
998 |
|
|
999 |
//need to change after network location manager module is avaliable
|
|
1000 |
//Use these values if the module is network location manager
|
|
1001 |
else if(aModuleId ==(TUid::Uid(NETWORK_MODINFO_MODULE_ID)))
|
|
1002 |
{
|
|
1003 |
aModInfo.SetModuleId(TUid::Uid(NETWORK_MODINFO_MODULE_ID));
|
|
1004 |
aModInfo.SetIsAvailable(NETWORK_MODINFO_IS_AVAILABLE);
|
|
1005 |
aModInfo.SetModuleName(NETWORK_MODINFO_MOD_NAME);
|
|
1006 |
aModInfo.SetTechnologyType(NETWORK_MODINFO_TECHNOLOGY_TYPE);
|
|
1007 |
aModInfo.SetDeviceLocation(NETWORK_MODINFO_DEVICE_LOCATION);
|
|
1008 |
aModInfo.SetCapabilities(NETWORK_MODINFO_CAPABILITIES);
|
|
1009 |
// Classes Supported - this is a binary bitmap, but support for each class
|
|
1010 |
// has to be set individually.
|
|
1011 |
|
|
1012 |
TInt supportedClasses = NETWORK_MODINFO_CLASSES_SUPPORTED_POSITION_FAMILY;
|
|
1013 |
TPositionClassFamily currentClass = EPositionInfoFamily;
|
|
1014 |
while(currentClass <= EPositionUpdateOptionsFamily)
|
|
1015 |
{
|
|
1016 |
aModInfo.SetClassesSupported(currentClass, supportedClasses & 1);
|
|
1017 |
supportedClasses >>= 1;
|
|
1018 |
currentClass = static_cast<TPositionClassFamily>(static_cast<TInt>(currentClass) + 1);
|
|
1019 |
}
|
|
1020 |
|
|
1021 |
aModInfo.SetVersion(NETWORK_MODINFO_VERSION);
|
|
1022 |
posQuality.SetTimeToFirstFix(NETWORK_MODINFO_TIME_TO_FIRST_FIX);
|
|
1023 |
posQuality.SetTimeToNextFix(NETWORK_MODINFO_TIME_TO_NEXT_FIX);
|
|
1024 |
posQuality.SetHorizontalAccuracy(NETWORK_MODINFO_HORIZONTAL_ACCURACY);
|
|
1025 |
posQuality.SetVerticalAccuracy(NETWORK_MODINFO_VERTICAL_ACCURACY);
|
|
1026 |
posQuality.SetCostIndicator(NETWORK_MODINFO_COST_INDICATOR);
|
|
1027 |
posQuality.SetPowerConsumption(NETWORK_MODINFO_POWER_CONSUMPTION);
|
|
1028 |
aModInfo.SetPositionQuality(posQuality);
|
|
1029 |
}
|
|
1030 |
else
|
|
1031 |
{
|
|
1032 |
User::Leave(KErrArgument);
|
|
1033 |
|
|
1034 |
}
|
|
1035 |
}
|
|
1036 |
|
|
1037 |
TInt T_LbsUtils::GetModIdByTechnology(RPositionServer& aServer, TPositionModuleInfo::TTechnologyType aTechnologyType, TPositionModuleId& aModuleId)
|
|
1038 |
/** Searchs for a module which matches the required technology type. Once found the module id of the matched module
|
|
1039 |
is given. The first module found which supports the technology will be returned.
|
|
1040 |
|
|
1041 |
@param aServer A position server. A client must have a connection with the server.
|
|
1042 |
@param aTechnologyType The technology to match.
|
|
1043 |
@param aModuleId The returned module id of the module which supports the required technology.
|
|
1044 |
@return Err code: KErrNone it module found.
|
|
1045 |
KErrNotFound if no module is found which matches the required technology.
|
|
1046 |
Any other system errors.
|
|
1047 |
*/
|
|
1048 |
{
|
|
1049 |
TInt err;
|
|
1050 |
TUint numMods;
|
|
1051 |
|
|
1052 |
err = aServer.GetNumModules(numMods);
|
|
1053 |
if (KErrNone == err)
|
|
1054 |
{
|
|
1055 |
TInt i = 0;
|
|
1056 |
TPositionModuleInfo modInfo;
|
|
1057 |
|
|
1058 |
// Look at each module until we find the required technology type.
|
|
1059 |
while (i < numMods)
|
|
1060 |
{
|
|
1061 |
err = aServer.GetModuleInfoByIndex(i, modInfo);
|
|
1062 |
|
|
1063 |
// Found it.
|
|
1064 |
if (modInfo.TechnologyType() == aTechnologyType)
|
|
1065 |
{
|
|
1066 |
aModuleId = modInfo.ModuleId();
|
|
1067 |
|
|
1068 |
return err;
|
|
1069 |
}
|
|
1070 |
i++;
|
|
1071 |
}
|
|
1072 |
}
|
|
1073 |
|
|
1074 |
else
|
|
1075 |
{
|
|
1076 |
return err;
|
|
1077 |
}
|
|
1078 |
|
|
1079 |
return KErrNotFound;
|
|
1080 |
}
|
|
1081 |
|
|
1082 |
|
|
1083 |
/**
|
|
1084 |
* Method for comparing base class member variables in Logevent types
|
|
1085 |
*/
|
|
1086 |
TBool T_LbsUtils::Compare_LogBase(const CLbsLogEvent& aLogEventSideA, const CLbsLogEvent& aLogEventSideB)
|
|
1087 |
{
|
|
1088 |
if(aLogEventSideA.Direction() != aLogEventSideB.Direction())
|
|
1089 |
return EFalse;
|
|
1090 |
|
|
1091 |
if(aLogEventSideA.EventType() != aLogEventSideB.EventType())
|
|
1092 |
return EFalse;
|
|
1093 |
|
|
1094 |
if(aLogEventSideA.RequestOutcome() != aLogEventSideB.RequestOutcome())
|
|
1095 |
return EFalse;
|
|
1096 |
|
|
1097 |
if(aLogEventSideA.IsCostInformationAvailable() != aLogEventSideB.IsCostInformationAvailable())
|
|
1098 |
return EFalse;
|
|
1099 |
else
|
|
1100 |
{
|
|
1101 |
//check cost info for each side
|
|
1102 |
if(aLogEventSideA.CostInformation() != aLogEventSideB.CostInformation())
|
|
1103 |
return EFalse;
|
|
1104 |
}
|
|
1105 |
|
|
1106 |
TPositionInfoBase* sideAPosInfo = reinterpret_cast<TPositionInfoBase*>(aLogEventSideA.PositionInfo());
|
|
1107 |
TPositionInfoBase* sideBPosInfo = reinterpret_cast<TPositionInfoBase*>(aLogEventSideB.PositionInfo());
|
|
1108 |
if(sideAPosInfo != NULL)
|
|
1109 |
{
|
|
1110 |
// If the actual log has a non-NULL posinfo...
|
|
1111 |
if((*aLogEventSideA.PositionInfo()).ModuleId() != (*aLogEventSideB.PositionInfo()).ModuleId())
|
|
1112 |
return EFalse;
|
|
1113 |
|
|
1114 |
if(!Compare_PosInfo(*aLogEventSideA.PositionInfo(), *aLogEventSideB.PositionInfo()))
|
|
1115 |
return EFalse;
|
|
1116 |
}
|
|
1117 |
else
|
|
1118 |
{
|
|
1119 |
// else cheach that both sides have NULL
|
|
1120 |
if(!(sideAPosInfo == NULL && sideBPosInfo == NULL))
|
|
1121 |
return EFalse;
|
|
1122 |
}
|
|
1123 |
|
|
1124 |
|
|
1125 |
|
|
1126 |
return ETrue;
|
|
1127 |
}
|
|
1128 |
/**
|
|
1129 |
* Method for comparing SelfLocateLog
|
|
1130 |
*/
|
|
1131 |
EXPORT_C TBool T_LbsUtils::Compare_SelfLocateLog(const CLbsSelfLocateLogEvent& aSelfLocateLogSideA, const CLbsSelfLocateLogEvent& aSelfLocateLogSideB)
|
|
1132 |
{
|
|
1133 |
//Compare base class member variables
|
|
1134 |
if(!Compare_LogBase(aSelfLocateLogSideA, aSelfLocateLogSideB))
|
|
1135 |
return EFalse;
|
|
1136 |
|
|
1137 |
if(aSelfLocateLogSideA.LocalApp() != aSelfLocateLogSideB.LocalApp())
|
|
1138 |
return EFalse;
|
|
1139 |
|
|
1140 |
return ETrue;
|
|
1141 |
}
|
|
1142 |
|
|
1143 |
/**
|
|
1144 |
* Method for comparing NetworkLocateLog
|
|
1145 |
*/
|
|
1146 |
EXPORT_C TBool T_LbsUtils::Compare_NetworkLocateLog(const CLbsNetworkLocateLogEvent& aNetworkLocateLogSideA, const CLbsNetworkLocateLogEvent& aNetworkLocateLogSideB)
|
|
1147 |
{
|
|
1148 |
//Compare base class member variables
|
|
1149 |
if(!Compare_LogBase(aNetworkLocateLogSideA, aNetworkLocateLogSideB))
|
|
1150 |
return EFalse;
|
|
1151 |
|
|
1152 |
if(aNetworkLocateLogSideA.LocalApp() != aNetworkLocateLogSideB.LocalApp())
|
|
1153 |
return EFalse;
|
|
1154 |
|
|
1155 |
return ETrue;
|
|
1156 |
}
|
|
1157 |
|
|
1158 |
/**
|
|
1159 |
* Method for comparing ExternalLocateLog
|
|
1160 |
*/
|
|
1161 |
EXPORT_C TBool T_LbsUtils::Compare_ExternalLocateLog(const CLbsExternalLocateLogEvent& aExternalLocateLogSideA, const CLbsExternalLocateLogEvent& aExternalLocateLogSideB)
|
|
1162 |
{
|
|
1163 |
//Compare base class member variables
|
|
1164 |
if(!Compare_LogBase(aExternalLocateLogSideA, aExternalLocateLogSideB))
|
|
1165 |
return EFalse;
|
|
1166 |
|
|
1167 |
if(!Compare_PosInfo(*aExternalLocateLogSideA.ReferenceLocation(), *aExternalLocateLogSideB.ReferenceLocation()))
|
|
1168 |
return EFalse;
|
|
1169 |
|
|
1170 |
if(aExternalLocateLogSideA.RequestOriginator() != aExternalLocateLogSideB.RequestOriginator())
|
|
1171 |
return EFalse;
|
|
1172 |
|
|
1173 |
if(!Compare_ExternalRequestPrivacyRequestParams(aExternalLocateLogSideA.PrivacyRequestParams(), aExternalLocateLogSideB.PrivacyRequestParams()))
|
|
1174 |
return EFalse;
|
|
1175 |
|
|
1176 |
if(!Compare_ExternalRequestPrivacyResponseParams(aExternalLocateLogSideA.PrivacyResponseParams(), aExternalLocateLogSideB.PrivacyResponseParams()))
|
|
1177 |
return EFalse;
|
|
1178 |
|
|
1179 |
return ETrue;
|
|
1180 |
}
|
|
1181 |
|
|
1182 |
|
|
1183 |
|
|
1184 |
/**
|
|
1185 |
* Method for comparing X3PLog
|
|
1186 |
*/
|
|
1187 |
EXPORT_C TBool T_LbsUtils::Compare_TransmitLocationLog(const CLbsTransmitLocationLogEvent& aX3PLogSideA, const CLbsTransmitLocationLogEvent& aX3PLogSideB)
|
|
1188 |
{
|
|
1189 |
//Compare base class member variables
|
|
1190 |
if(!Compare_LogBase(aX3PLogSideA, aX3PLogSideB))
|
|
1191 |
return EFalse;
|
|
1192 |
|
|
1193 |
if(aX3PLogSideA.X3PApp() != aX3PLogSideB.X3PApp())
|
|
1194 |
return EFalse;
|
|
1195 |
|
|
1196 |
if(!Compare_Destinations(aX3PLogSideA.Destination(), aX3PLogSideB.Destination()))
|
|
1197 |
return EFalse;
|
|
1198 |
|
|
1199 |
return ETrue;
|
|
1200 |
}
|
|
1201 |
|
|
1202 |
|
|
1203 |
/**
|
|
1204 |
* Method for comparing AssistanceDataLog
|
|
1205 |
*/
|
|
1206 |
EXPORT_C TBool T_LbsUtils::Compare_AssistanceDataLog(const CLbsAssistanceDataLogEvent& aAssistanceDataLogSideA, const CLbsAssistanceDataLogEvent& aAssistanceDataLogSideB)
|
|
1207 |
{
|
|
1208 |
//Compare base class member variables
|
|
1209 |
if(!Compare_LogBase(aAssistanceDataLogSideA, aAssistanceDataLogSideB))
|
|
1210 |
return EFalse;
|
|
1211 |
|
|
1212 |
if(aAssistanceDataLogSideA.RequestAssistanceDataType() != aAssistanceDataLogSideB.RequestAssistanceDataType())
|
|
1213 |
return EFalse;
|
|
1214 |
|
|
1215 |
|
|
1216 |
if(aAssistanceDataLogSideA.ReceiveAssistanceDataType() != aAssistanceDataLogSideB.ReceiveAssistanceDataType())
|
|
1217 |
return EFalse;
|
|
1218 |
|
|
1219 |
return ETrue;
|
|
1220 |
}
|
|
1221 |
|
|
1222 |
|
|
1223 |
/**
|
|
1224 |
* Method needed to compare external locate logs.
|
|
1225 |
*/
|
|
1226 |
TBool T_LbsUtils::Compare_ExternalRequestPrivacyRequestParams(const TLbsLoggingPrivacyRequestParams& aLogPrivacyRequestParamsSideA, const TLbsLoggingPrivacyRequestParams& aLogPrivacyRequestParamsSideB)
|
|
1227 |
{
|
|
1228 |
if(aLogPrivacyRequestParamsSideA.iSessionId != aLogPrivacyRequestParamsSideB.iSessionId)
|
|
1229 |
return EFalse;
|
|
1230 |
|
|
1231 |
if(!Compare_ExternalRequestInfo(aLogPrivacyRequestParamsSideA.iRequestInfo, aLogPrivacyRequestParamsSideB.iRequestInfo))
|
|
1232 |
return EFalse;
|
|
1233 |
|
|
1234 |
if(!Compare_ExternalRequestPrivacy(aLogPrivacyRequestParamsSideA.iRequestPrivacy, aLogPrivacyRequestParamsSideB.iRequestPrivacy))
|
|
1235 |
return EFalse;
|
|
1236 |
|
|
1237 |
|
|
1238 |
|
|
1239 |
return ETrue;
|
|
1240 |
}
|
|
1241 |
|
|
1242 |
|
|
1243 |
/**
|
|
1244 |
* Method needed to compare external locate logs.
|
|
1245 |
* Compares TLbsExternalRequestInfo class.
|
|
1246 |
*/
|
|
1247 |
TBool T_LbsUtils::Compare_ExternalRequestInfo(const TLbsExternalRequestInfo& aExternalRequestInfoSideA, const TLbsExternalRequestInfo& aExternalRequestInfoSideB)
|
|
1248 |
{
|
|
1249 |
TLbsRequesterId requesterIdSideA, requesterIdSideB;
|
|
1250 |
TLbsClientName clientNameSideA, clientNameSideB;
|
|
1251 |
TLbsClientExternalId clientExternalIdSideA, clientExternalIdSideB;
|
|
1252 |
|
|
1253 |
aExternalRequestInfoSideA.GetRequesterId(requesterIdSideA);
|
|
1254 |
aExternalRequestInfoSideA.GetClientName(clientNameSideA);
|
|
1255 |
aExternalRequestInfoSideA.GetClientExternalId(clientExternalIdSideA);
|
|
1256 |
|
|
1257 |
aExternalRequestInfoSideB.GetRequesterId(requesterIdSideB);
|
|
1258 |
aExternalRequestInfoSideB.GetClientName(clientNameSideB);
|
|
1259 |
aExternalRequestInfoSideB.GetClientExternalId(clientExternalIdSideB);
|
|
1260 |
|
|
1261 |
// If these values are different, then return false
|
|
1262 |
if(requesterIdSideA.Compare(requesterIdSideB)) // Should return 0 if equal
|
|
1263 |
return EFalse;
|
|
1264 |
|
|
1265 |
if(clientNameSideA.Compare(clientNameSideB))
|
|
1266 |
return EFalse;
|
|
1267 |
|
|
1268 |
if(clientExternalIdSideA.Compare(clientExternalIdSideB))
|
|
1269 |
return EFalse;
|
|
1270 |
|
|
1271 |
|
|
1272 |
return ETrue;
|
|
1273 |
}
|
|
1274 |
|
|
1275 |
|
|
1276 |
/**
|
|
1277 |
* Method needed to compare external locate logs.
|
|
1278 |
* Compares TLbsNetPosRequestPrivacy class.
|
|
1279 |
*/
|
|
1280 |
TBool T_LbsUtils::Compare_ExternalRequestPrivacy(const TLbsNetPosRequestPrivacy& aExternalRequestPrivacySideA, const TLbsNetPosRequestPrivacy& aExternalRequestPrivacySideB)
|
|
1281 |
{
|
|
1282 |
if(aExternalRequestPrivacySideA.RequestAdvice() != aExternalRequestPrivacySideB.RequestAdvice())
|
|
1283 |
return EFalse;
|
|
1284 |
|
|
1285 |
if(aExternalRequestPrivacySideA.RequestAction() != aExternalRequestPrivacySideB.RequestAction())
|
|
1286 |
return EFalse;
|
|
1287 |
|
|
1288 |
return ETrue;
|
|
1289 |
}
|
|
1290 |
|
|
1291 |
|
|
1292 |
/**
|
|
1293 |
* Method needed to compare external locate logs.
|
|
1294 |
* Compares TPrivacyResponseParams class.
|
|
1295 |
*/
|
|
1296 |
TBool T_LbsUtils::Compare_ExternalRequestPrivacyResponseParams(const TLbsLoggingPrivacyResponseParams& aExternalRequestPrivacyResponseSideA, const TLbsLoggingPrivacyResponseParams& aExternalRequestPrivacyResponseSideB)
|
|
1297 |
{
|
|
1298 |
if(aExternalRequestPrivacyResponseSideA.iSessionId != aExternalRequestPrivacyResponseSideB.iSessionId)
|
|
1299 |
return EFalse;
|
|
1300 |
|
|
1301 |
if(aExternalRequestPrivacyResponseSideA.iResult != aExternalRequestPrivacyResponseSideB.iResult)
|
|
1302 |
return EFalse;
|
|
1303 |
|
|
1304 |
return ETrue;
|
|
1305 |
}
|
|
1306 |
|
|
1307 |
/**
|
|
1308 |
* Method needed to Transmit to 3rd party destinations
|
|
1309 |
* Compares TDesC16.
|
|
1310 |
*/
|
|
1311 |
TBool T_LbsUtils::Compare_Destinations(TDesC16& aDestinationFromRealLog, TDesC16& aDestinationFromExpectedLog)
|
|
1312 |
{
|
|
1313 |
if(aDestinationFromRealLog != aDestinationFromExpectedLog)
|
|
1314 |
return EFalse;
|
|
1315 |
|
|
1316 |
return ETrue;
|
|
1317 |
}
|
|
1318 |
|