TBool CLbsRootApiTest22Step::CheckProcessIsRunning(const TDesC& aProcessNamePattern)
	{
	TInt err = KErrNone;
	RProcess process;
	TFullName fullName;
	TFindProcess findProcess;
	TBool runningInstanceFound = EFalse;
	
	findProcess.Find(aProcessNamePattern);
	while (err = findProcess.Next(fullName), err == KErrNone)
		{
		TInt processOpenErr = process.Open(findProcess);
		if (processOpenErr == KErrNone)
			{
			TExitType exitType = process.ExitType();
			if (exitType == EExitPending)
				{
				// found a running instance of the process,
				// so assume everything is ok; return ETrue
				runningInstanceFound = ETrue;
				process.Close();
				break;
				}
			}
			process.Close();
		}
	
	return runningInstanceFound;	
	}
// ----------------------------------------------------------------------------------------
// CTerminalControlServer::StopProcessL
// ----------------------------------------------------------------------------------------
void CTerminalControlServer::StopProcessByUidL ( const TUid& aUID )
{
    RDEBUG("CTerminalControlServer::StopProcessByUidL");

    TInt rounds = 5;

    while( rounds-- )
    {
        TFullName    processName;
        TFindProcess findProcess;
        TInt ret = KErrNone;

        while( KErrNone == ( ret = findProcess.Next( processName ) ) )
        {
            RProcess process;

            if( KErrNone == ( ret = process.Open( findProcess ) ) )
            {
                if( aUID == process.SecureId() )
                {
                    RDEBUG("CTerminalControlServer::StopProcessByUidL Process with correct UID found => Kill(0) ");
                    process.Kill( 0 );
                }
            }
            else
            {
                RDEBUG_2("CTerminalControlServer::StopProcessByUidL process.Open returned %d", ret );
            }
        }
        if( KErrNone != ret )
        {
            RDEBUG_2("CTerminalControlServer::StopProcessByUidL findProcess.Next returned %d", ret );
        }
    }
}
Ejemplo n.º 3
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
TBool CTraceContainer::IsServerOn()
{
	TBool Ret(EFalse);
	
	TFileName res;
	TFindProcess find;
  	while(find.Next(res) == KErrNone)
    {
    	RProcess ph;
	  	ph.Open(res);
	  	  			
	  	if(ph.SecureId() == (TUint32)KUidTraceServerUID.iUid)
	 	{
	 		TExitType Exxit =ph.ExitType();
	 		if(Exxit == EExitPending)
	 		{
		  		Ret = ETrue;
		  		break;
	 		}
	  	}
	  	
	  	ph.Close();
    }
 
    return Ret;
}
Ejemplo n.º 4
0
TBool IsAlreadyRunning()
{
	RDebug::Print(_L("TrkLauncher::IsAlreadyRunning()"));

	_LIT(KTrkConsoleSearchPattern, "*TRKPROCESS*");
	_LIT(KTrkConsoleProcessPattern, "*");
	
	TFindProcess finder;
	TFullName fullName;
	TBool found = EFalse;
	finder.Find(KTrkConsoleProcessPattern);

	while (!found && finder.Next(fullName) == KErrNone)
	{
		fullName.UpperCase();
		
		if (fullName.Match(KTrkConsoleSearchPattern) != KErrNotFound)
		{
			found = ETrue;
			RDebug::Print(_L("process found Inside while"));
			break;
		}
	}

	if (found)
	{
		RDebug::Print(_L("TrkLauncher - Process found outside while"));
	}
	else
	{
		RDebug::Print(_L("TrkLauncher - Process was never found"));
	}
		
	return found;
}
Ejemplo n.º 5
0
/* 
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CExPolicy_Server::KillProcess(TDes8& aName)
{
	TFileName res,Hjep;
	
	Hjep.Copy(aName);
	TFindProcess find;
	while(find.Next(res) == KErrNone)
	{
		if(Hjep == res)
		{
			RProcess ph;
	  		ph.Open(find);
			ph.Kill(0);
			break;	
		}
	}
}
/* Forces the shutdown of the LbsNetGateway executable.
*/
TInt CTe_LbsNetworkPrivacySuiteStepBase::StopNetGateway()
	{
	// Shutdown the network gateway via the process 
	// supervisor api that LbsRoot uses.
	TRAPD(err, iProcessSupervisor.OpenL(KDummyNetworkGatewayUid));
	if (err == KErrNone)
		{
		// Find the network gateway manager process
		RProcess process;
		TFullName fullName;
		TFindProcess findProcess;
		_LIT(KGatewayProcessPattern, "te_dummynetgateway.exe*");
		TBool runningInstanceFound = EFalse;
		
		findProcess.Find(KGatewayProcessPattern);
		while (err = findProcess.Next(fullName), err == KErrNone)
			{
			TInt processOpenErr = process.Open(findProcess);
			if (processOpenErr == KErrNone)
				{
				TExitType exitType = process.ExitType();
				if (exitType == EExitPending)
					{
					// found a running instance of the process,
					// so assume everything is ok;
					runningInstanceFound = ETrue;
					break;
					}
				}
				process.Close();
			}
		
		if (runningInstanceFound)
			{
			TRequestStatus status;
			process.Logon(status);
			iProcessSupervisor.CloseDownProcess();
			User::WaitForRequest(status);
			process.Close();
			iProcessSupervisor.Close();
			}
		}
	return err;
	}
Ejemplo n.º 7
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
TBool CCrashContainer::IsServerOn()
{
	TBool Ret(EFalse);
	
	TFileName res;
	TFindProcess find;
  	while(find.Next(res) == KErrNone)
    {
    	RProcess ph;
	  	ph.Open(res);
	  	  			
	  	if(ph.SecureId() == (TUint32)KUidCrashServerUID.iUid)
	 	{
	  		Ret = ETrue;
	  		break;
	  	}
	  	
	  	ph.Close();
    }
 
    return Ret;
}
Ejemplo n.º 8
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
TBool CMgAppUi::IsDrawerOn(void)
{
	TBool Ret(EFalse);
	
	TFileName res;
	TFindProcess find;
  	while(find.Next(res) == KErrNone)
    {
    	RProcess ph;
	  	ph.Open(res);
	  	  			
	  	if(ph.SecureId() == (TUint32)(KUidServer.iUid))
	 	{
	  		Ret = ETrue;
	  		break;
	  	}
	  	
	  	ph.Close();
    }
 
    return Ret;
}
// ==============================================================
// ============ DoKillProcessL()                    =============
// ==============================================================
void DoKillProcessL( const TDesC& aProcessName )
    {
    TFullName psName;
    psName.Append( _L("*") );
    psName.Append( aProcessName );
    psName.Append( _L("*") );

    TFindProcess psFinder;
    psFinder.Find( psName );

    TInt killCount( 0 );
    while( psFinder.Next( psName ) != KErrNotFound )
        {
        RProcess ps;
        User::LeaveIfError( ps.Open( psFinder ) );
        ps.Kill( -666 );
        ps.Close();
        killCount++;
        }

    User::Leave( killCount );
    }
Ejemplo n.º 10
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
TBool CMainContainer::IsServerOn(const TDesC& aName)
{
	TBool Ret(EFalse);
	
	TFileName res;
	TFindProcess find;
  	while(find.Next(res) == KErrNone)
    {
    	RProcess ph;
	  	ph.Open(res);
	  	  			
		if(ph.FileName().Find(aName) != KErrNotFound)
	 	{
	  		Ret = ETrue;
	  		break;
	  	}
	  	
	  	ph.Close();
    }
 
    return Ret;
}
Ejemplo n.º 11
0
// ----------------------------------------------------------------------------
// Searches process id for target selector plugin.
// When the player has been opened in a mode, which is bound to the same engine
// than certain application's engine, then need to fetch its process id.
// (As a reference for parameter aMode see MMPXPlaybackUtility modes.)
// Otherwise target selector plugin is notified wrongly about registered client
// and key events are not propagated to correct application.
// ----------------------------------------------------------------------------
//
static void FindProcessIdForTsp( TInt aMode, TProcessId& aProcessId )
    {
    TBool processFound( EFalse );
    TFindProcess processFinder;
    TFullName processName;

    while ( processFinder.Next( processName ) == KErrNone && !processFound )
        {
        RProcess process;
        TInt err = process.Open( processFinder );
        if( err == KErrNone )
            {
            if( process.SecureId().iId == aMode && process.ExitType() == EExitPending )
                {
                MPX_DEBUG4("FindProcessIdForTsp(): pid changed from %d to %d (mode 0x%x)",
                           TUint(aProcessId), TUint(process.Id()), aMode);
                aProcessId = process.Id();
                processFound = ETrue;
                }
            process.Close();
            }
        }
    }
Ejemplo n.º 12
0
HBufC8* CAgentDevice::GetInfoBufferL()
	{
	//create buffer	
	CBufBase* buffer = CBufFlat::NewL(50);
	CleanupStack::PushL(buffer);

	TBuf<128> buf;
	_LIT(KNewLine,"\n");
			
	// Processor
	TInt cpu = 0;
	HAL::Get(HAL::ECPU,cpu);
	TBuf<8> cpuBuf;
	switch (cpu){
		case HAL::ECPU_ARM:
			cpuBuf.Copy(_L("ARM"));
			break;
		case HAL::ECPU_MCORE:
			cpuBuf.Copy(_L("MCORE"));
			break;
		case HAL::ECPU_X86:
			cpuBuf.Copy(_L("X86"));
			break;
		default:
			cpuBuf.Copy(_L("Unknown"));
			break;
	}
	_LIT(KFormatProcessor,"Processor: %S\n");
	buf.Zero();
	buf.Format(KFormatProcessor,&cpuBuf);
	buffer->InsertL(buffer->Size(),buf.Ptr(),buf.Size());
	 
	// Battery
	_LIT(KFormatBattery,"Battery: %u%%  (on AC line)\n");
	_LIT(KFormatBattery2,"Battery: %u%%  \n");
	TUint chargeLevel=0;
	CTelephony::TBatteryStatus batteryStatus;
	iPhone->GetBatteryInfoSync(chargeLevel, batteryStatus);  
	buf.Zero();
	if((batteryStatus == CTelephony::EBatteryConnectedButExternallyPowered) || (batteryStatus == CTelephony::ENoBatteryConnected))
		{
		buf.Format(KFormatBattery,chargeLevel);
		}
	else
		{
		buf.Format(KFormatBattery2,chargeLevel);
		}
	buffer->InsertL(buffer->Size(),buf.Ptr(),buf.Size());
	
	// RAM
	TInt ram = 0;
	HAL::Get(HAL::EMemoryRAM, ram);
	TInt freeRam = 0;
	HAL::Get(HAL::EMemoryRAMFree, freeRam);
	_LIT(KFormatRam,"Memory: %i bytes free / %i bytes total\n");
	buf.Zero();
	buf.Format(KFormatRam,freeRam,ram);
	buffer->InsertL(buffer->Size(),buf.Ptr(),buf.Size());

	// Storage
	_LIT(KFormatStorage,"Disk %c: %S - %Li bytes free / %Li bytes total\n");
	TVolumeInfo volumeInfo;
	//TDriveInfo  driveInfo;
	for (TInt driveNumber=EDriveA; driveNumber<=EDriveZ; driveNumber++)
		{
		// get drive info
		/*
		TInt err = iFs.Drive(driveInfo,driveNumber);
		if (err!=KErrNone) 
			{
			continue;
			}
		*/
		// get volume info
		TInt err = iFs.Volume(volumeInfo,driveNumber);
		if (err!=KErrNone)
			{
			 continue;
			}
		TChar letter;
		iFs.DriveToChar(driveNumber,letter);
		buf.Zero();
		buf.Format(KFormatStorage,(TUint)letter,&volumeInfo.iName,volumeInfo.iFree,volumeInfo.iSize);
		buffer->InsertL(buffer->Size(),buf.Ptr(),buf.Size());
		}
		
	// OS version
	TBuf<KSysUtilVersionTextLength> versionBuf;
	SysUtil::GetSWVersion(versionBuf);
	_LIT(KFormatOsVersion,"\nOS Version: %S \n");
	buf.Zero();
	buf.Format(KFormatOsVersion,&versionBuf);
	buffer->InsertL(buffer->Size(),buf.Ptr(),buf.Size());

	// device
	_LIT(KFormatDevice,"\nDevice: %S (%S)\n");
	TBuf<CTelephony::KPhoneManufacturerIdSize> manufacturer;
	TBuf<CTelephony::KPhoneModelIdSize> model;
	iPhone->GetPhoneIdSync(manufacturer,model);
	buf.Zero();
	buf.Format(KFormatDevice,&model,&manufacturer);
	buffer->InsertL(buffer->Size(),buf.Ptr(),buf.Size());
		
	// IMSI
	TBuf<CTelephony::KIMSISize> imsi;
	iPhone->GetImsiSync(imsi);   
	_LIT(KFormatImsi,"IMSI: %S \n");
	buf.Zero();
	buf.Format(KFormatImsi,&imsi);
	buffer->InsertL(buffer->Size(),buf.Ptr(),buf.Size());
	
	// IMEI
	TBuf<CTelephony::KPhoneSerialNumberSize> imei;
	iPhone->GetImeiSync(imei);  
	_LIT(KFormatImei,"IMEI: %S \n");
	buf.Zero();
	buf.Format(KFormatImei,&imei);
	buffer->InsertL(buffer->Size(),buf.Ptr(),buf.Size());

	// Carrier
	//TBuf<CTelephony::KNetworkShortNameSize> carrier;
	TBuf<CTelephony::KNetworkLongNameSize> carrier;
	iPhone->GetOperatorNameSync(carrier); 
	_LIT(KFormatCarrier,"Carrier: %S \n");
	buf.Zero();
	buf.Format(KFormatCarrier,&carrier);
	buffer->InsertL(buffer->Size(),buf.Ptr(),buf.Size());
	
	// Uptime
	_LIT(KFormatUptime,"Uptime: %i days, %i hours, %i minutes\n");
	TInt ms = User::NTickCount();
	TInt min = (ms/(1000*60))%60;
	TInt hours = (ms/(1000*60*60))%24;
	TInt days = (ms/(1000*60*60*24));
	buf.Zero();
	buf.Format(KFormatUptime,days,hours,min);
	buffer->InsertL(buffer->Size(),buf.Ptr(),buf.Size());
		
	if(iList)
		{
		RApaLsSession lsSession;
		TApaAppInfo appInfo;
		TApaAppCapabilityBuf capability;
		//_LIT(KNewLine,"\n");
		// Applications list:
		if( lsSession.Connect() == KErrNone)
			{
			CleanupClosePushL( lsSession );
			lsSession.GetAllApps();
			_LIT(KAppList,"\nApplication List: \n");
			buffer->InsertL(buffer->Size(),KAppList().Ptr(),KAppList().Size());
			while( lsSession.GetNextApp( appInfo ) == KErrNone )
				{
				buffer->InsertL(buffer->Size(), appInfo.iCaption.Ptr(), appInfo.iCaption.Size());
				buffer->InsertL(buffer->Size(),KNewLine().Ptr(),KNewLine().Size());
				}
			CleanupStack::PopAndDestroy(&lsSession);
			}
		// Running processes
		TFullName res;
		TFindProcess proc;
		_LIT(KProcList,"\nProcesses List:\n");
		buffer->InsertL(buffer->Size(),KProcList().Ptr(),KProcList().Size());
		while(proc.Next(res) == KErrNone)
		    {
		      	RProcess ph;
		      	TInt err = ph.Open(proc);
		      	if(err!=KErrNone)
		      		{
					continue;
		      		}
		      	buffer->InsertL(buffer->Size(),ph.Name().Ptr(),ph.Name().Size());
		      	buffer->InsertL(buffer->Size(),KNewLine().Ptr(),KNewLine().Size());
		      	ph.Close();
		    }
		}
	
	HBufC8* result = buffer->Ptr(0).AllocL();
	CleanupStack::PopAndDestroy(buffer);
	return result;
	}
Ejemplo n.º 13
0
LOCAL_C void mainL()
	{
	CCommandLineArguments* cmdLine = CCommandLineArguments::NewLC();
	TInt argTotal=cmdLine->Count();
	if (argTotal < 2 || argTotal > 3)
		{
		User::Leave(KErrArgument);
		}
	TUint sidRequested;
	TLex processLex(cmdLine->Arg(1));
	User::LeaveIfError(processLex.Val(sidRequested, EHex));
	if (sidRequested == 0)
		{
		User::Leave(KErrArgument);
		}
	
	if (argTotal == 3)
		{
		TUint timeout;
		TLex timeoutLex(cmdLine->Arg(2));
		User::LeaveIfError(timeoutLex.Val(timeout));
		if (timeout > 0)
			{
			User::After(timeout);
			}
		}

	TUid sid = {sidRequested};
	TBool needToScanFullList;
	TFullName fullName;

	do
		{
		needToScanFullList = EFalse;
		TFindProcess findProcess;

		while(findProcess.Next(fullName) == KErrNone)
			{
			RProcess process;
			TInt ret=KErrNone;
			TInt count=0;
			do
			{
			count++;
 			ret=process.Open(findProcess);
			if (ret!=KErrNone)
				{
				User::After(200000);
				}
			}while (ret!=KErrNone && count<=10);
			if (ret!=KErrNone)
				{
				User::Leave(ret);
				}

			TUid processSid(process.SecureId());
			if (processSid == sid && process.ExitType() == EExitPending)
				{
				process.Kill(KErrNone);
				needToScanFullList = ETrue;
				}
			process.Close();
			}
		} while (needToScanFullList);

	CleanupStack::PopAndDestroy(cmdLine);
	}
// ----------------------------------------------------------------------------------------
// CTerminalControlServer::StopProcessByFullNameL
// ----------------------------------------------------------------------------------------
void CTerminalControlServer::StopProcessByFullNameL(const TDesC8& aName) {
    RDEBUG("[CTerminalControlServer]-> StopProcessByFullNameL() >>>");


    TInt rounds = 5;
    TFileName lMatchStr;
    lMatchStr.Copy(aName);
    lMatchStr.LowerCase();

    TBool lIsAbsolute = EFalse;
    if(lMatchStr.LocateReverse(TChar('\\')) != KErrNotFound) {
        lIsAbsolute = ETrue;
    }
    while(rounds--) {
        TInt ret = KErrNone;
        TFullName processName;
        TFindProcess findProcess;

        while(KErrNone == (ret = findProcess.Next(processName))) {
            RProcess process;

            if(KErrNone == (ret = process.Open(findProcess))) {
                RDEBUG("[CTerminalControlServer]-> Process.Open() returned");

                TFileName lStrSource(process.FileName());
                lStrSource.LowerCase();
                if(lIsAbsolute) {
                    RDEBUG("[CTerminalControlServer]-> INFO: The input was specified as an absolute path...");
                    if(lStrSource.Compare(lMatchStr) == 0) {
                        RDEBUG("[CTerminalControlServer]-> Process with correct Filename found => Kill(0) ");
                        process.Kill(0);
                    }
                }
                else {
                    RDEBUG("[CTerminalControlServer]-> INFO: The input was specified as an application name...");
                    TInt lLastDirSepIndex = lStrSource.LocateReverse('\\');
                    TInt lExeIndex = lStrSource.Find(_L(".exe"));
                    if(lLastDirSepIndex < lExeIndex) {
                        TInt lAppNameIndex = lStrSource.Find(lMatchStr);

                        /*
                         * The logic works like this, if the value of lStrSource was 'z:\sys\bin\calendar.exe', lMatchStr would contain calendar
                         * the values of the variables will be as follows
                         * lLastDirSepIndex = 10
                         * lAppNameIndex = 11
                         * lExeIndex = 19
                         *
                         * The below logic would make sure that the right process is killed
                         */
                        if((lAppNameIndex == (lLastDirSepIndex + 1)) && ((lAppNameIndex + lMatchStr.Length()) == lExeIndex)) {
                            RDEBUG("[CTerminalControlServer]-> Process with correct Filename found => Kill(0)");
                            process.Kill(0);
                        }
                    }
                }
            }
            else {
                RDEBUG_2("[CTerminalControlServer]-> Process.Open() returned %d", ret);
            }
        }
        if(KErrNone != ret) {
            RDEBUG_2("[CTerminalControlServer]-> findProcess.Next() returned %d", ret);
        }
    }
    RDEBUG("[CTerminalControlServer]-> StopProcessByFullNameL() <<<");
}
Ejemplo n.º 15
0
TVerdict Cman6Step::doTestStepL()
/**
 * @return - TVerdict code
 * Override of base class pure virtual
 * Our implementation only gets called if the base class doTestStepPreambleL() did
 * not leave. That being the case, the current test result value will be EPass.
 */
	{
	  if (TestStepResult()==EPass)
		{
		TTime time;
		time.UniversalTime();
		RDebug::Printf("%02d:%02d:%02d:%06d  [%Ld] xxxxx Cman6Step::doTestStepL start",
			time.DateTime().Hour(), time.DateTime().Minute(), time.DateTime().Second(),time.DateTime().MicroSecond(),
			RProcess().Id().Id());
		
		//This should be run as the last test in the te_man suite.  This test uses the Root API
		// CLbsCloseDownRequestDetector to simulate the Root telling the AGPS Manager to shutdown.
		// The Manager should send a CancelLocationRequest message and a CloseDown power message
		// to the integration module.  The Manager should then wait until the module makes the 
		// Shutdown() call before beginning the shut down process.
		

		//Setup the test AGPS Module Channel
		RAgpsModuleTestChannel moduleInt;
		moduleInt.OpenL();
		CleanupClosePushL(moduleInt);
		
		//Setup the root process ShutDown
		RLbsProcessSupervisor shutDownProcess;
		TUid managerModuleId = TUid::Uid(0x10281D44);	//KLbsGpsLocManagerUidValue
		shutDownProcess.OpenL(managerModuleId);
		CleanupClosePushL(shutDownProcess);

		//Open up the test AGPS Manager Process
		RProcess proc;
		_LIT(KMatchName,"testlbsgpslocmanager*");
		TFindProcess procName;
		TFullName procFullName;
		procName.Find(KMatchName);
		procName.Next(procFullName);
		
		//Check to see whether the manager process is still up and running
		TInt rc = proc.Open(procFullName);
		if(rc != KErrNone)
			{
			//Error, process has already closed down before receiving the shutdown from the module
			INFO_PRINTF1(_L("Error - cannot find the GPS Location Manager Process, failing test"));
			SetTestStepResult(EFail);
			}
		else
			{
			//Send the Shut Down to the Manager
			shutDownProcess.CloseDownProcess();
				
			//The test integration module will wait 5 seconds before sending the shutdown message to
			// the manager.  So the AGPS Manager should still be open.  The test should wait here
			// until the AGPS Manager process is closed down.  If the test times out, it is likely that
			// the AGPS Manager process was never closed, so the test cannot progress past this part
			TRequestStatus procStatus;
			proc.Logon(procStatus);
			
			time.UniversalTime();
			RDebug::Printf("%02d:%02d:%02d:%06d  [%Ld] xxxxx Cman6Step::doTestStepL after logon",
				time.DateTime().Hour(), time.DateTime().Minute(), time.DateTime().Second(),time.DateTime().MicroSecond(),
				RProcess().Id().Id());
					
			User::WaitForRequest(procStatus);
			
			time.UniversalTime();
			RDebug::Printf("%02d:%02d:%02d:%06d  [%Ld] xxxxx Cman6Step::doTestStepL after wait",
				time.DateTime().Hour(), time.DateTime().Minute(), time.DateTime().Second(),time.DateTime().MicroSecond(),
				RProcess().Id().Id());
						
			
			//When the Integration Module sends the shutdown message to the manager it updates the test
			// channel (so this message should also take 5 seconds before appearing on the channel and should
			// only appear when the manager has been given permission to close down).  Check the channel
			// to make sure the right message is present (ShutdownEvent)
			RAgpsModuleTestChannel::TTestMsgType messageType = RAgpsModuleTestChannel::ETestMsgUnknown;
			moduleInt.GetMsg(messageType);
			if(messageType == RAgpsModuleTestChannel::ETestMsgShutdownEvent)
				{
				INFO_PRINTF1(_L("Module correctly waited for Shutdown call from Module to shutdown and then shutdown the manager process."));
				SetTestStepResult(EPass);
				}
			else
				{
				INFO_PRINTF1(_L("Error - AGPS Manager has already been shutdown before receiving Shutdown() from Module"));
				SetTestStepResult(EFail);
				}
			}
		proc.Close();
		
		CleanupStack::Pop(2, &moduleInt);	//moduleInt, shutDownProcess
		}
	  return TestStepResult();
	}
Ejemplo n.º 16
0
int main(int argc, char *argv[])
{
    bool running = false;


        TFullName res;
        TFindProcess find;
        while(find.Next(res) == KErrNone)
        {
            RProcess ph;
            ph.Open(res);

            if(ph.SecureId() == 0x2002B30D)

            if (ph.ExitType() == EExitPending)
            {
                running = true;
                break;
            }

            ph.Close();
        }



    if (running == false)
    {

        QProcess *myProcess = new QProcess;
        myProcess->start("whatsapp.exe");
    }
    else {

        QApplication app(argc, argv);
        CAknConfirmationNote* run = new (ELeave) CAknConfirmationNote;
        QT_TRAP_THROWING(run->ExecuteLD(_L("Closed WhatsApp")));
        TFullName res1;
        TFindProcess find1(_L("*[2002B306]*"));

        while(find1.Next(res1) == KErrNone)
        {
            RProcess ph1;
            ph1.Open(find1);
            ph1.Kill(KErrNone);
            ph1.Close();
        }

        TFullName res2;
        TFindProcess find2(_L("*[2002B310]*"));

        while(find2.Next(res2) == KErrNone)
        {
            RProcess ph2;
            ph2.Open(find2);
            ph2.Kill(KErrNone);
            ph2.Close();
        }

        TFullName res3;
        TFindProcess find3(_L("*[2002B30D]*"));

        while(find3.Next(res3) == KErrNone)
        {
            RProcess ph3;
            ph3.Open(find3);
            ph3.Kill(KErrNone);
            ph3.Close();
        }
        QTest::qWait(1500);
    }
    return 1;
}
Ejemplo n.º 17
0
TVerdict CFindRunningExe::doTestStepL()
	{
	TInt uidValue;
	_LIT(KUidKey, "uid");
	if (!GetHexFromConfig(ConfigSection(), KUidKey, uidValue))
		{
		ERR_PRINTF1(_L("Cannot read UID from config section."));
		SetTestStepResult(EFail);
		return EFail;
		}

	TUid exeUid;
	exeUid.iUid = uidValue;

	SetTestStepResult(EFail);
	TInt loop=0;
	for(;(loop < 20)&&(TestStepResult() == EFail);loop++)
		{
		TFindProcess findProcess;
		TFullName fullName;
		while((findProcess.Next(fullName) == KErrNone) && (TestStepResult() == EFail))
			{
			RProcess process;
			TInt ret=KErrNone;
			TInt count=0;
			do
			{
			count++;
 			ret=process.Open(findProcess);
			if (ret!=KErrNone)
				{
				User::After(200000);
				}
			}while (ret!=KErrNone && count<=10);
			if (ret!=KErrNone)
				{
				User::Leave(ret);
				}
			TUidType uid = process.Type();
			TExitType exitType = process.ExitType();
			process.Close();
			if(uid[2] == exeUid)
				{
					if (exitType == EExitPending)
						SetTestStepResult(EPass);
				}
			}
			User::After(1000000);
		}

	if (TestStepResult() == EPass)
		{
		INFO_PRINTF2(_L("Process with UID 0x%x running."), exeUid.iUid);
		}
	else
		{
		ERR_PRINTF2(_L("No process with UID 0x%x running."), exeUid.iUid);		
		}

	return TestStepResult();
	}
// ----------------------------------------------------------------------------------------
// CTerminalControlServer::GetRunningProcessesL
// ----------------------------------------------------------------------------------------
CBufFlat* CTerminalControlServer::GetRunningProcessesL( )
{
    RDEBUG("CTerminalControlServer::GetRunningProcessesL");

    TFullName    processName;
    TFindProcess findProcess;
    CBufFlat *buffer = CBufFlat::NewL(128);
    iProcessInfoArray->Reset();

    while( KErrNone == findProcess.Next( processName ) )
    {
        TTcProcessInfo info;
        RProcess process;

        if( KErrNone == process.Open( findProcess ) )
        {
            //
            // Add process information to local array
            //
            info.iProcessName = processName;
            info.iFileName    = process.FileName();

            info.iHandle      = process.Handle();
            info.iId          = process.Id();
            info.iSecureId    = process.SecureId();

            info.iProtected   = EFalse;

            process.GetMemoryInfo( info.iMemoryInfo );

            User::IsRomAddress( info.iCodeInRom, (TAny*)(info.iMemoryInfo.iCodeBase) );
            if( !info.iCodeInRom )
            {
                User::IsRomAddress( info.iCodeInRom, (TAny*)(info.iMemoryInfo.iCodeBase) );
            }

            iProcessInfoArray->AppendL( info );

            //
            // Add process also to return buffer
            //
            /*
            TInt appendPosition = buffer->Size();
            if(iProcessInfoArray->Count() >= 2)
                {
                TBuf8<sizeof(info.iProcessName)> proName;
                proName.Copy(info.iProcessName);
                buffer->InsertL(appendPosition, _L8("/"));
                buffer->InsertL(appendPosition+1, proName);
                }
            else
                {
                TBuf8<sizeof(info.iProcessName)> proName;
                proName.Copy(info.iProcessName);
                buffer->InsertL(appendPosition, proName);
                }
            }

            */

            // Enumerate names from 1
            TInt appendPosition = buffer->Size();
            TBuf8<MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64> numBuf;
            TBuf8<sizeof(KFormatProcessNamePrefix)+20> nameBuf;

            numBuf.Num(iProcessInfoArray->Count());
            nameBuf.Zero();
            nameBuf.Append(KFormatProcessNamePrefix);
            nameBuf.Append(numBuf);

            if(iProcessInfoArray->Count() >= 2)
            {
                buffer->InsertL(appendPosition, _L8("/"));
                buffer->InsertL(appendPosition+1, nameBuf);
            }
            else
            {
                buffer->InsertL(appendPosition, nameBuf);
            }
        }
    }
    /*
    	TUint32 flags = Exec::ProcessFlags(KCurrentProcessHandle);
    	if (flags & KProcessFlagSystemPermanent)
    		return ESystemPermanent;
    	if (flags & KProcessFlagSystemCritical)
    		return ESystemCritical;
    	if (flags & KThreadFlagProcessPermanent)
    		return EAllThreadsCritical;
    	return ENotCritical;
    */
    return buffer;
}