Ejemplo n.º 1
0
/**
* Setup PSY
*/
void SetupPsyL(const TUid aPsyUid)
{
    CPosModules* db = CPosModules::OpenL();
    CleanupStack::PushL(db);

    CPosModuleUpdate* enable = CPosModuleUpdate::NewLC();
    CPosModuleUpdate* disable = CPosModuleUpdate::NewLC();

    disable->SetUpdateAvailability(EFalse);
    enable->SetUpdateAvailability(ETrue);

    CPosModuleIdList* prioList = db->ModuleIdListLC();

    for (TInt i = 0 ; i < prioList->Count(); i++)
    {
        if ((*prioList)[i] != aPsyUid)
        {
            // Disable all PSYs except one given as parameter
            db->UpdateModuleL((*prioList)[i], *disable);
        }
        else
        {
            // Enable the PSY that came as an in parameter
            db->UpdateModuleL((*prioList)[i], *enable);
        }
    }

    CleanupStack::PopAndDestroy(prioList);
    CleanupStack::PopAndDestroy(disable);
    CleanupStack::PopAndDestroy(enable);
    CleanupStack::PopAndDestroy(db);
}
// ---------------------------------------------------------
// CPosTp4708::SetupProxyPSYsL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp4708::SetupProxyPSYsL()
    {
    CPosModules* db = CPosModules::OpenL();
    CleanupStack::PushL(db);

    CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
    moduleUpdate->SetUpdateAvailability(EFalse);
    	
    // Disable all PSY:s except PSYs used by this test case
    CPosModuleIdList* prioList = db->ModuleIdListLC();
    for (TInt i = 0 ; i < prioList->Count(); i++)
        {
        if ((*prioList)[i] !=  iUidTestProxyPsy1 &&
            (*prioList)[i] != iUidTestProxyPsy2)
            {
            db->UpdateModuleL((*prioList)[i], *moduleUpdate);
            }
        }
    moduleUpdate->SetUpdateAvailability(ETrue);
    db->UpdateModuleL(iUidTestProxyPsy1, *moduleUpdate);
    db->UpdateModuleL(iUidTestProxyPsy2, *moduleUpdate);
    
    db->SetModulePriorityL(iUidTestProxyPsy1, 0);
    db->SetModulePriorityL(iUidTestProxyPsy2, 1);
    
    CleanupStack::PopAndDestroy(prioList);
    CleanupStack::PopAndDestroy(moduleUpdate);
    CleanupStack::PopAndDestroy(db);
    } 
Ejemplo n.º 3
0
/**
 * Two-phased constructor.
 *
 * @return A new instance of this class.
 */
EXPORT_C CPosModules* CPosModules::OpenL()
    {
    CPosModules* self = new (ELeave) CPosModules;

    CleanupStack::PushL( self );
    self->ConstructL();
    CleanupStack::Pop(self);

    return self;
    }
void CT_LbsClientStep_ModStat::ConstructL()
    {
    // Re-enable the network PSY
    CPosModules* db = CPosModules::OpenL();
    CleanupStack::PushL(db);

    CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
    
    moduleUpdate->SetUpdateAvailability(ETrue);
    moduleUpdate->SetUpdateVisibility(ETrue);
    TUid uid = TUid::Uid(KPosNETPSYImplUid);
    db->UpdateModuleL(uid, *moduleUpdate);
    
    CleanupStack::PopAndDestroy(moduleUpdate);
    CleanupStack::PopAndDestroy(db);
    }
void CT_LbsMolrTracking::EnablePsy(TInt aPsyUid)
{
    CPosModules* db = CPosModules::OpenL();
    CleanupStack::PushL(db);
    CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();

    CPosModuleIdList* prioList = db->ModuleIdListLC();

    // Enable the PSY that came as an in parameter
    moduleUpdate->SetUpdateAvailability(ETrue);
    db->UpdateModuleL(TUid::Uid(aPsyUid), *moduleUpdate);

    CleanupStack::PopAndDestroy(prioList);
    CleanupStack::PopAndDestroy(moduleUpdate);
    CleanupStack::PopAndDestroy(db);
}
void CTe_locsrvSuiteStepBase::SetupPsyPriorityL(TUid aPsyUid, TInt aPriority)
{
    CPosModules* modules = CPosModules::OpenL();
    CleanupStack::PushL(modules);
    CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();

    // enable module
    moduleUpdate->SetUpdateAvailability(ETrue);
    modules->UpdateModuleL(aPsyUid, *moduleUpdate);

    // set module priority
    modules->SetModulePriorityL(aPsyUid, aPriority);
    CleanupStack::PopAndDestroy(2, modules);   // moduleUpdate, modules

    User::After(KSecond);
}
void CTe_locsrvSuiteStepBase::DisableAllModulesL()
{
    CPosModules* modules = CPosModules::OpenL();
    CleanupStack::PushL(modules);
    CPosModuleIdList* idList = modules->ModuleIdListLC();

    CPosModuleUpdate* update = CPosModuleUpdate::NewLC();
    update->SetUpdateAvailability(EFalse); // disabled

    for (int i = 0; i < idList->Count(); i++)
    {
        modules->UpdateModuleL((*idList)[i], *update);
    }
    CleanupStack::PopAndDestroy(3, modules);

    User::After(KSecond);
}
void CTe_locsrvSuiteStepBase::TogglePsyL(TUid aPsyUid, TBool aEnabled)
{
		INFO_PRINTF1(_L("TogglePsyL() ++"));
    CPosModules* modules = CPosModules::OpenL();
    CleanupStack::PushL(modules);
    CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();

    // toggle module
    INFO_PRINTF2(_L("TogglePsyL with psy 0x%x"), aPsyUid);
    moduleUpdate->SetUpdateAvailability(aEnabled);
    modules->UpdateModuleL(aPsyUid, *moduleUpdate);

    CleanupStack::PopAndDestroy(2);   // moduleUpdate, modules

    User::After(KSecond);
    	
    INFO_PRINTF1(_L("TogglePsyL() --"));
}
void CT_LbsClientStep_CellBasedNotifyPosUpdate::ConstructL()
	{
	// Create the base class object.
    CT_LbsNetSimStep::ConstructL();
	
	// Re-enable the network PSY
    CPosModules* db = CPosModules::OpenL();
    CleanupStack::PushL(db);

    CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
    
    moduleUpdate->SetUpdateAvailability(ETrue);
    moduleUpdate->SetUpdateVisibility(ETrue);
    TUid uid = TUid::Uid(KPosNETPSYImplUid);
    db->UpdateModuleL(uid, *moduleUpdate);
    
    CleanupStack::PopAndDestroy(moduleUpdate);
    CleanupStack::PopAndDestroy(db);
    
    // Active object wrapper for the notify position update.
	iDoPosUpdate = CT_LbsDoPosUpdate::NewL(this, TPositionModuleInfo::ETechnologyNetwork);
	
	}
void CTe_locsrvSuiteStepBase::StandardPrepareL()
{
    // Setup modules:
    // LcfDummyPsy1,3 and LcfPsy6 should be enabled, other - disabled
    CPosModules* modules = CPosModules::OpenL();
    CleanupStack::PushL(modules);
    CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();

    CPosModuleIdList* idList = modules->ModuleIdListLC();
    for (TInt i = 0; i < idList->Count(); i++)
        {
        TPositionModuleInfo info;
        modules->GetModuleInfoL((*idList)[i], info);
        switch (info.ModuleId().iUid)
            {
            case KLcfPsy1UidValue:
            case KLcfPsy3UidValue:
            case KLcfPsy6UidValue:
                if (!info.IsAvailable())
                    {
                    moduleUpdate->SetUpdateAvailability(ETrue);
                    modules->UpdateModuleL(info.ModuleId(), *moduleUpdate);
                    }
                break;
            default:        
                if (info.IsAvailable())
                    {
                    moduleUpdate->SetUpdateAvailability(EFalse);
                    modules->UpdateModuleL(info.ModuleId(), *moduleUpdate);
                    }
                break;
            }
        }
    CleanupStack::PopAndDestroy(3, modules);
    User::After(KSecondsToMicro);
}
Ejemplo n.º 11
0
// ---------------------------------------------------------
// CT_LbsClientPosTp76::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp76::StartL()
    {
	// Open connection to Epos    
	RPositionServer posServer;
	CleanupClosePushL(posServer);
	TInt err = posServer.Connect();    
	_LIT(KConnectError, "TP76. Unable to open connection to Epos, return code %d");
	AssertTrueSecL(err == KErrNone, KConnectError, err);

	// Set priority for those psys that will be used in this tp.
	// The order will be testpsy1(externalgps),testpsy2,testpsy3
	TUid uidPsy1 = iUidTestPsy1;
	TUid uidPsy2 = iUidTestPsy2;
	TUid uidPsy3 = iUidTestPsy3;

    SetupPsyL(uidPsy1); // will disable all except uidPsy1

    CPosModules* db = CPosModules::OpenL();
    CleanupStack::PushL(db);

    // Enable the PSY test psys 
    CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
    moduleUpdate -> SetUpdateAvailability(ETrue);
    db->SetModulePriorityL(uidPsy1, 0);
    db->SetModulePriorityL(uidPsy2, 1);
    db->SetModulePriorityL(uidPsy3, 1);
    db->UpdateModuleL(uidPsy1, *moduleUpdate);
    db->UpdateModuleL(uidPsy2, *moduleUpdate);
    db->UpdateModuleL(uidPsy3, *moduleUpdate);
    CleanupStack::PopAndDestroy(moduleUpdate);

    // Setup the PSY:s in the correct order
    CPosModuleIdList* prioList = db->ModuleIdListLC();
    TInt numModules = prioList->Count();
    TPositionModuleInfo modInfoPsy2; //used to comapre that the same result is returned.
    db -> GetModuleInfoL(uidPsy2, modInfoPsy2);
    CleanupStack::PopAndDestroy(2); // db, prioList
	
	// Get default positioning module info. (testpsy1 or externalgps)
	TPositionModuleInfo modInfo;
    TPositionModuleId defaultId;
    err = posServer.GetDefaultModuleId(defaultId);
    _LIT(KDefaultModuleId, "Not possible to get default module id");
    AssertTrueSecL(err == KErrNone, KDefaultModuleId, err);
    // Check that the correct id was returned.
    if (defaultId != uidPsy1)
        {
        _LIT(KErrorWrongModule, "Default module was not returned in GetDefaultModuleId()");
        LogErrorAndLeaveL(KErrorWrongModule);
        }

    // Get default module info by using the id returned.
    err = posServer.GetModuleInfoById(defaultId, modInfo);
	_LIT(KGetDefPosModInfoError,
            "TP76. Error occured at GetModuleInfoById, return code %d");
	AssertTrueSecL(err == KErrNone, KGetDefPosModInfoError, err);
	// Check if the received psy is the right one
	_LIT(KIncorrectPsyError,
           "TP76. Incorrect PSY returned from Epos.");
	AssertTrueL(uidPsy1 == modInfo.ModuleId(), KIncorrectPsyError);
    //END TEST DEFAULT//

	//
    // TestGetModuleInfoById //
	//

    // Get info from specific psy (testpsy2)
	_LIT(KGetPosModInfoError, "Wrong data received from Epos");
    err = posServer.GetModuleInfoById(uidPsy2, modInfo);
	AssertTrueSecL(err == 0, KGetPosModInfoError, err);
	AssertTrueL(modInfo.ModuleId() == uidPsy2, KGetPosModInfoError);
    CheckModuleInfoL(modInfoPsy2, modInfo);
    //END TEST GetModuleInfoById//

	//
    // Test GetModuleInfoByIndex //
	//

	// Get info from the testpsys (testpsy1, testpsy2, testpsy3)
    TPositionModuleId id1;
    TPositionModuleId id2;
    TPositionModuleId id3;
    TUint count;
	err = posServer.GetNumModules(count);
	_LIT(KNumPosModInfoError,
            "TP76. Error occured at GetNumModules error code returned, return code %d");
	AssertTrueSecL(err == 0,KNumPosModInfoError,err);
	_LIT(KIncorrectNoOfModules,
           "TP76. Incorrect number of modules.");
    TUint no = (TUint) numModules; //Bad API implementation
	AssertTrueL(count == no, KIncorrectNoOfModules);

    err = posServer.GetModuleInfoByIndex(0, modInfo);
    AssertTrueSecL(err == KErrNone, KGetDefPosModInfoError, err);
    id1 = modInfo.ModuleId();
    if (!(id1 == uidPsy1 ||
        id1 == uidPsy2 ||
        id1 == uidPsy3))
        {
        LogErrorAndLeaveL(KGetPosModInfoError);
        }

    err = posServer.GetModuleInfoByIndex(1, modInfo);
    AssertTrueSecL(err == 0, KGetDefPosModInfoError, err);
    id2 = modInfo.ModuleId();
    if (!(id2 == uidPsy1 ||
        id2 == uidPsy2 ||
        id2 == uidPsy3))
        {
        LogErrorAndLeaveL(KGetPosModInfoError);
        }

    err = posServer.GetModuleInfoByIndex(2, modInfo);
    AssertTrueSecL(err == 0, KGetDefPosModInfoError, err);
    id3 = modInfo.ModuleId();
    if (!(id3 == uidPsy1 ||
        id3 == uidPsy2 ||
        id3 == uidPsy3))
        {
        LogErrorAndLeaveL(KGetPosModInfoError);
        }
    
    // Assuming that only 3 PSYs are installed
    err = posServer.GetModuleInfoByIndex(3, modInfo);
    AssertTrueSecL(err == 0, KGetDefPosModInfoError, err);

    // END TEST GetModuleInfoByIndex //

	CleanupStack::PopAndDestroy(); //posServer
	}
Ejemplo n.º 12
0
// ---------------------------------------------------------
// CT_LbsClientPosTp1::StartL
//
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsClientPosTp1::StartL()
    {
    ConnectL();
    
    CPosModules* db = CPosModules::OpenL();
    CleanupStack::PushL(db); 

    SetupPsyL(iUidMultiPsy);

    _LIT(KSetupPSY, "TP1: Has Setup Multi PSY");
    INFO_PRINTF1(KSetupPSY);
    
    //setting priority
	TPositionModuleInfo moduleInfoHp;//Hp - high prio;
	TPositionModuleInfo moduleInfoLp;//Lp - low prio;

    CPosModuleIdList* prioList = db->ModuleIdListLC();	
    db->GetModuleInfoL(prioList->At(0), moduleInfoHp);

    CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC();
    moduleUpdate->SetUpdateAvailability(ETrue);

    if (iUidMultiPsy.iUid == moduleInfoHp.ModuleId().iUid)
		{
		// Case when Multi PSY has highest prio: 
		// Ensuring it is enabled
	    _LIT(KMultiHighest, "TP1: Case when Multi PSY has highest prio");
	    INFO_PRINTF1(KMultiHighest);	    
		db->UpdateModuleL((*prioList)[0], *moduleUpdate);
		}
	else
		{
		// Case when Multi PSY has not highest prio: 
		// 
	    _LIT(KMultiNotHighest, "TP1: Case when Multi PSY has NOT highest prio");	    
	    INFO_PRINTF1(KMultiNotHighest);	    
        db->GetModuleInfoL(iUidMultiPsy, moduleInfoLp);
		// Ensuring it is enabled
		db->UpdateModuleL(iUidMultiPsy, *moduleUpdate);

		TUint hp = db->PriorityL(moduleInfoHp.ModuleId());
		TUint lp = db->PriorityL(moduleInfoLp.ModuleId());

		// Changing prio of highest prio PSY and Multi PSY.
		// Setting Multi PSY to highest prio
		db->SetModulePriorityL(iUidMultiPsy, hp);
        db->SetModulePriorityL((*prioList)[0], lp); 
		}

	_LIT(KTestPSY1On, "TP1: Enabling Test PSY 1");
    INFO_PRINTF1(KTestPSY1On);	    
	db -> UpdateModuleL(iUidTestPsy1, *moduleUpdate);
	_LIT(KTestPSY2On, "TP1: Enabling Test PSY 2");
    INFO_PRINTF1(KTestPSY2On);
	db -> UpdateModuleL(iUidTestPsy2, *moduleUpdate);
    
	CleanupStack::PopAndDestroy(moduleUpdate);
	CleanupStack::PopAndDestroy(2, db); // db, prioList

    User::LeaveIfError(OpenPositioner());

    // Request data from default psy should be Multi psy
    _LIT(KService, "service");
    TPositionInfo posInfo = TPositionInfo();
    TInt err = PerformSyncRequest(KService, &posInfo);
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "The request was not completed with KErrNone");
        LogErrorAndLeaveL(KErrorRequest, err);
        }
	
    if (iUidMultiPsy.iUid != posInfo.ModuleId().iUid)
		{
		_LIT(KIncorrectPsyError, "TP1. Position from wrong PSY received");
		LogErrorAndLeaveL(KIncorrectPsyError);
		}

	HPositionGenericInfo* genericInfo = HPositionGenericInfo::NewLC();
	err = PerformSyncRequest(KService, &(*genericInfo));
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "The request was not completed with KErrNone");
        LogErrorAndLeaveL(KErrorRequest);
        }

	 if (iUidMultiPsy.iUid != (genericInfo -> ModuleId()).iUid)
		{
		_LIT(KIncorrectPsyError,
           "TP1. Position from wrong PSY received");
		LogErrorAndLeaveL(KIncorrectPsyError);
		}

	TPositionCourseInfo courseInfo = TPositionCourseInfo();
	err = PerformSyncRequest(KService, &courseInfo);
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "Course info supported by default, but request failed");
        LogErrorAndLeaveL(KErrorRequest);
        }

	TPositionSatelliteInfo satelliteInfo = TPositionSatelliteInfo();
	err = PerformSyncRequest(KService, &satelliteInfo);
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "Satellite info supported by default, but request failed");
        LogErrorAndLeaveL(KErrorRequest);
        }	

    //Changing the priority and verifiy that it still possilbe
    //to request updated from a psy if basic position information
    //is used and that it is not possilbe to request sat or cource
    //any more.
    SetupPsyL(iUidTestPsy2);
    User::After(3000000);

    // Request data from default psy should be test psy 2 now
    err = PerformSyncRequest(KService, &posInfo);
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "The request was not completed with KErrNone");
        LogErrorAndLeaveL(KErrorRequest);
        }
	
    if (iUidTestPsy2.iUid != posInfo.ModuleId().iUid)
		{
		_LIT(KIncorrectPsyError,
           "TP1. Position from wrong PSY received");
		LogErrorAndLeaveL(KIncorrectPsyError);
		}

	err = PerformSyncRequest(KService, &(*genericInfo));
    if (err != KErrNone)
        {
        _LIT(KErrorRequest, "The request was not completed with KErrNone");
        LogErrorAndLeaveL(KErrorRequest);
        }

	 if (iUidTestPsy2.iUid != (genericInfo -> ModuleId()).iUid)
		{
		_LIT(KIncorrectPsyError,
           "TP1. Position from wrong PSY received");
		LogErrorAndLeaveL(KIncorrectPsyError);
        }

    err = PerformSyncRequest(KService, &courseInfo);
    if (err != KErrArgument)
        {
        _LIT(KErrorRequest, "Course info not supported by default, KErrArgument not returned");
        LogErrorAndLeaveL(KErrorRequest);
        }


	err = PerformSyncRequest(KService, &satelliteInfo);
    if (err != KErrArgument)
        {
        _LIT(KErrorRequest, "Satellite info not supported by default, KErrArgument not returned");
        LogErrorAndLeaveL(KErrorRequest);
        }

    //check that it is possilbe to change the different
    //type of class info during periodic request and
    //that the periodic update will fail if the class
    //type is incorrect.
    TTimeIntervalMicroSeconds interval = TTimeIntervalMicroSeconds(1000000);
    TPositionUpdateOptions posOption;
	posOption.SetUpdateInterval(interval);
	_LIT(KUpdateErr, "Error when setting update interval,  %d");
	err = iPositioner.SetUpdateOptions(posOption);
    AssertTrueL(err == KErrNone, KUpdateErr, err);

    _LIT(KErrPeriodic, "The periodic request did not return KErrNone, %d");
    err = PerformSyncRequest(KService, &posInfo);
    AssertTrueL(err == KErrNone , KErrPeriodic, err);
    
    _LIT(KErrPeriodicArr, "The periodic request did not return KErrArgument, %d");
    err = PerformSyncRequest(KService, &satelliteInfo);
    AssertTrueL(err == KErrArgument , KErrPeriodicArr, err);
    SetupPsyL(iUidMultiPsy);
    User::After(3000000);
    err = PerformSyncRequest(KService, &satelliteInfo);
    AssertTrueL(err == KErrNone , KErrPeriodic, err);

    CleanupStack::PopAndDestroy(genericInfo);
    ClosePositioner();
    Disconnect();
    }