/**
Bonus-test APPFWK-SYSMON-0001b using an application instead of a process
*/	
void CStepProcMonInit::DoTestAppL()
	{
	INFO_PRINTF1(_L("TEST APPFWK-SYSMON-0001B"));
		
	// Launch native application using an unconnected RApaLsSession
	INFO_PRINTF1(_L("Going to set a native application running"));
	TThreadId threadId;
	TRequestStatus requestStatus;
	StartViewlessBgApplicationL(KTestAppGood, threadId, requestStatus);
	
	// Test that the application was created, then wait for it to resume	
	RThread thread;
	RProcess process;
	CleanupClosePushL(thread);
	CleanupClosePushL(process);
	TEST(KErrNone == thread.Open(threadId));
	TEST(KErrNone == thread.Process(process)); 
	User::WaitForRequest(requestStatus);
	
	// Do the actual testing
	DoTestMonitorL(process, KTestAppGood);
	
	// Cleanup
	process.Kill(KErrNone);
	CleanupStack::PopAndDestroy(&process);
	CleanupStack::PopAndDestroy(&thread);
	}	
Ejemplo n.º 2
0
// ----------------------------------------------------------------------------
// Helper to get the window group ID associated with a process
// ----------------------------------------------------------------------------
//
EXPORT_C TInt MPXUser::FindWindowGroupIdL(
    TProcessId aProcId,
    RWsSession& aWsSession )
    {
    TInt wgId( KErrNotFound );
    RArray<RWsSession::TWindowGroupChainInfo> windowArray;
    CleanupClosePushL( windowArray );
    aWsSession.WindowGroupList( &windowArray );
    TInt wgCount( windowArray.Count() );

    for ( TInt i = 0; i < wgCount && wgId == KErrNotFound; i++ )
        {
        TThreadId threadId;
        User::LeaveIfError(
            aWsSession.GetWindowGroupClientThreadId(
                windowArray[i].iId, threadId ) );
        RThread thread;
        CleanupClosePushL( thread );
        User::LeaveIfError( thread.Open( threadId ));
        RProcess proc;
        CleanupClosePushL( proc );
        User::LeaveIfError( thread.Process( proc ));
        if ( proc.Id() == aProcId )
            {
            wgId = windowArray[i].iId;
            }
        CleanupStack::PopAndDestroy( &proc );
        CleanupStack::PopAndDestroy( &thread );
        }
    CleanupStack::PopAndDestroy( &windowArray );
    return wgId;
    }
Ejemplo n.º 3
0
/**
   @SYMTestCaseID T_RApaLsSessionTestStep_TestStartApp6L
  
   @SYMPREQ
  
   @SYMTestCaseDesc  
   
   @SYMTestPriority High 
  
   @SYMTestStatus Implemented
   
   @SYMTestActions \n
   API Calls:\n	
   \n
   
   @SYMTestExpectedResults 
    
 */
void CT_StartAppTestStep::TestStartApp6L()
	{	
	INFO_PRINTF1(_L("Test RApaLsSession::StartDocument....known App Uid"));

	TThreadId startAppThreadID;
	TInt  ret=iApaLsSession.StartDocument(iStartAppTestsFilename,iStartAppTestsUid,startAppThreadID);
	TEST(ret==KErrNone);
	
	//we need to close the started thread, if appropiate
	if (ret==KErrNone)	
		{
		RThread thread;
		User::LeaveIfError(thread.Open(startAppThreadID));
		CleanupClosePushL(thread);

		RProcess process;
		User::LeaveIfError(thread.Process(process));
		CleanupClosePushL(process);

		process.Kill(0);
		
		CleanupStack::PopAndDestroy(&process);
		CleanupStack::PopAndDestroy(&thread);
		}
		
	INFO_PRINTF1(KCompleted);
	}
void CTContentUpdateReceiver::DoSetInternalPriorityL()
	{
	RThread thread;
	User::LeaveIfError(thread.Open(iReceiverThreadId));
	thread.SetPriority(iInternalPriority);
	thread.Close();
	TInt compositionInterval = KCompositionInterval;
	CPeriodic::TPriority priority = CPeriodic::EPriorityStandard;
	if(iInternalPriority < EPriorityNormal)
		{
		priority = CPeriodic::EPriorityIdle;
		compositionInterval = KCompositionIntervalLong;
		}
	else if (iInternalPriority > EPriorityNormal)
		{
		priority = CPeriodic::EPriorityHigh;
		compositionInterval = KCompositionIntervalShort;
		}

	TCallBack callback(CallBack);
	callback.iPtr = this;
	iPeriodic->Cancel();
	delete iPeriodic;
	iPeriodic= CPeriodic::NewL(priority);
	iPeriodic->Start(TTimeIntervalMicroSeconds32(compositionInterval),TTimeIntervalMicroSeconds32(compositionInterval), callback);
	iSetInternalPriority = EFalse;
	iPriorityLock.Signal();
	}
Ejemplo n.º 5
0
/**
   @SYMTestCaseID T-RApaLsSessionTestStep-TestStartApp3L
  
   @SYMPREQ
  
   @SYMTestCaseDesc  
   
   @SYMTestPriority High 
  
   @SYMTestStatus Implemented
   
   @SYMTestActions \n
   API Calls:\n	
   \n
   
   @SYMTestExpectedResults 
   
 */	
void CT_StartAppTestStep::TestStartApp3L()
	{
	INFO_PRINTF1(_L("Test RApaLsSession::StartDocument.....start the app from the recognized doc given."));

	TThreadId startAppThreadID;
	TPtrC startAppTestsDoc(KLitTRApaLsSessionStartAppTest);
	TInt ret=iApaLsSession.StartDocument(startAppTestsDoc,startAppThreadID);
	TEST(ret==KErrNone);
	
	//we need to close the started thread, if appropiate
	if (ret==KErrNone)	
		{
		RThread thread;
		User::LeaveIfError(thread.Open(startAppThreadID));
		CleanupClosePushL(thread);

		RProcess process;
		User::LeaveIfError(thread.Process(process));
		CleanupClosePushL(process);

		process.Kill(0);
		
		CleanupStack::PopAndDestroy(&process);
		CleanupStack::PopAndDestroy(&thread);
		}
		
	INFO_PRINTF1(KCompleted);
	}
Ejemplo n.º 6
0
void CInterThreadObject::Cancel()
	{
    iCritSect.Wait();		
	if (!IsActive())
		{
		iState = ECancel;
		iStatus = KRequestPending;
		SetActive();
		RThread thread;
		TInt err = thread.Open(iThreadId, EOwnerThread);
		if (err == KErrNone)
			{
			TRequestStatus* status = &(iStatus);
			thread.RequestComplete(status, KErrNone);
			thread.Close();
		    iSemaphore.Wait();
			}
		else
			{
			iCritSect.Signal();			
			}
		}
	else
		{
		iCritSect.Signal();			
		}
	}
Ejemplo n.º 7
0
LOCAL_C void ProfileAllThreads()
	{
	TFindThread ft(_L("*"));
	TFullName fullname;
	test.Console()->ClearScreen();
	FOREVER
		{
		TInt r=ft.Next(fullname);
		if (r!=KErrNone)
			break;
		RThread t;
		r=t.Open(ft);
		if (r==KErrNone)
			{
			TProfileData data;
			r=Profile.Read(t,data);
			if (r==KErrNone)
				{
				while(fullname.Length()<40)
					fullname.Append(TChar(' '));
				test.Printf(_L("%S T=%9d C=%9d Y=%9d\n"),
					&fullname,data.iTotalCpuTime,data.iMaxContinuousCpuTime,data.iMaxTimeBeforeYield);
				}
			t.Close();
			}
		}
	}
Ejemplo n.º 8
0
void CTestAppUi::TestWaitOnAppStartL()
	{
	RDebug::Print(_L("TVIEW1 : Test Wait On App Start"));

	RThread appThread;
	TRequestStatus status;
	TThreadId threadId;

	RApaLsSession ls;
	CleanupClosePushL(ls);
	User::LeaveIfError(ls.Connect());
	TApaAppInfo info;
	User::LeaveIfError(ls.GetAppInfo(info,KUidViewAppTwo));
	CleanupStack::PopAndDestroy();	// ls 

	CApaCommandLine* cmdLine=CApaCommandLine::NewLC();	
	cmdLine->SetExecutableNameL(info.iFullName);
	cmdLine->SetCommandL(EApaCommandViewActivate);
	TFileName fName=_L("c:\\Documents\\");
	TParsePtrC parse(info.iFullName);
	fName.Append(parse.Name());
	cmdLine->SetDocumentNameL(fName);

	RApaLsSession lsSession;
  	User::LeaveIfError(lsSession.Connect());
  	CleanupClosePushL(lsSession);
  	threadId=User::LeaveIfError(lsSession.StartApp(*cmdLine, threadId));
  	CleanupStack::PopAndDestroy(&lsSession);
	CleanupStack::PopAndDestroy(); // cmdLine
	User::LeaveIfError(appThread.Open(threadId));
	appThread.Logon(status);
	User::WaitForRequest(status);
	}
Ejemplo n.º 9
0
void CWindowGroupListBoxData::DoInfoForDialogL(RBuf& aTitle, RBuf& inf, TDes* name)
	{
	SWgInfo& info = *reinterpret_cast<SWgInfo*>(iInfo);
	_LIT(KInfo, "Window group info");
	aTitle.Copy(KInfo);
	CApaWindowGroupName* wg = info.iName;
	*name = wg->WindowGroupName();
	PrettyName(EListWindowGroups, *name);

	inf.Append(*name);
	TThreadId tid;
	TInt res = info.iSession->GetWindowGroupClientThreadId(info.iHandle, tid);
	inf.AppendFormat(_L("\n\nOwner thread: %i"), res == KErrNone ? (TInt)tid : res);
	RThread thread;
	if (res == KErrNone)
		{
		res = thread.Open(tid);
		}
	if (res == KErrNone)
		{
		*name = thread.FullName();
		PrettyName(EListThread, *name);
		inf.AppendFormat(_L(" (%S)"), name);
		}
	inf.AppendFormat(_L("\nBusy=%i System=%i Hidden=%i"), wg->IsBusy(), wg->IsSystem(), wg->Hidden());
	}
Ejemplo n.º 10
0
// --------------------------------------------------------------------------
// Check whether client key event request can be executed
// --------------------------------------------------------------------------
void CAknCompaSrvSession::CheckKeyDownPermissionL(const RMessage2& aMessage)
    {
    // We try to increase security by allowing only foreground application
    // to set key down. As the simulated key events are sent to the
    // foreground application by window server, the application is
    // sending a key event to itself.

    // Granted if client has ECapabilitySwEvent or request is coming from
    // EikSrv. TApaTaskList won't report EikSrv in foreground though
    // it's displaying a note.
    if (!aMessage.HasCapability(ECapabilitySwEvent) &&
        !CAknCompaServer::IsGlobalUiSrv(aMessage))
        {
        // Allow key down only from a foreground task
        TApaTaskList tasklist(Server().WsSession());
        TApaTask foregroundTask = tasklist.FindByPos(0);

        RThread thread;
        User::LeaveIfError(thread.Open(foregroundTask.ThreadId()));
        TSecurityPolicy securityPolicy(thread.SecureId());
        thread.Close();

        if (!securityPolicy.CheckPolicy(aMessage))
            {
            User::Leave(KErrPermissionDenied);
            }
        }
    }
Ejemplo n.º 11
0
// RunL() completes a previously issued Observe call 
void CTargetObserver::RunL()
	{
    LOG_MSG2("->CTargetObserver::RunL(status:%d)", iStatus.Int());
	User::LeaveIfError(iStatus.Int()); //something bad happened

    iCrashEventInfo.iEventTime.UniversalTime(); //not 100% exact time of the crash, but as soon as we are notified about it

    Observe(); 

    RThread thread;
    LOG_MSG2("CTargetObserver::RunL() - opening handle to crashed thread:%Lu\n", iCrashEventInfo.iThreadId);
    TInt err = thread.Open(iCrashEventInfo.iThreadId);
    if(err != KErrNone)
        {
        LOG_MSG2("CTargetObserver::RunL - unable to open thread handle! err:%d\n", err); 
        User::Leave(err);
        }
    CleanupClosePushL(thread); 
    
    if( (iThreadList.Count() == 0) || (HasThread(thread.FullName())) )
        {
        //crash event of the whole process or thread that we observe
        LOG_MSG("CTargetObserver::RunL() -> HandleCrashEventL()");
        iHandler.HandleCrashEventL(iCrashEventInfo);
        }
    else //crash event of thread that we don't care about
        {
        LOG_MSG("CTargetObserver::RunL() - resuming crashed thread");
        iSecSess.ResumeThread(iCrashEventInfo.iThreadId);
        }
    CleanupStack::PopAndDestroy(); //thread

	}
Ejemplo n.º 12
0
TInt ChildThread(TAny* aArg)
	{
	TInt testType = (TInt)aArg;
	RThread mainThread;
	TInt r = mainThread.Open(MainThreadId);
	if (r != KErrNone)
		return r;
	// Open handle on dynamic DLL in this thread
	RLibrary library;
	test_KErrNone(library.Load(KDynamicDll));
	RThread().Rendezvous(KErrNone);
	TRequestStatus status;
	mainThread.Logon(status);
	User::WaitForRequest(status);
	if (mainThread.ExitType() != EExitKill)
		return KErrGeneral;
	if (mainThread.ExitReason() != KErrNone)
		return mainThread.ExitReason();
	mainThread.Close();
	if (testType != ETestRecursive)
		{
		RMsgQueue<TMessage> messageQueue;
		r = messageQueue.OpenGlobal(KMessageQueueName);
		if (r != KErrNone)
			return r;
		r = messageQueue.Send(EMessagePreDestruct);
		if (r != KErrNone)
			return r;
		}
	return testType;
	}
	EXPORT_C void KillApplicationL(RWsSession& aWs, TUid aUid, TInt aRetryInterval )
	{
		TTime wait_until; wait_until.HomeTime();
		wait_until+=TTimeIntervalSeconds(15);
	
		TApaTaskList taskList( aWs );

		for(;;) {
			TApaTask task = taskList.FindApp(aUid);
			if(! task.Exists()) {
				break;
			}
			TTime now; now.HomeTime();
			if (now < wait_until) {
				task.EndTask();
				//DebugMsg(_L("waiting..."), aDebugLog);
				User::After(TTimeIntervalMicroSeconds32(aRetryInterval*1000) );
			} else {
				break;
			}
		}
		TApaTask task = taskList.FindApp(aUid);
		if( task.Exists()) {
#ifdef __S60V3__
			task.KillTask();
#else
			RThread t;
			if (t.Open(task.ThreadId())==KErrNone) {
				//DebugMsg(_L("killing"), aDebugLog);
				t.Kill(2003);
				t.Close();
			}
#endif
		}
	}
EXPORT_C void CloseTestUpdateReceiver(CTContentUpdateReceiver* aReceiver)
	{
	if(!aReceiver)
		return;

	TBuf<64> contentUpdateReceiverThreadName;
	contentUpdateReceiverThreadName.Format(KMaskBackend, aReceiver->Screen());
	TBuf<64> contentUpdateReceiverThreadMask;
	contentUpdateReceiverThreadMask = contentUpdateReceiverThreadName;
	contentUpdateReceiverThreadMask.Insert(0, _L("*"));
	contentUpdateReceiverThreadMask.Append('*');
	TFindThread findThread(contentUpdateReceiverThreadMask);
	TFullName name;
	RThread thread;
	if((findThread.Next(name)!=KErrNone) ||
		(thread.Open(findThread) != KErrNone))
		{
		thread.Close();
		return;
		}
	TRequestStatus status; 
	thread.Logon(status);
	if(aReceiver)
		aReceiver->Stop();
	User::WaitForRequest(status);
	thread.Close();
	}
// ---------------------------------------------------------------------------
// Removes all requests belonging to a terminated client.
// ---------------------------------------------------------------------------
//
void CPolicyClientRequestHandler::RemoveDeadClients()
	{
	// Lint seems to have some trouble identifying the TThreadId class.
	// Due to this, Lint will report several errors here that are incorrect.
	// These errors are disabled.
	/*lint -e10 -e1013 -e1055 -e746 -e747 */
	RThread client;
	for( TInt i = iControlPolicyClients.Count() - 1; i >= 0; i--)
		{
		TInt err = client.Open(iControlPolicyClients[i]->iClientId.Id());
		if(err == KErrNone)
			{
			if(client.ExitType() != EExitPending)
				{
				//Client is dead, remove from list.
				iControlPolicyClients[i]->iMessage = RMessage2(); //Null message so destructor wont try to complete.
				delete iControlPolicyClients[i];
				iControlPolicyClients.Remove(i);
				}
		    client.Close();
			}
		else
			{
			//Could not open client, client handle was invalid.
			//So clean it up from list too.
			iControlPolicyClients[i]->iMessage = RMessage2(); //Null message so destructor wont try to complete.
			delete iControlPolicyClients[i];
			iControlPolicyClients.Remove(i);
			}
		}
	/*lint +e10 +e1013 +e1055 +e746 +e747 */
	}
Ejemplo n.º 16
0
void CThreadWatcher::DoCancel()
{
	RThread thread;
	if(thread.Open(iName) == KErrNone) {
		thread.LogonCancel(iStatus);
		thread.Close();
	}
}
void CThreadOwner::SignalStartupOkFailed(TInt result, 
                                         CThreadOwner::ThreadData& threadData)
{
   // NOTE! There may not be a cleanup stack active here and the heap
   // may be full. Be very very careful.
   RThread otherThread;
   otherThread.Open(threadData.startupStatusThread);
   otherThread.RequestComplete(threadData.startupStatus, result);
   otherThread.Close();
}
Ejemplo n.º 18
0
void CThreadWatcher::ConstructL()
{
	CActiveScheduler::Add(this);
	RThread thread;
	if(thread.Open(iName) == KErrNone) {
		thread.Logon(iStatus);
		thread.Close();
		SetActive();
	}
}
//*************************************************************************************
void TOAManagerStartupSignaller::SignalL()
	{
	// Signal the owning thread that the server has started successfully
	// This may itself fail
    KAOMANAGER_LOGGER_FN1("TOAManagerStartupSignaller::SignalL");
	RThread startingThread;
	User::LeaveIfError(startingThread.Open(iThreadId));
	startingThread.RequestComplete(iStatus, KErrNone);
	startingThread.Close();
    KAOMANAGER_LOGGER_FN2("TOAManagerStartupSignaller::SignalL");
	}
/**
   Auxiliary function for TestCaseID TAppLangFrenchSTARTER-doTestStepL
  
   This method is used to activate CMessageActive class to output the message
   to logs.
  
 */
void CMessageActive3::RequestForTheMessageOutput(TInt aCode)
{
	RThread	thread;
	TRequestStatus *pS=(&iStatus);

	*pS=KRequestPending;
	SetActive();

	thread.Open(iID);
	thread.RequestComplete(pS, aCode);
}
Ejemplo n.º 21
0
// ----------------------------------------------------------------------------
// Determines the owning process id of the thread
// ----------------------------------------------------------------------------
//
EXPORT_C TProcessId MPXUser::ProcessIdL(TThreadId aId)
    {
    RThread t;
    User::LeaveIfError(t.Open(aId));
    CleanupClosePushL(t);
    RProcess p;
    User::LeaveIfError(t.Process(p));
    TProcessId pid=p.Id();
    p.Close();
    CleanupStack::PopAndDestroy(&t);
    return pid;
    }
Ejemplo n.º 22
0
// Gets the CPU count of all threads in process aproc 
//and returns the hour minute second in the references passed
//If CPU count cant be obtained returns -1
	int getCpuCount(TFileName& apname,TDes& aResult)
	{
		TInt64 proctime=0;
		int res;
		RThread thrd;
		TTimeIntervalMicroSeconds cputime(0);
		TBool notime;
		TFileName aprocname(apname);
		aprocname.Append('*');
		TFindThread tfinder(aprocname);
		notime=false;
		while(1)
			{
			res = tfinder.Next(aprocname);
			if(res!=KErrNone)	
				{
				break;							
				}
			res=thrd.Open(tfinder);
			if(res!=KErrNone)
				{
				notime=true;
				continue;
				}
			res=thrd.GetCpuTime(cputime);
			if(res!=KErrNone)	
				{
				// GetCpuTime() not supported. 
				//kernel doesn't support this
				}
			proctime+=cputime.Int64();
			thrd.Close();
			}
		TTime time(proctime);
		TDateTime date=time.DateTime();
			
		if(date.Day()==0)
			{
			aResult.AppendFormat(_L(" %02d:%02d:%02d "),date.Hour(),date.Minute(),date.Second());
			}
		else
			{	
			aResult.AppendFormat(_L(" %d-%02d:%02d:%02d "),date.Day(),date.Hour(),date.Minute(),date.Second());
			}
		if(notime)
			{	
			aResult.Append(_L("?"));
			}
		if(!notime)
			return 0;
		else
			return -1;	
	}
Ejemplo n.º 23
0
void CInterThreadObject::Activate()
	{
	iObject->iStatus = KRequestPending;
	RThread thread;
	TInt err = thread.Open(iThreadId, EOwnerThread);
	if (err == KErrNone)
		{
		TRequestStatus* status = &(iObject->iStatus);
		thread.RequestComplete(status, KErrNone);
		thread.Close();	
		}
	}
Ejemplo n.º 24
0
void CScummVMUi::BringUpEmulatorL() {
	RThread thread;

	if(thread.Open(iThreadId) == KErrNone) {
		thread.Close();
		TApaTask apaTask(iEikonEnv->WsSession());
		apaTask.SetWgId(iExeWgId);
		apaTask.BringToForeground();
	} else {
		iExeWgId = -1;
		Exit();
	}
}
Ejemplo n.º 25
0
GLDEF_C TInt E32Main()
	{
	test.Title();
	TBuf<256> cmd;
	TFullName fn;
	User::CommandLine(cmd);
	TLex lex(cmd);
	TPtrC threadSpec(lex.NextToken());
	TFindThread ft(threadSpec);
	TExitType exitType=EExitKill;
	TInt exitCode=0;
	if (!lex.Eos())
		{
		TPtrC xtSpec(lex.NextToken());
		TPtrC xc(xtSpec);
		TChar xt0=xtSpec[0];
		if (xt0.IsAlpha())
			{
			xt0.LowerCase();
			if (xt0==TChar('t'))
				exitType=EExitTerminate;
			else if (xt0==TChar('p'))
				exitType=EExitPanic;
			new(&xc) TPtrC(lex.NextToken());
			}
		if (xc.Length())
			{
			TLex lex2(xc);
			lex2.Val(exitCode);
			}
		}
	while (ft.Next(fn)==KErrNone)
		{
		test.Printf(_L("Killing %S\n"),&fn);
		RThread t;
		TInt r=t.Open(ft);
		if (r==KErrNone)
			{
			// FIXME: SHOULD REMOVE CRITICALNESS - WOULD NEED DEVICE DRIVER
			switch (exitType)
				{
				case EExitKill:	t.Kill(exitCode); break;
				case EExitTerminate: t.Terminate(exitCode); break;
				case EExitPanic: t.Panic(KPanicCat,exitCode); break;
				default: break;
				}
			t.Close();
			}
		}
	return 0;
	}
Ejemplo n.º 26
0
void SDL_SYS_WaitThread(SDL_Thread *thread)
    {
    SDL_TRACE1("Close thread", thread);
    RThread t;
    const TInt err = t.Open(thread->threadid);
    if(err == KErrNone && t.ExitType() == EExitPending)
        {
        TRequestStatus status;
        t.Logon(status);
        User::WaitForRequest(status);
        }
    t.Close();
    SDL_TRACE1("Closed thread", thread);
    }
Ejemplo n.º 27
0
void CScummVMUi::HandleCommandL(TInt aCommand) {
	switch(aCommand) {
	case EEikCmdExit:
		{
			RThread thread;
			if(thread.Open(iThreadId) == KErrNone) {
				thread.Terminate(0);
				thread.Close();
			}
			Exit();
		}
		break;
	}
}
TInt CTContentUpdateReceiver::CheckNewNotifications()
	{
	iLock.Wait();
 	if(iStop && (iNumberElements <= 0))
		{
	    iLock.Signal();
		CActiveScheduler::Stop();
		return 0;//the return value is irrelevant for CPeriodic function
		}
	if(iSetInternalPriority)
		{
		TRAPD(res, DoSetInternalPriorityL());
	    iLock.Signal();
		__ASSERT_ALWAYS(res ==KErrNone, User::Panic(_L("CheckNewNotifications"), KErrGeneral));
		return 0;//the return value is irrelevant for CPeriodic function
		}	
	TInt index = 0;	
	RThread thread;
	TInt res = thread.Open(iThreadId);
	__ASSERT_ALWAYS(res ==KErrNone, User::Panic(_L("CheckNewNotifications"), KErrGeneral));

		//we will check only one limited amount of requests at the time
	for(TInt iteration = 0; (iNumberElements > index) && (iteration < KNotificationsAtTime); iteration++)
		{
		if(iArray[index].iType == EReqDisplayed)
			{
			*(iArray[index].iTimeStamp) = User::FastCounter();
			if(iCompositionOrder)
				{
				iCompositionOrder->SetOrder(EOrderComposition);
				}
			}
		else if(iArray[index].iType == EReqDisplayedXTimes)
			{
			iArray[index].iDisplayedXTimes--;
			if(iArray[index].iDisplayedXTimes > 0)
				{
				index++;
				continue;
				}
			}
		TRequestStatus* status = iArray[index].iStatus;
		res = iVisible ? KErrNone : KErrNotVisible;
		Remove(index);
		thread.RequestComplete(status, res);
		}
	thread.Close();	
    iLock.Signal();
	return 0;//the return value is irrelevant for CPeriodic function
	}
TInt TServerStart::Signal()
//
// Signal the owning thread that the server has started successfully
//
	{
	RThread starter;
	TInt err = starter.Open(iId);
	if(err==KErrNone)
		{
		starter.RequestComplete(iStatus,KErrNone);
		starter.Close();
		}
	return(err);
	}
Ejemplo n.º 30
0
/**
   @SYMTestCaseID APPFWK-APPARC-0071
 
   @SYMDEF PDEF100072 -- CApaWindowGroupName::SetAppUid() and FindByAppUid panic
 
   @SYMTestCaseDesc Test Launching of an application with unprotected application UID
  
   @SYMTestPriority High 
 
   @SYMTestStatus Implemented
  
   @SYMTestActions Prepare command line information to start an application using
   CApaCommandLine Apis.Call RApaLsSession::StartApp() to start an
   application defined by the command line information.\n
   Test the launching of application for following scenario:\n
   When Application specified by command line has unprotected application UID(negative uid).\n
   API Calls:\n	
   RApaLsSession::StartApp(const CApaCommandLine &aCommandLine, TThreadId &aThreadId);\n
  
   @SYMTestExpectedResults The test checks whether the thread has terminated with the exit reason KTUnProtectedAppTestPassed
 */
void CT_StartAppTestStep::TestStartApp8L()
	{
	INFO_PRINTF1(_L("Checking launching of an application which has unprotected UID"));
	CApaCommandLine* cmdLine=CApaCommandLine::NewLC();
	TFileName filename;
	_LIT(KAppFileName, "z:\\sys\\bin\\UnProctectedUidApp.exe");
	TFullName exePath(KAppFileName);
	filename = SearchAndReturnCompleteFileName(exePath);
	cmdLine->SetExecutableNameL(filename);
	
	TThreadId appThreadId(0U);
	TInt ret = iApaLsSession.StartApp(*cmdLine, appThreadId);
	TEST(ret == KErrNone);
	User::LeaveIfError(ret);
	CleanupStack::PopAndDestroy(cmdLine); // cmdLine
	
	RThread appThread;
	User::LeaveIfError(appThread.Open(appThreadId));
	
	TRequestStatus logonRequestStatus;
	appThread.Logon(logonRequestStatus);

	// wait for UnProctectedUidApp.exe to terminate
	INFO_PRINTF1(_L("Waiting for application to terminate..."));
	User::WaitForRequest(logonRequestStatus);

	const TExitType exitType = appThread.ExitType();
	const TInt exitReason = appThread.ExitReason();
	TExitCategoryName categoryName = appThread.ExitCategory();
	appThread.Close();

	TBuf<50> msg;
	if (exitType == EExitPanic)
		{
		_LIT(KAppPanicInfo, "Application panic: %S %d");
		msg.Format(KAppPanicInfo, &categoryName, exitReason);
		}
	else
		{
		_LIT(KAppExitInfo, "Application exited with code %d");
		msg.Format(KAppExitInfo, exitReason);
		}
	INFO_PRINTF1(msg);

	TEST(logonRequestStatus == KTUnProtectedAppTestPassed);
	TEST(exitType == EExitKill);
	TEST(exitReason == KTUnProtectedAppTestPassed);
	INFO_PRINTF1(KCompleted);
	}