# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1266613134 -7200 # Node ID 0fdb7f6b0309d370e3670b121891d714d533664f # Parent 2e3d3ce01487a77fe53efe6610b14bb2ed37d739 Revision: 201002 Kit: 201007 diff -r 2e3d3ce01487 -r 0fdb7f6b0309 Distribution.Policy.S60 --- a/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 appfw/apparchitecture/ServiceRegistry/distribution.policy.s60 --- a/appfw/apparchitecture/ServiceRegistry/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 appfw/apparchitecture/apfile/distribution.policy.s60 --- a/appfw/apparchitecture/apfile/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 appfw/apparchitecture/apgrfx/distribution.policy.s60 --- a/appfw/apparchitecture/apgrfx/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 appfw/apparchitecture/aplist/distribution.policy.s60 --- a/appfw/apparchitecture/aplist/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 appfw/apparchitecture/apparc/distribution.policy.s60 --- a/appfw/apparchitecture/apparc/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 appfw/apparchitecture/apserv/distribution.policy.s60 --- a/appfw/apparchitecture/apserv/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 appfw/apparchitecture/apsexe/distribution.policy.s60 --- a/appfw/apparchitecture/apsexe/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 appfw/apparchitecture/apstart/distribution.policy.s60 --- a/appfw/apparchitecture/apstart/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 appfw/apparchitecture/bwins/distribution.policy.s60 --- a/appfw/apparchitecture/bwins/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 appfw/apparchitecture/conf/distribution.policy.s60 --- a/appfw/apparchitecture/conf/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 appfw/apparchitecture/eabi/distribution.policy.s60 --- a/appfw/apparchitecture/eabi/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 appfw/apparchitecture/group/backup_registration.xml --- a/appfw/apparchitecture/group/backup_registration.xml Tue Feb 02 10:12:00 2010 +0200 +++ b/appfw/apparchitecture/group/backup_registration.xml Fri Feb 19 22:58:54 2010 +0200 @@ -1,10 +1,10 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/distribution.policy.s60 --- a/sysresmonitoring/oommonitor/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/eabi/distribution.policy.s60 --- a/sysresmonitoring/oommonitor/eabi/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/eabi/oommonitorU.DEF --- a/sysresmonitoring/oommonitor/eabi/oommonitorU.DEF Tue Feb 02 10:12:00 2010 +0200 +++ b/sysresmonitoring/oommonitor/eabi/oommonitorU.DEF Fri Feb 19 22:58:54 2010 +0200 @@ -17,4 +17,10 @@ _ZN20CAppOomMonitorPlugin4NewLE4TUid @ 16 NONAME _ZTI17COomMonitorPlugin @ 17 NONAME ; ## _ZTV17COomMonitorPlugin @ 18 NONAME ; ## + _ZN18ROomMonitorSession18RequestOptionalRamEiiiRi @ 19 NONAME + _ZN19COomMonitorPluginV27FreeRamEv @ 20 NONAME + _ZTI19COomMonitorPluginV2 @ 21 NONAME ; ## + _ZTV19COomMonitorPluginV2 @ 22 NONAME ; ## + _ZN18ROomMonitorSession18RequestOptionalRamEiiiR14TRequestStatus @ 23 NONAME + _ZN18ROomMonitorSession14SetOomPriorityENS_12TOomPriorityE @ 24 NONAME diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/group/bld.inf --- a/sysresmonitoring/oommonitor/group/bld.inf Tue Feb 02 10:12:00 2010 +0200 +++ b/sysresmonitoring/oommonitor/group/bld.inf Fri Feb 19 22:58:54 2010 +0200 @@ -18,16 +18,15 @@ #include +PRJ_PLATFORMS +DEFAULT + PRJ_EXPORTS -../rom/oommonitor.iby CORE_MW_LAYER_IBY_EXPORT_PATH(oommonitor.iby) +../rom/oommonitor.iby CORE_MW_LAYER_IBY_EXPORT_PATH(oommonitor.iby) +../data/oomconfig.xml /epoc32/RELEASE/winscw/UDEB/Z/private/10207218/oomconfig.xml +../data/oomconfig.xml /epoc32/RELEASE/winscw/UREL/Z/private/10207218/oomconfig.xml +../data/oomconfig.xml /epoc32/data/Z/private/10207218/oomconfig.xml PRJ_MMPFILES - -#ifndef TOOLS - oommonitor.mmp - -#endif - -PRJ_TESTMMPFILES -// ../internal/oomtestplugin/oomtestplugin.mmp +oommonitorlib.mmp diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/group/distribution.policy.s60 --- a/sysresmonitoring/oommonitor/group/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/group/oommonitor.mmp --- a/sysresmonitoring/oommonitor/group/oommonitor.mmp Tue Feb 02 10:12:00 2010 +0200 +++ b/sysresmonitoring/oommonitor/group/oommonitor.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -18,10 +18,22 @@ #include +//uncomment both of these macros to use the CLIENT_REQUEST_QUEUE +macro CLIENT_REQUEST_QUEUE +#define CLIENT_REQUEST_QUEUE + TARGET oommonitor.dll + TARGETTYPE dll UID 0x1000008D 0x10282DBF +NOEXPORTLIBRARY +#ifdef WINS +DEFFILE ../bwins/oommonitor.def +#else +DEFFILE ../eabi/oommonitor.def +#endif + CAPABILITY CAP_GENERAL_DLL VENDORID VID_DEFAULT @@ -32,9 +44,38 @@ MW_LAYER_SYSTEMINCLUDE SOURCEPATH ../src +SOURCE oomIdletimerule.cpp +SOURCE oomaction.cpp +SOURCE oomactionconfig.cpp +SOURCE oomactionlist.cpp +SOURCE oomactionref.cpp +SOURCE oomappclosetimer.cpp +SOURCE oomappclosewatcher.cpp +SOURCE oomapplicationconfig.cpp +SOURCE oomcloseapp.cpp +SOURCE oomcloseappconfig.cpp +SOURCE oomconfig.cpp +SOURCE oomconfigparser.cpp +SOURCE oomforegroundrule.cpp +SOURCE oomglobalconfig.cpp +SOURCE oomlog.cpp +SOURCE oommemorymonitor.cpp +SOURCE oommemorymonitorserver.cpp +SOURCE oommemorymonitorsession.cpp +SOURCE oommonitor.cpp SOURCE oommonitorplugin.cpp SOURCE oommonitorsession.cpp -SOURCE oommonitor.cpp +SOURCE oomoutofmemorywatcher.cpp +SOURCE oompanic.cpp +SOURCE oompluginwaiter.cpp +SOURCE oomrunplugin.cpp +SOURCE oomrunpluginconfig.cpp +SOURCE oomsubscribehelper.cpp +SOURCE oomwindowgrouplist.cpp +SOURCE oomwserveventreceiver.cpp +#ifdef CLIENT_REQUEST_QUEUE +SOURCE oomclientrequestqueue.cpp +#endif LIBRARY euser.lib LIBRARY apparc.lib @@ -46,3 +87,8 @@ LIBRARY ecom.lib LIBRARY hal.lib LIBRARY efsrv.lib +LIBRARY xmlframework.lib +LIBRARY cone.lib +#ifdef _DEBUG +LIBRARY flogger.lib +#endif diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/group/oommonitorlib.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/group/oommonitorlib.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Project definition file +* +*/ + +TARGET oommonitor.lib +TARGETTYPE IMPLIB +UID 0x1000008D 0x10282DBF + +#ifdef WINS + DEFFILE ../bwins/oommonitor.def +#else + DEFFILE ../eabi/oommonitor.def +#endif diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/OomTraces.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/OomTraces.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,487 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Includes some common defines used in the OOM monitor app. +* +*/ + + +#ifndef OOMTRACES_H +#define OOMTRACES_H + +#include "traceconfiguration.hrh" +#include "tracedefs.h" + +#ifdef TRACE_INTO_FILE +#include // RFileLogger +#else +#include // RDebug +#endif + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- +// + +/** +* Prefix error trace +*/ +#define _PREFIX_ERROR( aMsg ) _PREFIX_TRACE( "[ERROR: %d]: " L##aMsg ) + +/** +* Prefix info trace. +*/ +#define _PREFIX_INFO( aMsg ) _PREFIX_TRACE( "[INFO]: " L##aMsg ) + +/** +* Define needed directories if TRACE_INTO_FILE macro in use +*/ +#ifdef TRACE_INTO_FILE + + _LIT( KDir, "oommonitor2" ); + _LIT( KFile, "oommonitor2_log.txt" ); + _LIT( KFullPath, "c:\\logs\\oommonitor2\\" ); + +#endif + +//----------------------------------------------------------------------------- +// Error trace macros +//----------------------------------------------------------------------------- +// +#ifdef ERROR_TRACE + + /** + * Error trace definitions. + */ + #ifdef TRACE_INTO_FILE + + #define ERROR( aErr, aMsg )\ + {\ + if( aErr < KErrNone )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \ + _PREFIX_ERROR( aMsg ), aErr );\ + }\ + } + #define ERROR_1( aErr, aMsg, aP1 )\ + {\ + if( aErr < KErrNone )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \ + _PREFIX_ERROR( aMsg ), aErr, aP1 );\ + }\ + } + #define ERROR_2( aErr, aMsg, aP1, aP2 )\ + {\ + if( aErr < KErrNone )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \ + _PREFIX_ERROR( aMsg ), aErr, aP1, aP2 );\ + }\ + } + #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\ + {\ + if( aErr < KErrNone )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \ + _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3 );\ + }\ + } + + #else//TRACE_INTO_FILE not defined + + #define ERROR( aErr, aMsg )\ + {\ + if( aErr < KErrNone )\ + {\ + RDebug::Print( _PREFIX_ERROR( aMsg ), aErr );\ + }\ + } + #define ERROR_1( aErr, aMsg, aP1 )\ + {\ + if( aErr < KErrNone )\ + {\ + RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1 );\ + }\ + } + #define ERROR_2( aErr, aMsg, aP1, aP2 )\ + {\ + if( aErr < KErrNone )\ + {\ + RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2 );\ + }\ + } + #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 )\ + {\ + if( aErr < KErrNone )\ + {\ + RDebug::Print( _PREFIX_ERROR( aMsg ), aErr, aP1, aP2, aP3 );\ + }\ + } + + #endif//TRACE_INTO_FILE + + #define ERROR_GEN( aMsg ) ERROR( KErrGeneral, aMsg ) + #define ERROR_GEN_1( aMsg, aP1 ) ERROR_1( KErrGeneral, aMsg, aP1 ) + #define ERROR_GEN_2( aMsg, aP1, aP2 ) ERROR_2( KErrGeneral, aMsg, aP1, aP2 ) + #define ERROR_GEN_3( aMsg, aP1, aP2, aP3 ) ERROR_3( KErrGeneral, aMsg, aP1, aP3 ) + + #define ERROR_PARAM(_p) _p + + #define TRAPD_ERR( aErr, aStmt ) TRAPD( aErr, aStmt ) + #define TRAP_ERR( aErr, aStmt ) TRAP( aErr, aStmt ) + + #define TRAP_AND_LEAVE(_s,_t) \ + { TRAPD(_e,_s); ERROR(_e,_t); User::LeaveIfError(_e); } + +#else//ERROR_TRACE not defined + + #define ERROR( aErr, aMsg ) + #define ERROR_1( aErr, aMsg, aP1 ) + #define ERROR_2( aErr, aMsg, aP1, aP2 ) + #define ERROR_3( aErr, aMsg, aP1, aP2, aP3 ) + #define ERROR_GEN( aMsg ) + #define ERROR_GEN_1( aMsg, aP1 ) + #define ERROR_GEN_2( aMsg, aP1, aP2 ) + #define ERROR_GEN_3( aMsg, aP1, aP2, aP3 ) + + #define ERROR_PARAM(_p) + + #define TRAPD_ERR( aErr, aStmt ) TRAP_IGNORE( aStmt ) + #define TRAP_ERR( aErr, aStmt ) TRAP_IGNORE( aStmt ) + + #define TRAP_AND_LEAVE(_s,_t) { _s; } + +#endif//ERROR_TRACE + +//----------------------------------------------------------------------------- +// Info trace macros +//----------------------------------------------------------------------------- +// +#ifdef INFO_TRACE + + /** + * Info log message definitions. + */ + #ifdef TRACE_INTO_FILE + + #define TRACES( aMsg )\ + {\ + RFileLogger::Write( KDir, KFile, EFileLoggingModeAppend, \ + _PREFIX_INFO( aMsg ) );\ + } + #define TRACES1( aMsg, aP1 )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \ + _PREFIX_INFO( aMsg ), aP1 );\ + } + #define TRACES2( aMsg, aP1, aP2 )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \ + _PREFIX_INFO( aMsg ), aP1, aP2 );\ + } + #define TRACES3( aMsg, aP1, aP2, aP3 )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \ + _PREFIX_INFO( aMsg ), aP1, aP2, aP3 );\ + } + #define TRACES4( aMsg, aP1, aP2, aP3, aP4 )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \ + _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4 );\ + } + #define TRACES5( aMsg, aP1, aP2, aP3, aP4, aP5 )\ + {\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, \ + _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5 );\ + } + + #else//TRACE_INTO_FILE not defined + + #define TRACES( aMsg )\ + {\ + RDebug::Print( _PREFIX_INFO( aMsg ) );\ + } + #define TRACES1( aMsg, aP1 )\ + {\ + RDebug::Print( _PREFIX_INFO( aMsg ), aP1 );\ + } + #define TRACES2( aMsg, aP1, aP2 )\ + {\ + RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2 );\ + } + #define TRACES3( aMsg, aP1, aP2, aP3 )\ + {\ + RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3 );\ + } + #define TRACES4( aMsg, aP1, aP2, aP3, aP4 )\ + {\ + RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4 );\ + } + #define TRACES5( aMsg, aP1, aP2, aP3, aP4, aP5 )\ + {\ + RDebug::Print( _PREFIX_INFO( aMsg ), aP1, aP2, aP3, aP4, aP5 );\ + } + + #endif//TRACE_INTO_FILE + + #define TRACES_PARAM( aParam ) aParam + +#else//INFO_TRACE not defined + + #define TRACES( aMsg ) + #define TRACES1( aMsg, aP1 ) + #define TRACES2( aMsg, aP1, aP2 ) + #define TRACES3( aMsg, aP1, aP2, aP3 ) + #define TRACES4( aMsg, aP1, aP2, aP3, aP4 ) + #define TRACES5( aMsg, aP1, aP2, aP3, aP4, aP5 ) + #define TRACES_PARAM( aParam ) + +#endif//INFO_TRACE + +//----------------------------------------------------------------------------- +// Trace current client thread name and process id +//----------------------------------------------------------------------------- +// +#ifdef CLIENT_TRACE + + #define CLIENT( aMessage )\ + {\ + RThread thread;\ + TInt err = aMessage.Client( thread );\ + if( err == KErrNone )\ + {\ + RProcess process;\ + err = thread.Process( process );\ + if( err == KErrNone )\ + {\ + TPtrC thredName( thread.Name() );\ + TUid processUid( process.SecureId() );\ + TRACES2( "Current client process UID: [%x], thread name: [%S]",\ + processUid,\ + &thredName );\ + }\ + process.Close();\ + }\ + thread.Close();\ + } + +#else + + #define CLIENT( aMessage ) + +#endif + +//----------------------------------------------------------------------------- +// Function trace macros +//----------------------------------------------------------------------------- +// +#ifdef FUNC_TRACE + + #include // TCleanupItem + + /** + * Function logging definitions. + */ + #ifdef TRACE_INTO_FILE + + #define FUNC( aMsg, aP1 )\ + {\ + TPtrC8 trace( _S8( aMsg ) );\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend, trace, aP1 );\ + }\ + + #else//TRACE_INTO_FILE not defined + + #define FUNC( aMsg, aP1 )\ + {\ + RDebug::Printf( aMsg, aP1 );\ + }\ + + #endif//TRACE_INTO_FILE + + /** + * Function trace helper class. + * + * NOTE: + * LC -methods cannot be trapped. Therefore if LC -method leaves + * END trace is used instead of LEAVE trace. + * If you have an idea how to round this problem please tell. + */ + _LIT8( KFuncNameTerminator, "(" ); + _LIT8( KFuncLeavePatternL, "L" ); + class TFuncLog + { + public: + static void Cleanup( TAny* aPtr ) + { + TFuncLog* self = static_cast< TFuncLog* >( aPtr ); + self->iLeft = ETrue; + FUNC( _PREFIX_CHAR("%S-LEAVE"), &self->iFunc ); // Leave detected + } + inline TFuncLog( const char* aFunc ) : + iFunc( aFunc ? _S8( aFunc ) : _S8("") ), + iLeft( EFalse ), + iCleanupItem( Cleanup, this ), + iCanLeave( EFalse ) + { + TInt pos( iFunc.Find( KFuncNameTerminator ) ); + if( pos != KErrNotFound ) + { + iFunc.Set( iFunc.Left( pos ) ); + iCanLeave = !iFunc.Right( + KFuncLeavePatternL().Length() ).Compare( KFuncLeavePatternL ); + if ( iCanLeave ) + { + CleanupStack::PushL( iCleanupItem ); // Ignore warnings + } + } + FUNC( _PREFIX_CHAR("%S-START"), &iFunc ); + } + + inline ~TFuncLog() + { + if ( !iLeft ) + { + if ( iCanLeave ) + { + CleanupStack::Pop( this ); // Pop the cleanup item + } + FUNC( _PREFIX_CHAR("%S-END"), &iFunc ); // Normally finished + } + } + + private: // Data + TPtrC8 iFunc; + TBool iLeft; + TCleanupItem iCleanupItem; + TBool iCanLeave; + }; + #define FUNC_LOG TFuncLog _fl( __PRETTY_FUNCTION__ ); + +#else//FUNC_TRACE not defined + + #define FUNC_LOG + +#endif//FUNC_TRACE + +//----------------------------------------------------------------------------- +// Timestamp trace macros +//----------------------------------------------------------------------------- +// +#ifdef TIMESTAMP_TRACE + + #define PREFIX_TIMESTAMP( aCaption ) _PREFIX_TRACE_2("[TIMESTAMP] (%d:%02d:%02d.%06d us) ",aCaption) + #define CURRENT_TIME( aDt ) TDateTime aDt; { TTime t; t.HomeTime(); aDt = t.DateTime(); } + #define EXTRACT_TIME( aDt ) aDt.Hour(), aDt.Minute(), aDt.Second(), aDt.MicroSecond() + + #ifdef TRACE_INTO_FILE + + #define TIMESTAMP( aCaption )\ + {\ + CURRENT_TIME( dt );\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend,\ + PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ) );\ + } + + #define TIMESTAMP_1( aCaption, aP1 )\ + {\ + CURRENT_TIME( dt );\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend,\ + PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1 );\ + } + + #define TIMESTAMP_2( aCaption, aP1, aP2 )\ + {\ + CURRENT_TIME( dt );\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend,\ + PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1,aP2 );\ + } + + #define TIMESTAMP_3( aCaption, aP1, aP2, aP3 )\ + {\ + CURRENT_TIME( dt );\ + RFileLogger::WriteFormat( KDir, KFile, EFileLoggingModeAppend,\ + PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1,aP2,aP3 );\ + } + + #else//TRACE_INTO_FILE not defined + + #define TIMESTAMP( aCaption )\ + {\ + CURRENT_TIME( dt );\ + RDebug::Print( PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ) );\ + } + + #define TIMESTAMP_1( aCaption, aP1 )\ + {\ + CURRENT_TIME( dt );\ + RDebug::Print( PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1 );\ + } + + #define TIMESTAMP_2( aCaption, aP1, aP2 )\ + {\ + CURRENT_TIME( dt );\ + RDebug::Print( PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1,aP2 );\ + } + + #define TIMESTAMP_3( aCaption, aP1, aP2, aP3 )\ + {\ + CURRENT_TIME( dt );\ + RDebug::Print( PREFIX_TIMESTAMP(aCaption),EXTRACT_TIME( dt ),aP1,aP2,aP3 );\ + } + + #endif//TRACE_INTO_FILE + +#else//TIMESTAMP_TRACE not defined + + #define TIMESTAMP( aCaption ) + #define TIMESTAMP_1( aCaption, aP1 ) + #define TIMESTAMP_2( aCaption, aP1, aP2 ) + #define TIMESTAMP_3( aCaption, aP1, aP2, aP3 ) + +#endif//TIMESTAMP_TRACE + +#ifdef _DEBUG + + #include // RDebug + + static void Panic( const TDesC8& aFileName, const TInt aLineNum ) + { + TPath name; + name.Copy( aFileName ); + RDebug::Print( _L( "Assertion failed in file=%S, line=%d" ), &name, aLineNum ); + User::Invariant(); + } + + #define ASSERT_ALWAYS_TRACE Panic( _L8(__FILE__), __LINE__ ); + #define ASSERT_TRACE( _s ) if ( !( _s ) ) { ASSERT_ALWAYS_TRACE; } + +#else // _DEBUG + + #define ASSERT_ALWAYS_TRACE + #define ASSERT_TRACE( _s ) + +#endif // _DEBUG + +#define TRACE_MATRIX( aMsg, aMatrix ) \ + TRACES( aMsg ); \ + TRACES( "------------------------------------------------" ); \ + TRACES3( " [%f %f %f]", (TReal)(aMatrix)[0], (TReal)(aMatrix)[1], (TReal)(aMatrix)[2] ); \ + TRACES3( "Matrix [%f %f %f]", (TReal)(aMatrix)[3], (TReal)(aMatrix)[4], (TReal)(aMatrix)[5] ); \ + TRACES3( " [%f %f %f]", (TReal)(aMatrix)[6], (TReal)(aMatrix)[7], (TReal)(aMatrix)[8] ); \ + TRACES( "------------------------------------------------" ); + +#endif // OOMTRACES_H + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/distribution.policy.s60 --- a/sysresmonitoring/oommonitor/inc/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomaction.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomaction.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + +#ifndef OOMACTION_H_ +#define OOMACTION_H_ + +#include + +class MOomActionObserver; + +/* + * The base class for all OOM actions (i.e. close application or run OOM plug-in). + * + * A base class is used because both types of action have common aspects, specifically: + * - They are prioritised according to application idle time + * - They need to be prioritised against each other + * - For each action it is possible to either continue immediately or to wait for completion + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomAction) : public CBase + { +public: + + virtual ~COomAction(); + + /** + * Activate the OOM action + * + * @since S60 5.0 + * @param aBytesRequested ?description + */ + virtual void FreeMemory(TInt aBytesRequested) = 0; + + /** + * @since S60 5.0 + * @return ETrue if the action is currently freeing memory, else EFalse + */ + virtual TBool IsRunning() = 0; + +protected: + // + /** + * To be called by the derived class after the memory has been freed (or if it fails) + * + * @since S60 5.0 + * @param aError KErrNone if memory has successfully been freed, otherwise any system wide error code + */ + void MemoryFreed(TInt aError); + + COomAction(MOomActionObserver& aStateChangeObserver); + +private: //data + + enum TOomActionState + { + EOomIdle, + EOomFreeingMemory + }; + TOomActionState iState; + + MOomActionObserver& iStateChangeObserver; + }; + +#endif /*OOMACTION_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomactionconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomactionconfig.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMACTIONCONFIG_ +#define OOMACTIONCONFIG_ + +#include +#include +#include + +class MOomRuleConfig; +class COomWindowGroupList; + +enum TOomSyncMode + { + EContinue, // Continue with the next action regardless of anything else (exluding max_batch_size) + EEstimate, // Continue with the next action if we estimate that we need to free more memory + ECheckRam, // Wait for this action to complete, then check the free RAM before continuing + EContinueIgnoreMaxBatchSize // Continue with the next action regardless of anything else (including max_batch_size) + }; + +/* + * The base class for the configuration of all OOM actions + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomActionConfig) : public CBase + { +public: + // Add a rule + // This class takes ownership of the given rule + void AddRuleL(MOomRuleConfig* aRule); // Add the configuration for a rule (e.g. an idle time rule) + + virtual ~COomActionConfig(); + + // Set the priority of this action + // This priority will be applied if none of the attached rules can be applied + inline void SetDefaultPriority(TUint aPriority); + +protected: + + // Return the priority for this action for the idle time of the target app + TUint Priority(const COomWindowGroupList& aWindowGroupList, TInt aAppIndexInWindowGroup) const; + + void ConstructL(); + + COomActionConfig(TInt32 aId); + +public: + + TOomSyncMode iSyncMode; + + TInt iRamEstimate; // The estimated RAM saving after performing this action + + TInt32 iId; // The ID of the affected component (e.g. an application ID for app closure, or a plugin ID for a plugin event) + + TUint iDefaultPriority; + +protected: + + RPointerArray iRules; + }; + +#include "oomactionconfig.inl" + +#endif /*OOMACTIONCONFIG_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomactionconfig.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomactionconfig.inl Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMACTIONCONFIGINL_H_ +#define OOMACTIONCONFIGINL_H_ + +// Set the priority of this action +// This priority will be applied if none of the attached rules can be applied +inline void COomActionConfig::SetDefaultPriority(TUint aPriority) + { + iDefaultPriority = aPriority; + } + + +#endif /*OOMACTIONCONFIGINL_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomactionlist.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomactionlist.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,237 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + +#ifndef OOMACTIONLIST_H_ +#define OOMACTIONLIST_H_ + +#include +#include + +#include "oommonitorplugin.h" + +class COomWindowGroupList; +class CMemoryMonitorServer; +class COomCloseApp; +class TActionRef; +class COomRunPlugin; +class COomConfig; + +/* + * Interface for reporting a change of state in an OOM action + * e.g. that the action has changed from a freeing-memory state to an idle state + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +class MOomActionObserver + { +public: + virtual void StateChanged() = 0; + }; + + +template +/** + * A class for getting instances of all of the OOM ECom plugins + * This class is templated because we actually need two types of list + * One list for V1 plugins + * One list for V2 plugins + * The functionality of each list is nearly identical, hence the templated class + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomPluginList) : public CBase + { +public: + + /** + * Two-phased constructor. + * @param aInterfaceUid The interface of the plugin (either V1 or V2) depending on the templated type + */ + static COomPluginList* NewL(TInt aInterfaceUid); + inline TInt Count(); + inline T& Implementation(TInt aIndex); + inline TInt32 Uid(TInt aIndex); + + ~COomPluginList(); + +private: + COomPluginList(); + void ConstructL(TInt aInterfaceUid); + +private: // data + + struct TPlugin + { + TPlugin(); + T* iImpl; + TUid iDtorUid; + TInt32 iUid; + }; + + RArray iPlugins; + }; + +/* + * The list of possible OOM actions to be run. + * + * This class is responsible for identifying the best action(s) to execute at a given time. + * This decision is based on the properties of each action and idle time of the target apps. + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomActionList) : public CBase, public MOomActionObserver + { +public: + + /** + * Two-phased constructor. + * @param aMonitor the owning Memory Monitor + * @param aServer + * @param aWs a handle to a window server session, opened by the Memory Monitor + * @param aConfig + */ + static COomActionList* NewL(CMemoryMonitor& aMonitor, CMemoryMonitorServer& aServer, RWsSession& aWs, COomConfig& aConfig); + + ~COomActionList(); + + /** + * Creates a list of actions based on the contents of the config and the current window group list + * Any old actions will be replaced. + * + * @since S60 5.0 + * @param aWindowGroupList + * @param aConfig + */ + void BuildActionListL(COomWindowGroupList& aWindowGroupList, COomConfig& aConfig); + + template + void BuildPluginActionsL(COomPluginList& aPluginList, COomWindowGroupList& aWindowGroupList, COomConfig& aConfig, TInt& aActionsIndex); + + /** + * Execute the OOM actions according to their priority + * Actions are run in batches according to their sync mode + * + * @since S60 5.0 + * @param aMaxPriority The maximum priority of actions to run + */ + void FreeMemory(TInt aMaxPriority); + + /** + * Sets the target; the maximum prioirity up to which actions are run when an OomMonitor event + * occurs + * + * @since S60 5.0 + * @param aCurrentTarget the prio + */ + inline void SetCurrentTarget(TUint aCurrentTarget); + + /** + * Switch all plugins to Off (Memory Good) state + * Should be called when the memory situation is good, i.e. the actions run have released enough memory + * so that the device is above the current target. + * It is also always called after an optional RAM request has been processed, even if insufficient + * memory could be freed to successfully complete the request. + * + * @since S60 5.0 + */ + void SwitchOffPlugins(); + + /** + * Compares priorites of two actions, hard-coded rules are used to determine the order + * of actions with equal priority: + * - application plugins are run in preference to system plugins + * - appliction plugins where the target app is not running are run first + * - Z order of the target app determines order of the rest of the application plugins (furthest back first) + * - system plugins are run before app close actions + * - Z order determines the prioirty of app close actions (furthest back first) + * + * @since S60 5.0 + */ + static TInt ComparePriorities(const TActionRef& aPos1, const TActionRef& aPos2 ); + + /** + * A callback from the UI framework that an applications has failed to respond to the close event. + * Allows us to cleanup the related app close action object and move on the next available action. + * + * @since S60 5.0 + * @param aWgId the window group ID of the application that has not closed. + */ + void AppNotExiting(TInt aWgId); + +// from MOomActionObserver + + /** + * + * from MOomActionObserver + * + * An action has changed state (possibly it has completed freeing memory) + */ + void StateChanged(); + +private: + + COomActionList(CMemoryMonitor& aMonitor, CMemoryMonitorServer& aServer, RWsSession& aWs); + + void ConstructL(COomConfig& aConfig); + +private: //data + + RWsSession& iWs; + + RPointerArray iCloseAppActions; + RPointerArray iRunPluginActions; + RArray iActionRefs; + + TInt iCurrentActionIndex; + + TUint iCurrentTarget; + + /* + * Flag specifying that a OomMonitor event is in progress. + */ + TBool iFreeingMemory; + + CMemoryMonitor& iMonitor; + + /** + * The list of V1 plugins + * Own + */ + COomPluginList* iPluginList; + + /** + * The list of V2 plugins + * Own + */ + COomPluginList* iPluginListV2; + + /** + * The maximum priority of actions that should be run by an OomMonitor Event + */ + TInt iMaxPriority; + + CMemoryMonitorServer& iServer; + + }; + +#include "oomactionlist.inl" + +#endif /*OOMACTIONLIST_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomactionlist.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomactionlist.inl Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + +#ifndef OOMACTIONLISTINL_H_ +#define OOMACTIONLISTINL_H_ + +template +inline TInt COomPluginList::Count() + { + return iPlugins.Count(); + } + +template +inline T& COomPluginList::Implementation(TInt aIndex) + { + return *(iPlugins[aIndex].iImpl); + } + +template +inline TInt32 COomPluginList::Uid(TInt aIndex) + { + return iPlugins[aIndex].iUid; + } + +inline void COomActionList::SetCurrentTarget(TUint aCurrentTarget) + { + iCurrentTarget = aCurrentTarget; + } + + +#endif /*OOMACTIONLISTINL_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomactionref.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomactionref.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + +#ifndef OOMACTIONREF_H_ +#define OOMACTIONREF_H_ + +#include +#include "oomactionconfig.h" + +class COomRunPlugin; + +/** + * Encapsulates a reference to an action. + * + * Objects of this T-class are instantiated at memory freeing time in preference to the + * COomAction derived objects, so that we do not instantiate anything on the heap at a time + * when the device is, by-definition, low on memory. + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +class TActionRef + { +public: + + enum TActionType + { + EAppPlugin, + ESystemPlugin, + EAppClose + }; + + //constructor for Plugin actions + TActionRef(TActionType aType, TInt aPriority, TOomSyncMode aSyncMode, TInt aRamEstimate, COomRunPlugin& aRunPlugin, TUint aWgIndexOfTargetApp); + + //constructor for AppClose actions + TActionRef(TActionType aType, TInt aPriority, TOomSyncMode aSyncMode, TInt aRamEstimate, TInt aWgId, TUint aWgIndex); + + TActionType Type() const; + TUint Priority() const; + TOomSyncMode SyncMode() const; + TInt RamEstimate() const; + TInt WgId() const; + TInt WgIndex() const; + COomRunPlugin& RunPlugin(); + +private: //data + + TActionType iType; + TUint iPriority; + TOomSyncMode iSyncMode; //needed as we don't have reference to the config + TInt iRamEstimate; //needed as we don't have reference to the config + TInt iWgId; //For AppClose + TInt iWgIndex; + COomRunPlugin* iRunPlugin; //For Plugins. Not owned + }; + +#endif /*OOMACTIONREF_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomappclosetimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomappclosetimer.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Timer class which implements a timeout for an application close action. +* +*/ + + +#ifndef OOMAPPCLOSETIMER_H_ +#define OOMAPPCLOSETIMER_H_ + +#include + +class COomCloseApp; + +/** + * A simple timer class which implements a timeout for an application close action. + * + * If the application has not been closed within the period this timer is started with, + * then we complete the action as if he had been successful, allowing us to move on to the + * action or set of actions. + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomAppCloseTimer) : public CTimer + { +public: + static COomAppCloseTimer* NewL(COomCloseApp& aMonitor); +private: + COomAppCloseTimer(COomCloseApp& aMonitor); + void RunL(); + +private: //data + + /** + * A reference to the owning close app action + */ + COomCloseApp& iMonitor; + + }; + +#endif /*OOMAPPCLOSETIMER_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomappclosewatcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomappclosewatcher.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: An active object which watches for app close actions successfully completing. +* +*/ + + +#ifndef OOMAPPCLOSEWATCHER_H_ +#define OOMAPPCLOSEWATCHER_H_ + +#include + +class COomCloseApp; +class TApaTask; + +/** + * This class implements an active object which watches for app close actions successfully completing. + * + * This watcher object logs-on to the thread of the application being closed and completes + * the app close action when the thread dies. + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomAppCloseWatcher) : public CActive + { +public: + COomAppCloseWatcher(COomCloseApp& aMonitor); + ~COomAppCloseWatcher(); + void Start(const TApaTask& aTask); +private: + void DoCancel(); + void RunL(); + +private: //data + + /** + * A reference to the owning close app action + */ + COomCloseApp& iMonitor; + + /** + * A handle to the main thread of the application to be closed. + */ + RThread iThread; + + /** + * A backup of the orginal priority of the application's process + */ + TProcessPriority iOriginalProcessPriority; + }; + +#endif /*OOMAPPCLOSEWATCHER_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomapplicationconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomapplicationconfig.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMAPPLICATIONCONFIG_ +#define OOMAPPLICATIONCONFIG_ + +#include + +class COomCloseAppConfig; +class MOomRuleConfig; + +/* + * A list of action configurations for a particular target application. + * + * All configured actions in this list must be for the same target application. + * Actions may be configured to close the application or to run an OOM plugin. + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomApplicationConfig) : public CBase + { +public: + + /** + * Two-phased constructor + * @param aApplicationId the UID of the application + */ + static COomApplicationConfig* NewL(TUint aApplicationId); + +// Functions for getting configuration + + /** + * Return a pointer to the close app config, this may be NULL if no app close config has been configured + * Ownership is NOT passed to the caller + */ + inline COomCloseAppConfig* GetAppCloseConfig(); + + inline TUint Id(); + +// Functions for setting configuration + + inline void SetAppCloseConfig(COomCloseAppConfig* aActionConfig); + + /** + * Add a rule + * + * This class takes ownership of the given rule + * The rule would will apply to the "application close" event + */ + void AddRuleL(MOomRuleConfig* aRule); + + ~COomApplicationConfig(); + +public: + + TUint iGoodRamThreshold; + TUint iLowRamThreshold; + +private: + + void ConstructL(); + + COomApplicationConfig(TUint aApplicationId); + + COomCloseAppConfig* iCloseAppConfig; + + TInt iIndex; + + TUint iApplicationId; + }; + +#include "oomapplicationconfig.inl" + +#endif /*OOMAPPLICATIONCONFIG_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomapplicationconfig.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomapplicationconfig.inl Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMAPPLICATIONCONFIGINL_H_ +#define OOMAPPLICATIONCONFIGINL_H_ + +#include "oompanic.h" + +inline COomCloseAppConfig* COomApplicationConfig::GetAppCloseConfig() + { + return iCloseAppConfig; + } + +inline void COomApplicationConfig::SetAppCloseConfig(COomCloseAppConfig* aActionConfig) + { + __ASSERT_ALWAYS(iCloseAppConfig == NULL, OomMonitorPanic(KSameAppClosureConfiguredTwice)); + + iCloseAppConfig = aActionConfig; + } + + +inline TUint COomApplicationConfig::Id() + { + return iApplicationId; + } + +#endif /*OOMAPPLICATIONCONFIGINL_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomclientrequestqueue.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomclientrequestqueue.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: COomClientRequestQueue.cpp. +* +*/ + + +#ifndef COOMCLIENTREQUESTQUEUE_H +#define COOMCLIENTREQUESTQUEUE_H + +#include +#include +#include + +#include "oommemorymonitor.h" + +class COomClientRequestQueue; +class CMemoryMonitor; +class CSubscribeHelper; + +class TClientRequest + { +public: + TClientRequest(TActionTriggerType aClientRequestType, TInt aBytesRequested); + TClientRequest(TActionTriggerType aClientRequestType, const RMessage2& aRequestFreeRam); +public: + TActionTriggerType iClientRequestType; + TInt iBytesRequested; + RMessage2 iRequestFreeRamMessage; + TSglQueLink iLink; + }; + +/* + * If two client requests are queued, the COomClientRequestTimer is used to wait after the first request + * has been completed, to allow the first client time to allocate the memory it requested. + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomClientRequestTimer) : public CTimer + { +public: + static COomClientRequestTimer* NewL(COomClientRequestQueue& aQueue); +private: + COomClientRequestTimer(COomClientRequestQueue& aQueue); + void RunL(); + +private: //data + COomClientRequestQueue& iClientRequestQueue; + }; + +/** + * Queues client requests so that the actual RAM level of the device is in a state where it can be more + * accurately determined whether more actions need to be run + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomClientRequestQueue) : public CBase + { +public: + + // Constructors and destructor + + /** + * Destructor. + */ + ~COomClientRequestQueue(); + + /** + * Two-phased constructor. + */ + static COomClientRequestQueue* NewL(CMemoryMonitor& aMonitor); + + CMemoryMonitor& Monitor(); + + void RequestFreeMemoryL(const RMessage2& aMessage); + void RequestOptionalRamL(const RMessage2& aMessage); + void ActionsCompleted(TInt aBytesFree, TBool aMemoryGood); + void RequestTimerCallbackL(); + +private: + + /** + * Constructor for performing 1st stage construction + */ + COomClientRequestQueue(CMemoryMonitor& aMonitor); + + /** + * EPOC default constructor for performing 2nd stage construction + */ + void ConstructL(); + + static TInt WatchdogStatusStatusChanged(TAny* aPtr); + void HandleWatchdogStatusCallBack(); + void AddClientRequestL(TClientRequest& request); + void StartClientRequestL(); + + // parameters for P&S watcher. + + /** + * The handle to the P&S property that can be used to initiate OOM Monitor actions + */ + RProperty iWatchdogStatusProperty; + + /** + * The active object which monitors the P&S property that can be used to initiate OOM Monitor actions + * Own. + */ + CSubscribeHelper* iWatchdogStatusSubscriber; + + TSglQue iQueue; + + TBool iClientRequestActive; + + CMemoryMonitor& iMonitor; + + COomClientRequestTimer* iClientRequestTimer; + + TTime iLastClientCompletedTime; + }; + +#endif // COOMCLIENTREQUESTQUEUE_H diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomcloseapp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomcloseapp.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + +#ifndef OOMCLOSEAPP_H_ +#define OOMCLOSEAPP_H_ + + +#include + +#include "oomaction.h" + +class COomAppCloseTimer; +class COomAppCloseWatcher; +class TApaTask; +class TActionRef; + +/* + * The OOM action of closing an application in order to free up memory. + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomCloseApp) : public COomAction + { +public: + /** + * Two-phased constructor. + * @param aStateChangeObserver an observer to the state of the application + * @param aWs a connected handle to a window server session + */ + static COomCloseApp* NewL(MOomActionObserver& aStateChangeObserver, RWsSession& aWs); + + //from COomAction + + /** + * Close the application in order to free memory + * Call the COomAction::MemoryFreed when it is done + * @param aBytesRequested not used for clsoe app actions + */ + virtual void FreeMemory(TInt aBytesRequested); + + ~COomCloseApp(); + + /** + * Callback from COomAppCloseWatcher and COomAppCloseTimer + */ + void CloseAppEvent(); + + inline TBool IsRunning(); + + /** + * Configure, or reconfigure the COomCloseApp object + * Action objects are reused to minimize any memory allocation when memory is low + */ + void Reconfigure(const TActionRef& aRef); + + inline TUint WgId() const; + +private: + + COomCloseApp(MOomActionObserver& aStateChangeObserver, RWsSession& aWs); + + void ConstructL(); + + TUint iWgId; + + TBool iAppCloserRunning; + TApaTask iCurrentTask; + + /** + * A timeout for an app close action + * Own + */ + COomAppCloseTimer* iAppCloseTimer; + + /** + * A watcher for the application closing + * Own + */ + COomAppCloseWatcher* iAppCloseWatcher; + }; + +#include "oomcloseapp.inl" + +#endif /*OOMCLOSEAPP_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomcloseapp.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomcloseapp.inl Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + +#ifndef OOMCLOSEAPPINL_H_ +#define OOMCLOSEAPPINL_H_ + +inline TBool COomCloseApp::IsRunning() + { + return iAppCloserRunning; + } + +inline TUint COomCloseApp::WgId() const + { + return iWgId; + } + +#endif /*OOMCLOSEAPPINL_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomcloseappconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomcloseappconfig.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMCLOSEAPPCONFIG_ +#define OOMCLOSEAPPCONFIG_ + +#include "oomactionconfig.h" + +/* + * + */ +/** + * The OOM action of closing an application in order to free up memory. + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomCloseAppConfig) : public COomActionConfig + { +public: + /** + * Two-phased constructor. + * @param aId The Uid of the applicaton + */ + static COomCloseAppConfig* NewL(TInt32 aId); + + ~COomCloseAppConfig(); + + /** + * Calculates the priority of a close app action, based on its position on the window group list + * + * @param aWindowGroupList a fully constructed, collapsed window group list + * @param aAppIndexInWindowGroup the position in the window group list + */ + inline TUint CalculateCloseAppPriority(const COomWindowGroupList& aWindowGroupList, TUint aAppIndexInWindowGroup); + +private: + + COomCloseAppConfig(TInt32 aId); + }; + +#include "oomcloseappconfig.inl" + +#endif /*OOMCLOSEAPPCONFIG_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomcloseappconfig.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomcloseappconfig.inl Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMCLOSEAPPCONFIGINL_H_ +#define OOMCLOSEAPPCONFIGINL_H_ + +inline TUint COomCloseAppConfig::CalculateCloseAppPriority(const COomWindowGroupList& aWindowGroupList, TUint aAppIndexInWindowGroup) + { + // Calculating the priority for application closures is simple, we just get the base class to apply the rules + return Priority(aWindowGroupList, aAppIndexInWindowGroup); + } + +#endif /*OOMCLOSEAPPCONFIGINL_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomconfig.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMCONFIG_ +#define OOMCONFIG_ + +#include + +#include "oomglobalconfig.h" + +class COomCloseAppConfig; +class COomRunPluginConfig; +class MOomRuleConfig; +class COomApplicationConfig; + +/* + * A class representing the entire configuration. + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomConfig) : public CBase + { +public: + + static COomConfig* NewL(); + +// Functions for setting configuration + + // Add the configuration for an application closure. + // This class takes ownership of this configuration object. + void SetAppCloseConfigL(COomCloseAppConfig* aActionConfig); + + // Add the configuration for a plugin action. + // This class takes ownership of the configuration object. + void AddPluginConfigL(COomRunPluginConfig* aPluginConfig); + + // Add a rule for an application + // This class takes ownership of the given rule + // This rule applies to the specified application (and not a plugin associated with this application) + // The rule would usually apply to an "application close" event + void AddApplicationRuleL(TUint aTargetAppId, MOomRuleConfig* aRule); + + // Add a rule for a plugin + // This class takes ownership of the given rule + // This rule is applied to the plugin with the specified ID + void AddPluginRuleL(TUint aPluginId, MOomRuleConfig* aRule); + + // Add this application config - this class takes ownership of it + // Application config includes settings for a particular application, e.g. whether or not it can be closed + void AddApplicationConfigL(COomApplicationConfig* aApplicationConfig); + +// Functions for getting configuration + + // Get the application configuration for the given app id + // If no specific actions have been configured for this application then the default application configuration is returned + COomApplicationConfig& GetApplicationConfig(TInt32 aAppId); + + // Get the plugin configuration for the given plugin id + // If no specific actions have been configured for this plugin then the default plugin configuration is returned + COomRunPluginConfig& GetPluginConfig(TInt32 aPluginId); + +// Functions for setting global configuration + + ~COomConfig(); + + inline COomGlobalConfig& GlobalConfig(); + + inline void SetDefaultLowRamThreshold(TInt aLowRamThreshold); + inline void SetDefaultGoodRamThreshold(TInt aGoodRamThreshold); + inline void SetMaxCloseAppBatch(TUint MaxCloseAppBatch); + inline void SetDefaultWaitAfterPlugin(TInt aMilliseconds); + inline void SetMaxAppExitTime(TInt aMilliseconds); + +private: + void ConstructL(); + + RHashMap iApplicationToConfigMapping; // A hash-map of application configs, keyed on the application ID + + RHashMap iPluginToConfigMapping; // A hash-map of plug-in configs, keyed on the plugin ID + + COomGlobalConfig iGlobalConfig; + }; + +#include "oomconfig.inl" + +#endif /*OOMCONFIG_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomconfig.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomconfig.inl Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMCONFIGINL_H_ +#define OOMCONFIGINL_H_ + +inline COomGlobalConfig& COomConfig::GlobalConfig() + { + return iGlobalConfig; + } + +void COomConfig::SetDefaultLowRamThreshold(TInt aLowRamThreshold) + { + iGlobalConfig.iLowRamThreshold = aLowRamThreshold; + } + +void COomConfig::SetDefaultGoodRamThreshold(TInt aGoodRamThreshold) + { + iGlobalConfig.iGoodRamThreshold = aGoodRamThreshold; + } + +void COomConfig::SetMaxCloseAppBatch(TUint aMaxCloseAppBatch) + { + iGlobalConfig.iMaxCloseAppBatch = aMaxCloseAppBatch; + } +void COomConfig::SetDefaultWaitAfterPlugin(TInt aMilliseconds) + { + iGlobalConfig.iDefaultWaitAfterPlugin = aMilliseconds; + } + +void COomConfig::SetMaxAppExitTime(TInt aMilliseconds) + { + iGlobalConfig.iMaxAppExitTime = aMilliseconds; + } + +#endif /*OOMCONFIGINL_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomconfigparser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomconfigparser.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The parser for the OOM configuration file. +* +*/ + + +#ifndef OOMCONFIGPARSER_H_ +#define OOMCONFIGPARSER_H_ + +#include + +using namespace Xml; + +class COomConfig; +class COomRunPluginConfig; + +/** + * Parser for the Oom Monitor configuration file + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomConfigParser) : public CBase, public MContentHandler + { +public: + COomConfigParser(COomConfig& aConfig, RFs& aFs); + + void ParseL(); + + + // From MContent handler + virtual void OnStartDocumentL(const RDocumentParameters& aDocParam, TInt aErrorCode); + virtual void OnEndDocumentL(TInt aErrorCode); + virtual void OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, + TInt aErrorCode); + virtual void OnEndElementL(const RTagInfo& aElement, TInt aErrorCode); + virtual void OnContentL(const TDesC8& aBytes, TInt aErrorCode); + virtual void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, + TInt aErrorCode); + virtual void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode); + virtual void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode); + virtual void OnSkippedEntityL(const RString& aName, TInt aErrorCode); + virtual void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, + TInt aErrorCode); + virtual void OnError(TInt aErrorCode); + virtual TAny* GetExtendedInterface(const TInt32 aUid); + + + +private: + + void ConfigError(TInt aError); + + + + void StartElementL(const TDesC8& aLocalName, + const RAttributeArray& aAttributes); + + void SetGlobalSettings(const RAttributeArray& aAttributes); + void SetForceCheckConfigL(const RAttributeArray& aAttributes); + void SetAppConfigL(const RAttributeArray& aAttributes); + void SetCloseAppConfigL(const RAttributeArray& aAttributes); + void SetAppCloseIdlePriorityConfigL(const RAttributeArray& aAttributes); + void SetForegroundAppPriorityL(const RAttributeArray& aAttributes); + + void SetSystemPluginConfigL(const RAttributeArray& aAttributes); + void SetAppPluginConfigL(const RAttributeArray& aAttributes); + void SetPluginIdlePriorityL(const RAttributeArray& aAttributes); + void SetPluginForegroundAppPriorityL(const RAttributeArray& aAttributes); + + TInt GetValueFromAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TPtrC8& aValue); + TInt GetValueFromHexAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TUint& aValue); + TInt GetValueFromDecimalAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TUint& aValue); + TInt GetValueFromDecimalAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TInt& aValue); + TInt GetValueFromBooleanAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TBool& aValue); + + void SetPluginSyncMode(const RAttributeArray& aAttributes, COomRunPluginConfig& aRunPluginConfig); + + enum TOomParsingState + { + EOomParsingStateNone, + EOomParsingStateRoot, + EOomParsingStateGlobalSettings, + EOomParsingStateAppSettings, + EOomParsingStateAppCloseSettings, + EOomParsingStateSystemPluginSettings, + EOomParsingStateAppPluginSettings + }; + + // Check that the current state is as expected + // If not then the specified config error is generated + void CheckState(TOomParsingState aExpectedState, TInt aError); + + // Check that the current state is as expected + // If not then the specified config error is generated + // This version checks to ensure that the current state matches either of the passed in states + void CheckState(TOomParsingState aExpectedState1, TOomParsingState aExpectedState2, TInt aError); + + COomConfig& iConfig; + + RFs& iFs; + + void ChangeState(TOomParsingState aState); + + TOomParsingState iState; + + TUint iParentUid; + TUint iParentTargetApp; + }; + +#endif /*OOMCONFIGPARSER_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomconstants.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomconstants.hrh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Out of Memory Monitor Constants. +* +*/ + + +#ifndef OOMCONSTANTS_HRH_ +#define OOMCONSTANTS_HRH_ + +const TInt KAppNotInWindowGroupList = -1; + +const TInt KOomDefaultAppId = 0; +const TInt KOomDefaultPluginId = 0; +const TInt KOomThresholdUnset = 0; + +const TInt KOomBusyAppId = 0x10286A84; +const TInt KOomHighPriorityAppId = 0x10286A85; + +const TInt KOomPriorityInfinate = 1024; + +// same as Akncapserver since fast swap is contained in it +const TUid KUidFastSwap = { 0x10207218 }; +const TUid KUidPenInputServer = { 0x10281855 }; + +const TInt KMicrosecondsInMillisecond = 1000; + +#endif /*OOMCONSTANTS_HRH_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomforegroundrule.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomforegroundrule.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMFOREGROUNDRULE_ +#define OOMFOREGROUNDRULE_ + +#include +#include "oomruleconfig.h" + +/** + * A rule to modify the priority if a particular application is in the foreground + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomForegroundRule) : public CBase, public MOomRuleConfig + { +public: + // If the specified target app is in the foreground then apply the specified priority + COomForegroundRule(TInt aTargetAppId, TInt aPriority); + + TBool RuleIsApplicable(const COomWindowGroupList& aWindowGroupList, TInt aAppIndexInWindowGroup) const; + + inline TUint Priority() const; + +private: + TInt iTargetAppId; + TInt iPriority; // The priority to apply if the specified app is in the foreground + }; + +#include "oomforegroundrule.inl" + +#endif /*OOMFOREGROUNDRULE_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomforegroundrule.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomforegroundrule.inl Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMFOREGROUNDRULEINL_H_ +#define OOMFOREGROUNDRULEINL_H_ + + +inline TUint COomForegroundRule::Priority() const + { + return iPriority; + } + +#endif /*OOMFOREGROUNDRULEINL_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomglobalconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomglobalconfig.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMGLOBALCONFIG_ +#define OOMGLOBALCONFIG_ + +#include +#include + +/** + * Class presenting the parts of the configuration that are global defaults rather than specific + * to the current state of the device + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomGlobalConfig) : public CBase + { +public: + ~COomGlobalConfig(); + + inline void AddForceCheckPriorityL(TUint aPriority); + + // Return ETrue if a force check has been added for this priority, return EFalse otherwise + inline TBool ForceCheckAtPriority(TUint aPriority) const; + +public: + TInt iLowRamThreshold; + TInt iGoodRamThreshold; + TUint iMaxCloseAppBatch; + TInt iDefaultWaitAfterPlugin; + TInt iMaxAppExitTime; + + RHashSet iForceCheckPriorities; + }; + +#include "oomglobalconfig.inl" + +#endif /*OOMGLOBALCONFIG_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomglobalconfig.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomglobalconfig.inl Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMGLOBALCONFIGINL_H_ +#define OOMGLOBALCONFIGINL_H_ + +void COomGlobalConfig::AddForceCheckPriorityL(TUint aPriority) + { + iForceCheckPriorities.InsertL(aPriority); + } + +// Return ETrue if a force check has been added for this priority, return EFalse otherwise +TBool COomGlobalConfig::ForceCheckAtPriority(TUint aPriority) const + { + return (iForceCheckPriorities.Find(aPriority) != NULL); + } + +#endif /*OOMGLOBALCONFIGINL_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomidletimerule.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomidletimerule.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMIDLETIMERULE_ +#define OOMIDLETIMERULE_ + +#include + +#include "oomruleconfig.h" + +/** + * A rule to modify the priority of an app close action if it has been idle for a period of time + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomIdleTimeRule) : public CBase, public MOomRuleConfig + { +public: + static COomIdleTimeRule* NewL(TTimeIntervalSeconds aIdleTime, TInt aPriority); + + TBool RuleIsApplicable(const COomWindowGroupList& aWindowGroupList, TInt aAppIndexInWindowGroup) const; + + inline TUint Priority() const; + + ~COomIdleTimeRule(); + +private: + COomIdleTimeRule(TTimeIntervalSeconds aIdleTime, TInt aPriority); + +private: + TTimeIntervalSeconds iIdleTime; // The idle time after which to apply the given priority + TInt iPriority; // The priority to apply after the given idle time + }; + +#include "oomidletimerule.inl" + +#endif /*OOMIDLETIMERULE_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomidletimerule.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomidletimerule.inl Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMIDLETIMERULEINL_H_ +#define OOMIDLETIMERULEINL_H_ + +inline TUint COomIdleTimeRule::Priority() const + { + return iPriority; + } + +#endif /*OOMIDLETIMERULEINL_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomlog.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomlog.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Logging functionality for OOM monitor profiling. +* +*/ + + +#ifndef OOMLOG_H_ +#define OOMLOG_H_ + +#ifdef _DEBUG + +#include + +#include "oomwindowgrouplist.h" + +const TUint KTimeBetweenMemorySamples = 100000; // In microseconds +const TUint KSamplingDurationUint = 3000000; + +const TUint KMaxBytesOfLoggingPerSample = 20; + +NONSHARABLE_CLASS(COomLogger) : public CTimer + { +public: + static COomLogger* NewL(RWsSession& aWs, RFs& aFs); + + // Start logging the available memory every n micro seconds + // Firstly a list of the app IDs is written to the log (foreground app first) + // Note that the log is created in memory (to a pre-allocated buffer) and flushed out after it is complete + // the samples are saved in CSV format so that they can easily be cut and pasted to plot graphs etc. + void StartL(); + +// From CTimer / CActice + void RunL(); + void DoCancel(); + + ~COomLogger(); + + void Write(const TDesC8& aBuffer); + +protected: + void LogApplicationIds(); + void LogFreeMemory(); + + COomLogger(RWsSession& aWs, RFs& aFs); + void ConstructL(); + + // Duplicated functionality from OomMonitor + // Duplicated because it was messy to reuse it and to minimise changes to OOM monitor during development of new features + void ColapseWindowGroupTree(); + + TUid GetUidFromWindowGroupId(TInt aWgId); + + RWsSession& iWs; + + // Used to get a list of open applications + RArray iWgIds; + CApaWindowGroupName* iWgName; + HBufC* iWgNameBuf; // owned by iWgName + + RFs& iFs; + + RFile iFile; + TBool iIsOpen; + + // The time when the logging was started + TTime iStartTime; + + TBuf8<(KSamplingDurationUint / KTimeBetweenMemorySamples) * KMaxBytesOfLoggingPerSample> iWriteBuffer; + }; + +#endif //_DEBUG + +#endif /*OOMLOG_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oommemorymonitor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oommemorymonitor.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,196 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMMEMORYMONITOR_H +#define OOMMEMORYMONITOR_H + +#include +#include +#include +#include "oomglobalconfig.h" +#include "oomwindowgrouplist.h" +#include "oommonitorsession.h" + +enum TActionTriggerType + { + ERamRotation, + EClientServerRequestOptionalRam, + EClientServerRequestFreeMemory, + EPublishAndSubscribe + }; + +// --------------------------------------------------------- +// CMemoryMonitor +// --------------------------------------------------------- +// +class COutOfMemoryWatcher; +class CSubscribeHelper; +class COomMonitorPlugin; +class CMemoryMonitorServer; +class CWservEventReceiver; +class COomActionList; +class COomLogger; +class COomConfig; +class COomClientRequestQueue; + +/** + * The main manager class for Oom Monitor. It has the following responsibility: + * + * - initiates building the static configuration at boot time and owns the object which holds this. + * - owns and drives the action list which runs actions + * - owns the internal representation of the window group list and an active object to monitor window group changes + * - owns the public API via the server and client request queue. + * - has an active object which monitors low RAM events + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(CMemoryMonitor) : public CBase + { +public: + static CMemoryMonitor* NewL(); + ~CMemoryMonitor(); + +public: // event handlers + void FreeMemThresholdCrossedL(); + void AppNotExiting(TInt aWgId); + void StartFreeSomeRamL(TInt aTargetFree); + void StartFreeSomeRamL(TInt aTargetFree, TInt aMaxPriority); + void FreeOptionalRamL(TInt aBytesRequested, TInt aPluginId); // The ID of the plugin that will clear up the allocation, used to determine the priority of the allocation + void HandleFocusedWgChangeL(); + static const COomGlobalConfig& GlobalConfig(); + void SetPriorityBusy(TInt aWgId); + void SetPriorityNormal(TInt aWgId); + void SetPriorityHigh(TInt aWgId); + void ResetTargets(); + void RequestTimerCallbackL(); + void GetFreeMemory(TInt& aCurrentFreeMemory); + TActionTriggerType ActionTrigger() const; +#ifdef CLIENT_REQUEST_QUEUE + void ActionsCompleted(TInt aBytesFree, TBool aMemoryGood); + TInt GoodThreshold() const; + TInt LowThreshold() const; +#endif + void RequestFreeMemoryL(TInt aBytesRequested); + void RequestFreeMemoryPandSL(TInt aBytesRequested); + + /* + * Sets the RProperty associated with KOomMemoryMonitorStatusPropertyKey + * It checks if the value is going to be changed. + * If the new value is the same as the old one then the property is not updated + * If the new value is different from the previously set one then the property is update + * + * @param aNewValue one of TMemoryMonitorStatusPropertyValues + */ + void SetMemoryMonitorStatusProperty(const TMemoryMonitorStatusPropertyValues aValue); + +private: + CMemoryMonitor(); + void ConstructL(); +#ifndef CLIENT_REQUEST_QUEUE + static TInt WatchdogStatusStatusChanged(TAny* aPtr); + void HandleWatchdogStatusCallBack(); + TBool FreeMemoryAboveThreshold(TInt& aCurrentFreeMemory); void CloseNextApp(); +#endif + void RefreshThresholds(); + +public: + // All members are owned + // generally useful sessions + RFs iFs; + RWsSession iWs; + +private: //data + + // parameters for OOM watcher. + TInt iLowThreshold; + TInt iGoodThreshold; + TInt iCurrentTarget; +#ifdef CLIENT_REQUEST_QUEUE + TInt iClientBytesRequested; +#endif + // event receivers + + /** + * The active object which monitors the kernel change notifier for changes in the low and good thresholds + * Own + */ + COutOfMemoryWatcher* iOOMWatcher; + + + CWservEventReceiver* iWservEventReceiver; + +#ifndef CLIENT_REQUEST_QUEUE + // parameters for P&S watcher. + /** + * The handle to the P&S property that can be used to initiate OOM Monitor actions + */ + RProperty iWatchdogStatusProperty; + + /** + * The active object which monitors the P&S property that can be used to initiate OOM Monitor actions + * Own. + */ + CSubscribeHelper* iWatchdogStatusSubscriber; +#endif + + /** + * The Memory Monitor Server + * Own. + */ + CMemoryMonitorServer* iServer; + +#ifdef CLIENT_REQUEST_QUEUE + COomClientRequestQueue* iQueue; +#endif + +#ifdef _DEBUG + /** + * Oom logging tool - samples free memory for profiling + * Own. + */ + COomLogger* iLogger; +#endif + + /** + * A list of window group Ids, with child window groups removed such that there is one Id per application + * Own. + */ + COomWindowGroupList* iOomWindowGroupList; + + /** + * The object responsible for identifying the best actions to run, and running them + * Own. + */ + COomActionList* iOomActionList; + + /** + * The entire Oom Monitor configuration + * Own. + */ + COomConfig* iConfig; + + /** + * The most recent value the memory monitor status property was set to + */ + TInt iLastMemoryMonitorStatusProperty; + + TActionTriggerType iActionTrigger; + }; + +#endif /*OOMMEMORYMONITOR_H*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oommemorymonitorserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oommemorymonitorserver.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMMEMORYMONITORSERVER_H +#define OOMMEMORYMONITORSERVER_H + +#include + +class CMemoryMonitor; +class COomClientRequestQueue; + +NONSHARABLE_CLASS(CMemoryMonitorServer) : public CServer2 + { +public: +#ifdef CLIENT_REQUEST_QUEUE + static CMemoryMonitorServer* NewL(COomClientRequestQueue& aQueue); +#else + static CMemoryMonitorServer* NewL(CMemoryMonitor& aMonitor); +#endif + ~CMemoryMonitorServer(); + + CMemoryMonitor& Monitor(); +#ifndef CLIENT_REQUEST_QUEUE + void CloseAppsFinished(TInt aBytesFree, TBool aMemoryGood); +#endif +#ifdef CLIENT_REQUEST_QUEUE + COomClientRequestQueue& ClientRequestQueue(); +#endif + +private: +#ifdef CLIENT_REQUEST_QUEUE + CMemoryMonitorServer(COomClientRequestQueue& aQueue); +#else + CMemoryMonitorServer(CMemoryMonitor& aMonitor); +#endif + void ConstructL(); + CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const; + TInt RunError(TInt aError); + +private: +#ifdef CLIENT_REQUEST_QUEUE + COomClientRequestQueue& iQueue; +#else + CMemoryMonitor& iMonitor; +#endif + }; + +#endif /*OOMMEMORYMONITORSERVER_H*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oommemorymonitorsession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oommemorymonitorsession.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMMEMORYMONITORSESSION_H +#define OOMMEMORYMONITORSESSION_H + +#include + +class CMemoryMonitorServer; +class CMemoryMonitor; +class COomClientRequestQueue; + +NONSHARABLE_CLASS(CMemoryMonitorSession) : public CSession2 + { +public: + CMemoryMonitorSession(); +#ifndef CLIENT_REQUEST_QUEUE + void CloseAppsFinished(TInt aBytesFree, TBool aMemoryGood); +#endif + +private: + ~CMemoryMonitorSession(); + CMemoryMonitorServer& Server(); +#ifdef CLIENT_REQUEST_QUEUE + COomClientRequestQueue& ClientRequestQueue(); +#endif + CMemoryMonitor& Monitor(); + void ServiceL(const RMessage2& aMessage); + +private: + RMessagePtr2 iRequestFreeRam; +#ifndef CLIENT_REQUEST_QUEUE + TInt iFunction; +#endif + TInt iMinimumMemoryRequested; + }; + +#endif /*OOMMEMORYMONITORSESSION_H*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oommonitorclientserver.h --- a/sysresmonitoring/oommonitor/inc/oommonitorclientserver.h Tue Feb 02 10:12:00 2010 +0200 +++ b/sysresmonitoring/oommonitor/inc/oommonitorclientserver.h Fri Feb 19 22:58:54 2010 +0200 @@ -11,7 +11,7 @@ * * Contributors: * -* Description: Command definitions for OOM Monitor client/server interface. +* Description: The client / server classes allowing clients to make requests to OOM monitor. * */ @@ -22,20 +22,24 @@ #include enum TOomMonitorClientPanic - { - EPanicIllegalFunction, - EPanicRequestActive - }; + { + EPanicIllegalFunction, + EPanicRequestActive + }; void PanicClient(const RMessagePtr2& aMessage,TOomMonitorClientPanic aPanic); _LIT(KMemoryMonitorServerName, "OomMonitorServer"); enum TOomMonitorCmd - { - EOomMonitorRequestFreeMemory, - EOomMonitorCancelRequestFreeMemory, - EOomMonitorThisAppIsNotExiting - }; + { + EOomMonitorRequestFreeMemory, + EOomMonitorCancelRequestFreeMemory, + EOomMonitorThisAppIsNotExiting, + EOomMonitorRequestOptionalRam, + EOomMonitorSetPriorityBusy, + EOomMonitorSetPriorityNormal, + EOomMonitorSetPriorityHigh + }; #endif // OOMMONITORCLIENTSERVER_H diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomoutofmemorywatcher.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomoutofmemorywatcher.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMOUTOFMEMORYWATCHER_H +#define OOMOUTOFMEMORYWATCHER_H + +#include + +class CMemoryMonitor; + +/** + * This class is an active object which monitors a kernel change notifer for changes in the + * low and good memory thresholds. + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COutOfMemoryWatcher) : public CActive + { +public: + static COutOfMemoryWatcher* NewL(CMemoryMonitor& aLafShutdown, TInt aLowThreshold, TInt aGoodThreshold); + ~COutOfMemoryWatcher(); + void Start(); + + /** + * Set the Low and Good thresholds that we are listening for. + * These values can change from the global default values when certain applications are in the foreground. + * @param aLowThreshold If Ram Level drops below the low threshold Oom Monitor actions are started. + * @param aGoodThreshold When memory returns above the Good threshold then Oom Monitor stops freeing memory. + */ + void UpdateThresholds(TInt aLowThreshold, TInt aGoodThreshold); +private: + COutOfMemoryWatcher(CMemoryMonitor& aLafShutdown); + void ConstructL(TInt aLowThreshold, TInt aGoodThreshold); +private: // from CActive + void DoCancel(); + void RunL(); +private: // data + RChangeNotifier iChangeNotifier; + CMemoryMonitor& iLafShutdown; + }; + +#endif /*OOMOUTOFMEMORYWATCHER_H*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oompanic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oompanic.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Panic codes for OOM monitor. +* +*/ + + +#ifndef OOMPANIC_ +#define OOMPANIC_ + +#include + +enum TOomMonitorPanic + { + KRuleConfiguredBeforeApplication, + KCloseAppActionIsResued, + KAppConfigAddedTwice, + KSameAppClosureConfiguredTwice, + KOomDefaultAppCloseNotConfigured, + KPluginConfigAddedTwice, + KRuleConfiguredBeforePlugin, + KOomDefaultAppNotConfigured, + KOomDefaultPluginNotConfigured, + KNoCoeEnvFound, + KInvalidWgName, + KOomInvalidPriority, + KAppCloseActionEqualPriorities, + KClientQueueNotEmpty, + KClientRequestTimerActive, + KInvalidClientRequestType, + KPluginArrayIndexOutOfBounds, + KWindowGroupArrayIndexOutOfBounds, + KStartingActiveCloseAppTimer, + KStartingActiveAppCloseWatcher, + KStartingActivePluginWaiter + }; + +void OomMonitorPanic(TOomMonitorPanic aReason); +void OomConfigParserPanic(TInt aReason); + +#endif /*OOMPANIC_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oompluginwaiter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oompluginwaiter.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + +#ifndef OOMPLUGINWAITER_H_ +#define OOMPLUGINWAITER_H_ + +#include + +class COomRunPlugin; + + +/* + * A class used for waiting for a pre-determined period before completing the plugin operation + * It is intended to be used to force a delay between the call to the plugin and the memory check, + * thus allowing the plugin to free some memory first. + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomPluginWaiter) : public CTimer + { +public: + static COomPluginWaiter* NewL(TInt aMillisecondsToWait, COomRunPlugin& aCallbackClass); + + // Start the timer, it will call the plugin back when it expires + void Start(); + +protected: + void RunL(); + + COomPluginWaiter(TInt aMillisecondsToWait, COomRunPlugin& aCallbackClass); + +private: + TInt iMillisecondsToWait; + COomRunPlugin& iCallbackClass; + }; + +#endif /*OOMPLUGINWAITER_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomruleconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomruleconfig.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMRULECONFIG_ +#define OOMRULECONFIG_ + +#include + +class COomWindowGroupList; + +NONSHARABLE_CLASS(MOomRuleConfig) + { +public: + virtual TBool RuleIsApplicable(const COomWindowGroupList& aWindowGroupList, TInt aAppIndexInWindowGroup) const = 0; + virtual TUint Priority() const = 0; + }; + +#endif /*OOMRULECONFIG_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomrunplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomrunplugin.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + +#ifndef OOMRUNPLUGIN_H_ +#define OOMRUNPLUGIN_H_ + +#include "oomaction.h" + +class COomRunPlugin; +class COomRunPluginConfig; +class MOomActionObserver; +class COomPluginWaiter; +class COomMonitorPlugin; +class COomMonitorPluginV2; +class COomActionConfig; + +/* + * The OOM action of running an OOM plug-in to free up memory. + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomRunPlugin) : public COomAction + { +public: + static COomRunPlugin* NewL(TUint aPluginId, COomRunPluginConfig& aConfig, MOomActionObserver& aStateChangeObserver, COomMonitorPlugin& aPlugin, COomMonitorPluginV2* aV2Plugin = NULL); + + ~COomRunPlugin(); + + // Run the OOM plugin in order to free memory + // Call the COomAction::MemoryFreed when it is done + virtual void FreeMemory(TInt aBytesRequested); + + // Call the memory good function on the plugin but... + // only if there is an outstanding FreeMemory request + void MemoryGood(); + + inline TBool IsRunning(); + + // To be called by the COomPluginWaiter + inline void WaitCompleted(); + +protected: + + void ConstructL(COomRunPluginConfig& aPluginConfig); + + inline COomActionConfig& GetConfig(); + +private: + + COomRunPlugin(TUint aPluginId, COomRunPluginConfig& aConfig, MOomActionObserver& aStateChangeObserver, COomMonitorPlugin& aPlugin, COomMonitorPluginV2* aV2Plugin); + + TUint iPluginId; + + COomMonitorPlugin& iPlugin; + + COomRunPluginConfig& iConfig; + + COomPluginWaiter* iPluginWaiter; + + // Note that this shouldn't be deleted + // If it is pointing to a V2 plugin then it is a cast to the same instance as iPlugin + COomMonitorPluginV2* iV2Plugin; + + TBool iFreeMemoryCalled; // True if FreeMemory has been called since the last call to MemoryGood + }; + +#include "oomrunplugin.inl" + +#endif /*OOMRUNPLUGIN_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomrunplugin.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomrunplugin.inl Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + +#ifndef OOMRUNPLUGININL_H_ +#define OOMRUNPLUGININL_H_ + +#include "oomactionconfig.h" +#include "oompluginwaiter.h" +#include "oomrunpluginconfig.h" + +inline COomActionConfig& COomRunPlugin::GetConfig() + { + return iConfig; + } + + +inline TBool COomRunPlugin::IsRunning() + { + return iPluginWaiter->IsActive(); + } + +inline void COomRunPlugin::WaitCompleted() + { + MemoryFreed(KErrNone); + } + + +#endif /*OOMRUNPLUGININL_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomrunpluginconfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomrunpluginconfig.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMRUNPLUGINCONFIG_ +#define OOMRUNPLUGINCONFIG_ + +#include "oomactionconfig.h" + +enum TOomPluginType + { + EOomAppPlugin, + EOomSystemPlugin + }; + +/* + * The OOM action of running an OOM plug-in to free up memory. + */ +NONSHARABLE_CLASS(COomRunPluginConfig) : public COomActionConfig + { +public: + static COomRunPluginConfig* NewL(TUint aPluginId, TOomPluginType aPluginType); + + TUint CalculatePluginPriority(const COomWindowGroupList& aWindowGroupList); + + inline TUint Id(); + + inline void SetTargetApp(TUint aTargetAppId); + + inline TUint TargetApp() const; + + ~COomRunPluginConfig(); + + // Returns ETrue if a wait period has been explicitly configured for this plugin + inline TBool WaitAfterPluginDefined() const; + + // Returns the configured wait after the plugin has been called + inline TInt WaitAfterPlugin() const; + + inline TBool CallIfTargetAppNotRunning() const; + + // Set the time to wait + inline void SetWaitAfterPlugin(TInt aMillisecondsToWait); + + inline void SetCallIfTargetAppNotRunning(TBool aCallIfTargetAppNotRunning); + + inline TOomPluginType PluginType(); + +private: + COomRunPluginConfig(TUint aPluginId, TOomPluginType aPluginType); + + TUint iPluginId; + + TUint iTargetAppId; + + TBool iWaitAfterPluginDefined; + + TInt iWaitAfterPlugin; // The period to wait after a plugin has been called + + TBool iCallIfTargetAppNotRunning; + + TOomPluginType iPluginType; + }; + +#include "oomrunpluginconfig.inl" + +#endif /*OOMRUNPLUGINCONFIG_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomrunpluginconfig.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomrunpluginconfig.inl Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMRUNPLUGINCONFIGINL_H_ +#define OOMRUNPLUGINCONFIGINL_H_ + + +// Returns ETrue if a wait period has been explicitly configured for this plugin +inline TBool COomRunPluginConfig::WaitAfterPluginDefined() const + { + return iWaitAfterPluginDefined; + } + +// Returns the configured wait after the plugin has been called +inline TInt COomRunPluginConfig::WaitAfterPlugin() const + { + return iWaitAfterPlugin; + } + +inline TBool COomRunPluginConfig::CallIfTargetAppNotRunning() const + { + return iCallIfTargetAppNotRunning; + } + +// Set the time to wait +inline void COomRunPluginConfig::SetWaitAfterPlugin(TInt aMillisecondsToWait) + { + iWaitAfterPluginDefined = ETrue; + iWaitAfterPlugin = aMillisecondsToWait; + } + +inline void COomRunPluginConfig::SetCallIfTargetAppNotRunning(TBool aCallIfTargetAppNotRunning) + { + iCallIfTargetAppNotRunning = aCallIfTargetAppNotRunning; + } + +inline void COomRunPluginConfig::SetTargetApp(TUint aTargetAppId) + { + iTargetAppId = aTargetAppId; + } + +inline TUint COomRunPluginConfig::Id() + { + return iPluginId; + } + +inline TOomPluginType COomRunPluginConfig::PluginType() + { + return iPluginType; + } + +inline TUint COomRunPluginConfig::TargetApp() const + { + return iTargetAppId; + } + +#endif /*OOMRUNPLUGINCONFIGINL_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomsubscribehelper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomsubscribehelper.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMSUBSCRIBEHELPER_H +#define OOMSUBSCRIBEHELPER_H + +#include + +class RProperty; + +/** + * This class is a simple active object which monitors the publish subscribe key method of calling the + * requesting that the OOM Monitor starts to free memory + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(CSubscribeHelper) : public CActive + { +public: + CSubscribeHelper(TCallBack aCallBack, RProperty& aProperty); + ~CSubscribeHelper(); + +public: // New functions + void Subscribe(); + void StopSubscribe(); + +private: // from CActive + void RunL(); + void DoCancel(); + +private: + TCallBack iCallBack; + RProperty& iProperty; + }; + +#endif /*OOMSUBSCRIBEHELPER_H*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomwindowgrouplist.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomwindowgrouplist.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,119 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: A wrapper for the window group list, adding additional functionality required by OOM Monitor v2. +* +*/ + + +#ifndef OOMWINDOWGROUPLIST_H_ +#define OOMWINDOWGROUPLIST_H_ + +#include +#include +#include + +class CApaWindowGroupName; + +/** + * This class holds a snapshot of the window group tree. + * + * The window group tree is collapsed (see CollapseWindowGroupTree) to remove child windows as we are only + * interested in a single window group Id per application. + * + * @lib oommonitor.lib + * @since S60 v5.0 + */ +NONSHARABLE_CLASS(COomWindowGroupList) : public CBase + { +public: + + static COomWindowGroupList* NewL(RWsSession& aWs); + + // Update the list of window groups + void RefreshL(); + + // Update the list of window groups, non-leaving version + void Refresh(); + + // Return the number of application instances in this list + inline TUint Count() const; + + TUint AppId(TInt aIndex, TBool aResolveFromThread = EFalse) const; + + inline const RWsSession::TWindowGroupChainInfo& WgId(TInt aIndex) const; + + TTimeIntervalSeconds IdleTime(TInt aIndex) const; + + ~COomWindowGroupList(); + + void SetPriorityBusy(TInt aWgId); + + void SetPriorityNormal(TInt aWgId); + + void SetPriorityHigh(TInt aWgId); + + TBool IsBusy(TInt wgIndex); + + // Returns ETrue if an application has registered itself as high priority at runtime + TBool IsDynamicHighPriority(TInt wgIndex); + + CApaWindowGroupName* WgName() const; + + // Find the specificed application in the window group list and return the index + TInt GetIndexFromAppId(TUint aAppId) const; + +private: + + void CollapseWindowGroupTree(); + + void RemovePropertiesForClosedWindowsL(); + + TInt FindParentIdL(TInt aWgId); + +private: + + COomWindowGroupList(RWsSession& aWs); + + void ConstructL(); + + RArray iWgIds; + RArray iUncollapsedWgIds; + + enum TOomPriority + { + EOomPriorityNormal, + EOomPriorityHigh, + EOomPriorityBusy + }; + + class TOomWindowGroupProperties + { + public: + TOomWindowGroupProperties(); + TUint32 iIdleTickTime; + TOomPriority iDynamicPriority; + }; + + RHashMap iWgToPropertiesMapping; // A mapping between window group IDs and the properties such as idle time and the high-priority flag + RHashSet iExistingWindowIds; // Used locally in RemoveIdleTimesForClosedWindows(), declared globally because we need to reserve space + + RWsSession& iWs; + + CApaWindowGroupName* iWgName; + HBufC* iWgNameBuf; // owned by iWgName + }; + +#include "oomwindowgrouplist.inl" + +#endif /*OOMWINDOWGROUPLIST_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomwindowgrouplist.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomwindowgrouplist.inl Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + +#ifndef OOMWINDOWGROUPLISTINL_H_ +#define OOMWINDOWGROUPLISTINL_H_ + +// Return the number of application instances in this list +inline TUint COomWindowGroupList::Count() const + { + return iWgIds.Count(); + } + +inline const RWsSession::TWindowGroupChainInfo& COomWindowGroupList::WgId(TInt aIndex) const + { + return iWgIds[aIndex]; + } + +#endif /*OOMWINDOWGROUPLISTINL_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/oomwserveventreceiver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/oomwserveventreceiver.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main classes for Out of Memory Monitor. +* +*/ + + +#ifndef OOMWSERVEVENTRECEIVER_H +#define OOMWSERVEVENTRECEIVER_H + +#include +class CMemoryMonitor; + +NONSHARABLE_CLASS(CWservEventReceiver) : public CActive + { +public: + CWservEventReceiver(CMemoryMonitor& aMonitor, RWsSession& aWs); + ~CWservEventReceiver(); + void ConstructL(); +private: + void Queue(); + void DoCancel(); + void RunL(); +private: + CMemoryMonitor& iMonitor; + RWsSession& iWs; + RWindowGroup iWg; + }; + +#endif /*OOMWSERVEVENTRECEIVER_H*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/traceconfiguration.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/traceconfiguration.hrh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Tracing flags configuration. +* +*/ + + +#ifndef TRACECONFIGURATION_HRH +#define TRACECONFIGURATION_HRH + +//----------------------------------------------------------------------------- +// Trace definitions +//----------------------------------------------------------------------------- +// + +/** +* Error trace enabled +*/ +#ifdef _DEBUG + #define ERROR_TRACE +#else + #undef ERROR_TRACE +#endif + +/** +* Info trace enabled +*/ +#define __OOM_INFO_TRACE__ +#if defined _DEBUG && defined __OOM_INFO_TRACE__ + #define INFO_TRACE + #define TIMESTAMP_TRACE +#else + #undef INFO_TRACE + #undef TIMESTAMP_TRACE +#endif + +/** +* Function trace enabled +*/ +#if defined _DEBUG && defined __OOM_FUNC_TRACE__ + #define FUNC_TRACE +#else + #undef FUNC_TRACE +#endif + +/** +* Timestamp tracing on +*/ +#if defined _DEBUG && defined __OOM_TIMESTAMP_TRACE__ + #define TIMESTAMP_TRACE +#else + #undef TIMESTAMP_TRACE +#endif + +/** +* Tracing current client process and thread +*/ +#ifdef _DEBUG + #define CLIENT_TRACE +#else + #undef CLIENT_TRACE +#endif + +/** +* Tracing into file enabled, default RDebug +*/ +#ifdef __OOM_TRACE_INTO_FILE__ + #define TRACE_INTO_FILE +#else + #undef TRACE_INTO_FILE +#endif + +#endif diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/inc/tracedefs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/inc/tracedefs.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Definitions for tracing. +* +*/ + + +#ifndef TRACEDEFS_H +#define TRACEDEFS_H + +//----------------------------------------------------------------------------- +// Constants +//----------------------------------------------------------------------------- +// + +/** +* Prefix trace macro to complete tracing with component name. +* Returns TDesC which can be used directly with RDebug or RFileLogger. +*/ +#define _PREFIX_TRACE( aMsg ) TPtrC( (const TText*)L"[OOM]: " L##aMsg ) +#define _PREFIX_TRACE_2( aMsg1, aMsg2 ) TPtrC( (const TText*)L"[OOM]: " L##aMsg1 L##aMsg2 ) + +/** +* Prefix macro for strings +*/ +#define _PREFIX_CHAR( aMsg ) (const char*)"[OOM]: " ##aMsg + +#endif // TRACEDEFS_H diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/rom/distribution.policy.s60 --- a/sysresmonitoring/oommonitor/rom/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/rom/oommonitor.iby --- a/sysresmonitoring/oommonitor/rom/oommonitor.iby Tue Feb 02 10:12:00 2010 +0200 +++ b/sysresmonitoring/oommonitor/rom/oommonitor.iby Fri Feb 19 22:58:54 2010 +0200 @@ -22,6 +22,7 @@ #include file=ABI_DIR\BUILD_DIR\oommonitor.dll SHARED_LIB_DIR\oommonitor.dll +data=ZSYSTEM\..\private\10207218\oomconfig.xml private\10207218\oomconfig.xml #endif // OOMMONITOR_IBY diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/distribution.policy.s60 --- a/sysresmonitoring/oommonitor/src/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomIdletimerule.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomIdletimerule.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + +#include "oomidletimerule.h" +#include "oomwindowgrouplist.h" +#include "oomtraces.h" + +COomIdleTimeRule* COomIdleTimeRule::NewL(TTimeIntervalSeconds aIdleTime, TInt aPriority) + { + FUNC_LOG; + + COomIdleTimeRule* self = new (ELeave) COomIdleTimeRule(aIdleTime, aPriority); + return self; + } + +TBool COomIdleTimeRule::RuleIsApplicable(const COomWindowGroupList& aWindowGroupList, TInt aAppIndexInWindowGroup) const + { + FUNC_LOG; + + TBool applicable = EFalse; + if (aAppIndexInWindowGroup >= 0) + { + applicable = (aWindowGroupList.IdleTime(aAppIndexInWindowGroup) >= iIdleTime); + } + return applicable; + } + +COomIdleTimeRule::~COomIdleTimeRule() + { + FUNC_LOG; + } + +COomIdleTimeRule::COomIdleTimeRule(TTimeIntervalSeconds aIdleTime, TInt aPriority) : iIdleTime(aIdleTime), iPriority(aPriority) + { + FUNC_LOG; + } + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomaction.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomaction.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + +#include "oomaction.h" +#include "oomactionlist.h" +#include "oomtraces.h" + +COomAction::~COomAction() + { + FUNC_LOG; + } + +// To be called by the derived class after the memory has been freed (or if it fails) +void COomAction::MemoryFreed(TInt) + { + FUNC_LOG; + + iState = EOomIdle; + iStateChangeObserver.StateChanged(); + } + +COomAction::COomAction(MOomActionObserver& aStateChangeObserver) : iStateChangeObserver(aStateChangeObserver) + { + FUNC_LOG; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomactionconfig.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomactionconfig.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + + +#include "oomactionconfig.h" +#include "oomruleconfig.h" +#include "oomtraces.h" + +// Add a rule +// This class takes ownership of the given rule +void COomActionConfig::AddRuleL(MOomRuleConfig* aRule) // Add the configuration for a rule (e.g. an idle time rule) + { + FUNC_LOG; + + iRules.AppendL(aRule); + } + +COomActionConfig::~COomActionConfig() + { + FUNC_LOG; + + iRules.ResetAndDestroy(); + iRules.Close(); + } + +// Utility function to return the priority for this action for the given rule +TUint COomActionConfig::Priority(const COomWindowGroupList& aWindowGroupList, TInt aAppIndexInWindowGroup) const + { + FUNC_LOG; + + TUint priority = iDefaultPriority; + + // See if any rules apply + TInt index = 0; + while (index < iRules.Count()) + { + if (iRules[index]->RuleIsApplicable(aWindowGroupList, aAppIndexInWindowGroup)) + { + // If an applicable rule has been found, then apply the new priority + // The last applicable rule in the config file should be used + // This is ensured because the last rule in the list will be the last rule from the file + if (iRules[index]->Priority()) + priority = iRules[index]->Priority(); + } + + index++; + } + + return priority; + } + +void COomActionConfig::ConstructL() + { + FUNC_LOG; + } + +COomActionConfig::COomActionConfig(TInt32 aId) : iId(aId) + { + FUNC_LOG; + } + + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomactionlist.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomactionlist.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,678 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + + +#include +#include + +#include "oommonitorplugin.h" +#include "oommonitorplugin.hrh" +#include "oomactionlist.h" +#include "oomwindowgrouplist.h" +#include "oompanic.h" +#include "OomTraces.h" +#include "oomconstants.hrh" +#include "oommemorymonitor.h" +#include "oommemorymonitorserver.h" +#include "oomrunplugin.h" +#include "oomcloseapp.h" +#include "oomconfig.h" +#include "oomactionref.h" +#include "oomapplicationconfig.h" +#include "oomcloseappconfig.h" +#include "oomrunpluginconfig.h" + +const TUid KUidMatrixMenuApp = { 0x101F4CD2 }; + +template +COomPluginList::COomPluginList() + { + FUNC_LOG; + } + +template +COomPluginList::~COomPluginList() + { + FUNC_LOG; + + TInt count = iPlugins.Count(); + for (TInt ii=0; ii +void COomPluginList::ConstructL(TInt aInterfaceUid) + { + FUNC_LOG; + + RImplInfoPtrArray implArray; + CleanupClosePushL(implArray); + REComSession::ListImplementationsL(TUid::Uid(aInterfaceUid), implArray); + + TInt count = implArray.Count(); + iPlugins.ReserveL(count); + + for (TInt ii=0; iiImplementationUid()); + plugin.iImpl = static_cast(REComSession::CreateImplementationL(uid, plugin.iDtorUid, NULL)); + plugin.iUid = uid.iUid; + } + + CleanupStack::PopAndDestroy(&implArray); + } + +template +COomPluginList::TPlugin::TPlugin() +: iImpl(0) + { + FUNC_LOG; + } + +template +COomPluginList* COomPluginList::NewL(TInt aInterfaceUid) + { + FUNC_LOG; + + COomPluginList* self = new (ELeave) COomPluginList(); + CleanupStack::PushL(self); + self->ConstructL(aInterfaceUid); + CleanupStack::Pop(self); + return self; + } + +COomActionList* COomActionList::NewL(CMemoryMonitor& aMonitor, CMemoryMonitorServer& aServer, RWsSession& aWs, COomConfig& aConfig) + { + FUNC_LOG; + + COomActionList* self = new (ELeave) COomActionList(aMonitor, aServer, aWs); + CleanupStack::PushL(self); + self->ConstructL(aConfig); + CleanupStack::Pop(self); + return self; + } + +COomActionList::~COomActionList() + { + FUNC_LOG; + + iCloseAppActions.ResetAndDestroy(); + iCloseAppActions.Close(); + iRunPluginActions.ResetAndDestroy(); + iRunPluginActions.Close(); + + iActionRefs.Close(); + + delete iPluginList; + delete iPluginListV2; + } + + + +// Creates a list of actions based on the contents of the config and the current window group list +// Any old actions will be replaced. +// This function may leave, however enough memory should be reserved for this process so that at least +// some actions have been created for freeing memory, these can then be run by calling FreeMemory. +// Note that this function will only leave in extreme circumstances, in normal usage we should have +// enough reserved memory to build the complete action list. +void COomActionList::BuildActionListL(COomWindowGroupList& aWindowGroupList, COomConfig& aConfig) + { + FUNC_LOG; + + if (iFreeingMemory) + { + TRACES("COomActionList::BuildActionListL Memory is currently being freed, do not build action list"); + return; + } + + iActionRefs.Reset(); + iCurrentActionIndex = 0; + + aWindowGroupList.RefreshL(); + + TInt actionsIndex = 0; + + // we rely on the two pluginlists not having changed since construction + BuildPluginActionsL(*iPluginList, aWindowGroupList, aConfig, actionsIndex); + BuildPluginActionsL(*iPluginListV2, aWindowGroupList, aConfig, actionsIndex); + + // Go through each item in the wglist, create an app close action for this application + TUint wgIndex = aWindowGroupList.Count() - 1; + + // Fix for when fast swap has focus, or pen input server has put itself into the foreground: + // the wg at index 1 should be considered as the foreground app. + // stopIndex is calculated to take this into account. + TUint stopIndex = 0; + TUid foregroundUid = TUid::Uid(aWindowGroupList.AppId(0)); + if ( KUidFastSwap == foregroundUid || KUidPenInputServer == foregroundUid) + { + stopIndex = 1; + } + + while (wgIndex > stopIndex) // Don't go down to entry stopIndex because this is the foreground window + { + COomCloseAppConfig* appCloseConfig = NULL; + + CApaWindowGroupName* wgName = aWindowGroupList.WgName(); + __ASSERT_DEBUG(wgName, OomMonitorPanic(KInvalidWgName)); + + // Get the app ID for the wglist item + // This sets the window group name + TInt32 appId = aWindowGroupList.AppId(wgIndex); + + if ( !appId || wgName->IsSystem() || wgName->Hidden() ) + { + //If the UID is NULL at this point, we assume the process is not an application + //and therefore is not a suitable candidate for closure. + //We also do not close system or hidden apps. + + //Matrix Menu is temporarily hardcoded here as a system app that can be closed + TUid appUid = TUid::Uid(aWindowGroupList.AppId(wgIndex, ETrue)); + if ( KUidMatrixMenuApp == appUid) + { + TRACES2("BuildActionListL: System App is Matrix Menu; UID = %x, wgIndex = %d", aWindowGroupList.AppId(wgIndex, ETrue),wgIndex); + // Find the app close config for Menu App + appCloseConfig = aConfig.GetApplicationConfig(appId).GetAppCloseConfig(); + } + else + { + TRACES2("BuildActionListL: Not adding process to action list; UID = %x, wgIndex = %d", aWindowGroupList.AppId(wgIndex, ETrue),wgIndex); + TRACES2("BuildActionListL: IsSystem = %d, Hidden = %d", wgName->IsSystem() ? 1 : 0, wgName->Hidden() ? 1 : 0); + wgIndex--; + continue; + } + } + if (aWindowGroupList.IsBusy(wgIndex) || wgName->IsBusy()) + // If the application has been flagged as busy then look up the configuration for busy apps in the config file + { + // Find the app close config for this app ID + appCloseConfig = aConfig.GetApplicationConfig(KOomBusyAppId).GetAppCloseConfig(); + } + else if (aWindowGroupList.IsDynamicHighPriority(wgIndex)) + // If the application has been flagged as busy then look up the configuration for busy apps in the config file + { + // Find the app close config for this app ID + appCloseConfig = aConfig.GetApplicationConfig(KOomHighPriorityAppId).GetAppCloseConfig(); + } + else + // If the application hasn't been flagged as busy or high priority then look up the priority according to the config + { + // Find the app close config for this app ID + appCloseConfig = aConfig.GetApplicationConfig(appId).GetAppCloseConfig(); + } + + //If the app close config is NULL it is because there is an app specific threshold for this + //app but no specific close config. Use the default app close config + if (!appCloseConfig) + { + appCloseConfig = aConfig.GetApplicationConfig(KOomDefaultAppId).GetAppCloseConfig(); + } + + TUint priority = appCloseConfig->CalculateCloseAppPriority(aWindowGroupList, wgIndex); + TInt wgId = aWindowGroupList.WgId(wgIndex).iId; + TOomSyncMode syncMode = appCloseConfig->iSyncMode; + TInt ramEstimate = appCloseConfig->iRamEstimate; + TActionRef ref = TActionRef(TActionRef::EAppClose, priority, syncMode, ramEstimate, wgId, wgIndex); + + //AppClose Actions should always have a unique prioirity determined by the application's z order. + TInt err = iActionRefs.InsertInOrder(ref, ComparePriorities); + if ((err != KErrNone) && (err != KErrAlreadyExists)) + { + User::Leave(err); + } + TRACES3("BuildActionListL: Adding app to action list, Uid = %x, wgId = %d, wgIndex = %d", appId, wgId, wgIndex); + + wgIndex--; + } + + TRACES1("BuildActionListL: Action list built with %d items",iActionRefs.Count()); + } + +template +void COomActionList::BuildPluginActionsL(COomPluginList& aPluginList, COomWindowGroupList& aWindowGroupList, COomConfig& aConfig, TInt& aActionsIndex) + { + TInt pluginIndex = aPluginList.Count(); + + while (pluginIndex--) + { + // Get the config for this plugin + COomRunPluginConfig& pluginConfig = aConfig.GetPluginConfig(aPluginList.Uid(pluginIndex)); + + TActionRef::TActionType actionType; + + if (pluginConfig.PluginType() == EOomAppPlugin) + { + if (pluginConfig.CallIfTargetAppNotRunning() == EFalse) + { + //loop through wg group and if find can't find the target app, don't add this plugin + TInt index = aWindowGroupList.Count() - 1; + TUint targetApp = pluginConfig.TargetApp(); + TBool targetAppFound = EFalse; + while (index >= 0) + { + if (aWindowGroupList.AppId(index) == targetApp) + { + targetAppFound = ETrue; + break; + } + index--; + } + if (targetAppFound == EFalse) + { + aActionsIndex++; + continue; + } + } + actionType = TActionRef::EAppPlugin; + } + else + { + actionType = TActionRef::ESystemPlugin; + } + + TInt priority = pluginConfig.CalculatePluginPriority(aWindowGroupList); + TOomSyncMode syncMode = pluginConfig.iSyncMode; + TInt ramEstimate = pluginConfig.iRamEstimate; + + __ASSERT_DEBUG(aActionsIndex < iRunPluginActions.Count(), OomMonitorPanic(KPluginArrayIndexOutOfBounds)); + TActionRef ref = TActionRef(actionType, priority, syncMode, ramEstimate, *(iRunPluginActions[aActionsIndex]), aWindowGroupList.GetIndexFromAppId(pluginConfig.TargetApp())); + + //It is valid to have plugins with equal priority + User::LeaveIfError(iActionRefs.InsertInOrderAllowRepeats(ref, ComparePriorities)); + + aActionsIndex++; + } + } + + +// Execute the OOM actions according to their priority +// Run batches of OOM actions according to their sync mode +void COomActionList::FreeMemory(TInt aMaxPriority) + { + FUNC_LOG; + if (iFreeingMemory) + { + TRACES("COomActionList::FreeMemory Memory is currently being freed, do not start any more actions"); + return; + } + + iMaxPriority = aMaxPriority; + + TBool memoryFreeingActionRun = EFalse; + + // Get the configured maximum number of applications that can be closed at one time + const COomGlobalConfig& globalConfig = CMemoryMonitor::GlobalConfig(); + TInt maxBatchSize = globalConfig.iMaxCloseAppBatch; + TInt numberOfRunningActions = 0; + + TInt memoryEstimate; // The amount of free memory we expect to be free after the currently initiated operations + HAL::Get(HALData::EMemoryRAMFree, memoryEstimate); + + + while (iCurrentActionIndex < iActionRefs.Count() + && iActionRefs[iCurrentActionIndex].Priority() <= aMaxPriority) + { + TActionRef ref = iActionRefs[iCurrentActionIndex]; + COomAction* action = NULL; + if (ref.Type() == TActionRef::EAppClose) + { + action = iCloseAppActions[numberOfRunningActions]; + static_cast(action)->Reconfigure(ref); + } + else + { + action = &(ref.RunPlugin()); + } + + iFreeingMemory = ETrue; + TRACES2("COomActionList::FreeMemory: Running action %d which has priority %d", iCurrentActionIndex,ref.Priority()); + + iMonitor.SetMemoryMonitorStatusProperty(EFreeingMemory); + + action->FreeMemory(iCurrentTarget - memoryEstimate); + memoryFreeingActionRun = ETrue; + + // Actions with EContinueIgnoreMaxBatchSize don't add to the tally of running actions + if (ref.SyncMode() != EContinueIgnoreMaxBatchSize) + numberOfRunningActions++; + + // Update our estimate of how much RAM we think we'll have after this operation + memoryEstimate += ref.RamEstimate(); + + // Do we estimate that we are freeing enough memory (only applies if the sync mode is "esimtate" for this action) + TBool estimatedEnoughMemoryFreed = EFalse; + if ((ref.SyncMode() == EEstimate) + && (memoryEstimate >= iCurrentTarget)) + { + estimatedEnoughMemoryFreed = ETrue; + } + + if ((ref.SyncMode() == ECheckRam) + || (numberOfRunningActions >= maxBatchSize) + || estimatedEnoughMemoryFreed + || globalConfig.ForceCheckAtPriority(iActionRefs[iCurrentActionIndex].Priority())) + // If this actions requires a RAM check then wait for it to complete + // Also force a check if we've reached the maximum number of concurrent operations + // Also check if we estimate that we have already freed enough memory (assuming that the sync mode is "estimate" + { + // Return from the loop - we will be called back (in COomActionList::StateChanged()) when the running actions complete + TRACES("COomActionList::FreeMemory: Exiting run action loop"); + return; + } + // ... otherwise continue running actions, don't wait for any existing ones to complete + iCurrentActionIndex++; + } + + + if (!memoryFreeingActionRun) + { + // No usable memory freeing action has been found, so we give up + TRACES("COomActionList::FreeMemory: No usable memory freeing action has been found"); + iMonitor.ResetTargets(); + TInt freeMemory; + iMonitor.GetFreeMemory(freeMemory); + if (freeMemory >= iCurrentTarget) + { + SwitchOffPlugins(); + iMonitor.SetMemoryMonitorStatusProperty(EAboveTreshHold); + } + else + { + if (iMonitor.ActionTrigger() == EClientServerRequestOptionalRam) + { + //We always switch off the plugins after an optional RAM request + SwitchOffPlugins(); + } + iMonitor.SetMemoryMonitorStatusProperty(EBelowTreshHold); + } +#ifdef CLIENT_REQUEST_QUEUE + iMonitor.ActionsCompleted(freeMemory, EFalse); +#else + iServer.CloseAppsFinished(freeMemory, EFalse); +#endif + } + } + +void COomActionList::SwitchOffPlugins() + { + FUNC_LOG; + + TInt actionRefIndex = iActionRefs.Count(); + + // Go through each of the action references, if it's a plugin action then call MemoryGood on it + // Note that this only results in a call to the plugin if FreeMemory has been called on this plugin since that last call to MemoryGood + while (actionRefIndex--) + { + if ((iActionRefs[actionRefIndex].Type() == TActionRef::EAppPlugin) + || (iActionRefs[actionRefIndex].Type() == TActionRef::ESystemPlugin)) + { + iActionRefs[actionRefIndex].RunPlugin().MemoryGood(); + } + } + } + +TInt COomActionList::ComparePriorities(const TActionRef& aPos1, const TActionRef& aPos2 ) + { + FUNC_LOG; + + if (aPos1.Priority()< aPos2.Priority()) + { + return -1; + } + if (aPos1.Priority() > aPos2.Priority()) + { + return 1; + } + + // If priorities are equal then we use hardcoded rules to determine which one is run... + + // All other actions are run in preference to application closures + if ((aPos1.Type() != TActionRef::EAppClose) + && ((aPos2.Type() == TActionRef::EAppClose))) + { + return -1; + } + if ((aPos1.Type() == TActionRef::EAppClose) + && ((aPos2.Type() != TActionRef::EAppClose))) + { + return 1; + } + // If both actions are application closures then the Z order is used to determine which one to run (furthest back application will be closed first) + if ((aPos1.Type() == TActionRef::EAppClose) + && ((aPos2.Type() == TActionRef::EAppClose))) + { + if (aPos1.WgIndex() < aPos2.WgIndex()) + { + return 1; + } + else + { + return -1; + } + //Two Apps should not have equal window group indexes, we panic below if this is the case. + } + + // Application plugins will be run in preference to system plugins + if ((aPos1.Type() == TActionRef::EAppPlugin) + && ((aPos2.Type() == TActionRef::ESystemPlugin))) + { + return -1; + } + if ((aPos1.Type() == TActionRef::ESystemPlugin) + && ((aPos2.Type() == TActionRef::EAppPlugin))) + { + return 1; + } + + // If both actions are application plugins then the Z order of the target app is used to determine which one to run (the one with the furthest back target app will be closed first) + // If the target app is not running then the plugin is run in preference to target apps where the target app is running + if ((aPos1.Type() == TActionRef::EAppPlugin) + && ((aPos2.Type() == TActionRef::EAppPlugin))) + { + // When the target app is not running then the plugin will be run ahead of plugins where the target app is running + if ((aPos1.WgIndex() == KAppNotInWindowGroupList) && (aPos2.WgIndex() != KAppNotInWindowGroupList)) + { + return -1; + } + if ((aPos1.WgIndex() != KAppNotInWindowGroupList) && (aPos2.WgIndex() == KAppNotInWindowGroupList)) + { + return 1; + } + // If the target apps for both plugins are running then compare the Z order + if ((aPos1.WgIndex() != KAppNotInWindowGroupList) && (aPos2.WgIndex() != KAppNotInWindowGroupList)) + { + if (aPos1.WgIndex() < aPos2.WgIndex()) + { + return 1; + } + else + { + return -1; + } + } + // If the target app for neither plugin is running then they are of equal priority + } + //App Close Actions must have a unique priority. + __ASSERT_DEBUG((aPos1.Type() != TActionRef::EAppClose) && (aPos2.Type() != TActionRef::EAppClose), OomMonitorPanic(KAppCloseActionEqualPriorities)); + return 0; + } + +void COomActionList::AppNotExiting(TInt aWgId) + { + FUNC_LOG; + + TInt index = iCloseAppActions.Count(); + while (index--) + { + COomCloseApp* action = iCloseAppActions[index]; + if ( (action->WgId() == aWgId) && (action->IsRunning()) ) + { + TRACES1("COomCloseApp::AppNotExiting: App with window group id %d has not responded to the close event", aWgId); + action->CloseAppEvent(); + } + } + } + +// From MOomActionObserver +// An action has changed state (possibly it has completed freeing memory) +void COomActionList::StateChanged() + { + FUNC_LOG; + + TBool allActionsComplete = ETrue; + + // Note that the actions themselves are responsible for timing out if necessary. + TInt index = iCloseAppActions.Count(); + while ((index--) && (allActionsComplete)) + { + if (iCloseAppActions[index]->IsRunning()) + { + allActionsComplete = EFalse; + } + } + + index = iRunPluginActions.Count(); + while ((index--) && (allActionsComplete)) + { + if (iRunPluginActions[index]->IsRunning()) + { + allActionsComplete = EFalse; + } + } + + if (allActionsComplete) + { + //All immediate actions are complete and iFreeingMemory is being set to false but + //SetMemoryMonitorStatusProperty will not change here because it is possible for the freeing actions to recommence + //in essence, all immediate actions have been completed but not all possible actions have been processed + //and therefore we are still in a memory freeing state + iFreeingMemory = EFalse; + // If all of the actions are complete then check memory and run more if necessary + TInt freeMemory; + iMonitor.GetFreeMemory(freeMemory); + if (freeMemory < iCurrentTarget) + // If we are still below the good-memory-threshold then continue running actions + { + iCurrentActionIndex++; + + if (iCurrentActionIndex >= iActionRefs.Count()) + { + // There are no more actions to try, so we give up + TRACES1("COomActionList::StateChanged: All current actions complete, below good threshold with no more actions available. freeMemory=%d", freeMemory); + iMonitor.ResetTargets(); + if (freeMemory >= iCurrentTarget) + { + SwitchOffPlugins(); + iMonitor.SetMemoryMonitorStatusProperty(EAboveTreshHold); + } + else + { + if (iMonitor.ActionTrigger() == EClientServerRequestOptionalRam) + { + //We always switch off the plugins after an optional RAM request + SwitchOffPlugins(); + } + iMonitor.SetMemoryMonitorStatusProperty(EBelowTreshHold); + } +#ifdef CLIENT_REQUEST_QUEUE + iMonitor.ActionsCompleted(freeMemory, EFalse); +#else + iServer.CloseAppsFinished(freeMemory, EFalse); +#endif + } + else + { + // There are still more actions to try, so we continue + TRACES1("COomActionList::StateChanged: All current actions complete, running more actions. freeMemory=%d", freeMemory); + FreeMemory(iMaxPriority); + } + } + else + { + TRACES1("COomActionList::StateChanged: All current actions complete, memory good. freeMemory=%d", freeMemory); + iMonitor.ResetTargets(); + SwitchOffPlugins(); + iMonitor.SetMemoryMonitorStatusProperty(EAboveTreshHold); +#ifdef CLIENT_REQUEST_QUEUE + iMonitor.ActionsCompleted(freeMemory, ETrue); +#else + iServer.CloseAppsFinished(freeMemory, ETrue); +#endif + } + } + + // If some actions are not yet in the idle state then we must continue to wait for them (they will notify us of a state change via a callback) + } + +COomActionList::COomActionList(CMemoryMonitor& aMonitor, CMemoryMonitorServer& aServer, RWsSession& aWs) + : iWs(aWs), iMonitor(aMonitor), iServer(aServer) + { + FUNC_LOG; + } + +void COomActionList::ConstructL(COomConfig& aConfig) + { + FUNC_LOG; + + iCurrentActionIndex = 0; + iFreeingMemory = EFalse; + + // Get the list of V1 and V2 plugins available to the system + iPluginList = COomPluginList::NewL(KOomPluginInterfaceUidValue); + iPluginListV2 = COomPluginList::NewL(KOomPluginInterfaceV2UidValue); + // Go through each plugin in the plugin list, create a run-plugin action for each one + TInt pluginIndex = iPluginList->Count(); + while (pluginIndex--) + { + // Get the config for this plugin + COomRunPluginConfig& pluginConfig = aConfig.GetPluginConfig(iPluginList->Uid(pluginIndex)); + + // Create an action acording to the config + COomRunPlugin* action = COomRunPlugin::NewL(iPluginList->Uid(pluginIndex), pluginConfig, *this, iPluginList->Implementation(pluginIndex)); + + iRunPluginActions.AppendL(action); + } + + // Go through each V2 in the V2 plugin list, create a run-plugin action for each one + pluginIndex = iPluginListV2->Count(); + while (pluginIndex--) + { + // Get the config for this plugin + COomRunPluginConfig& pluginConfig = aConfig.GetPluginConfig(iPluginListV2->Uid(pluginIndex)); + + // Create an action acording to the config + COomRunPlugin* action = COomRunPlugin::NewL(iPluginList->Uid(pluginIndex), pluginConfig, *this, iPluginListV2->Implementation(pluginIndex), &(iPluginListV2->Implementation(pluginIndex))); + + iRunPluginActions.AppendL(action); + } + + //allocate empty COomCloseApp objects + TInt appCloseIndex = aConfig.GlobalConfig().iMaxCloseAppBatch; + while (appCloseIndex--) + { + COomCloseApp* action = COomCloseApp::NewL(*this, iWs); + iCloseAppActions.AppendL(action); + } + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomactionref.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomactionref.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + + +#include "oomactionref.h" + +TActionRef::TActionRef(TActionType aType, TInt aPriority, TOomSyncMode aSyncMode, TInt aRamEstimate, COomRunPlugin& aRunPlugin, TUint aWgIndexOfTargetApp) + : iType(aType), iPriority(aPriority), iSyncMode(aSyncMode), iRamEstimate(aRamEstimate), iWgIndex(aWgIndexOfTargetApp), iRunPlugin(&aRunPlugin) + { + } + +TActionRef::TActionRef(TActionType aType, TInt aPriority, TOomSyncMode aSyncMode, TInt aRamEstimate, TInt aWgId, TUint aWgIndex) +: iType(aType), iPriority(aPriority), iSyncMode(aSyncMode), iRamEstimate(aRamEstimate), iWgId(aWgId), iWgIndex(aWgIndex), iRunPlugin(NULL) + { + } + + +TActionRef::TActionType TActionRef::Type() const + { + return iType; + } + +TUint TActionRef::Priority() const + { + return iPriority; + } + +TOomSyncMode TActionRef::SyncMode() const + { + return iSyncMode; + } + +TInt TActionRef::RamEstimate() const + { + return iRamEstimate; + } + +TInt TActionRef::WgId() const + { + return iWgId; + } + +TInt TActionRef::WgIndex() const + { + return iWgIndex; + } + +COomRunPlugin& TActionRef::RunPlugin() + { + return *iRunPlugin; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomappclosetimer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomappclosetimer.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Timer class which implements a timeout for an application close action. +* +*/ + + +#include "oomappclosetimer.h" +#include "oomcloseapp.h" +#include "oomtraces.h" + +COomAppCloseTimer* COomAppCloseTimer::NewL(COomCloseApp& aMonitor) + { + FUNC_LOG; + + COomAppCloseTimer* self = new (ELeave) COomAppCloseTimer(aMonitor); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +COomAppCloseTimer::COomAppCloseTimer(COomCloseApp& aMonitor) +: CTimer(CActive::EPriorityStandard), iMonitor(aMonitor) + { + FUNC_LOG; + + CActiveScheduler::Add(this); + } + +void COomAppCloseTimer::RunL() + { + FUNC_LOG; + + iMonitor.CloseAppEvent(); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomappclosewatcher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomappclosewatcher.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: An active object which watches for app close actions successfully completing. +* +*/ + + + +#include "oomappclosewatcher.h" +#include "oomcloseapp.h" +#include "oomtraces.h" + +COomAppCloseWatcher::COomAppCloseWatcher(COomCloseApp& aMonitor) : CActive(CActive::EPriorityStandard), iMonitor(aMonitor) + { + FUNC_LOG; + + CActiveScheduler::Add(this); + } + +COomAppCloseWatcher::~COomAppCloseWatcher() + { + FUNC_LOG; + + Cancel(); + } + +void COomAppCloseWatcher::Start(const TApaTask& aTask) + { + FUNC_LOG; + + if (!IsActive()) + { + TInt err = iThread.Open(aTask.ThreadId()); + if (err == KErrNone) + { + iOriginalProcessPriority = iThread.ProcessPriority(); + iThread.SetProcessPriority(EPriorityForeground); + iThread.Logon(iStatus); + SetActive(); + } + else + { + TRequestStatus* s = &iStatus; + User::RequestComplete(s, err); + SetActive(); + } + } + } + +void COomAppCloseWatcher::DoCancel() + { + FUNC_LOG; + + iThread.LogonCancel(iStatus); + iThread.SetProcessPriority(iOriginalProcessPriority); + iThread.Close(); + } + +void COomAppCloseWatcher::RunL() + { + FUNC_LOG; + + if (iThread.Handle()) + iThread.SetProcessPriority(iOriginalProcessPriority); + iThread.Close(); + // Experimentation shows that memory may take up to 40ms + // to be released back to the system after app thread close. + // Using this delay should minimise the number of apps that + // need to be closed to recover the necessary memory. + const TInt KAppTidyUpDelay = 40000; + User::After(KAppTidyUpDelay); + iMonitor.CloseAppEvent(); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomapplicationconfig.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomapplicationconfig.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + + +#include "oomapplicationconfig.h" +#include "oomconstants.hrh" +#include "oomcloseappconfig.h" +#include "oomtraces.h" + +COomApplicationConfig* COomApplicationConfig::NewL(TUint aApplicationId) + { + FUNC_LOG; + + COomApplicationConfig* self = new (ELeave) COomApplicationConfig(aApplicationId); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// Add a rule +// This class takes ownership of the given rule +// This rule applies to this application itself (and not a plugin associated with this application) +// The rule would usually apply to an "application close" event +void COomApplicationConfig::AddRuleL(MOomRuleConfig* aRule) + { + FUNC_LOG; + + __ASSERT_ALWAYS(iCloseAppConfig, OomMonitorPanic(KRuleConfiguredBeforeApplication)); + + iCloseAppConfig->AddRuleL(aRule); + } + +COomApplicationConfig::~COomApplicationConfig() + { + FUNC_LOG; + + delete iCloseAppConfig; + } + +void COomApplicationConfig::ConstructL() + { + FUNC_LOG; + + iGoodRamThreshold = KOomThresholdUnset; + iLowRamThreshold = KOomThresholdUnset; + } + +COomApplicationConfig::COomApplicationConfig(TUint aApplicationId) : iApplicationId(aApplicationId) + { + FUNC_LOG; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomclientrequestqueue.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomclientrequestqueue.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,344 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: COomClientRequestQueue.cpp. +* +*/ + + + +#include "oomclientrequestqueue.h" +#include "oomtraces.h" +#include "oomsubscribehelper.h" +#include "oompanic.h" +#include "oommemorymonitor.h" +#include + +const TInt KOomWatchDogStatusIdle = -1; +const TInt KClientTimeToFreeMemory = 500000; //microseconds + +COomClientRequestQueue::COomClientRequestQueue(CMemoryMonitor& aMonitor) + :iQueue(_FOFF(TClientRequest,iLink)), + iMonitor(aMonitor) + { + FUNC_LOG; + } + +COomClientRequestQueue::~COomClientRequestQueue() + { + FUNC_LOG; + + if (iWatchdogStatusSubscriber) + { + iWatchdogStatusSubscriber->StopSubscribe(); + } + iWatchdogStatusProperty.Close(); + delete iWatchdogStatusSubscriber; + + if (iClientRequestTimer) + { + iClientRequestTimer->Cancel(); + } + delete iClientRequestTimer; + + TClientRequest* request; + TSglQueIter iter(iQueue); + iter.SetToFirst(); + while (iter) + { + request = iter++; + iQueue.Remove(*request); + delete request; + }; + } + +COomClientRequestQueue* COomClientRequestQueue::NewL(CMemoryMonitor& aMonitor) + { + FUNC_LOG; + + COomClientRequestQueue* self = new (ELeave) COomClientRequestQueue(aMonitor); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +void COomClientRequestQueue::ConstructL() + { + FUNC_LOG; + + TInt err = iWatchdogStatusProperty.Attach(KPSUidUikon, KUikOOMWatchdogStatus); + + TRACES1("COomClientRequestQueue::ConstructL: KUikOOMWatchdogStatus err = %d", err); + + err = iWatchdogStatusProperty.Set(KOomWatchDogStatusIdle); + + iWatchdogStatusSubscriber = new (ELeave) CSubscribeHelper(TCallBack(WatchdogStatusStatusChanged, this), iWatchdogStatusProperty); + iWatchdogStatusSubscriber->Subscribe(); + + + iClientRequestTimer = COomClientRequestTimer::NewL(*this); + } + +void COomClientRequestQueue::RequestFreeMemoryL(const RMessage2& aMessage) + { + FUNC_LOG; + + TClientRequest* request = new (ELeave) TClientRequest(EClientServerRequestFreeMemory, aMessage); + CleanupStack::PushL(request); + AddClientRequestL(*request); + CleanupStack::Pop(request); + } + +void COomClientRequestQueue::RequestOptionalRamL(const RMessage2& aMessage) + { + FUNC_LOG; + + TClientRequest* request = new (ELeave) TClientRequest(EClientServerRequestOptionalRam, aMessage); + CleanupStack::PushL(request); + AddClientRequestL(*request); + CleanupStack::Pop(request); + } + +TInt COomClientRequestQueue::WatchdogStatusStatusChanged(TAny* aPtr) + { + FUNC_LOG; + + COomClientRequestQueue* self = static_cast(aPtr); + if (self) + { + self->HandleWatchdogStatusCallBack(); + } + return KErrNone; + } + +void COomClientRequestQueue::HandleWatchdogStatusCallBack() + { + FUNC_LOG; + + // Someone has set the key to request some free memory. + TInt memoryRequested = 0; + iWatchdogStatusProperty.Get(memoryRequested); + + // Try to free the RAM. + if (memoryRequested >= 1) + { + TClientRequest request = TClientRequest(EPublishAndSubscribe, memoryRequested); + TRAP_IGNORE(AddClientRequestL(request)); + } + // Set the key back to KOomWatchDogStatusIdle to indicate we're done. + iWatchdogStatusProperty.Set(KOomWatchDogStatusIdle); + } + +// The new request is added to the queue, then we have the following conditions: +// 1. A client request is currently being processed +// 2. The last client request completed less than KClientTimeToFreeMemory microseconds ago -> start the timer +// 3. The timer has already been started +// 4. none of the above -> process this request +void COomClientRequestQueue::AddClientRequestL(TClientRequest& request) + { + FUNC_LOG; + + iQueue.AddLast(request); + + if ( !iClientRequestActive && !iClientRequestTimer->IsActive() ) + { + TTime now; + now.UniversalTime(); + TInt64 interval64 = (now.MicroSecondsFrom(iLastClientCompletedTime)).Int64(); + TRACES3("COomClientRequestQueue::AddClientRequestL: now = %Ld, iLastClientCompletedTime = %Ld, interval64 = %Ld", + now.Int64(), iLastClientCompletedTime.Int64(), interval64); + + if ( interval64 < 0) + { + //If the system time is moved backwards we lose the information about when the last request was + //made, so we wait for KClientTimeToFreeMemory microseconds + iClientRequestTimer->After(TTimeIntervalMicroSeconds32(KClientTimeToFreeMemory)); + } + else if ( interval64 < KClientTimeToFreeMemory) + { + //The last completed client is given KClientTimeToFreeMemory microseconds to allocate the memory + //it requested + iClientRequestTimer->After(TTimeIntervalMicroSeconds32(interval64)); + } + else + { + StartClientRequestL(); + } + } + } + +void COomClientRequestQueue::StartClientRequestL() + { + FUNC_LOG; + + iClientRequestActive = ETrue; + + TClientRequest* request = iQueue.First(); + + switch (request->iClientRequestType) + { + case EClientServerRequestOptionalRam: + { + TInt pluginId = request->iRequestFreeRamMessage.Int2(); + iMonitor.FreeOptionalRamL(request->iBytesRequested, pluginId); + break; + } + case EClientServerRequestFreeMemory: + iMonitor.RequestFreeMemoryL(request->iBytesRequested); + break; + case EPublishAndSubscribe: + iMonitor.RequestFreeMemoryPandSL(request->iBytesRequested); + break; + default: + OomMonitorPanic(KInvalidClientRequestType); + break; + } + } + +CMemoryMonitor& COomClientRequestQueue::Monitor() + { + FUNC_LOG; + + return iMonitor; + } + +TClientRequest::TClientRequest(TActionTriggerType aClientRequestType, TInt aBytesRequested) + : iClientRequestType(aClientRequestType), iBytesRequested(aBytesRequested) + { + FUNC_LOG; + } + +TClientRequest::TClientRequest(TActionTriggerType aClientRequestType, const RMessage2& aRequestFreeRam) + : iClientRequestType(aClientRequestType), iRequestFreeRamMessage(aRequestFreeRam) + { + FUNC_LOG; + + iBytesRequested = aRequestFreeRam.Int0(); + } + +void COomClientRequestQueue::ActionsCompleted(TInt aBytesFree, TBool aMemoryGood) + { + FUNC_LOG; + + if (iClientRequestActive) + { +#ifdef _DEBUG + TSglQueIter iter(iQueue); + iter.SetToFirst(); + TClientRequest* req; + while (iter) + { + req = iter++; + TActionTriggerType crt = req->iClientRequestType; + TInt bytes = req->iBytesRequested; + TRACES2("COomClientRequestQueue::ActionsCompleted Printing Queue: Type = %d, Bytes Requested = %d", crt, bytes); + }; +#endif + + __ASSERT_DEBUG(!iQueue.IsEmpty(), OomMonitorPanic(KClientQueueNotEmpty)); + __ASSERT_DEBUG(!iClientRequestTimer->IsActive(), OomMonitorPanic(KClientRequestTimerActive)); + + TClientRequest* request = iQueue.First(); + RMessage2 message; + + switch (request->iClientRequestType) + { + case EClientServerRequestOptionalRam: + message = request->iRequestFreeRamMessage; + if (!message.IsNull()) + { + TInt memoryAvailable = aBytesFree - iMonitor.GoodThreshold(); + TInt minimumNeeded = message.Int1(); + if (memoryAvailable >= minimumNeeded) + { + message.Complete(memoryAvailable); + } + else + { + message.Complete(KErrNoMemory); + } + } + break; + case EClientServerRequestFreeMemory: + message = request->iRequestFreeRamMessage; + if (!message.IsNull()) + { + // If memory available is greater than the requested RAM then complete with the amount of free memory, otherwise complete with KErrNoMemory + message.Complete(aMemoryGood ? KErrNone : KErrNoMemory); + } + break; + case EPublishAndSubscribe: + // No action required for P&S key + break; + default: + OomMonitorPanic(KInvalidClientRequestType); + break; + } + + iClientRequestActive = EFalse; + iQueue.Remove(*request); + delete request; + + iLastClientCompletedTime.UniversalTime(); + + if (!iQueue.IsEmpty()) + { + //We give the client KClientTimeToFreeMemory microseconds to free the memory it requested before + //processing the next request + iClientRequestTimer->After(TTimeIntervalMicroSeconds32(KClientTimeToFreeMemory)); + } + } + } + +void COomClientRequestQueue::RequestTimerCallbackL() + { + FUNC_LOG; + + __ASSERT_DEBUG(!iQueue.IsEmpty(), OomMonitorPanic(KClientQueueNotEmpty)); + + StartClientRequestL(); + } + +COomClientRequestTimer* COomClientRequestTimer::NewL(COomClientRequestQueue& aQueue) + { + FUNC_LOG; + + COomClientRequestTimer* self = new (ELeave) COomClientRequestTimer(aQueue); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +COomClientRequestTimer::COomClientRequestTimer(COomClientRequestQueue& aQueue) +: CTimer(CActive::EPriorityStandard), iClientRequestQueue(aQueue) + { + FUNC_LOG; + + CActiveScheduler::Add(this); + } + + +void COomClientRequestTimer::RunL() + { + FUNC_LOG; + + iClientRequestQueue.RequestTimerCallbackL(); + } + + + + + + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomcloseapp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomcloseapp.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,111 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + +#include + +#include "oomcloseapp.h" +#include "OomTraces.h" +#include "oomappclosetimer.h" +#include "oomappclosewatcher.h" +#include "oomactionref.h" +#include "oommemorymonitor.h" +#include "oomconstants.hrh" +#include "oompanic.h" + +COomCloseApp* COomCloseApp::NewL(MOomActionObserver& aStateChangeObserver, RWsSession& aWs) + { + FUNC_LOG; + + COomCloseApp* self = new (ELeave) COomCloseApp(aStateChangeObserver, aWs); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// Close the application in order to free memory +// Call the COomAction::MemoryFreed when it is done +void COomCloseApp::FreeMemory(TInt) + { + FUNC_LOG; + + iAppCloserRunning = ETrue; + + // Set the TApaTask to the app + iCurrentTask.SetWgId(iWgId); + + __ASSERT_DEBUG(!iAppCloseTimer->IsActive(), OomMonitorPanic(KStartingActiveCloseAppTimer)); + __ASSERT_DEBUG(!iAppCloseWatcher->IsActive(), OomMonitorPanic(KStartingActiveAppCloseWatcher)); + // Start a timer and the thread watcher + iAppCloseTimer->After(CMemoryMonitor::GlobalConfig().iMaxAppExitTime * KMicrosecondsInMillisecond); + iAppCloseWatcher->Start(iCurrentTask); + // Tell the app to close + TRACES1("COomCloseApp::FreeMemory: Closing app with window group id %d",iWgId); + iCurrentTask.EndTask(); + } + +COomCloseApp::~COomCloseApp() + { + FUNC_LOG; + + if (iAppCloseTimer) + iAppCloseTimer->Cancel(); + + if (iAppCloseWatcher) + iAppCloseWatcher->Cancel(); + + delete iAppCloseTimer; + delete iAppCloseWatcher; + } + +// Callback from COomAppCloseWatcher and COomAppCloseTimer +void COomCloseApp::CloseAppEvent() + { + FUNC_LOG; + + // The application has closed (or we have a timeout) + iAppCloserRunning = EFalse; + + if (iAppCloseTimer) + iAppCloseTimer->Cancel(); + if (iAppCloseWatcher) + iAppCloseWatcher->Cancel(); + + MemoryFreed(KErrNone); + } + +void COomCloseApp::Reconfigure(const TActionRef& aRef) + { + FUNC_LOG; + + iWgId = aRef.WgId(); + } + +void COomCloseApp::ConstructL() + { + FUNC_LOG; + + iAppCloseTimer = COomAppCloseTimer::NewL(*this); + iAppCloseWatcher = new(ELeave) COomAppCloseWatcher(*this); + } + +COomCloseApp::COomCloseApp(MOomActionObserver& aStateChangeObserver, RWsSession& aWs) + : COomAction(aStateChangeObserver), iCurrentTask(aWs) + { + FUNC_LOG; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomcloseappconfig.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomcloseappconfig.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + + +#include "oomcloseappconfig.h" +#include "oomtraces.h" + +COomCloseAppConfig* COomCloseAppConfig::NewL(TInt32 aId) + { + FUNC_LOG; + + COomCloseAppConfig* self = new (ELeave) COomCloseAppConfig(aId); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +COomCloseAppConfig::~COomCloseAppConfig() + { + FUNC_LOG; + } + +COomCloseAppConfig::COomCloseAppConfig(TInt32 aId) : COomActionConfig(aId) + { + FUNC_LOG; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomconfig.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomconfig.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,195 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + + +#include + +#include "oomconfig.h" +#include "oomconstants.hrh" +#include "oomapplicationconfig.h" +#include "oomrunpluginconfig.h" +#include "oomcloseappconfig.h" +#include "oomtraces.h" + +COomConfig* COomConfig::NewL() + { + FUNC_LOG; + + COomConfig* self = new (ELeave) COomConfig; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + + +// Add the configuration for an application closure. +// This class takes ownership of this action. +void COomConfig::SetAppCloseConfigL(COomCloseAppConfig* aActionConfig) + { + FUNC_LOG; + + // Find the right application config (if there is one) for the app + // The map actually contains pointers for values, so we get pointers to pointers here... + COomApplicationConfig** applicationConfigPointer = iApplicationToConfigMapping.Find(aActionConfig->iId); + + // Used to de-reference the pointer-to-pointer, hopefully making the code more readable + COomApplicationConfig* applicationConfig = NULL; + + // Create a new COomApplicationConfig if there isn't one for this app + if (!applicationConfigPointer) + { + applicationConfig = COomApplicationConfig::NewL(aActionConfig->iId); + iApplicationToConfigMapping.InsertL(aActionConfig->iId, applicationConfig); + } + else + { + applicationConfig = *applicationConfigPointer; + } + + // Append the action config to the appropriate list (the list for the relevant application) + applicationConfig->SetAppCloseConfig(aActionConfig); + } + +// Add the configuration for a plugin action. +// This class takes ownership of the configuration object. +void COomConfig::AddPluginConfigL(COomRunPluginConfig* aPluginConfig) + { + FUNC_LOG; + + // Check if the plugin has already been added, if so then this is an error in configuration (something is trying to add the same plugin twice) + COomRunPluginConfig** runPluginConfig = iPluginToConfigMapping.Find(aPluginConfig->Id()); + if (runPluginConfig) + { + OomMonitorPanic(KPluginConfigAddedTwice); + } + + iPluginToConfigMapping.InsertL(aPluginConfig->Id(), aPluginConfig); + + } + +// Add a rule +// This class takes ownership of the given rule +// This rule applies to the specified application (and not a plugin associated with this application) +// The rule would usually apply to an "application close" event +void COomConfig::AddApplicationRuleL(TUint aTargetAppId, MOomRuleConfig* aRule) + { + FUNC_LOG; + + COomApplicationConfig** applicationConfig = iApplicationToConfigMapping.Find(aTargetAppId); + + if (applicationConfig) + { + (*applicationConfig)->AddRuleL(aRule); + } + else + { + OomMonitorPanic(KRuleConfiguredBeforeApplication); + } + } + +// Add a rule for a plugin +// This class takes ownership of the given rule +// This rule is applied to the plugin with the specified ID +void COomConfig::AddPluginRuleL(TUint aPluginId, MOomRuleConfig* aRule) + { + FUNC_LOG; + + COomRunPluginConfig** runPluginConfig = iPluginToConfigMapping.Find(aPluginId); + + if (runPluginConfig) + { + (*runPluginConfig)->AddRuleL(aRule); + } + else + { + OomMonitorPanic(KRuleConfiguredBeforePlugin); + } + } + +// Add this application config - this class takes ownership of it +// Application config includes settings for a particular application, e.g. whether or not it can be closed +void COomConfig::AddApplicationConfigL(COomApplicationConfig* aApplicationConfig) + { + FUNC_LOG; + + // Check if the application has already been added, if so then this is an error in configuration (something is trying to add the same app twice) + COomApplicationConfig** applicationConfig = iApplicationToConfigMapping.Find(aApplicationConfig->Id()); + if (applicationConfig) + { + OomMonitorPanic(KAppConfigAddedTwice); + } + + iApplicationToConfigMapping.InsertL(aApplicationConfig->Id(), aApplicationConfig); + } + +// Get the list of configured actions for the given app id +// If no specific actions have been configured for this application then the default action is returned +COomApplicationConfig& COomConfig::GetApplicationConfig(TInt32 aAppId) + { + FUNC_LOG; + + COomApplicationConfig** applicationConfig = iApplicationToConfigMapping.Find(aAppId); + + if (!applicationConfig) + applicationConfig = iApplicationToConfigMapping.Find(KOomDefaultAppId); + + // The default app configuration should always exist + __ASSERT_ALWAYS(applicationConfig, OomMonitorPanic(KOomDefaultAppNotConfigured)); + + return *(*applicationConfig); + } + +// Get the plugin configuration for the given plugin id +// If no specific actions have been configured for this plugin then the default plugin configuration is returned +COomRunPluginConfig& COomConfig::GetPluginConfig(TInt32 aPluginId) + { + FUNC_LOG; + + COomRunPluginConfig** runPluginConfig = iPluginToConfigMapping.Find(aPluginId); + + if (!runPluginConfig) + runPluginConfig = iPluginToConfigMapping.Find(KOomDefaultPluginId); + + // The default app configuration should always exist + __ASSERT_ALWAYS(runPluginConfig, OomMonitorPanic(KOomDefaultPluginNotConfigured)); + + return *(*runPluginConfig); + } + +COomConfig::~COomConfig() + { + FUNC_LOG; + + // Iterate through the hash map deleting all of the items + RHashMap::TIter iterator(iApplicationToConfigMapping); + while (iterator.NextValue()) + delete iterator.CurrentValue(); + + // Iterate through the plugiun hash map deleting all of the items + RHashMap::TIter pluginIterator(iPluginToConfigMapping); + while (pluginIterator.NextValue()) + delete pluginIterator.CurrentValue(); + + iApplicationToConfigMapping.Close(); + } + +void COomConfig::ConstructL() + { + FUNC_LOG; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomconfigparser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomconfigparser.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,1077 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: The parser for the OOM configuration file. +* +*/ +#include +#include + +#include "oomconfigparser.h" +#include "oompanic.h" +#include "oomtraces.h" +#include "oomidletimerule.h" +#include "oomforegroundrule.h" +#include "oomconstants.hrh" +#include "oomapplicationconfig.h" +#include "oomcloseappconfig.h" +#include "oomconfig.h" +#include "oomrunpluginconfig.h" + +enum TOomConfigParserPanic +{ +KOomErrMoreThanOneOomConfig = 0, +KOomErrGlobalSettingsMustComeAfterRoot, +KOomErrAppSettingsMustComeAfterGlobalSettings, +KOomErrCloseAppSettingsMustComeAfterAppSettings, +KOomErrAppIdleSettingsMustComeAfterAppCloseSettings, +KOomErrLowRamErrorInGlobalSettings, +KOomErrGoodRamErrorInGlobalSettings, +KOomErrMaxCloseErrorInGlobalSettings, +KOomErrDefaultPriorityErrorInGlobalSettings, +KOomErrMissingUidFromAppCloseConfig, +KOomErrMissingPriorityFromAppCloseConfig, +KOomErrMissingSyncModeFromAppCloseConfig, +KOomErrMissingEstimateFromAppCloseConfig, +KOomErrInvalidSyncMode, +KOomErrMissingSyncModeInAppCloseConfig, +KOomErrBadOrMissingPriorityInAppIdleRule, +KOomErrBadOrMissingIdleTimeInAppIdleRule, +KOomErrBadOrMissingUidInAppIdleRule, +KOomErrBadNeverCloseValue, +KOomErrBadOrMissingUidInAppConfig, +KOomErrBadOrMissingPriorityInAppCloseConfig, +KOomErrBadLowThresholdValueForAppConfig, +KOomErrBadGoodThresholdValueForAppConfig, +KOomErrSystemPluginSettingsMustComeAfterAppCloseSettings, +KOomErrAppPluginSettingsMustComeAfterSystemPluginSettings, +KOomErrAppPluginIdleTimeRulesMustComeAfterAppPluginSettings, +KOomErrBadOrMissingUidInAppCloseConfig, +KOomErrBadOrMissingUidInSystemPluginConfig, +KOomErrBadOrMissingPriorityInSystemPluginConfig, +KOomErrBadOrMissingTargetAppIdInAppPluginConfig, +KOomErrBadOrMissingUidInAppPluginConfig, +KOomErrBadOrMissingPriorityInAppPluginConfig, +KOomErrBadOrMissingPriorityInPluginIdleRule, +KOomErrBadOrMissingIdleTimeInPluginIdleRule, +KOomErrBadOrMissingUidInPluginIdleRule, +KOomErrBadOrMissingUidInForegroundAppRule, +KOomErrBadOrMissingPriorityInForegroundAppRule, +KOomErrBadOrMissingTargetAppIdInForegroundAppRule, +KOomErrDefaultWaitAfterPluginInGlobalSettings, +KOomErrBadOrMissingPriorityInForceCheck, +KOomErrOomRulesMustComeLast, +KOomErrBadPluginWaitTime, +KOomErrBadXml, +KOomErrAppCloseIdleRuleOutsideAppCloseElement, +KOomErrForegroundAppRuleOutsideAppCloseElement, +KOomErrPluginIdleRuleOutsideAppPluginElement, +KOomErrPluginForegroundRuleOutsidePluginElement, +KOomErrBadCallIfTargetAppNotRunning +}; + +const TInt KOomXmlFileBufferSize = 1024; +const TInt KOomMaxAppExitTime = 2000; +const TInt KBytesInMegabyte = 1024; +#ifdef __WINS__ +const TInt KEmulatorTickDivisor = 5; // The tick is 5 times slower on the emulator than on the phone +#endif +using namespace Xml; + +// Mime type of the parsed document +_LIT8(KXmlMimeType, "text/xml"); + +_LIT(KOomConfigFilePath, ":\\private\\10207218\\oomconfig.xml"); +_LIT(KRomDrive, "z"); + +// Element strings +// Root +_LIT8(KOomConfigOomConfig, "oom_config"); + +// Global settings +_LIT8(KOomConfigGlobalSettings, "global_settings"); +_LIT8(KOomConfigForceCheckAtPriority, "force_check"); + +// App settings +_LIT8(KOomConfigAppSettings, "app_specific_thresholds"); +_LIT8(KOomConfigApp, "app"); + +// App close settings +_LIT8(KOomConfigAppCloseSettings, "app_close_settings"); +_LIT8(KOomConfigCloseApp, "close_app"); + +// App close idle time +_LIT8(KOomConfigAppCloseIdlePriority, "app_close_idle_priority"); + +_LIT8(KOomConfigForegroundAppPriority, "foreground_app_priority"); + +// Global settings attribute names +_LIT8(KOomAttributeLowRamThreshold, "low_ram_threshold"); +_LIT8(KOomAttributeGoodRamThreshold, "good_ram_threshold"); +_LIT8(KOomAttributeMaxAppCloseBatch, "max_app_close_batch"); +_LIT8(KOomAttributeDefaultWaitAfterPlugin, "default_wait_after_plugin"); +_LIT8(KOomAttributeMaxAppExitTime , "max_app_exit_time"); + +// System plugins + +_LIT8(KOomAttributeSystemPluginSettings, "system_plugin_settings"); +_LIT8(KOomAttributeSystemPlugin, "system_plugin"); + +// Application plugins + +_LIT8(KOomAttributeAppPluginSettings, "app_plugin_settings"); +_LIT8(KOomAttributeAppPlugin, "app_plugin"); + +// Plugin idle time rules + +_LIT8(KOomAttributePluginIdlePriority, "plugin_idle_priority"); + +// Plugin foreground app rules +_LIT8(KOomAttributePluginForegroundAppPriority, "plugin_foreground_app_priority"); + +// Atribute names +_LIT8(KOomAttibuteUid, "uid"); +_LIT8(KOomAttibuteSyncMode, "sync_mode"); +_LIT8(KOomAttibutePriority, "priority"); +_LIT8(KOomAttibuteRamEstimate, "ram_estimate"); + +_LIT8(KOomConfigSyncModeContinue, "continue"); +_LIT8(KOomConfigSyncModeCheck, "check"); +_LIT8(KOomConfigSyncModeEstimate, "estimate"); + +_LIT8(KOomAttibuteIdleTime, "idle_time"); +_LIT8(KOomAttibuteIdlePriority, "priority"); + +_LIT8(KOomAttibuteNeverClose, "NEVER_CLOSE"); + +_LIT8(KOomAttributeTargetAppId, "target_app_id"); + +_LIT8(KOomAttributeWait, "wait"); + +_LIT8(KOomAttributeIfForegroundAppId, "if_foreground_app_id"); + +_LIT8(KOomAttributeCallIfTargetAppNotRunning, "call_if_target_app_not_running"); +_LIT8(KOomAttributeTrue, "true"); +_LIT8(KOomAttributeFalse, "false"); +_LIT8(KOomAttribute0, "0"); +_LIT8(KOomAttribute1, "1"); + + +_LIT8(KOomConfigDefaultAppUid, "DEFAULT_APP"); +_LIT8(KOomConfigDefaultPluginUid, "DEFAULT_PLUGIN"); +_LIT8(KOomConfigTargetAppValue, "TARGET_APP"); + +_LIT8(KOomConfigBusyAppUid, "BUSY_APP"); +_LIT8(KOomConfigHighPriorityAppUid, "HIGH_PRIORITY_APP"); + +COomConfigParser::COomConfigParser(COomConfig& aConfig, RFs& aFs) : iConfig(aConfig), iFs(aFs), iState(EOomParsingStateNone) + { + } + +void COomConfigParser::ParseL() + { + FUNC_LOG; + + TRACES("COomConfigParser::ParseL: Parsing Config File"); + + CParser* parser = CParser::NewLC(KXmlMimeType, *this); + + RFile configFile; + TFileName configFileName; + TChar driveChar = iFs.GetSystemDriveChar(); + configFileName.Append(driveChar); + configFileName.Append(KOomConfigFilePath); + if (configFile.Open(iFs, configFileName, EFileShareExclusive) != KErrNone) + { + configFileName.Replace(0,1,KRomDrive); //replace 'c' with 'z' + User::LeaveIfError(configFile.Open(iFs, configFileName, EFileShareExclusive)); + } + CleanupClosePushL(configFile); + + TBuf8 fileBuffer; + TInt bytesRead; + do + { + User::LeaveIfError(configFile.Read(fileBuffer)); + bytesRead = fileBuffer.Size(); + + parser->ParseL(fileBuffer); + + } while (bytesRead != 0); + + CleanupStack::PopAndDestroy(2, parser); // config file - automatically closes it + // parser + + TRACES("COomConfigParser::ParseL: Finished Parsing Config File"); + } + +void COomConfigParser::OnStartDocumentL(const RDocumentParameters&, TInt) + { + FUNC_LOG; + } + +void COomConfigParser::OnEndDocumentL(TInt) + { + FUNC_LOG; + } + + +void COomConfigParser::OnEndElementL(const RTagInfo&, TInt) + { + } + +void COomConfigParser::OnContentL(const TDesC8&, TInt) + { + } + +void COomConfigParser::OnStartPrefixMappingL(const RString&, const RString&, + TInt) + { + } + +void COomConfigParser::OnEndPrefixMappingL(const RString&, TInt) + { + } + +void COomConfigParser::OnIgnorableWhiteSpaceL(const TDesC8&, TInt) + { + } + +void COomConfigParser::OnSkippedEntityL(const RString&, TInt) + { + } + +void COomConfigParser::OnProcessingInstructionL(const TDesC8&, const TDesC8&, + TInt) + { + } + +void COomConfigParser::OnError(TInt) + { + } + +TAny* COomConfigParser::GetExtendedInterface(const TInt32) + { + return 0; + } + +void COomConfigParser::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, + TInt aErrorCode) + { + if (aErrorCode != KErrNone) + ConfigError(KOomErrBadXml); + + StartElementL(aElement.LocalName().DesC(), aAttributes); + } + +void COomConfigParser::StartElementL(const TDesC8& aLocalName, + const RAttributeArray& aAttributes) + { + // Root + if (aLocalName == KOomConfigOomConfig) + { + if (iState != EOomParsingStateNone) + ConfigError(KOomErrMoreThanOneOomConfig); + + ChangeState(EOomParsingStateRoot); + } + // Parse main elements + else if (aLocalName == KOomConfigGlobalSettings) + { + if (iState != EOomParsingStateRoot) + ConfigError(KOomErrGlobalSettingsMustComeAfterRoot); + + SetGlobalSettings(aAttributes); + + ChangeState(EOomParsingStateGlobalSettings); + } + else if (aLocalName == KOomConfigAppSettings) + { + ChangeState(EOomParsingStateAppSettings); + } + else if (aLocalName == KOomConfigAppCloseSettings) + { + ChangeState(EOomParsingStateAppCloseSettings); + } + else if (aLocalName == KOomAttributeSystemPluginSettings) + { + ChangeState(EOomParsingStateSystemPluginSettings); + } + else if (aLocalName == KOomAttributeAppPluginSettings) + { + ChangeState(EOomParsingStateAppPluginSettings); + } + // Parse actual configuration elements + else if (aLocalName == KOomConfigForceCheckAtPriority) + { + SetForceCheckConfigL(aAttributes); + } + else if (aLocalName == KOomConfigApp) + { + SetAppConfigL(aAttributes); + } + else if (aLocalName == KOomConfigCloseApp) + { + SetCloseAppConfigL(aAttributes); + } + else if (aLocalName == KOomConfigAppCloseIdlePriority) + { + CheckState(EOomParsingStateAppCloseSettings, KOomErrAppCloseIdleRuleOutsideAppCloseElement); + SetAppCloseIdlePriorityConfigL(aAttributes); + } + else if (aLocalName == KOomConfigForegroundAppPriority) + { + CheckState(EOomParsingStateAppCloseSettings, KOomErrForegroundAppRuleOutsideAppCloseElement); + SetForegroundAppPriorityL(aAttributes); + } + else if (aLocalName == KOomAttributeSystemPlugin) + { + SetSystemPluginConfigL(aAttributes); + } + else if (aLocalName == KOomAttributeAppPlugin) + { + SetAppPluginConfigL(aAttributes); + } + else if (aLocalName == KOomAttributePluginIdlePriority) + { + CheckState(EOomParsingStateAppPluginSettings, KOomErrPluginIdleRuleOutsideAppPluginElement); + SetPluginIdlePriorityL(aAttributes); + } + else if (aLocalName == KOomAttributePluginForegroundAppPriority) + { + CheckState(EOomParsingStateAppPluginSettings, EOomParsingStateSystemPluginSettings, KOomErrPluginForegroundRuleOutsidePluginElement); + SetPluginForegroundAppPriorityL(aAttributes); + } + + } + +void COomConfigParser::ConfigError(TInt aError) + { + OomConfigParserPanic(aError); + } + +void COomConfigParser::SetGlobalSettings(const RAttributeArray& aAttributes) + { + TInt defaultLowMemoryThreshold; + TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeLowRamThreshold, defaultLowMemoryThreshold); + + if (err == KErrNone) + iConfig.SetDefaultLowRamThreshold(defaultLowMemoryThreshold * KBytesInMegabyte); + else + ConfigError(KOomErrLowRamErrorInGlobalSettings); + + if (err == KErrNone) + { + TInt defaultGoodMemoryThreshold; + TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeGoodRamThreshold, defaultGoodMemoryThreshold); + + if (err == KErrNone) + iConfig.SetDefaultGoodRamThreshold(defaultGoodMemoryThreshold * KBytesInMegabyte); + else + ConfigError(KOomErrGoodRamErrorInGlobalSettings); + } + + if (err == KErrNone) + { + TInt defaultMaxCloseAppBatch; + TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeMaxAppCloseBatch, defaultMaxCloseAppBatch); + + if (err == KErrNone) + iConfig.SetMaxCloseAppBatch(defaultMaxCloseAppBatch); + else + ConfigError(KOomErrMaxCloseErrorInGlobalSettings); + } + + if (err == KErrNone) + { + TInt defaultWaitAfterPlugin; + TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeDefaultWaitAfterPlugin, defaultWaitAfterPlugin); + + if (err == KErrNone) + iConfig.SetDefaultWaitAfterPlugin(defaultWaitAfterPlugin); + else + ConfigError(KOomErrDefaultWaitAfterPluginInGlobalSettings); + } + + if (err == KErrNone) + { + TInt maxAppExitTime; + TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeMaxAppExitTime, maxAppExitTime); + + if (err == KErrNone) + iConfig.SetMaxAppExitTime(maxAppExitTime); + else + iConfig.SetMaxAppExitTime(KOomMaxAppExitTime); + } + } + +void COomConfigParser::SetForceCheckConfigL(const RAttributeArray& aAttributes) + { + TUint priority; + TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibutePriority, priority); + if (err == KErrNone) + { + iConfig.GlobalConfig().AddForceCheckPriorityL(priority); + } + else + { + ConfigError(KOomErrBadOrMissingPriorityInForceCheck); + } + } + +void COomConfigParser::SetAppConfigL(const RAttributeArray& aAttributes) + { + TUint uid; + COomApplicationConfig* appConfig = NULL; + + TInt err = GetValueFromHexAttributeList(aAttributes, KOomAttibuteUid, uid); + + if (err != KErrNone) + { + ConfigError(KOomErrBadOrMissingUidInAppConfig); + } + else + iParentUid = uid; + + appConfig = COomApplicationConfig::NewL(uid); + CleanupStack::PushL(appConfig); + + // Set the app specific memory thresholds (if they exist) + // Get the app specific low threshold + if (err == KErrNone) + { + TUint lowThreshold; + err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeLowRamThreshold, lowThreshold); + if (err == KErrNone) + { + appConfig->iLowRamThreshold = lowThreshold * KBytesInMegabyte; + } + else if (err == KErrNotFound) + err = KErrNone; + + if (err != KErrNone) + ConfigError(KOomErrBadLowThresholdValueForAppConfig); + } + + // Get the app specific good threshold + if (err == KErrNone) + { + TUint goodThreshold; + err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeGoodRamThreshold, goodThreshold); + if (err == KErrNone) + { + appConfig->iGoodRamThreshold = goodThreshold * KBytesInMegabyte; + } + else if (err == KErrNotFound) + err = KErrNone; + + if (err != KErrNone) + ConfigError(KOomErrBadGoodThresholdValueForAppConfig); + } + + // Add the applciation config to the main config + if ((err == KErrNone) && (appConfig)) + { + iConfig.AddApplicationConfigL(appConfig); + } + + if (appConfig) + CleanupStack::Pop(appConfig); + } + +void COomConfigParser::SetCloseAppConfigL(const RAttributeArray& aAttributes) + { + // Get and convert uid attribute to TInt + TInt err = KErrNone; + + TUint uid; + err = GetValueFromHexAttributeList(aAttributes, KOomAttibuteUid, uid); + + if (err != KErrNone) + { + ConfigError(KOomErrBadOrMissingUidInAppCloseConfig); + return; + } + else + iParentUid = uid; + + COomCloseAppConfig* closeAppConfig = COomCloseAppConfig::NewL(uid); // Radio UID + CleanupStack::PushL(closeAppConfig); + + if (err == KErrNone) + { + // Check that we have a priority for the added app_close event + // Specifying a priority is mandatory + TUint priority; + err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibutePriority, priority); + if (err == KErrNone) + { + closeAppConfig->SetDefaultPriority(priority); + } + else + { + ConfigError(KOomErrBadOrMissingPriorityInAppCloseConfig); + } + } + + if (err == KErrNone) + { + TPtrC8 syncModeString; + err = GetValueFromAttributeList(aAttributes, KOomAttibuteSyncMode, syncModeString); + + if (err == KErrNone) + { + TOomSyncMode syncMode = EContinue; + + if (syncModeString == KOomConfigSyncModeContinue) + syncMode = EContinue; + else if (syncModeString == KOomConfigSyncModeCheck) + syncMode = ECheckRam; + else if (syncModeString == KOomConfigSyncModeEstimate) + syncMode = EEstimate; + else + ConfigError(KOomErrInvalidSyncMode); + + if (err == KErrNone) + { + closeAppConfig->iSyncMode = syncMode; + } + } + else + { + ConfigError(KOomErrMissingSyncModeInAppCloseConfig); + } + } + + + if (err == KErrNone) + { + // If we have a default priority attribute then add it, otherwise use the global default priority + TInt ramEstimate; + err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteRamEstimate, ramEstimate); + if ((err == KErrNotFound) && (closeAppConfig->iSyncMode != EEstimate)) + { + err = KErrNone; + } + + if (err != KErrNone) + ConfigError(KOomErrMissingEstimateFromAppCloseConfig); + else + closeAppConfig->iRamEstimate = ramEstimate * KBytesInMegabyte; + } + + if (err == KErrNone) + iConfig.SetAppCloseConfigL(closeAppConfig); + + CleanupStack::Pop(closeAppConfig); + } + +void COomConfigParser::SetAppCloseIdlePriorityConfigL(const RAttributeArray& aAttributes) + { + TUint uid; + TInt idleTime; + TUint priority; + + // Use the UID from the parent scope + uid = iParentUid; + + TInt err = KErrNone; + + err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdleTime, idleTime); + +#ifdef __WINS__ + // The tick is 5 times slower on the emulator than on the phone + idleTime = idleTime / KEmulatorTickDivisor; +#endif + + if (err != KErrNone) + { + ConfigError(KOomErrBadOrMissingIdleTimeInAppIdleRule); + } + + if (err == KErrNone) + { + err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdlePriority, priority); + + if (err != KErrNone) + { + ConfigError(KOomErrBadOrMissingPriorityInAppIdleRule); + } + } + + if (err == KErrNone) + { + COomIdleTimeRule* idleRule = COomIdleTimeRule::NewL(idleTime, priority); + CleanupStack::PushL(idleRule); + iConfig.AddApplicationRuleL(uid, idleRule); + CleanupStack::Pop(idleRule); + } + } + +void COomConfigParser::SetForegroundAppPriorityL(const RAttributeArray& aAttributes) + { + TUint appUid; + TUint targetAppId; + TUint priority; + + TInt err = KErrNone; + + // Use the UID from the parent scope + appUid = iParentUid; + + // Check that we have a priority for the added system plugin action + // Specifying a priority is mandatory + err = GetValueFromHexAttributeList(aAttributes, KOomAttributeIfForegroundAppId, targetAppId); + if (err != KErrNone) + { + ConfigError(KOomErrBadOrMissingTargetAppIdInForegroundAppRule); + } + + if (err == KErrNone) + { + err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdlePriority, priority); + + if (err != KErrNone) + { + ConfigError(KOomErrBadOrMissingPriorityInForegroundAppRule); + } + } + + if (err == KErrNone) + { + COomForegroundRule* foregroundRule = new (ELeave) COomForegroundRule(targetAppId, priority); + CleanupStack::PushL(foregroundRule); + iConfig.AddApplicationRuleL(appUid, foregroundRule); + CleanupStack::Pop(foregroundRule); + } + + } + +void COomConfigParser::SetSystemPluginConfigL(const RAttributeArray& aAttributes) + { + // Get and convert uid attribute to TInt + TInt err = KErrNone; + + TUint uid; + err = GetValueFromHexAttributeList(aAttributes, KOomAttibuteUid, uid); + + if (err != KErrNone) + { + ConfigError(KOomErrBadOrMissingUidInSystemPluginConfig); + return; + } + else + iParentUid = uid; + + COomRunPluginConfig* pluginConfig = COomRunPluginConfig::NewL(uid, EOomSystemPlugin); + CleanupStack::PushL(pluginConfig); + + if (err == KErrNone) + { + // Check that we have a priority for the added system plugin action + // Specifying a priority is mandatory + TUint priority; + err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibutePriority, priority); + if (err == KErrNone) + { + pluginConfig->SetDefaultPriority(priority); + } + else + { + ConfigError(KOomErrBadOrMissingPriorityInSystemPluginConfig); + } + } + + if (err == KErrNone) + { + TInt wait; + err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeWait, wait); + if (err == KErrNone) + { + pluginConfig->SetWaitAfterPlugin(wait); + } + else if (err == KErrNotFound) + { + // If this attribute isn't present then just don't set it, and clear the error + err = KErrNone; + } + else + ConfigError(KOomErrBadPluginWaitTime); + } + + if (err == KErrNone) + { + // Get the config for the sync mode for this plugin (if one is specified) and set it + SetPluginSyncMode(aAttributes, *pluginConfig); + } + + iConfig.AddPluginConfigL(pluginConfig); + + CleanupStack::Pop(pluginConfig); + } + +void COomConfigParser::SetAppPluginConfigL(const RAttributeArray& aAttributes) + { + // Get and convert uid attribute to TInt + TInt err = KErrNone; + + TUint uid; + err = GetValueFromHexAttributeList(aAttributes, KOomAttibuteUid, uid); + + if (err != KErrNone) + { + ConfigError(KOomErrBadOrMissingUidInAppPluginConfig); + return; + } + else + iParentUid = uid; + + COomRunPluginConfig* pluginConfig = COomRunPluginConfig::NewL(uid, EOomAppPlugin); + CleanupStack::PushL(pluginConfig); + + if (err == KErrNone) + { + // Check that we have a priority for the added system plugin action + // Specifying a priority is mandatory + TUint priority; + err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibutePriority, priority); + if (err == KErrNone) + { + pluginConfig->SetDefaultPriority(priority); + } + else + { + ConfigError(KOomErrBadOrMissingPriorityInAppPluginConfig); + } + } + + if (err == KErrNone) + { + // Check that we have a priority for the added system plugin action + // Specifying a priority is mandatory + TUint targetAppId; + err = GetValueFromHexAttributeList(aAttributes, KOomAttributeTargetAppId, targetAppId); + if (err == KErrNone) + { + pluginConfig->SetTargetApp(targetAppId); + iParentTargetApp = targetAppId; + } + else + { + ConfigError(KOomErrBadOrMissingTargetAppIdInAppPluginConfig); + } + } + + if (err == KErrNone) + { + TInt wait; + err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeWait, wait); + if (err == KErrNone) + { + pluginConfig->SetWaitAfterPlugin(wait); + } + else if (err == KErrNotFound) + { + // If this attribute isn't present then just don't set it, and clear the error + err = KErrNone; + } + else + ConfigError(KOomErrBadPluginWaitTime); + } + + if (err == KErrNone) + { + // Get the config for the sync mode for this plugin (if one is specified) and set it + SetPluginSyncMode(aAttributes, *pluginConfig); + + TBool targetAppNotRunning; + err = GetValueFromBooleanAttributeList(aAttributes, KOomAttributeCallIfTargetAppNotRunning, targetAppNotRunning); + if (err == KErrNone) + { + pluginConfig->SetCallIfTargetAppNotRunning(targetAppNotRunning); + } + else if (err == KErrNotFound) + { + // If this attribute isn't present then just don't set it, and clear the error + err = KErrNone; + } + else + { + ConfigError(KOomErrBadCallIfTargetAppNotRunning); + } + } + + iConfig.AddPluginConfigL(pluginConfig); + + CleanupStack::Pop(pluginConfig); + + } + +void COomConfigParser::SetPluginIdlePriorityL(const RAttributeArray& aAttributes) + { + TUint uid; + TInt idleTime; + TUint priority; + + TInt err = KErrNone; + + // Use the UID from the parent scope + uid = iParentUid; + + err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdleTime, idleTime); + +#ifdef __WINS__ + // The tick is 5 times slower on the emulator than on the phone + idleTime = idleTime / KEmulatorTickDivisor; +#endif + + if (err != KErrNone) + { + ConfigError(KOomErrBadOrMissingIdleTimeInPluginIdleRule); + } + + if (err == KErrNone) + { + err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdlePriority, priority); + + if (err != KErrNone) + { + ConfigError(KOomErrBadOrMissingPriorityInPluginIdleRule); + } + } + + if (err == KErrNone) + { + COomIdleTimeRule* idleRule = COomIdleTimeRule::NewL(idleTime, priority); + CleanupStack::PushL(idleRule); + iConfig.AddPluginRuleL(uid, idleRule); + CleanupStack::Pop(idleRule); + } + } + +void COomConfigParser::SetPluginForegroundAppPriorityL(const RAttributeArray& aAttributes) + { + TUint uid; + TUint targetAppId; + TUint priority; + + TInt err = KErrNone; + + // Use the UID from the parent scope + uid = iParentUid; + + // Check that we have a priority for the added system plugin action + // Specifying a priority is mandatory + + TPtrC8 targetAppString; + err = GetValueFromAttributeList(aAttributes, KOomAttributeTargetAppId, targetAppString); + if ((err == KErrNone) + && (targetAppString == KOomConfigTargetAppValue) + && (iState == EOomParsingStateAppPluginSettings)) + // If the target app is specified as "TARGET_APP" then we use the target app from the parent entry + { + targetAppId = iParentTargetApp; + } + else + { + err = GetValueFromHexAttributeList(aAttributes, KOomAttributeTargetAppId, targetAppId); + if (err != KErrNone) + { + ConfigError(KOomErrBadOrMissingTargetAppIdInForegroundAppRule); + } + } + + if (err == KErrNone) + { + err = GetValueFromDecimalAttributeList(aAttributes, KOomAttibuteIdlePriority, priority); + + if (err != KErrNone) + { + ConfigError(KOomErrBadOrMissingPriorityInForegroundAppRule); + } + } + + if (err == KErrNone) + { + COomForegroundRule* foregroundRule = new (ELeave) COomForegroundRule(targetAppId, priority); + CleanupStack::PushL(foregroundRule); + iConfig.AddPluginRuleL(uid, foregroundRule); + CleanupStack::Pop(foregroundRule); + } + } + +// Finds an attribute of the given name and gets its value +// A value is only valid as long as AAtrributes is valid (and unmodified) +// Returns KErrNone if the attribute is present in the list, KErrNotFound otherwise +TInt COomConfigParser::GetValueFromAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TPtrC8& aValue) + { + TInt index = aAttributes.Count(); + TBool attributeFound = EFalse; + while ((index--) && (!attributeFound)) + { + if (aAttributes[index].Attribute().LocalName().DesC() == aName) + { + attributeFound = ETrue; + aValue.Set(aAttributes[index].Value().DesC()); + } + } + + TInt err = KErrNone; + + if (!attributeFound) + err = KErrNotFound; + + return err; + } + +// Finds an attribute of the given name and gets its value (coverting the string hex value to a UInt) +// Returns KErrNone if the attribute is present in the list, KErrNotFound otherwise +// Returns KErrCorrupt if the string is not a valid hex number +TInt COomConfigParser::GetValueFromHexAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TUint& aValue) + { + TPtrC8 hexString; + TInt err = GetValueFromAttributeList(aAttributes, aName, hexString); + + if (hexString == KOomConfigDefaultAppUid) + { + // This is a special case + // When we hit this value in a hex field then we return the default app UID + aValue = KOomDefaultAppId; + } + else if (hexString == KOomConfigDefaultPluginUid) + { + // This is a special case + // When we hit this value in a hex field then we return the default app UID + aValue = KOomDefaultPluginId; + } + else if (hexString == KOomConfigBusyAppUid) + { + aValue = KOomBusyAppId; + } + else if (hexString == KOomConfigHighPriorityAppUid) + { + aValue = KOomHighPriorityAppId; + } + else if (err == KErrNone) + { + TLex8 hexLex(hexString); + err = hexLex.Val(aValue, EHex); + if (err != KErrNone) + err = KErrCorrupt; + } + + return err; + } + +// Finds an attribute of the given name and gets its value (coverting the string decimal value to a UInt) +// Returns KErrNone if the attribute is present in the list, KErrNotFound otherwise +// Returns KErrCorrupt if the string is not a valid decimal number +TInt COomConfigParser::GetValueFromDecimalAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TUint& aValue) + { + TPtrC8 decimalString; + TInt err = GetValueFromAttributeList(aAttributes, aName, decimalString); + + if (err == KErrNone) + { + if (decimalString == KOomAttibuteNeverClose) + aValue = KOomPriorityInfinate; + else + { + TLex8 decimalLex(decimalString); + err = decimalLex.Val(aValue, EDecimal); + if (err != KErrNone) + err = KErrCorrupt; + } + } + + return err; + } + +TInt COomConfigParser::GetValueFromDecimalAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TInt& aValue) + { + TUint uintValue; + TInt err = GetValueFromDecimalAttributeList(aAttributes, aName, uintValue); + aValue = uintValue; + return err; + } + +TInt COomConfigParser::GetValueFromBooleanAttributeList(const RAttributeArray& aAttributes, const TDesC8& aName, TBool& aValue) + { + TPtrC8 ptrValue; + TInt err = GetValueFromAttributeList(aAttributes, aName, ptrValue); + if (err == KErrNone) + { + if (ptrValue == KOomAttributeTrue || ptrValue == KOomAttribute1) + { + aValue = ETrue; + } + else if (ptrValue == KOomAttributeFalse || ptrValue == KOomAttribute0) + { + aValue = EFalse; + } + else + { + err = KErrCorrupt; + } + } + return err; + } + +void COomConfigParser::SetPluginSyncMode(const RAttributeArray& aAttributes, COomRunPluginConfig& aRunPluginConfig) + { + TPtrC8 syncModeString; + TInt err = GetValueFromAttributeList(aAttributes, KOomAttibuteSyncMode, syncModeString); + + if (err == KErrNone) + // If there is no specified sync mode then leave it as the default + { + TOomSyncMode syncMode = EContinue; + + if (syncModeString == KOomConfigSyncModeContinue) + syncMode = EContinueIgnoreMaxBatchSize; + else if (syncModeString == KOomConfigSyncModeCheck) + syncMode = ECheckRam; + else if (syncModeString == KOomConfigSyncModeEstimate) + syncMode = EEstimate; + else + ConfigError(KOomErrInvalidSyncMode); + + if (err == KErrNone) + { + aRunPluginConfig.iSyncMode = syncMode; + } + } + } + +// Check that the current state is as expected +// If not then the specified config error is generated +void COomConfigParser::CheckState(TOomParsingState aExpectedState, TInt aError) + { + if (iState != aExpectedState) + ConfigError(aError); + } + +// Check that the current state is as expected +// If not then the specified config error is generated +// This version checks to ensure that the current state matches either of the passed in states +void COomConfigParser::CheckState(TOomParsingState aExpectedState1, TOomParsingState aExpectedState2, TInt aError) + { + if ((iState != aExpectedState1) + && (iState != aExpectedState2)) + ConfigError(aError); + } + +void COomConfigParser::ChangeState(TOomParsingState aState) + { + iState = aState; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomforegroundrule.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomforegroundrule.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#include "oomforegroundrule.h" +#include "oomwindowgrouplist.h" +#include "oomtraces.h" + +// If the specified target app is in the foreground then apply the specified priority +COomForegroundRule::COomForegroundRule(TInt aTargetAppId, TInt aPriority) : iTargetAppId(aTargetAppId), iPriority(aPriority) + { + FUNC_LOG; + } + +TBool COomForegroundRule::RuleIsApplicable(const COomWindowGroupList& aWindowGroupList, TInt /*aAppIndexInWindowGroup*/) const + { + FUNC_LOG; + + TBool ruleIsApplicable = EFalse; + if (aWindowGroupList.Count() > 0) + { + // If the target app is in the foreground then this rule is applicable + TUint foregroundAppId = aWindowGroupList.AppId(0, ETrue); + if (foregroundAppId == iTargetAppId) + ruleIsApplicable = ETrue; + } + + return ruleIsApplicable; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomglobalconfig.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomglobalconfig.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + + +#include "oomglobalconfig.h" +#include "oomtraces.h" + +COomGlobalConfig::~COomGlobalConfig() + { + FUNC_LOG; + + iForceCheckPriorities.Close(); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomlog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomlog.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,306 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Logging functionality for OOM monitor profiling. +* +*/ + + + +#ifdef _DEBUG + +#include +#include +#include +#include +#include + +#include "oomlog.h" +#include "oompanic.h" + +_LIT8(KMemorySampleLoggingString, "%d"); +_LIT8(KMemorySampleLoggingSeparator, ", "); + +_LIT8(KCrLf, "\r\n"); + +_LIT8(KOomLogCancel, "Sampling triggered before previous sampling has completed. Results so far: "); + +_LIT(KOomLogFile, ":\\logs\\OOM\\liveoommonitor.txt"); +_LIT(KOomOldLogFile, ":\\logs\\OOM\\oommonitor.txt"); + +const TInt KMaxTimeStampSize = 30; +_LIT(KTimeStampFormat, "%F %H:%T:%S"); + +_LIT(KDummyWgName, "20"); + +_LIT8(KUidPreamble, "App UIDs:"); +_LIT8(KUidFormat, " 0x%x"); + +const TInt KPreallocatedSpaceForAppList = 50; + +const TInt KMaxUidBufferSize = 1024; + +COomLogger* COomLogger::NewL(RWsSession& aWs, RFs& aFs) + { + COomLogger* self = new (ELeave) COomLogger(aWs, aFs); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// Start logging the available memory every n micro seconds +// Firstly a list of the app IDs is written to the log (foreground app first) +// Note that the log is created in memory (to a pre-allocated buffer) and flushed out after it is complete +// the samples are saved in CSV format so that they can easily be cut and pasted to plot graphs etc. +void COomLogger::StartL() + { + // If the log file doesn't exist then don't attempt to sample anything + if (!iIsOpen) + return; + + // If we are already active then cancel first + if (IsActive()) + Cancel(); + + iWriteBuffer.Zero(); + + iStartTime.HomeTime(); + + // Log the timestamp + TBuf16 timeStamp; + iStartTime.FormatL(timeStamp, KTimeStampFormat); + TBuf8 timeStamp8; + timeStamp8.Copy(timeStamp); + Write(timeStamp8); + + // Log all of the application IDs (foreground app first, then the other apps moving towards the back) + LogApplicationIds(); + + // Then, record the free memory + // Note that this is done to a buffer so as not to affect the timing too much + LogFreeMemory(); + + // Finally, set a timer to record the memory every n microseconds + HighRes(KTimeBetweenMemorySamples); + } + +// From CTimer / CActice +void COomLogger::RunL() + { + TTime currentTime; + currentTime.HomeTime(); + TTimeIntervalMicroSeconds loggingDuration = currentTime.MicroSecondsFrom(iStartTime); + TTimeIntervalMicroSeconds samplingDuration = KSamplingDurationUint; + if (loggingDuration > samplingDuration) + // If we have passed the desired logging duration then write the data we have collected + { + Write(iWriteBuffer); + } + else + { + // If we haven't passed the desired logging duration then record the free memory + // Note that this is recorded into a buffer and then logged later + iWriteBuffer.Append(KMemorySampleLoggingSeparator); + LogFreeMemory(); + + // Wait before taking another memory sample + HighRes(KTimeBetweenMemorySamples); + } + } + +void COomLogger::DoCancel() + { + CTimer::DoCancel(); + + Write(KOomLogCancel); + Write(iWriteBuffer); + } + +COomLogger::~COomLogger() + { + iWgIds.Close(); + // delete iWgName; // Not owned + if (iIsOpen) + iFile.Close(); + + } + +void COomLogger::Write(const TDesC8& aBuffer) + { + if (iIsOpen) + { + iFile.Write(aBuffer); + + // Add the line break + iFile.Write(KCrLf); + } + } + +void COomLogger::LogApplicationIds() + { + // get all window groups, with info about parents + TInt numGroups = iWs.NumWindowGroups(0); + TRAPD(err, iWgIds.ReserveL(numGroups)); + + if (err != KErrNone) + return; + + if (iWs.WindowGroupList(0, &iWgIds) != KErrNone) + return; + + // Remove all child window groups, promote parents to foremost child position + ColapseWindowGroupTree(); + + // Go through each window group ID in the list, get the Uid of each app then log it + // Start with the foreground application + TInt index = 0; + + TUid uid; + + TBuf8 uidBuffer; + + uidBuffer = KUidPreamble; + + while (index < numGroups) + { + __ASSERT_DEBUG(index < iWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds)); + uid = GetUidFromWindowGroupId(iWgIds[index].iId); + + uidBuffer.AppendFormat(KUidFormat, uid.iUid); + + index++; + } + + Write(uidBuffer); + } + +void COomLogger::LogFreeMemory() + { + TMemoryInfoV1Buf meminfo; + UserHal::MemoryInfo(meminfo); + TInt freeMem = meminfo().iFreeRamInBytes; + + // Save the free memory to a descriptor which will be written later + iWriteBuffer.AppendFormat(KMemorySampleLoggingString(), freeMem); + } + +COomLogger::COomLogger(RWsSession& aWs, RFs& aFs) : CTimer(EPriorityStandard), iWs(aWs), iFs(aFs) + { + } + +void COomLogger::ConstructL() + { + CActiveScheduler::Add(this); + + CTimer::ConstructL(); + + TFileName oldLogFileName; + TFileName newLogFileName; + TChar driveChar = iFs.GetSystemDriveChar(); + oldLogFileName.Append(driveChar); + oldLogFileName.Append(KOomOldLogFile); + newLogFileName.Append(driveChar); + newLogFileName.Append(KOomLogFile); + // If there is an existing log then copy it, this will be the log that can be sent to the PC + // Without this feature then you can't get the logs off of the device because the "live" log will always be is use. + CFileMan* fileMan = CFileMan::NewL(iFs); + CleanupStack::PushL(fileMan); + fileMan->Copy(newLogFileName, oldLogFileName); + CleanupStack::PopAndDestroy(fileMan); + + // Create the log file, or open it if is already exists (note that the directory must already be present + TInt err = iFile.Create(iFs, KOomLogFile, EFileShareAny | EFileWrite); + if (KErrNone != err) + { + err = iFile.Open(iFs, KOomLogFile, EFileShareAny | EFileWrite); + } + + if (KErrNone == err) + { + iIsOpen = ETrue; + + // Append all new data to the end of the file + TInt offset = 0; + iFile.Seek(ESeekEnd, offset); + } + + // Reserve enough space to build an app list later. + iWgIds.ReserveL(KPreallocatedSpaceForAppList); + // Reserve enough space for CApaWindowGroupName. + iWgName = CApaWindowGroupName::NewL(iWs); + iWgNameBuf = HBufC::NewL(CApaWindowGroupName::EMaxLength); + (*iWgNameBuf) = KDummyWgName; + iWgName->SetWindowGroupName(iWgNameBuf); // iWgName takes ownership of iWgNameBuf*/ + + } + +void COomLogger::ColapseWindowGroupTree() + { + // start from the front, wg count can reduce as loop runs + for (TInt ii=0; ii 0) // wg has a parent + { + // Look for the parent position + TInt parentPos = ii; // use child pos as not-found signal + TInt count = iWgIds.Count(); + for (TInt jj=0; jj ii) // parent should be moved forward + { + iWgIds[ii] = iWgIds[parentPos]; + iWgIds.Remove(parentPos); + } + else if (parentPos < ii) // parent is already ahead of child, remove child + iWgIds.Remove(ii); + else // parent not found, skip + ii++; + } + else // wg does not have a parent, skip + ii++; + } + } + +TUid COomLogger::GetUidFromWindowGroupId(TInt aWgId) + { + // get the app's details + TPtr wgPtr(iWgNameBuf->Des()); + + TUid uid; + + TInt err = iWs.GetWindowGroupNameFromIdentifier(aWgId, wgPtr); + + if (KErrNone != err) + // If there is an error then set the UID to 0; + { + uid.iUid = 0; + } + else + { + iWgName->SetWindowGroupName(iWgNameBuf); + uid = iWgName->AppUid(); // This UID comes from the app, not the mmp! + } + + return uid; + } + +#endif //_DEBUG diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oommemorymonitor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oommemorymonitor.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,469 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main classes for Out of Memory Monitor. +* +*/ + + +#include + +#include + +#include "oommemorymonitor.h" +#include "oommonitorplugin.h" +#include "oomsubscribehelper.h" +#include "oomconfig.h" +#include "oommemorymonitorserver.h" +#include "oomconfigparser.h" +#include "oomactionlist.h" +#include "oomlog.h" +#include "OomTraces.h" +#include "oomoutofmemorywatcher.h" +#include "oomwserveventreceiver.h" +#include "oomconstants.hrh" +#include "oomrunpluginconfig.h" +#include "oomapplicationconfig.h" +#include "oomclientrequestqueue.h" + +#ifndef CLIENT_REQUEST_QUEUE +const TInt KOomWatchDogStatusIdle = -1; +#endif + +// ====================================================================== +// class CMemoryMonitor +// ====================================================================== + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +CMemoryMonitor* CMemoryMonitor::NewL() + { // static + FUNC_LOG; + + CMemoryMonitor* self = new(ELeave) CMemoryMonitor(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CMemoryMonitor::CMemoryMonitor() + { + FUNC_LOG; + + SetMemoryMonitorTls(this); + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +CMemoryMonitor::~CMemoryMonitor() + { + FUNC_LOG; + +#ifndef CLIENT_REQUEST_QUEUE + if (iWatchdogStatusSubscriber) + { + iWatchdogStatusSubscriber->StopSubscribe(); + } + iWatchdogStatusProperty.Close(); + delete iWatchdogStatusSubscriber; +#endif + + delete iServer; + delete iWservEventReceiver; + delete iOOMWatcher; + iFs.Close(); + iWs.Close(); + + delete iOomWindowGroupList; + delete iOomActionList; + delete iConfig; +#ifdef CLIENT_REQUEST_QUEUE + delete iQueue; +#endif + +#ifdef _DEBUG + delete iLogger; +#endif + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void CMemoryMonitor::ConstructL() + { + FUNC_LOG; + + User::LeaveIfError(iWs.Connect()); + + iOomWindowGroupList = COomWindowGroupList::NewL(iWs); + + iConfig = COomConfig::NewL(); + +#ifdef CLIENT_REQUEST_QUEUE + iQueue = COomClientRequestQueue::NewL(*this); + + iServer = CMemoryMonitorServer::NewL(*iQueue); +#else + iServer = CMemoryMonitorServer::NewL(*this); +#endif + + // Load up threshold & OOM app lists from resource. + User::LeaveIfError(iFs.Connect()); + + COomConfigParser* oomConfigParser = new (ELeave) COomConfigParser(*iConfig, iFs); + CleanupStack::PushL(oomConfigParser); + oomConfigParser->ParseL(); + CleanupStack::PopAndDestroy(oomConfigParser); + + iOomActionList = COomActionList::NewL(*this, *iServer, iWs, *iConfig); + +#ifdef _DEBUG + iLogger = COomLogger::NewL(iWs, iFs); +#endif + + // Get the thresholds based on the current foreground app and the config + RefreshThresholds(); + + _LIT_SECURITY_POLICY_S0(KOomMemoryMonitorPolicyWrite, KOomMemoryMonitorStatusPropertyCategory.iUid); + _LIT_SECURITY_POLICY_PASS(KOomMemoryMonitorPolicyRead); + + // Define MemoryMonitorStatusProperty. set to "above treshhold". + TInt err = RProperty::Define(KOomMemoryMonitorStatusPropertyCategory, KOomMemoryMonitorStatusPropertyKey, RProperty::EInt, KOomMemoryMonitorPolicyRead, KOomMemoryMonitorPolicyWrite); + TRACES1("CMemoryMonitor::ConstructL: KOomMemoryMonitorStatusProperty: Define err = %d", err); + + err = RProperty::Set(KOomMemoryMonitorStatusPropertyCategory, KOomMemoryMonitorStatusPropertyKey, EAboveTreshHold); + TRACES1("CMemoryMonitor::ConstructL: KOomMemoryMonitorStatusProperty: Set err = %d", err); + +#ifndef CLIENT_REQUEST_QUEUE + err = iWatchdogStatusProperty.Attach(KPSUidUikon, KUikOOMWatchdogStatus); + + TRACES1("CMemoryMonitor::ConstructL: KUikOOMWatchdogStatus err = %d", err); + + err = iWatchdogStatusProperty.Set(KOomWatchDogStatusIdle); + + iWatchdogStatusSubscriber = new (ELeave) CSubscribeHelper(TCallBack(WatchdogStatusStatusChanged, this), iWatchdogStatusProperty); + iWatchdogStatusSubscriber->Subscribe(); +#endif + + + iOOMWatcher = COutOfMemoryWatcher::NewL(*this, iLowThreshold, iGoodThreshold); + iOOMWatcher->Start(); + + iWservEventReceiver = new(ELeave) CWservEventReceiver(*this, iWs); + iWservEventReceiver->ConstructL(); + } + +const COomGlobalConfig& CMemoryMonitor::GlobalConfig() + { + CMemoryMonitor* globalMemoryMonitor = static_cast(Dll::Tls()); + return globalMemoryMonitor->iConfig->GlobalConfig(); + } + + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void CMemoryMonitor::FreeMemThresholdCrossedL() + { + FUNC_LOG; + + iActionTrigger = ERamRotation; + StartFreeSomeRamL(iGoodThreshold); + } + +void CMemoryMonitor::HandleFocusedWgChangeL() + { + FUNC_LOG; + + TInt oldGoodThreshold = iGoodThreshold; + TInt oldLowThreshold = iLowThreshold; + + // Refresh the low and good memory thresholds as they may have changed due to the new foreground application + RefreshThresholds(); + + if ((oldGoodThreshold != iGoodThreshold) + || (oldLowThreshold != iLowThreshold)) + // If the thresholds have changed then update the memory watched + { + iOOMWatcher->UpdateThresholds(iLowThreshold, iGoodThreshold); + } + + // If the available memory is less than the low memory threshold then free some RAM + User::CompressAllHeaps(); + TInt current = 0; + HAL::Get( HALData::EMemoryRAMFree, current ); + + if (current < iLowThreshold) + { + iActionTrigger = ERamRotation; + StartFreeSomeRamL(iGoodThreshold); + } + } + +void CMemoryMonitor::StartFreeSomeRamL(TInt aTargetFree) + { + StartFreeSomeRamL(aTargetFree, KOomPriorityInfinate - 1); + } + +void CMemoryMonitor::StartFreeSomeRamL(TInt aTargetFree, TInt aMaxPriority) // The maximum priority of action to run + { + FUNC_LOG; + + TRACES2("MemoryMonitor::StartFreeSomeRamL: aTargetFree = %d, iCurrentTarget = %d", aTargetFree, iCurrentTarget); + + // Update the target if new target is higher. If the target is lower than the current target and memory + // is currently being freed then we do not want to reduce the amount of memory this operation frees. + if (aTargetFree > iCurrentTarget) + iCurrentTarget = aTargetFree; + + // check if there is enough free memory already. + TInt freeMemory; + GetFreeMemory(freeMemory); + + TRACES1("MemoryMonitor::StartFreeSomeRamL, freeMemory = %d", freeMemory); + + if (freeMemory >= iCurrentTarget) + { + if (iLastMemoryMonitorStatusProperty != EFreeingMemory) + { + ResetTargets(); + iOomActionList->SwitchOffPlugins(); + SetMemoryMonitorStatusProperty(EAboveTreshHold); +#ifdef CLIENT_REQUEST_QUEUE + iQueue->ActionsCompleted(freeMemory, ETrue); +#else + iServer->CloseAppsFinished(freeMemory, ETrue); +#endif + } + return; + } + +#ifdef _DEBUG + iLogger->StartL(); +#endif + + // Build the list of memory freeing actions + iOomActionList->BuildActionListL(*iOomWindowGroupList, *iConfig); + + iOomActionList->SetCurrentTarget(iCurrentTarget); + + // Run the memory freeing actions + iOomActionList->FreeMemory(aMaxPriority); + } + +void CMemoryMonitor::RequestFreeMemoryPandSL(TInt aBytesRequested) + { + FUNC_LOG; + + iActionTrigger = EPublishAndSubscribe; + StartFreeSomeRamL(aBytesRequested + iLowThreshold); + } + +void CMemoryMonitor::RequestFreeMemoryL(TInt aBytesRequested) + { + FUNC_LOG; + + iActionTrigger = EClientServerRequestFreeMemory; + StartFreeSomeRamL(aBytesRequested + iLowThreshold); + } + +void CMemoryMonitor::FreeOptionalRamL(TInt aBytesRequested, TInt aPluginId) // The ID of the plugin that will clear up the allocation, used to determine the priority of the allocation + { + FUNC_LOG; + + iActionTrigger = EClientServerRequestOptionalRam; + + // Calculate the priority of the allocation (the priority of the plugin that will clear it up - 1) + TInt priorityOfAllocation = iConfig->GetPluginConfig(aPluginId).CalculatePluginPriority(*iOomWindowGroupList) - 1; + + StartFreeSomeRamL(aBytesRequested + iGoodThreshold, priorityOfAllocation); + } + +void CMemoryMonitor::GetFreeMemory(TInt& aCurrentFreeMemory) + { + FUNC_LOG; + + // may cause some extra load but allows more precise action + User::CompressAllHeaps(); + + HAL::Get( HALData::EMemoryRAMFree, aCurrentFreeMemory ); + + TRACES1("CMemoryMonitor::GetFreeMemory: Free RAM now %d", aCurrentFreeMemory); + } + +#ifndef CLIENT_REQUEST_QUEUE +TInt CMemoryMonitor::WatchdogStatusStatusChanged(TAny* aPtr) + { + FUNC_LOG; + + CMemoryMonitor* self = STATIC_CAST(CMemoryMonitor*,aPtr); + if (self) + self->HandleWatchdogStatusCallBack(); + return KErrNone; + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void CMemoryMonitor::HandleWatchdogStatusCallBack() + { + FUNC_LOG; + + // Someone has set the key to request some free memory. + TInt memoryRequested = 0; + iWatchdogStatusProperty.Get(memoryRequested); + + // Try to free the RAM. + if (memoryRequested >= 1) + { + iOOMWatcher->Cancel(); // Pause memory notifys. + TRAP_IGNORE(RequestFreeMemoryPandSL(memoryRequested + iLowThreshold)); // This call could take a few seconds to do its stuff. + iOOMWatcher->Start(); // Restarts memory monitoring. + } + // Set the key back to KOomWatchDogStatusIdle to indicate we're done. + iWatchdogStatusProperty.Set(KOomWatchDogStatusIdle); + } +#endif //CLIENT_REQUEST_QUEUE + +void CMemoryMonitor::AppNotExiting(TInt aWgId) + { + FUNC_LOG; + + iOomActionList->AppNotExiting(aWgId); + } + + +void CMemoryMonitor::RefreshThresholds() + { + FUNC_LOG; + + iOomWindowGroupList->Refresh(); + + // Calculate the desired good threshold, this could be the globally configured value... + iGoodThreshold = CMemoryMonitor::GlobalConfig().iGoodRamThreshold; + iLowThreshold = CMemoryMonitor::GlobalConfig().iLowRamThreshold; + TRACES2("CMemoryMonitor::RefreshThresholds: Global Good Threshold = %d, Global Low Threshold = %d", iGoodThreshold, iLowThreshold); + +#ifdef _DEBUG + TRACES("CMemoryMonitor::RefreshThresholds: Dumping Window Group List"); + TInt wgIndex = iOomWindowGroupList->Count() - 1; + while (wgIndex >= 0) + { + TInt32 appId = iOomWindowGroupList->AppId(wgIndex, ETrue); + TInt wgId = iOomWindowGroupList->WgId(wgIndex).iId; + TInt parentId = iOomWindowGroupList->WgId(wgIndex).iId; + TRACES4("CMemoryMonitor::RefreshThresholds: wgIndex=%d, oom uid=%x, wgId(child)=%d, parentId=%d", wgIndex, appId, wgId, parentId); + wgIndex--; + } +#endif + + // The global value can be overridden by an app specific value + // Find the application config entry for the foreground application + if (iOomWindowGroupList->Count()) + { + TUint foregroundAppId = iOomWindowGroupList->AppId(0, ETrue); + TUid foregroundAppUid = TUid::Uid(foregroundAppId); + + if ( (foregroundAppUid == KUidPenInputServer || foregroundAppUid == KUidFastSwap) && + iOomWindowGroupList->Count() > 1 ) + { + // pen input server puts itself to the foreground when the web browser is active + // fast swap should not reset the thresholds for the app behind it + foregroundAppId = iOomWindowGroupList->AppId(1, ETrue); + } + + // If this application configuration overrides the good_ram_threshold then set it + if (iConfig->GetApplicationConfig(foregroundAppId).iGoodRamThreshold != KOomThresholdUnset) + { + iGoodThreshold = iConfig->GetApplicationConfig(foregroundAppId).iGoodRamThreshold; + TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Good Threshold = %d", foregroundAppId, iGoodThreshold); + } + // If this application configuration overrides the low_ram_threshold then set it + if (iConfig->GetApplicationConfig(foregroundAppId).iLowRamThreshold != KOomThresholdUnset) + { + iLowThreshold = iConfig->GetApplicationConfig(foregroundAppId).iLowRamThreshold; + TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Low Threshold = %d", foregroundAppId, iLowThreshold); + } + + } + } + +// SetMemoryMonitorStatusProperty - updates the property value only if it has changed +void CMemoryMonitor::SetMemoryMonitorStatusProperty(const TMemoryMonitorStatusPropertyValues aValue) + { + if (iLastMemoryMonitorStatusProperty != aValue) + { + TInt err = RProperty::Set(KOomMemoryMonitorStatusPropertyCategory, KOomMemoryMonitorStatusPropertyKey, aValue); + TRACES1("CMemoryMonitor::SetMemoryMonitorStatusProperty: err = %d", err); + iLastMemoryMonitorStatusProperty = aValue; + } + } + +void CMemoryMonitor::ResetTargets() + { + FUNC_LOG; + + //we reset the target when a memory free operation completes, to deal with the case + //where the operation was initiated with a target larger than the current good threshold + iCurrentTarget = iGoodThreshold; + iOomActionList->SetCurrentTarget(iCurrentTarget); + } + +void CMemoryMonitor::SetPriorityBusy(TInt aWgId) + { + FUNC_LOG; + + iOomWindowGroupList->SetPriorityBusy(aWgId); + } + +void CMemoryMonitor::SetPriorityNormal(TInt aWgId) + { + FUNC_LOG; + + iOomWindowGroupList->SetPriorityNormal(aWgId); + } + +void CMemoryMonitor::SetPriorityHigh(TInt aWgId) + { + iOomWindowGroupList->SetPriorityHigh(aWgId); + } + +TActionTriggerType CMemoryMonitor::ActionTrigger() const + { + return iActionTrigger; + } + +#ifdef CLIENT_REQUEST_QUEUE +TInt CMemoryMonitor::GoodThreshold() const + { + return iGoodThreshold; + } + +TInt CMemoryMonitor::LowThreshold() const + { + return iLowThreshold; + } + +void CMemoryMonitor::ActionsCompleted(TInt aBytesFree, TBool aMemoryGood) + { + iQueue->ActionsCompleted(aBytesFree, aMemoryGood); + } +#endif //CLIENT_REQUEST_QUEUE diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oommemorymonitorserver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oommemorymonitorserver.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main classes for Out of Memory Monitor. +* +*/ + + + +#include "oommemorymonitorserver.h" +#include "oommonitorclientserver.h" +#include "oommemorymonitorsession.h" +#include "oommemorymonitor.h" +#include "oomtraces.h" + +#ifdef CLIENT_REQUEST_QUEUE +CMemoryMonitorServer* CMemoryMonitorServer::NewL(COomClientRequestQueue& aQueue) +#else +CMemoryMonitorServer* CMemoryMonitorServer::NewL(CMemoryMonitor& aMonitor) +#endif + { + FUNC_LOG; + +#ifdef CLIENT_REQUEST_QUEUE + CMemoryMonitorServer* self=new(ELeave) CMemoryMonitorServer(aQueue); +#else + CMemoryMonitorServer* self=new(ELeave) CMemoryMonitorServer(aMonitor); +#endif + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CMemoryMonitorServer::~CMemoryMonitorServer() + { + FUNC_LOG; + } + +#ifdef CLIENT_REQUEST_QUEUE +CMemoryMonitorServer::CMemoryMonitorServer(COomClientRequestQueue& aQueue) + :CServer2(CActive::EPriorityStandard), iQueue(aQueue) +#else +CMemoryMonitorServer::CMemoryMonitorServer(CMemoryMonitor& aMonitor) + :CServer2(CActive::EPriorityStandard), iMonitor(aMonitor) +#endif + { + FUNC_LOG; + } + +void CMemoryMonitorServer::ConstructL() + { + FUNC_LOG; + + StartL(KMemoryMonitorServerName); + } + +CSession2* CMemoryMonitorServer::NewSessionL(const TVersion& /*aVersion*/, const RMessage2& /*aMessage*/) const + { + FUNC_LOG; + + return new(ELeave) CMemoryMonitorSession(); + } + +TInt CMemoryMonitorServer::RunError(TInt aError) + { + FUNC_LOG; + + Message().Complete(aError); + // + // The leave will result in an early return from CServer::RunL(), skipping + // the call to request another message. So do that now in order to keep the + // server running. + ReStart(); + return KErrNone; // handled the error fully + } + +#ifdef CLIENT_REQUEST_QUEUE +COomClientRequestQueue& CMemoryMonitorServer::ClientRequestQueue() + { + FUNC_LOG; + + return iQueue; + } +#else +CMemoryMonitor& CMemoryMonitorServer::Monitor() + { + FUNC_LOG; + + return iMonitor; + } +#endif + +#ifndef CLIENT_REQUEST_QUEUE +void CMemoryMonitorServer::CloseAppsFinished(TInt aBytesFree, TBool aMemoryGood) + { + FUNC_LOG; + + iSessionIter.SetToFirst(); + CSession2* s; + while ((s = iSessionIter++) != 0) + static_cast(s)->CloseAppsFinished(aBytesFree, aMemoryGood); + } +#endif diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oommemorymonitorsession.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oommemorymonitorsession.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,156 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main classes for Out of Memory Monitor. +* +*/ + + +#include "oommonitorclientserver.h" +#include "oommemorymonitorsession.h" +#include "oommemorymonitor.h" +#include "oommemorymonitorserver.h" +#include "oomtraces.h" +#include "oomclientrequestqueue.h" + +CMemoryMonitorSession::CMemoryMonitorSession() + { + FUNC_LOG; + } + + +CMemoryMonitorSession::~CMemoryMonitorSession() + { + FUNC_LOG; + } + +CMemoryMonitorServer& CMemoryMonitorSession::Server() + { + FUNC_LOG; + + return *static_cast(const_cast(CSession2::Server())); + } + +#ifdef CLIENT_REQUEST_QUEUE +COomClientRequestQueue& CMemoryMonitorSession::ClientRequestQueue() + { + FUNC_LOG; + + return Server().ClientRequestQueue(); + } +#endif + +CMemoryMonitor& CMemoryMonitorSession::Monitor() + { + FUNC_LOG; + +#ifdef CLIENT_REQUEST_QUEUE + return ClientRequestQueue().Monitor(); +#else + return Server().Monitor(); +#endif + } + +void CMemoryMonitorSession::ServiceL(const RMessage2& aMessage) + { + FUNC_LOG; + +#ifndef CLIENT_REQUEST_QUEUE + iFunction = aMessage.Function(); +#endif + + switch (aMessage.Function()) + { + case EOomMonitorRequestFreeMemory: + if (!iRequestFreeRam.IsNull()) + PanicClient(aMessage, EPanicRequestActive); + // message will be completed when CloseAppsFinished() is called. +#ifdef CLIENT_REQUEST_QUEUE + ClientRequestQueue().RequestFreeMemoryL(aMessage); +#else + iRequestFreeRam = aMessage; + Monitor().RequestFreeMemoryL(aMessage.Int0()); +#endif + break; + + case EOomMonitorCancelRequestFreeMemory: + if (!iRequestFreeRam.IsNull()) + iRequestFreeRam.Complete(KErrCancel); + aMessage.Complete(KErrNone); + break; + + case EOomMonitorThisAppIsNotExiting: + Monitor().AppNotExiting(aMessage.Int0()); + aMessage.Complete(KErrNone); + break; + + case EOomMonitorRequestOptionalRam: + if (!iRequestFreeRam.IsNull()) + PanicClient(aMessage, EPanicRequestActive); + // message will be completed when CloseAppsFinished() is called. +#ifdef CLIENT_REQUEST_QUEUE + ClientRequestQueue().RequestOptionalRamL(aMessage); +#else + iRequestFreeRam = aMessage; + iMinimumMemoryRequested = aMessage.Int1(); + Monitor().FreeOptionalRamL(aMessage.Int0(), aMessage.Int2()); +#endif + break; + + case EOomMonitorSetPriorityBusy: + Monitor().SetPriorityBusy(aMessage.Int0()); + aMessage.Complete(KErrNone); + break; + + case EOomMonitorSetPriorityNormal: + Monitor().SetPriorityNormal(aMessage.Int0()); + aMessage.Complete(KErrNone); + break; + + case EOomMonitorSetPriorityHigh: + Monitor().SetPriorityHigh(aMessage.Int0()); + aMessage.Complete(KErrNone); + break; + + default: + PanicClient(aMessage, EPanicIllegalFunction); + break; + } + } + +#ifndef CLIENT_REQUEST_QUEUE +void CMemoryMonitorSession::CloseAppsFinished(TInt aBytesFree, TBool aMemoryGood) + { + FUNC_LOG; + + if (!iRequestFreeRam.IsNull()) + { + if (iFunction == EOomMonitorRequestOptionalRam) + { + TInt memoryAvailable = aBytesFree - CMemoryMonitor::GlobalConfig().iGoodRamThreshold; + + // If memory available is greater than the requested RAM then complete with the amount of free memory, otherwise complete with KErrNoMemory + if (memoryAvailable >= iMinimumMemoryRequested) + { + iRequestFreeRam.Complete(memoryAvailable); + } + else + { + iRequestFreeRam.Complete(KErrNoMemory); + } + } + else + iRequestFreeRam.Complete(aMemoryGood ? KErrNone : KErrNoMemory); + } + } +#endif diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oommonitor.cpp --- a/sysresmonitoring/oommonitor/src/oommonitor.cpp Tue Feb 02 10:12:00 2010 +0200 +++ b/sysresmonitoring/oommonitor/src/oommonitor.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -16,41 +16,20 @@ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include #include "oommonitor.h" -#include "oommonitorplugin.h" -#include "oommonitorplugin.hrh" +#include "oommemorymonitor.h" #include "oommonitorclientserver.h" - -#define OOM_WATCHDOG_STATUS_IDLE -1 +#include "oomtraces.h" -const TInt KPreallocatedSpaceForAppList = 50; -const TInt KPluginFreeMemoryTime = 100000; // 100 milliseconds for plugins to free memory, overridden by LafMemoryWatcher.rss +const TInt KStackSize = 0x2000; -_LIT(KDriveZ, "z:"); -_LIT(KOOMWatcherResourceFileName, "lafmemorywatcher.rsc"); _LIT(KOOMWatcherThreadName, "OOM FW"); -_LIT(KDummyWgName, "20"); // Implements just Error() to avoid panic -class CSimpleScheduler : public CActiveScheduler +NONSHARABLE_CLASS(CSimpleScheduler) : public CActiveScheduler { void Error( TInt ) const{} // From CActiveScheduler }; @@ -58,6 +37,8 @@ // thread function for OOM watcher GLDEF_C TInt WatcherThreadFunction( TAny* ) { + FUNC_LOG; + TInt err( KErrNone ); CTrapCleanup* cleanup = CTrapCleanup::New(); @@ -95,12 +76,14 @@ // Creates thread for OOM watchers EXPORT_C void CreateOOMWatcherThreadL() { + FUNC_LOG; + RThread thread; TInt ret = thread.Create( KOOMWatcherThreadName, WatcherThreadFunction, - 0x2000, // stack size + KStackSize, // stack size NULL, // uses caller thread's heap - (TAny*)NULL ); + NULL ); if ( ret == KErrNone ) { @@ -111,941 +94,10 @@ User::LeaveIfError( ret ); } - -// ====================================================================== -// class CMemoryMonitor -// ====================================================================== - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -CMemoryMonitor* CMemoryMonitor::NewL() - { // static - CMemoryMonitor* self = new(ELeave) CMemoryMonitor(); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -CMemoryMonitor::CMemoryMonitor() -: iRamPluginRunTime(KPluginFreeMemoryTime), iCurrentTask(iWs), - iMemoryAboveThreshold(ETrue), iPluginMemoryGood(ETrue) - { - SetMemoryMonitorTls(this); - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -CMemoryMonitor::~CMemoryMonitor() - { - if (iWatchdogStatusSubscriber) - { - iWatchdogStatusSubscriber->StopSubscribe(); - } - iWatchdogStatusProperty.Close(); - delete iWatchdogStatusSubscriber; - - delete iServer; - delete iWservEventReceiver; - delete iAppCloseTimer; - delete iAppCloseWatcher; - delete iOOMWatcher; - delete iPlugins; - iAppCloseOrderMap.Close(); - iWgIds.Close(); - delete iWgName; - iFs.Close(); - iWs.Close(); - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -void CMemoryMonitor::ConstructL() - { - User::LeaveIfError(iWs.Connect()); - - // Reserve enough space to build an app list later. - iWgIds.ReserveL(KPreallocatedSpaceForAppList); - // Reserve enough space for CApaWindowGroupName. - iWgName = CApaWindowGroupName::NewL(iWs); - iWgNameBuf = HBufC::NewL(CApaWindowGroupName::EMaxLength); - (*iWgNameBuf) = KDummyWgName; - iWgName->SetWindowGroupName(iWgNameBuf); // iWgName takes ownership of iWgNameBuf - - // Load up threshold & OOM app lists from resource. - User::LeaveIfError(iFs.Connect()); - - RResourceFile resFile; - TFileName filename(KDriveZ); - filename.Append(KDC_RESOURCE_FILES_DIR); - filename.Append(KOOMWatcherResourceFileName); - BaflUtils::NearestLanguageFile(iFs, filename); - resFile.OpenL(iFs, filename); - CleanupClosePushL(resFile); - - HBufC8* thresholds = resFile.AllocReadLC(R_APP_OOM_THRESHOLDS); - RResourceReader theReader; - theReader.OpenLC(*thresholds); - - iLowThreshold = theReader.ReadInt32L(); - iGoodThreshold = theReader.ReadInt32L(); - iMaxExitTime = theReader.ReadInt32L(); - TRAP_IGNORE(iRamPluginRunTime = theReader.ReadInt32L()); // trapped in case lafmemorywatcher.rss does not define this value - - CleanupStack::PopAndDestroy(&theReader); - CleanupStack::PopAndDestroy(thresholds); - - // apps to close first, first app in list gets closed first - ReadAppResourceArrayL(resFile, R_APP_OOM_EXIT_CANDIDATES, ECloseFirst, +1); // +1 means apps later in the list are closed later - // apps to never close, all apps get order ENeverClose - ReadAppResourceArrayL(resFile, R_APP_OOM_EXIT_NEVER, ENeverClose, 0); // 0 means that all apps get ENeverClose - // apps to close last, first app in list gets closed last - ReadAppResourceArrayL(resFile, R_APP_OOM_EXIT_LAST, ECloseLast, -1); // -1 means apps later in the list are closed earlier - - CleanupStack::PopAndDestroy(); // resFile.Close(); - - iPlugins = new(ELeave) COomPlugins; - iPlugins->ConstructL(); - - TInt err = iWatchdogStatusProperty.Attach(KPSUidUikon, KUikOOMWatchdogStatus); -#ifdef _DEBUG - RDebug::Print(_L("xxxx KUikOOMWatchdogStatus err=%d"), err); -#endif - err = iWatchdogStatusProperty.Set(OOM_WATCHDOG_STATUS_IDLE); - - iWatchdogStatusSubscriber = new (ELeave) CSubscribeHelper(TCallBack(WatchdogStatusStatusChanged, this), iWatchdogStatusProperty); - iWatchdogStatusSubscriber->SubscribeL(); - - iOOMWatcher = COutOfMemoryWatcher::NewL(*this, iLowThreshold, iGoodThreshold); - iOOMWatcher->Start(); - - iAppCloseTimer = CAppCloseTimer::NewL(*this); - iAppCloseWatcher = new(ELeave) CAppCloseWatcher(*this); - - iWservEventReceiver = new(ELeave) CWservEventReceiver(*this, iWs); - iWservEventReceiver->ConstructL(); - - iServer = CMemoryMonitorServer::NewL(*this); - } - -void CMemoryMonitor::ReadAppResourceArrayL(RResourceFile& aResFile, TInt aResId, TInt aOrderBase, TInt aOrderInc) - { - // apps in this list will be ordered starting from aOrderBase - TInt order = aOrderBase; - // get the resource and set up the resource reader - HBufC8* apps = aResFile.AllocReadLC(aResId); - TResourceReader theReader; - theReader.SetBuffer(apps); - // go through all apps in the list - TInt appsCount = theReader.ReadUint16(); - for (TInt ii = 0; ii < appsCount; ii++) - { - TInt appUid = theReader.ReadInt32(); - // insert the app UID with the appropriate order - iAppCloseOrderMap.Insert(appUid, order); - // change the order number as appropriate for this list - order += aOrderInc; - } - CleanupStack::PopAndDestroy(apps); - } - -void CMemoryMonitor::CancelAppCloseWatchers() - { - iAppCloserRunning = EFalse; - iCurrentTask.SetWgId(0); - if (iAppCloseTimer) - iAppCloseTimer->Cancel(); - if (iAppCloseWatcher) - iAppCloseWatcher->Cancel(); - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -void CMemoryMonitor::FreeMemThresholdCrossedL() - { - StartFreeSomeRamL(iGoodThreshold); - } - -void CMemoryMonitor::HandleFocusedWgChangeL() - { - // The focused window group has changed. - if (iAppCloserRunning) - { - // if the app closer is currently running, restart it - RestartAppCloser(); - } - else if (!iMemoryAboveThreshold) - { - // If memory is low, rescan for free memory - StartFreeSomeRamL(iGoodThreshold); - } - } - -void CMemoryMonitor::RestartAppCloser() - { - CancelAppCloseWatchers(); - // StartFreeSomeRamL is trapped so that clients waiting - // for completion will definitely receive it. - TRAPD(err, StartFreeSomeRamL(iCurrentTarget)) - if (err != KErrNone) - CloseAppsFinished(FreeMemoryAboveThreshold()); - } - -// --------------------------------------------------------- -// This function attempts to free enough RAM to leave the target amount of space free. -// This function could take a substantial time to return as it may have to close a number -// of applications, and each will be given a timeout of KAPPEXITTIMEOUT. -// --------------------------------------------------------- -// -void CMemoryMonitor::StartFreeSomeRamL(TInt aTargetFree) - { - // update the target if new target is higher - if (aTargetFree > iCurrentTarget) - iCurrentTarget = aTargetFree; - - // do nothing more if app closer is already running - if (iAppCloserRunning) - return; - - iCurrentTarget = aTargetFree; - - // check if there is enough free memory already. - if (FreeMemoryAboveThreshold()) - { - CloseAppsFinished(ETrue); - return; - } - - // Tell plugins to free memory - bool pluginsToldToFreeMemory = iPluginMemoryGood; - SetPluginMemoryGood(EFalse); - - // get the list of apps to free - GetWgsToCloseL(); - - if (pluginsToldToFreeMemory) - { - // Give the plugins a short time to free memory. - // App close timer will kick off the app closer. - iAppCloseTimer->After(iRamPluginRunTime); - } - else - { - // start closing apps - CloseNextApp(); - } - } - -void CMemoryMonitor::CloseNextApp() - { - if(iNextAppToClose >= 0) - { - // close an app, if there's an app to be closed -#ifdef _DEBUG - RDebug::Print(_L("OOM WATCHER: Target not achieved; continuing... Target:%d"),iCurrentTarget); -#endif - // CloseNextApp() may have been called by one of the event - // watchers, cancel them all to prevent more events from the - // last app before restarting the watchers for the new app to close - CancelAppCloseWatchers(); - iAppCloserRunning = ETrue; - // Set the TApaTask to the app - iCurrentTask.SetWgId(iWgIds[iNextAppToClose].iId); - // Start a timer and the thread watcher - iAppCloseTimer->After(iMaxExitTime); - iAppCloseWatcher->Start(iCurrentTask); - // Tell the app to close - iCurrentTask.EndTask(); - iNextAppToClose--; - } - else - { - // stop if we have no more apps - CloseAppsFinished(EFalse); - } - } - -// handle an app closed event -void CMemoryMonitor::CloseAppEvent() - { - if (FreeMemoryAboveThreshold()) - { - // stop if we have enough memory - CloseAppsFinished(ETrue); - } - else - { - // otherwise try to close another app - CloseNextApp(); - } - } - -// The app closer is finished -void CMemoryMonitor::CloseAppsFinished(TBool aMemoryGood) - { - CancelAppCloseWatchers(); -#ifdef _DEBUG - RDebug::Print(_L("OOM WATCHER: Final result: Target:%d Good?:%d"),iCurrentTarget,aMemoryGood); -#endif - iServer->CloseAppsFinished(aMemoryGood); - // plugins can start using memory if result is good - SetPluginMemoryGood(aMemoryGood); - } - -TBool CMemoryMonitor::FreeMemoryAboveThreshold() - { - // may cause some extra load but allows more precise action - User::CompressAllHeaps(); - - TInt current = 0; - HAL::Get( HALData::EMemoryRAMFree, current ); - -#ifdef _DEBUG - RDebug::Print(_L("OOM WATCHER: Free RAM now:%d "),current); -#endif - - iMemoryAboveThreshold = (current >= iCurrentTarget); - return iMemoryAboveThreshold; - } - -void CMemoryMonitor::GetWgsToCloseL() - { - // get all window groups, with info about parents - TInt numGroups = iWs.NumWindowGroups(0); - iWgIds.ReserveL(numGroups); - User::LeaveIfError(iWs.WindowGroupList(0, &iWgIds)); - - // Remove all child window groups, promote parents to foremost child position - ColapseWindowGroupTree(); - - // now rearange the list so that it only contains apps to close - // first remove the foreground window group - iWgIds.Remove(0); - - // go through the list from start to end. - // this divides the list into two sections. Apps that never - // close move towards the end of the list, apps that will close - // go towards the start. - // apps to close first will be placed further back in the close list. - TInt numAppsToClose = 0; // numAppsToClose marks the boundary between closing and non-closing apps - TInt count = iWgIds.Count(); - for (TInt ii=0; ii= numAppsToClose); // we are always looking at apps after the sorted section - // get the next window group - RWsSession::TWindowGroupChainInfo info = iWgIds[ii]; - // get the close order for the window group - TInt closeOrder = AppCloseOrder(ii, info.iId); - if (closeOrder == ENeverClose) - { - // leave apps which should not be closed in place, - // after the last app to close. - continue; - } - else - { - // We no longer need the parent id. Use it to store the close order, to avoid the need to allocate more array space - info.iParentId = closeOrder; - // remove the app from it's current position - iWgIds.Remove(ii); - // find the right place to insert the app (lower orders are put further back) - TInt insertPos; - for (insertPos = 0; insertPos < numAppsToClose; insertPos++) - { - // compare this close order with window groups already in the list, - // whose close order is stored in iParentId - if (closeOrder > iWgIds[insertPos].iParentId) - break; - } - // Insert the app in the correct place - ASSERT(insertPos <= ii && insertPos <= numAppsToClose); // apps to close are always moved to front, before the close boundary - iWgIds.Insert(info, insertPos); - numAppsToClose++; - } - } - - // start closing apps from the end of the list of apps to close - iNextAppToClose = numAppsToClose - 1; - } - -// Calculate the order number in which this app should be closed -// This is based on the app's UID and its window group Z-order -// Apps given a lower order will be closed before those with a -// higher order. -TInt CMemoryMonitor::AppCloseOrder(TInt aWgIndex, TInt aWgId) - { - // get the app's details - TPtr wgPtr(iWgNameBuf->Des()); - if (iWs.GetWindowGroupNameFromIdentifier(aWgId, wgPtr) != KErrNone) - return ENeverClose; - iWgName->SetWindowGroupName(iWgNameBuf); - TUid uid = iWgName->AppUid(); // This UID comes from the app, not the mmp! - TInt* order = iAppCloseOrderMap.Find(uid.iUid); - - // The default app close order is normal with further - // back apps getting a lower order - TInt closeOrder = ECloseNormal - aWgIndex; - if (order) - { - // Apps with a defined close order get that order. - closeOrder = *order; - } - else if (uid.iUid == 0 || iWgName->IsSystem() || iWgName->Hidden() || iWgName->IsBusy()) - { - // Apps that should never close get the ENeverClose rank - closeOrder = ENeverClose; - } - - return closeOrder; - } - -void CMemoryMonitor::SetPluginMemoryGood(TBool aSetToGood) - { - if (aSetToGood && !iPluginMemoryGood) - iPlugins->MemoryGood(); - else if (!aSetToGood && iPluginMemoryGood) - iPlugins->FreeRam(); - iPluginMemoryGood = aSetToGood; - } - - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -TInt CMemoryMonitor::WatchdogStatusStatusChanged(TAny* aPtr) - { - CMemoryMonitor* self = STATIC_CAST(CMemoryMonitor*,aPtr); - if (self) - self->HandleWatchdogStatusCallBackL(); - return KErrNone; - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -void CMemoryMonitor::HandleWatchdogStatusCallBackL() - { - // Someone has set the key to request some free memory. - TInt target = 0; - iWatchdogStatusProperty.Get(target); - - // Try to free the RAM. - if (target >= 1) - { - iOOMWatcher->Cancel(); // Pause memory notifys. - TRAP_IGNORE(StartFreeSomeRamL(target)); // This call could take a few seconds to do its stuff. - iOOMWatcher->Start(); // Restarts memory monitoring. - } - // Set the key back to OOM_WATCHDOG_STATUS_IDLE to indicate we're done. - iWatchdogStatusProperty.Set(OOM_WATCHDOG_STATUS_IDLE); - } - -// --------------------------------------------------------- -// Remove child window groups. Promote parent window groups forward to child position -// --------------------------------------------------------- -// -void CMemoryMonitor::ColapseWindowGroupTree() - { - // start from the front, wg count can reduce as loop runs - for (TInt ii=0; ii 0) // wg has a parent - { - // Look for the parent position - TInt parentPos = ii; // use child pos as not-found signal - TInt count = iWgIds.Count(); - for (TInt jj=0; jj ii) // parent should be moved forward - { - iWgIds[ii] = iWgIds[parentPos]; - iWgIds.Remove(parentPos); - } - else if (parentPos < ii) // parent is already ahead of child, remove child - iWgIds.Remove(ii); - else // parent not found, skip - ii++; - } - else // wg does not have a parent, skip - ii++; - } - } - -void CMemoryMonitor::AppNotExiting(TInt aWgId) - { - if (aWgId == iCurrentTask.WgId()) - CloseAppEvent(); - } - - -// ====================================================================== -// class COutOfMemoryWatcher -// - notifies when free memory crosses preset thresholds -// ====================================================================== - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -COutOfMemoryWatcher* COutOfMemoryWatcher::NewL(CMemoryMonitor& aMonitor, TInt aLowThreshold, TInt aGoodThreshold) - { - COutOfMemoryWatcher* self = new (ELeave) COutOfMemoryWatcher(aMonitor); - CleanupStack::PushL(self); - self->ConstructL(aLowThreshold, aGoodThreshold); - CleanupStack::Pop(self); - return self; - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -COutOfMemoryWatcher::~COutOfMemoryWatcher() - { - Cancel(); - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -COutOfMemoryWatcher::COutOfMemoryWatcher(CMemoryMonitor& aMonitor) -: CActive(CActive::EPriorityStandard), - iLafShutdown(aMonitor) - { - CActiveScheduler::Add(this); - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -void COutOfMemoryWatcher::ConstructL(TInt aLowThreshold, TInt aGoodThreshold) - { - UserSvr::SetMemoryThresholds(aLowThreshold,aGoodThreshold); - User::LeaveIfError(iChangeNotifier.Create()); - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -void COutOfMemoryWatcher::Start() - { - if (!IsActive()) - { - iChangeNotifier.Logon(iStatus); - SetActive(); - } - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -void COutOfMemoryWatcher::DoCancel() - { - iChangeNotifier.LogonCancel(); - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -void COutOfMemoryWatcher::RunL() - { - TInt status = iStatus.Int(); - - if (status < 0) - { - User::Leave(status); - } - - // Check for memory status change. - if (status & EChangesFreeMemory) - { - iLafShutdown.FreeMemThresholdCrossedL(); - } - - // We are not active until FreeMemThresholdCrossedL returns. - Start(); - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -CSubscribeHelper::CSubscribeHelper(TCallBack aCallBack, RProperty& aProperty) - : CActive(EPriorityNormal), iCallBack(aCallBack), iProperty(aProperty) - { - CActiveScheduler::Add(this); - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -CSubscribeHelper::~CSubscribeHelper() - { - Cancel(); - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -void CSubscribeHelper::SubscribeL() - { - if (!IsActive()) - { - iProperty.Subscribe(iStatus); - SetActive(); - } - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -void CSubscribeHelper::StopSubscribe() - { - Cancel(); - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -void CSubscribeHelper::RunL() - { - if (iStatus.Int() == KErrNone) - { - iCallBack.CallBack(); - SubscribeL(); - } - } - -// --------------------------------------------------------- -// -// --------------------------------------------------------- -// -void CSubscribeHelper::DoCancel() - { - iProperty.Cancel(); - } - - -COomPlugins::COomPlugins() - { - } - -COomPlugins::~COomPlugins() - { - TInt count = iPlugins.Count(); - for (TInt ii=0; iiImplementationUid()); - plugin.iImpl = static_cast(REComSession::CreateImplementationL(uid, plugin.iDtorUid, NULL)); - } - - CleanupStack::PopAndDestroy(&implArray); - } - -void COomPlugins::FreeRam() - { - TInt count = iPlugins.Count(); - for (TInt ii=0; iiFreeRam(); - } - } - -void COomPlugins::MemoryGood() - { - TInt count = iPlugins.Count(); - for (TInt ii=0; iiMemoryGood(); - } - } - -COomPlugins::TPlugin::TPlugin() -: iImpl(0) - { - } - - -CAppCloseTimer* CAppCloseTimer::NewL(CMemoryMonitor& aMonitor) - { - CAppCloseTimer* self = new(ELeave)CAppCloseTimer(aMonitor); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -CAppCloseTimer::CAppCloseTimer(CMemoryMonitor& aMonitor) -: CTimer(CActive::EPriorityStandard), iMonitor(aMonitor) - { - CActiveScheduler::Add(this); - } - -void CAppCloseTimer::RunL() - { - iMonitor.CloseAppEvent(); - } - - - -CAppCloseWatcher::CAppCloseWatcher(CMemoryMonitor& aMonitor) -: CActive(CActive::EPriorityStandard), iMonitor(aMonitor) - { - CActiveScheduler::Add(this); - } - -CAppCloseWatcher::~CAppCloseWatcher() - { - Cancel(); - } - -void CAppCloseWatcher::Start(const TApaTask& aTask) - { - TInt err = iThread.Open(aTask.ThreadId()); - if (err == KErrNone) - { - iOriginalProcessPriority = iThread.ProcessPriority(); - iThread.SetProcessPriority(EPriorityForeground); - iThread.Logon(iStatus); - SetActive(); - } - else - { - iStatus = KRequestPending; - TRequestStatus* s = &iStatus; - User::RequestComplete(s, err); - SetActive(); - } - } - -void CAppCloseWatcher::DoCancel() - { - iThread.LogonCancel(iStatus); - iThread.SetProcessPriority(iOriginalProcessPriority); - iThread.Close(); - } - -void CAppCloseWatcher::RunL() - { - if (iThread.Handle()) - iThread.SetProcessPriority(iOriginalProcessPriority); - iThread.Close(); - // Experimentation shows that memory may take up to 40ms - // to be released back to the system after app thread close. - // Using this delay should minimise the number of apps that - // need to be closed to recover the necessary memory. - const TInt KAppTidyUpDelay = 40000; - User::After(KAppTidyUpDelay); - iMonitor.CloseAppEvent(); - } - - - -CWservEventReceiver::CWservEventReceiver(CMemoryMonitor& aMonitor, RWsSession& aWs) -: CActive(CActive::EPriorityStandard), iMonitor(aMonitor), iWs(aWs), iWg(aWs) - { - CActiveScheduler::Add(this); - } - -CWservEventReceiver::~CWservEventReceiver() - { - Cancel(); - iWg.Close(); - } - -void CWservEventReceiver::ConstructL() - { - User::LeaveIfError(iWg.Construct((TUint32)this, EFalse)); - iWg.SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront); - iWg.EnableFocusChangeEvents(); - Queue(); - } - -void CWservEventReceiver::Queue() - { - iWs.EventReady(&iStatus); - SetActive(); - } - -void CWservEventReceiver::DoCancel() - { - iWs.EventReadyCancel(); - } - -void CWservEventReceiver::RunL() - { - TWsEvent event; - iWs.GetEvent(event); - if (event.Type() == EEventFocusGroupChanged) - iMonitor.HandleFocusedWgChangeL(); - Queue(); - } - - - -CMemoryMonitorServer* CMemoryMonitorServer::NewL(CMemoryMonitor& aMonitor) - { - CMemoryMonitorServer* self=new(ELeave) CMemoryMonitorServer(aMonitor); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -CMemoryMonitorServer::~CMemoryMonitorServer() - { - } - -CMemoryMonitorServer::CMemoryMonitorServer(CMemoryMonitor& aMonitor) -:CServer2(CActive::EPriorityStandard), iMonitor(aMonitor) - { - } - -void CMemoryMonitorServer::ConstructL() - { - StartL(KMemoryMonitorServerName); - } - -CSession2* CMemoryMonitorServer::NewSessionL(const TVersion& /*aVersion*/, const RMessage2& /*aMessage*/) const - { - return new(ELeave) CMemoryMonitorSession(); - } - -TInt CMemoryMonitorServer::RunError(TInt aError) - { - Message().Complete(aError); - // - // The leave will result in an early return from CServer::RunL(), skipping - // the call to request another message. So do that now in order to keep the - // server running. - ReStart(); - return KErrNone; // handled the error fully - } - -CMemoryMonitor& CMemoryMonitorServer::Monitor() - { - return iMonitor; - } - -void CMemoryMonitorServer::CloseAppsFinished(TBool aMemoryGood) - { - iSessionIter.SetToFirst(); - CSession2* s; - while ((s = iSessionIter++) != 0) - static_cast(s)->CloseAppsFinished(aMemoryGood); - } - - -CMemoryMonitorSession::CMemoryMonitorSession() - { - } - -void CMemoryMonitorSession::CreateL() - { - } - -CMemoryMonitorSession::~CMemoryMonitorSession() - { - } - -CMemoryMonitorServer& CMemoryMonitorSession::Server() - { - return *static_cast(const_cast(CSession2::Server())); - } - -CMemoryMonitor& CMemoryMonitorSession::Monitor() - { - return Server().Monitor(); - } - -void CMemoryMonitorSession::ServiceL(const RMessage2& aMessage) - { - aMessage.HasCapabilityL(ECapabilityWriteDeviceData); //Leaves if client has not correct capability - switch (aMessage.Function()) - { - case EOomMonitorRequestFreeMemory: - if (!iRequestFreeRam.IsNull()) - PanicClient(aMessage, EPanicRequestActive); - // message will be completed when CloseAppsFinished() is called. - iRequestFreeRam = aMessage; - Monitor().StartFreeSomeRamL(aMessage.Int0()); - break; - - case EOomMonitorCancelRequestFreeMemory: - if (!iRequestFreeRam.IsNull()) - iRequestFreeRam.Complete(KErrCancel); - aMessage.Complete(KErrNone); - break; - - case EOomMonitorThisAppIsNotExiting: - Monitor().AppNotExiting(aMessage.Int0()); - aMessage.Complete(KErrNone); - break; - - default: - PanicClient(aMessage, EPanicIllegalFunction); - break; - } - } - -void CMemoryMonitorSession::CloseAppsFinished(TBool aMemoryGood) - { - if (!iRequestFreeRam.IsNull()) - iRequestFreeRam.Complete(aMemoryGood ? KErrNone : KErrNoMemory); - } - - void PanicClient(const RMessagePtr2& aMessage,TOomMonitorClientPanic aPanic) { + FUNC_LOG; + aMessage.Panic(KMemoryMonitorServerName, aPanic); } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oommonitorplugin.cpp --- a/sysresmonitoring/oommonitor/src/oommonitorplugin.cpp Tue Feb 02 10:12:00 2010 +0200 +++ b/sysresmonitoring/oommonitor/src/oommonitorplugin.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -16,26 +16,33 @@ */ +#include #include "oommonitorplugin.h" -#include "oommonitor.h" -#include +#include "oommemorymonitor.h" +#include "oomtraces.h" // TLS is used to store the CMemoryMonitor pointer, CMemoryMonitor // being the main object in the OOM monitor thread. This allows // plugins to access the CMemoryMonitor object easily. EXPORT_C void SetMemoryMonitorTls(CMemoryMonitor* aMonitor) { + FUNC_LOG; + Dll::SetTls(aMonitor); } CMemoryMonitor* MemoryMonitorTls() { + FUNC_LOG; + return static_cast(Dll::Tls()); } void OomMonitorPluginPanic(TOomMonitorPluginPanic aReason) { + FUNC_LOG; + _LIT(KCat, "OomMonitorPlugin"); User::Panic(KCat, aReason); } @@ -43,34 +50,53 @@ EXPORT_C COomMonitorPlugin::COomMonitorPlugin() : iMemoryMonitor(MemoryMonitorTls()) - { - __ASSERT_ALWAYS(iMemoryMonitor, OomMonitorPluginPanic(EOomMonitorPluginPanic_PluginConstructedOutsideOomMonitorThread)); - } + { + FUNC_LOG; + + __ASSERT_ALWAYS(iMemoryMonitor, OomMonitorPluginPanic(EOomMonitorPluginPanic_PluginConstructedOutsideOomMonitorThread)); + } EXPORT_C COomMonitorPlugin::~COomMonitorPlugin() - { - } + { + FUNC_LOG; + } EXPORT_C void COomMonitorPlugin::ConstructL() - { - // CAppOomMonitorPlugin assumes ConstructL is empty - } + { + FUNC_LOG; + + // CAppOomMonitorPlugin assumes ConstructL is empty + } EXPORT_C void COomMonitorPlugin::ExtensionInterface(TUid /*aInterfaceId*/, TAny*& /*aImplementaion*/) - { - } + { + FUNC_LOG; + } EXPORT_C RFs& COomMonitorPlugin::FsSession() { + FUNC_LOG; + return iMemoryMonitor->iFs; } EXPORT_C RWsSession& COomMonitorPlugin::WsSession() { + FUNC_LOG; + return iMemoryMonitor->iWs; } + +EXPORT_C void COomMonitorPluginV2::FreeRam() + { + // Note that OomMonitorV2 will not call this version of the function + // so it does not need to be implemented in derived classes. + } + + + EXPORT_C CAppOomMonitorPlugin* CAppOomMonitorPlugin::NewL(TUid aAppUid) { CAppOomMonitorPlugin* self = new(ELeave) CAppOomMonitorPlugin(aAppUid); @@ -96,18 +122,18 @@ void CAppOomMonitorPlugin::SendMessageToApp(TInt aMessage) { RWsSession& ws = WsSession(); - TInt wgId = 0; + TInt wgId = 0; do { - CApaWindowGroupName::FindByAppUid(iAppUid, ws, wgId); - if (wgId>0) - { - TWsEvent event; - event.SetType(aMessage); - event.SetTimeNow(); - ws.SendEventToWindowGroup(wgId, event); - } + CApaWindowGroupName::FindByAppUid(iAppUid, ws, wgId); + if (wgId>0) + { + TWsEvent event; + event.SetType(aMessage); + event.SetTimeNow(); + ws.SendEventToWindowGroup(wgId, event); + } } - while (wgId>0); + while (wgId>0); } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oommonitorsession.cpp --- a/sysresmonitoring/oommonitor/src/oommonitorsession.cpp Tue Feb 02 10:12:00 2010 +0200 +++ b/sysresmonitoring/oommonitor/src/oommonitorsession.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -16,33 +16,104 @@ */ -#include "oommonitorsession.h" +#include +#include #include "oommonitorclientserver.h" +#include "oompanic.h" +#include "oomtraces.h" EXPORT_C TInt ROomMonitorSession::Connect() - { - return CreateSession(KMemoryMonitorServerName, TVersion(0,0,0)); - } + { + FUNC_LOG; + + return CreateSession(KMemoryMonitorServerName, TVersion(0,0,0)); + } EXPORT_C TInt ROomMonitorSession::RequestFreeMemory(TInt aBytesRequested) - { - TIpcArgs p(aBytesRequested); - return SendReceive(EOomMonitorRequestFreeMemory, p); - } + { + FUNC_LOG; + + TIpcArgs p(aBytesRequested); + return SendReceive(EOomMonitorRequestFreeMemory, p); + } + +EXPORT_C TInt ROomMonitorSession::RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable) + { + FUNC_LOG; + + TIpcArgs p(aBytesRequested, aMinimumBytesNeeded, aPluginId, aBytesAvailable); + TInt ret = SendReceive(EOomMonitorRequestOptionalRam, p); + if (ret >= 0) + { + aBytesAvailable = ret; + ret = KErrNone; + } + + return ret; + } + + + +EXPORT_C void ROomMonitorSession::RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TRequestStatus& aStatus) + { + FUNC_LOG; + + TIpcArgs p(aBytesRequested, aMinimumBytesNeeded, aPluginId); + SendReceive(EOomMonitorRequestOptionalRam, p, aStatus); + } EXPORT_C void ROomMonitorSession::RequestFreeMemory(TInt aBytesRequested, TRequestStatus& aStatus) - { - TIpcArgs p(aBytesRequested); - SendReceive(EOomMonitorRequestFreeMemory, p, aStatus); - } + { + FUNC_LOG; + + TIpcArgs p(aBytesRequested); + SendReceive(EOomMonitorRequestFreeMemory, p, aStatus); + } EXPORT_C void ROomMonitorSession::CancelRequestFreeMemory() - { - SendReceive(EOomMonitorCancelRequestFreeMemory, TIpcArgs()); - } + { + FUNC_LOG; + + SendReceive(EOomMonitorCancelRequestFreeMemory, TIpcArgs()); + } EXPORT_C void ROomMonitorSession::ThisAppIsNotExiting(TInt aWgId) - { - TIpcArgs p(aWgId); - SendReceive(EOomMonitorThisAppIsNotExiting, p); - } + { + FUNC_LOG; + + TIpcArgs p(aWgId); + SendReceive(EOomMonitorThisAppIsNotExiting, p); + } + + +EXPORT_C void ROomMonitorSession::SetOomPriority(TOomPriority aPriority) + { + FUNC_LOG; + + CCoeEnv* coeEnv = CCoeEnv::Static(); + + __ASSERT_DEBUG(coeEnv, OomMonitorPanic(KNoCoeEnvFound)); + + if (coeEnv) + { + TInt wgId = coeEnv->RootWin().Identifier(); + TIpcArgs p(wgId); + switch (aPriority) + { + case EOomPriorityNormal: + SendReceive(EOomMonitorSetPriorityNormal, p); + break; + case EOomPriorityHigh: + SendReceive(EOomMonitorSetPriorityHigh, p); + break; + case EOomPriorityBusy: + SendReceive(EOomMonitorSetPriorityBusy, p); + break; + default: + OomMonitorPanic(KOomInvalidPriority); + break; + } + } + } + + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomoutofmemorywatcher.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomoutofmemorywatcher.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,136 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main classes for Out of Memory Monitor. +* +*/ + + + +#include "oomoutofmemorywatcher.h" +#include "oommemorymonitor.h" +#include "oomtraces.h" + +// ====================================================================== +// class COutOfMemoryWatcher +// - notifies when free memory crosses preset thresholds +// ====================================================================== + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +COutOfMemoryWatcher* COutOfMemoryWatcher::NewL(CMemoryMonitor& aMonitor, TInt aLowThreshold, TInt aGoodThreshold) + { + FUNC_LOG; + + COutOfMemoryWatcher* self = new (ELeave) COutOfMemoryWatcher(aMonitor); + CleanupStack::PushL(self); + self->ConstructL(aLowThreshold, aGoodThreshold); + CleanupStack::Pop(self); + return self; + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +COutOfMemoryWatcher::~COutOfMemoryWatcher() + { + FUNC_LOG; + + Cancel(); + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +COutOfMemoryWatcher::COutOfMemoryWatcher(CMemoryMonitor& aMonitor) +: CActive(CActive::EPriorityStandard), + iLafShutdown(aMonitor) + { + FUNC_LOG; + + CActiveScheduler::Add(this); + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void COutOfMemoryWatcher::ConstructL(TInt aLowThreshold, TInt aGoodThreshold) + { + FUNC_LOG; + + UserSvr::SetMemoryThresholds(aLowThreshold,aGoodThreshold); + User::LeaveIfError(iChangeNotifier.Create()); + } + +void COutOfMemoryWatcher::UpdateThresholds(TInt aLowThreshold, TInt aGoodThreshold) + { + FUNC_LOG; + + UserSvr::SetMemoryThresholds(aLowThreshold,aGoodThreshold); + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void COutOfMemoryWatcher::Start() + { + FUNC_LOG; + + if (!IsActive()) + { + iChangeNotifier.Logon(iStatus); + SetActive(); + } + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void COutOfMemoryWatcher::DoCancel() + { + FUNC_LOG; + + iChangeNotifier.LogonCancel(); + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void COutOfMemoryWatcher::RunL() + { + FUNC_LOG; + + TInt status = iStatus.Int(); + + if (status < 0) + { + User::Leave(status); + } + + // Check for memory status change. + if (status & EChangesFreeMemory) + { + iLafShutdown.FreeMemThresholdCrossedL(); + } + + // We are not active until FreeMemThresholdCrossedL returns. + Start(); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oompanic.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oompanic.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Panic codes for OOM monitor. +* +*/ + +#include "oompanic.h" + +#include + +void OomMonitorPanic(TOomMonitorPanic aReason) + { + _LIT(KCat, "OomMonitor"); + User::Panic(KCat, aReason); + } + +void OomConfigParserPanic(TInt aReason) + { + _LIT(KParserCat, "OomParser"); + User::Panic(KParserCat, aReason); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oompluginwaiter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oompluginwaiter.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + + +#include "oompluginwaiter.h" +#include "oomrunplugin.h" +#include "oomtraces.h" +#include "oomconstants.hrh" + +COomPluginWaiter* COomPluginWaiter::NewL(TInt aMillisecondsToWait, COomRunPlugin& aCallbackClass) + { + FUNC_LOG; + + COomPluginWaiter* self = new (ELeave) COomPluginWaiter(aMillisecondsToWait, aCallbackClass); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +COomPluginWaiter::COomPluginWaiter(TInt aMillisecondsToWait, COomRunPlugin& aCallbackClass) : CTimer(EPriorityStandard), iMillisecondsToWait(aMillisecondsToWait), iCallbackClass(aCallbackClass) + { + FUNC_LOG; + + CActiveScheduler::Add(this); + } + +// Start the timer, it will call the plugin back when it expires +void COomPluginWaiter::Start() + { + FUNC_LOG; + + HighRes(iMillisecondsToWait * KMicrosecondsInMillisecond); + } + +void COomPluginWaiter::RunL() + { + FUNC_LOG; + + iCallbackClass.WaitCompleted(); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomrunplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomrunplugin.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Classes for executing OOM actions (e.g. closing applications and running plugins). +* +*/ + +#include "oomrunplugin.h" +#include "OomTraces.h" +#include "oommemorymonitor.h" +#include "oommonitorplugin.h" +#include "oompanic.h" + +COomRunPlugin* COomRunPlugin::NewL(TUint aPluginId, COomRunPluginConfig& aConfig, MOomActionObserver& aStateChangeObserver, COomMonitorPlugin& aPlugin, COomMonitorPluginV2* aV2Plugin) + { + FUNC_LOG; + + COomRunPlugin* self = new (ELeave) COomRunPlugin(aPluginId, aConfig, aStateChangeObserver, aPlugin, aV2Plugin); + CleanupStack::PushL(self); + self->ConstructL(aConfig); + CleanupStack::Pop(self); + return self; + } + +// Run the OOM plugin in order to free memory +// Call the COomAction::MemoryFreed when it is done +void COomRunPlugin::FreeMemory(TInt aBytesRequested) + { + FUNC_LOG; + TRACES1("COomRunPlugin::FreeMemory: iPluginId = %x", iPluginId); + + // Ask the plugin to free some memory + + // Do we have a V2 plugin, if so then use it + if (iV2Plugin) + iV2Plugin->FreeRam(aBytesRequested); + else + // If we only have a V1 plugin then use that + iPlugin.FreeRam(); + + iFreeMemoryCalled = ETrue; + + // Wait for the required time before we signal completion. + __ASSERT_DEBUG(!iPluginWaiter->IsActive(), OomMonitorPanic(KStartingActivePluginWaiter)); + iPluginWaiter->Start(); + } + +// Call the memory good function on the plugin but... +// only if there is an outstanding FreeMemory request +void COomRunPlugin::MemoryGood() + { + FUNC_LOG; + + if (iFreeMemoryCalled) + { + iPlugin.MemoryGood(); + iFreeMemoryCalled = EFalse; + } + } + +COomRunPlugin::~COomRunPlugin() + { + FUNC_LOG; + + delete iPluginWaiter; + } + +COomRunPlugin::COomRunPlugin(TUint aPluginId, COomRunPluginConfig& aConfig, MOomActionObserver& aStateChangeObserver, COomMonitorPlugin& aPlugin, COomMonitorPluginV2* aV2Plugin) : COomAction(aStateChangeObserver), iPluginId(aPluginId), iPlugin(aPlugin), iConfig(aConfig), iV2Plugin(aV2Plugin) + { + FUNC_LOG; + } + +void COomRunPlugin::ConstructL(COomRunPluginConfig& aPluginConfig) + { + FUNC_LOG; + + TInt waitDuration = CMemoryMonitor::GlobalConfig().iDefaultWaitAfterPlugin; + + if (aPluginConfig.WaitAfterPluginDefined()) + { + // If the wait duration for this plugin is overridden then use the overridden value + waitDuration = aPluginConfig.WaitAfterPlugin(); + } + + iPluginWaiter = COomPluginWaiter::NewL(waitDuration, *this); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomrunpluginconfig.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomrunpluginconfig.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Configuration representation classes for Out of Memory Monitor. +* +*/ + + +#include "oomrunpluginconfig.h" +#include "oomwindowgrouplist.h" +#include "oomtraces.h" + +COomRunPluginConfig* COomRunPluginConfig::NewL(TUint aPluginId, TOomPluginType aPluginType) + { + FUNC_LOG; + + COomRunPluginConfig* self = new (ELeave) COomRunPluginConfig(aPluginId, aPluginType); + return self; + } + +TUint COomRunPluginConfig::CalculatePluginPriority(const COomWindowGroupList& aWindowGroupList) + { + FUNC_LOG; + + // Call the Priority function on the CActionConfig base class + // This function will check if any rules match the current system state and then adjust the priority if they do + // Rules may apply to system plugins or application plugins + return Priority(aWindowGroupList, aWindowGroupList.GetIndexFromAppId(iTargetAppId)); + } + + +COomRunPluginConfig::~COomRunPluginConfig() + { + FUNC_LOG; + } + + +COomRunPluginConfig::COomRunPluginConfig(TUint aPluginId, TOomPluginType aPluginType) : COomActionConfig(aPluginId), iPluginId(aPluginId), iPluginType(aPluginType) + { + FUNC_LOG; + + iSyncMode = EContinueIgnoreMaxBatchSize; + iCallIfTargetAppNotRunning = ETrue; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomsubscribehelper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomsubscribehelper.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main classes for Out of Memory Monitor. +* +*/ + +#include +#include "oomsubscribehelper.h" +#include "oomtraces.h" + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +CSubscribeHelper::CSubscribeHelper(TCallBack aCallBack, RProperty& aProperty) + : CActive(EPriorityNormal), iCallBack(aCallBack), iProperty(aProperty) + { + FUNC_LOG; + + CActiveScheduler::Add(this); + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +CSubscribeHelper::~CSubscribeHelper() + { + FUNC_LOG; + + Cancel(); + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void CSubscribeHelper::Subscribe() + { + FUNC_LOG; + + if (!IsActive()) + { + iProperty.Subscribe(iStatus); + SetActive(); + } + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void CSubscribeHelper::StopSubscribe() + { + FUNC_LOG; + + Cancel(); + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void CSubscribeHelper::RunL() + { + FUNC_LOG; + + if (iStatus.Int() == KErrNone) + { + iCallBack.CallBack(); + Subscribe(); + } + } + +// --------------------------------------------------------- +// +// --------------------------------------------------------- +// +void CSubscribeHelper::DoCancel() + { + FUNC_LOG; + + iProperty.Cancel(); + } + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomwindowgrouplist.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomwindowgrouplist.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,480 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: A wrapper for the window group list, adding additional functionality required by OOM Monitor v2. +* +*/ + +#include +#include +#include +#include + +#include "oomwindowgrouplist.h" +#include "OomTraces.h" +#include "oomconstants.hrh" +#include "oompanic.h" + +_LIT(KDummyWgName, "20"); +const TInt KPreallocatedSpaceForAppList = 50; + +const TUint KOomTicksPerSecond = 1000; + +COomWindowGroupList::TOomWindowGroupProperties::TOomWindowGroupProperties() : iIdleTickTime(0), iDynamicPriority(EOomPriorityNormal) + { + FUNC_LOG; + } + +// Update the list of window groups +void COomWindowGroupList::Refresh() + { + FUNC_LOG; + +#ifdef _DEBUG + TRAPD(err, RefreshL()); + if (err) + { + TRACES1("COomWindowGroupList::Refresh(): RefreshL leave %d", err); + } +#else + TRAP_IGNORE(RefreshL()); + // Ignore any error + // Errors are very unlikely, the only possibility is OOM errors (which should be very unlikely due to pre-created, re-reserved lists) + // The outcome of any error is that the most foreground operations will be missing from the list + // meaning that they will not be considered candidates for closing +#endif + } + +// Update the list of window groups +// Should be called whenever the +void COomWindowGroupList::RefreshL() + { + FUNC_LOG; + + // Refresh window group list + // get all window groups, with info about parents + TInt numGroups = iWs.NumWindowGroups(0); + iWgIds.ReserveL(numGroups); + User::LeaveIfError(iWs.WindowGroupList(0, &iWgIds)); + + // Remove all child window groups, promote parents to foremost child position + CollapseWindowGroupTree(); + + // Note the current foreground window ID (if there is one) + TBool oldForegroundWindowExists = EFalse; + + TInt oldForegroundWindowId; + if (iWgIds.Count() > 0) + { + oldForegroundWindowId = iWgIds[0].iId; + oldForegroundWindowExists = ETrue; + } + + // Cleanup the idletime hash map to remove idle times for any windows that have closed + RemovePropertiesForClosedWindowsL(); + + // Update the idle tick on the old foreground application (which might now be in the background) + // This will be set to the current system tick count and will be used later to determine the idle time + if (oldForegroundWindowExists) + { + TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(oldForegroundWindowId); + if (wgProperties) + { + wgProperties->iIdleTickTime = User::NTickCount(); + } + + // If there is no idle tick entry for this window ID then it will be created in the next step... + } + + TInt index = iWgIds.Count(); + + while (index--) + { + // See if there is a tick count entry for each window in the list + TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(iWgIds[index].iId); + + if (!wgProperties) + { + TOomWindowGroupProperties wgProperties; + wgProperties.iIdleTickTime = User::NTickCount(); + // If there is no idle tick entry for this window then add one + iWgToPropertiesMapping.InsertL(iWgIds[index].iId, wgProperties); + } + } + } + + + +void COomWindowGroupList::RemovePropertiesForClosedWindowsL() + { + FUNC_LOG; + + // First, clear the existing set of window IDs (it would be quicker to delete it BUT we have reserved memory for it and don't want to be allocating in low memory conditions) + RHashSet::TIter windowIdSetIter(iExistingWindowIds); + while (windowIdSetIter.Next()) + { + windowIdSetIter.RemoveCurrent(); + } + + // Create the set of existing window IDs (this saves expensive/repeated searching later on) + TInt index = iWgIds.Count(); + while (index--) + { + iExistingWindowIds.InsertL(iWgIds[index].iId); + } + + // Iterate the idle-time hash map - remove any items where the window no longer exists + RHashMap::TIter wgToIdleIterator(iWgToPropertiesMapping); + while (wgToIdleIterator.NextKey()) + { + // If the current key (window ID) does not exist in the set then remove the idle-time as it is no longer relevant + if (!iExistingWindowIds.Find(*(wgToIdleIterator.CurrentKey()))) + wgToIdleIterator.RemoveCurrent(); + } + } + + +TUint COomWindowGroupList::AppId(TInt aIndex, TBool aResolveFromThread) const + { + FUNC_LOG; + + // get the app's details + TPtr wgPtr(iWgNameBuf->Des()); + + TUid uid; + + __ASSERT_DEBUG(aIndex < iWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds)); + TInt wgId = iWgIds[aIndex].iId; + + TInt err = iWs.GetWindowGroupNameFromIdentifier(wgId, wgPtr); + + if (KErrNone != err) + // If there is an error then set the UID to 0; + { + uid.iUid = 0; + } + else + { + iWgName->SetWindowGroupName(iWgNameBuf); // iWgName takes ownership of iWgNameBuf + uid = iWgName->AppUid(); // This UID comes from the app, not the mmp! + if (aResolveFromThread && uid.iUid == 0) + { + TApaTask task(iWs); + task.SetWgId(wgId); + TThreadId threadId = task.ThreadId(); + + TUint resolvedUid = 0; + RThread appThread; + TInt err = appThread.Open( threadId ); + if ( err == KErrNone ) + { + resolvedUid = appThread.SecureId().iId; + } + appThread.Close(); + TRACES2("COomWindowGroupList::AppId: NULL wg UID, taking from thread; resolvedUid = %x aIndex = %d", resolvedUid, aIndex); + return resolvedUid; + } + } + + return uid.iUid; + } + + +TTimeIntervalSeconds COomWindowGroupList::IdleTime(TInt aIndex) const + { + FUNC_LOG; + + TUint32 currentTickCount = User::NTickCount(); + + __ASSERT_DEBUG(aIndex < iWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds)); + const TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(iWgIds[aIndex].iId); + + TTimeIntervalSeconds idleTime = 0; + + if (wgProperties) + { + // This should also handle the case where the current tick count has wrapped to a lower value than the idle tick time + // It will only work if it has wrapped once, but + TUint32 differenceBetweenTickCounts = currentTickCount - wgProperties->iIdleTickTime; + idleTime = differenceBetweenTickCounts / KOomTicksPerSecond; + } + + return idleTime; + } + + + +void COomWindowGroupList::CollapseWindowGroupTree() + { + FUNC_LOG; + + // start from the front, wg count can reduce as loop runs + for (TInt ii=0; ii 0) // wg has a parent + { + // Look for the parent position + TInt parentPos = ii; // use child pos as not-found signal + TInt count = iWgIds.Count(); + for (TInt jj=0; jj ii) // parent should be moved forward + { + iWgIds[ii] = iWgIds[parentPos]; + iWgIds.Remove(parentPos); + } + else if (parentPos < ii) // parent is already ahead of child, remove child + iWgIds.Remove(ii); + else // parent not found, skip + ii++; + } + else // wg does not have a parent, skip + ii++; + } + } + + + +COomWindowGroupList::COomWindowGroupList(RWsSession& aWs) : iWs(aWs) + { + FUNC_LOG; + } + + + +void COomWindowGroupList::ConstructL() + { + FUNC_LOG; + + // Reserve enough space to build an app list later. + iWgIds.ReserveL(KPreallocatedSpaceForAppList); + iUncollapsedWgIds.ReserveL(KPreallocatedSpaceForAppList); + + // Reserve enough space for the WG to idle tick mapping + iWgToPropertiesMapping.ReserveL(KPreallocatedSpaceForAppList); + + // Reserve enough space for CApaWindowGroupName. + iWgName = CApaWindowGroupName::NewL(iWs); + iWgNameBuf = HBufC::NewL(CApaWindowGroupName::EMaxLength); + (*iWgNameBuf) = KDummyWgName; + iWgName->SetWindowGroupName(iWgNameBuf); // iWgName takes ownership of iWgNameBuf + + RefreshL(); + } + + + +COomWindowGroupList* COomWindowGroupList::NewL(RWsSession& aWs) + { + FUNC_LOG; + + COomWindowGroupList* self = new (ELeave) COomWindowGroupList(aWs); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + + + +COomWindowGroupList::~COomWindowGroupList() + { + FUNC_LOG; + + iWgIds.Close(); + iUncollapsedWgIds.Close(); + iWgToPropertiesMapping.Close(); + iExistingWindowIds.Close(); + delete iWgName; + } + + +void COomWindowGroupList::SetPriorityBusy(TInt aWgId) + { + FUNC_LOG; + + Refresh(); + + TInt parentId; + TRAPD(err, parentId = FindParentIdL(aWgId)); + if (err) + { + parentId = aWgId; + } + + TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(parentId); + if (wgProperties) + { + wgProperties->iDynamicPriority = EOomPriorityBusy; + } + + // If we can't find the window group then ignore it + } + + +TInt COomWindowGroupList::FindParentIdL(TInt aWgId) + { + TInt numGroups = iWs.NumWindowGroups(0); + iUncollapsedWgIds.ReserveL(numGroups); + User::LeaveIfError(iWs.WindowGroupList(0, &iUncollapsedWgIds)); + + TInt parentPos = KErrNotFound; + + //loop through the window group list + for (TInt i=0; i=0 ) + { + __ASSERT_DEBUG(parentPos < iUncollapsedWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds)); + while (iUncollapsedWgIds[parentPos].iParentId > 0) + { + // find the index for the parent + for (TInt j=0; jiDynamicPriority == EOomPriorityBusy); + } + + return isBusy; + } + +// Returns ETrue if an application has registered itself as high priority at runtime +TBool COomWindowGroupList::IsDynamicHighPriority(TInt aWgIndex) + { + FUNC_LOG; + + TBool isHighPriority = EFalse; + __ASSERT_DEBUG(aWgIndex < iWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds)); + TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(iWgIds[aWgIndex].iId); + if (wgProperties) + { + isHighPriority = (wgProperties->iDynamicPriority == EOomPriorityHigh); + } + + return isHighPriority; + } + +CApaWindowGroupName* COomWindowGroupList::WgName() const + { + return iWgName; + } + +void COomWindowGroupList::SetPriorityNormal(TInt aWgId) + { + FUNC_LOG; + + Refresh(); + + TInt parentId; + TRAPD(err, parentId = FindParentIdL(aWgId)); + if (err) + { + parentId = aWgId; + } + + TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(parentId); + if (wgProperties) + { + wgProperties->iDynamicPriority = EOomPriorityNormal; + } + + // If we can't find the window group then ignore it + } + + +void COomWindowGroupList::SetPriorityHigh(TInt aWgId) + { + FUNC_LOG; + + Refresh(); + + TInt parentId; + TRAPD(err, parentId = FindParentIdL(aWgId)); + if (err) + { + parentId = aWgId; + } + + TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(parentId); + if (wgProperties) + { + wgProperties->iDynamicPriority = EOomPriorityHigh; + } + + // If we can't find the window group then ignore it + } + +// Find the specificed application in the window group list and return the index +TInt COomWindowGroupList::GetIndexFromAppId(TUint aAppId) const + { + FUNC_LOG; + + TInt indexInGroupList = Count(); + TBool appFoundInWindowGroupList = EFalse; + + while (indexInGroupList--) + { + if (AppId(indexInGroupList, ETrue) == aAppId) + { + appFoundInWindowGroupList = ETrue; + break; + } + } + + if (!appFoundInWindowGroupList) + indexInGroupList = KAppNotInWindowGroupList; + + return indexInGroupList; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/src/oomwserveventreceiver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/src/oomwserveventreceiver.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main classes for Out of Memory Monitor. +* +*/ + +#include +#include +#include "oomwserveventreceiver.h" +#include "oommemorymonitor.h" +#include "oomtraces.h" +#include "oomconstants.hrh" + +#include "apgwgnam.h" + +CWservEventReceiver::CWservEventReceiver(CMemoryMonitor& aMonitor, RWsSession& aWs) +: CActive(CActive::EPriorityStandard), iMonitor(aMonitor), iWs(aWs), iWg(aWs) + { + FUNC_LOG; + + CActiveScheduler::Add(this); + } + +CWservEventReceiver::~CWservEventReceiver() + { + FUNC_LOG; + + Cancel(); + iWg.Close(); + } + +void CWservEventReceiver::ConstructL() + { + FUNC_LOG; + + User::LeaveIfError(iWg.Construct((TUint32)this, EFalse)); + iWg.SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront); + iWg.EnableFocusChangeEvents(); + Queue(); + } + +void CWservEventReceiver::Queue() + { + FUNC_LOG; + + iWs.EventReady(&iStatus); + SetActive(); + } + +void CWservEventReceiver::DoCancel() + { + FUNC_LOG; + + iWs.EventReadyCancel(); + } + +void CWservEventReceiver::RunL() + { + FUNC_LOG; + + TWsEvent event; + iWs.GetEvent(event); + if (event.Type() == EEventFocusGroupChanged) + { + // The following is done in order to avoid changing application threshholds when fastswap is activated + // 1) get the new focused app's details + // 2) we check to see if the fastswap uid caused the change + // 3a) If it didn't we proceed as normal: handleFocusedWgChangeL is called + // 3b) If not, we skip handleFocusedWgChangeL + CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(iWs, iWs.GetFocusWindowGroup()); + if(wgName->AppUid() != KUidFastSwap) + { + iMonitor.HandleFocusedWgChangeL(); + } + CleanupStack::PopAndDestroy(wgName); + } + + Queue(); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/conf/oomtest.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/conf/oomtest.cfg Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,3 @@ +[StifSettings] +CheckHeapBalance= on +[EndStifSettings] diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/data/oomconfig.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/data/oomconfig.xml Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/group/bld.inf Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +PRJ_PLATFORMS +DEFAULT + +PRJ_TESTEXPORTS +../init/oomtest.ini /epoc32/winscw/c/testframework/testframework.ini +../conf/oomtest.cfg /epoc32/winscw/c/testframework/oomtest.cfg +../data/oomconfig.xml /epoc32/release/winscw/udeb/z/private/10207218/oomconfig.xml +../data/oomconfig.xml /epoc32/release/winscw/urel/z/private/10207218/oomconfig.xml + +PRJ_TESTMMPFILES +#include "../t_oomallocserver/group/bld.inf" +#include "../t_oomdummyapp/group/bld.inf" +#include "../t_oomdummyplugin/group/bld.inf" +#include "../t_oomdummyplugin2/group/bld.inf" +//#include "../t_oomharness/group/bld.inf" +#include "../t_oomtestapp/group/bld.inf" +#include "../t_oomharness_stif/group/bld.inf" + +// End of File + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest.pkg Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,68 @@ +;Languages +&EN + +#{"t_oomharness_stif"},(0x101FB3E7),1,0,0,TYPE=SA + +;Localised Vendor name +%{"t_oomharness_stif EN"} + +; Vendor name +: "t_oomharness_stif" + +"\epoc32\release\armv5\urel\t_oomharness_stif.dll"-"c:\sys\bin\t_oomharness_stif.dll" +"..\init\oomtest.ini"-"c:\testframework\oomtest.ini" +"..\conf\oomtest.cfg"-"c:\testframework\oomtest.cfg" +;"..\data\oomconfig.xml"-"c:\private\10207218\oomconfig.xml" + +"\epoc32\release\armv5\urel\t_oomclient.dll"-"c:\sys\bin\t_oomclient.dll" +"\epoc32\release\armv5\urel\t_oomallocserver.exe"-"c:\sys\bin\t_oomallocserver.exe" + +"\epoc32\release\armv5\urel\t_oomdummyapp_0xE6CFBA00.exe"-"c:\sys\bin\t_oomdummyapp_0xE6CFBA00.exe" +"\epoc32\data\z\resource\apps\t_oomdummyapp_0xE6CFBA00.rsc"-"c:\resource\apps\t_oomdummyapp_0xE6CFBA00.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomdummyapp_0xE6CFBA00_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomdummyapp_0xE6CFBA00_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomdummyplugin.dll"-"c:\sys\bin\t_oomdummyplugin.dll" +"\epoc32\data\z\resource\plugins\t_oomdummyplugin.rsc"-"c:\resource\plugins\t_oomdummyplugin.rsc" + +"\epoc32\release\armv5\urel\t_oomdummyplugin2.dll"-"c:\sys\bin\t_oomdummyplugin2.dll" +"\epoc32\data\z\resource\plugins\t_oomdummyplugin2.rsc"-"c:\resource\plugins\t_oomdummyplugin2.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp.exe"-"c:\sys\bin\t_oomtestapp.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp.rsc"-"c:\resource\apps\t_oomtestapp.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp2.exe"-"c:\sys\bin\t_oomtestapp2.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp2.rsc"-"c:\resource\apps\t_oomtestapp2.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp2_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp2_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp3.exe"-"c:\sys\bin\t_oomtestapp3.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp3.rsc"-"c:\resource\apps\t_oomtestapp3.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp3_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp3_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp4.exe"-"c:\sys\bin\t_oomtestapp4.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp4.rsc"-"c:\resource\apps\t_oomtestapp4.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp4_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp4_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp5.exe"-"c:\sys\bin\t_oomtestapp5.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp5.rsc"-"c:\resource\apps\t_oomtestapp5.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp5_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp5_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp6.exe"-"c:\sys\bin\t_oomtestapp6.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp6.rsc"-"c:\resource\apps\t_oomtestapp6.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp6_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp6_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp7.exe"-"c:\sys\bin\t_oomtestapp7.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp7.rsc"-"c:\resource\apps\t_oomtestapp7.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp7_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp7_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp8.exe"-"c:\sys\bin\t_oomtestapp8.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp8.rsc"-"c:\resource\apps\t_oomtestapp8.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp8_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp8_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp9.exe"-"c:\sys\bin\t_oomtestapp9.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp9.rsc"-"c:\resource\apps\t_oomtestapp9.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp9_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp9_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp10.exe"-"c:\sys\bin\t_oomtestapp10.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp10.rsc"-"c:\resource\apps\t_oomtestapp10.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp10_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp10_reg.rsc" diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest_manualtestrun.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest_manualtestrun.pkg Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,68 @@ +;Languages +&EN + +#{"t_oomharness_stif"},(0x101FB3E7),1,0,0,TYPE=SA + +;Localised Vendor name +%{"t_oomharness_stif EN"} + +; Vendor name +: "t_oomharness_stif" + +"\epoc32\release\armv5\urel\t_oomharness_stif.dll"-"c:\sys\bin\t_oomharness_stif.dll" +"..\init\oomtest.ini"-"c:\testframework\oomtest.ini" +"..\conf\oomtest.cfg"-"c:\testframework\oomtest.cfg" +"..\data\oomconfig.xml"-"c:\data\oomconfig.xml" + +"\epoc32\release\armv5\urel\t_oomclient.dll"-"c:\sys\bin\t_oomclient.dll" +"\epoc32\release\armv5\urel\t_oomallocserver.exe"-"c:\sys\bin\t_oomallocserver.exe" + +"\epoc32\release\armv5\urel\t_oomdummyapp_0xE6CFBA00.exe"-"c:\sys\bin\t_oomdummyapp_0xE6CFBA00.exe" +"\epoc32\data\z\resource\apps\t_oomdummyapp_0xE6CFBA00.rsc"-"c:\resource\apps\t_oomdummyapp_0xE6CFBA00.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomdummyapp_0xE6CFBA00_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomdummyapp_0xE6CFBA00_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomdummyplugin.dll"-"c:\sys\bin\t_oomdummyplugin.dll" +"\epoc32\data\z\resource\plugins\t_oomdummyplugin.rsc"-"c:\resource\plugins\t_oomdummyplugin.rsc" + +"\epoc32\release\armv5\urel\t_oomdummyplugin2.dll"-"c:\sys\bin\t_oomdummyplugin2.dll" +"\epoc32\data\z\resource\plugins\t_oomdummyplugin2.rsc"-"c:\resource\plugins\t_oomdummyplugin2.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp.exe"-"c:\sys\bin\t_oomtestapp.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp.rsc"-"c:\resource\apps\t_oomtestapp.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp2.exe"-"c:\sys\bin\t_oomtestapp2.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp2.rsc"-"c:\resource\apps\t_oomtestapp2.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp2_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp2_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp3.exe"-"c:\sys\bin\t_oomtestapp3.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp3.rsc"-"c:\resource\apps\t_oomtestapp3.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp3_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp3_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp4.exe"-"c:\sys\bin\t_oomtestapp4.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp4.rsc"-"c:\resource\apps\t_oomtestapp4.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp4_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp4_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp5.exe"-"c:\sys\bin\t_oomtestapp5.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp5.rsc"-"c:\resource\apps\t_oomtestapp5.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp5_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp5_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp6.exe"-"c:\sys\bin\t_oomtestapp6.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp6.rsc"-"c:\resource\apps\t_oomtestapp6.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp6_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp6_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp7.exe"-"c:\sys\bin\t_oomtestapp7.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp7.rsc"-"c:\resource\apps\t_oomtestapp7.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp7_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp7_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp8.exe"-"c:\sys\bin\t_oomtestapp8.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp8.rsc"-"c:\resource\apps\t_oomtestapp8.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp8_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp8_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp9.exe"-"c:\sys\bin\t_oomtestapp9.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp9.rsc"-"c:\resource\apps\t_oomtestapp9.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp9_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp9_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp10.exe"-"c:\sys\bin\t_oomtestapp10.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp10.rsc"-"c:\resource\apps\t_oomtestapp10.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp10_reg.rsc"-"c:\private\10003a3f\import\apps\t_oomtestapp10_reg.rsc" diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest_manualtestrun.sis Binary file sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest_manualtestrun.sis has changed diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest_manualtestrun.sisx Binary file sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest_manualtestrun.sisx has changed diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/group/readme.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/group/readme.txt Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,13 @@ +To test in emulator: + 1) bldmake bldfiles + abld test build + 2) start emulator + 3) run "consoleui" from "eshell" + +To test (manually) in HW: + 1) bldmake bldfiles + abld test build + 2) create and sign sis from oomtest_manualtestrun.pkg (note that oomtest.pkg is for automated testing) + 3) install sis into phone + 4) select OOM test config xml from c:\data\ (use t_oomtestapp -> Options -> Select...) + 5) reboot phone (config xml is taken in use) + 6) rename oomtest.ini in c:\testframework to testframework.ini (use FileBrowse) + 7) run "consoleui" from "eshell" diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/inc/t_oomclient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/inc/t_oomclient.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __T_CLIENT_H__ +#define __T_CLIENT_H__ + +#include + +class ROOMAllocSession : public RSessionBase + { +public: + IMPORT_C TInt Connect(); + IMPORT_C TInt Reset(); + IMPORT_C TInt StartAllocating(); + IMPORT_C TInt StopAllocating(); + IMPORT_C TInt Configure(TUid aPlugin, TUint aAllocRate, TUint aAllocInitial, TUint aAllocLimit); + IMPORT_C TInt MemoryLow(TUid aPlugin); + IMPORT_C TInt MemoryGood(TUid aPlugin); + }; + +#endif diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/inc/t_oomdummyplugin_properties.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/inc/t_oomdummyplugin_properties.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef DUMMYPLUGIN_PROPETIES_H_ +#define DUMMYPLUGIN_PROPETIES_H_ + +const TUid KUidOomPropertyCategory = {0x10286A3E}; + +//The key is the UID of the implementation instance, i.e. 10286A34 To 10286A3D +const TInt KUidOOMDummyPluginFirstImplementation(0x10286A34); +const TInt KUidOOMDummyPluginLastImplementation(0x10286A3D); + +const TUint KOOMDummyPluginImplementationCount = 10; + +const TUint KOOMDummyPluginLowMemoryCount = 0; +const TUint KOOMDummyPluginGoodMemoryCount = 1 * KOOMDummyPluginImplementationCount; +const TUint KOOMDummyPluginCurrentAllocationBytes = 2 * KOOMDummyPluginImplementationCount; +const TUint KOOMDummyPluginBytesRequested = 3 * KOOMDummyPluginImplementationCount; + +#endif /* DUMMYPLUGIN_PROPETIES_H_ */ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/inc/t_oomdummyplugin_properties2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/inc/t_oomdummyplugin_properties2.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,21 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/init/oomtest.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/init/oomtest.ini Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,173 @@ +# +# This is STIFTestFramework initialization file +# Comment lines start with '#'-character. +# See STIF TestFramework users guide.doc for instructions + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set following test engine settings: +# - Set Test Reporting mode. TestReportMode's possible values are: +# + 'Summary': Summary of the tested test cases. +# + 'Environment': Hardware and software info. +# + 'TestCases': Test case report. +# + 'FullReport': Set of all above ones. +# + Example 'TestReportMode= Summary TestCases' +# +# - CreateTestReport setting controls report creation mode +# + YES, Test report will created. +# + NO, No Test report. +# +# - File path indicates the base path of the test report. +# - File name indicates the name of the test report. +# +# - File format indicates the type of the test report. +# + TXT, Test report file will be txt type, for example 'TestReport.txt'. +# + HTML, Test report will be html type, for example 'TestReport.html'. +# +# - File output indicates output source of the test report. +# + FILE, Test report logging to file. +# + RDEBUG, Test report logging to using rdebug. +# +# - File Creation Mode indicates test report overwriting if file exist. +# + OVERWRITE, Overwrites if the Test report file exist. +# + APPEND, Continue logging after the old Test report information if +# report exist. + +[Engine_Defaults] + +TestReportMode= FullReport # Possible values are: + # 'Summary', 'Environment', 'TestCases' or 'FullReport' + +CreateTestReport= YES # Possible values: YES or NO + +TestReportFilePath= C:\LOGS\TestFramework\ +TestReportFileName= TestReport + +TestReportFormat= TXT # Possible values: TXT or HTML +TestReportOutput= FILE # Possible values: FILE or RDEBUG +TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +[End_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Module configurations start +# Modules are added between module tags +# tags. Module name is specified after ModuleName= tag, like +# ModuleName= XXXXXXXXX +# Modules might have initialisation file, specified as +# IniFile= YYYYYY +# Modules might have several configuration files, like +# TestCaseFile= NormalCases.txt +# TestCaseFile= SmokeCases.txt +# TestCaseFile= ManualCases.txt + +# (TestCaseFile is synonym for old term ConfigFile) + +# Following case specifies demo module settings. Demo module +# does not read any settings from file, so tags +# IniFile and TestCaseFile are not used. +# In the simplest case it is enough to specify only the +# name of the test module when adding new test module + +[New_Module] +ModuleName= t_oomharness_stif +TestCaseFile= c:\testframework\oomtest.cfg +[End_Module] + + +#Load testmoduleXXX, optionally with initialization file and/or test case files +#[New_Module] +#ModuleName= testmodulexxx + +#TestModuleXXX used initialization file +#IniFile= init.txt + +#TestModuleXXX used configuration file(s) +#TestCaseFile= testcases1.cfg +#TestCaseFile= testcases2.cfg +#TestCaseFile= manualtestcases.cfg + +#[End_Module] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + + + +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# Set STIFTestFramework logging overwrite parameters for Logger. +# Hardware and emulator environment logging path and styles can +# be configured from here to overwrite the Logger's implemented values. +# +# Settings description: +# - Indicates option for creation log directory/directories. If log directory/directories +# is/are not created by user they will make by software. +# + YES, Create log directory/directories if not allready exist. +# + NO, Log directory/directories not created. Only created one is used. +# +# - Overwrite emulator path setting. +# + Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined +# Logger's path 'D:\\LOGS\\Module\\' with those definition the path +# will be 'C:\LOGS\TestFramework\LOGS\Module\' +# +# - Overwrite emulator's logging format. +# + TXT, Log file(s) will be txt type(s), for example 'Module.txt'. +# + HTML, Log file(s) will be html type(s), for example 'Module.html'. +# +# - Overwrited emulator logging output source. +# + FILE, Logging to file(s). +# + RDEBUG, Logging to using rdebug(s). +# +# - Overwrite hardware path setting (Same description as above in emulator path). +# - Overwrite hardware's logging format(Same description as above in emulator format). +# - Overwrite hardware's logging output source(Same description as above in emulator output). +# +# - File Creation Mode indicates file overwriting if file exist. +# + OVERWRITE, Overwrites if file(s) exist. +# + APPEND, Continue logging after the old logging information if file(s) exist. +# +# - Will thread id include to the log filename. +# + YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'. +# + NO, No thread id to log file(s), Example filename 'Module.txt'. +# +# - Will time stamps include the to log file. +# + YES, Time stamp added to each line in log file(s). Time stamp is +# for example'12.Nov.2003 115958 LOGGING INFO' +# + NO, No time stamp(s). +# +# - Will line breaks include to the log file. +# + YES, Each logging event includes line break and next log event is in own line. +# + NO, No line break(s). +# +# - Will event ranking include to the log file. +# + YES, Event ranking number added to each line in log file(s). Ranking number +# depends on environment's tics, for example(includes time stamp also) +# '012 12.Nov.2003 115958 LOGGING INFO' +# + NO, No event ranking. +# + +[Logger_Defaults] + +#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#' + +#CreateLogDirectories= YES # Possible values: YES or NO + +#EmulatorBasePath= C:\LOGS\TestFramework\ +#EmulatorFormat= HTML # Possible values: TXT or HTML +#EmulatorOutput= FILE # Possible values: FILE or RDEBUG + +#HardwareBasePath= D:\LOGS\TestFramework\ +#HardwareFormat= HTML # Possible values: TXT or HTML +#HardwareOutput= FILE # Possible values: FILE or RDEBUG + +#FileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND + +#ThreadIdToLogFile= YES # Possible values: YES or NO +#WithTimeStamp= YES # Possible values: YES or NO +#WithLineBreak= YES # Possible values: YES or NO +#WithEventRanking= YES # Possible values: YES or NO + +[End_Logger_Defaults] +# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- + +# End of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/stub/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/stub/group/bld.inf Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +PRJ_PLATFORMS +DEFAULT + +PRJ_TESTEXPORTS +../../data/oomconfig.xml /epoc32/data/Z/private/10207218/oomconfig.xml + +PRJ_TESTMMPFILES + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/bwins/t_oomclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/bwins/t_oomclientu.def Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,9 @@ +EXPORTS + ?Configure@ROOMAllocSession@@QAEHVTUid@@III@Z @ 1 NONAME ; int ROOMAllocSession::Configure(class TUid, unsigned int, unsigned int, unsigned int) + ?Connect@ROOMAllocSession@@QAEHXZ @ 2 NONAME ; int ROOMAllocSession::Connect(void) + ?MemoryGood@ROOMAllocSession@@QAEHVTUid@@@Z @ 3 NONAME ; int ROOMAllocSession::MemoryGood(class TUid) + ?MemoryLow@ROOMAllocSession@@QAEHVTUid@@@Z @ 4 NONAME ; int ROOMAllocSession::MemoryLow(class TUid) + ?Reset@ROOMAllocSession@@QAEHXZ @ 5 NONAME ; int ROOMAllocSession::Reset(void) + ?StartAllocating@ROOMAllocSession@@QAEHXZ @ 6 NONAME ; int ROOMAllocSession::StartAllocating(void) + ?StopAllocating@ROOMAllocSession@@QAEHXZ @ 7 NONAME ; int ROOMAllocSession::StopAllocating(void) + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/clisrc/client.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/clisrc/client.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include "t_oomclient.h" +#include "../inc/clientserver.h" + +const TInt KServerDefaultMessageSlots = 1; //Number of message slots available per session. +const TInt KServerRetryCount = 2; + +static TInt StartServer() +// +// Start the server process. Simultaneous launching +// of two such processes should be detected when the second one attempts to +// create the server object, failing with KErrAlreadyExists. +// + { + const TUidType serverUid(KNullUid,KNullUid,KServerUid3); + RProcess server; + TInt r=server.Create(KAllocServerImg,KNullDesC,serverUid); + if (r!=KErrNone) + return r; + TRequestStatus stat; + server.Rendezvous(stat); + if (stat!=KRequestPending) + server.Kill(0); // abort startup + else + server.Resume(); // logon OK - start the server + User::WaitForRequest(stat); // wait for start or death + // we can't use the 'exit reason' if the server panicked as this + // is the panic 'reason' and may be '0' which cannot be distinguished + // from KErrNone + r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int(); + server.Close(); + return r; + } + +EXPORT_C TInt ROOMAllocSession::Connect() +// +// Connect to the server, attempting to start it if necessary +// + { + TInt retry=KServerRetryCount; + for (;;) + { + TInt r=CreateSession(KAllocServerName,TVersion(0,0,0),KServerDefaultMessageSlots); + if (r!=KErrNotFound && r!=KErrServerTerminated) + return r; + if (--retry==0) + return r; + r=StartServer(); + if (r!=KErrNone && r!=KErrAlreadyExists) + return r; + } + } + +EXPORT_C TInt ROOMAllocSession::Reset() + { + return SendReceive(EAllocServReset); + } + +EXPORT_C TInt ROOMAllocSession::StartAllocating() + { + return SendReceive(EAllocServStart); + } + +EXPORT_C TInt ROOMAllocSession::StopAllocating() + { + return SendReceive(EAllocServStop); + } + +EXPORT_C TInt ROOMAllocSession::MemoryLow(TUid aPlugin) + { + return SendReceive(EAllocServMemoryLow, TIpcArgs(aPlugin.iUid)); + } + +EXPORT_C TInt ROOMAllocSession::MemoryGood(TUid aPlugin) + { + return SendReceive(EAllocServMemoryGood, TIpcArgs(aPlugin.iUid)); + } + +EXPORT_C TInt ROOMAllocSession::Configure(TUid aPlugin, TUint aAllocRate, TUint aAllocInitial, TUint aAllocLimit) + { + return SendReceive(EAllocServConfig,TIpcArgs(aPlugin.iUid, aAllocRate, aAllocInitial, aAllocLimit)); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/eabi/t_oomclientu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/eabi/t_oomclientu.def Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,9 @@ +EXPORTS + _ZN16ROOMAllocSession10MemoryGoodE4TUid @ 1 NONAME + _ZN16ROOMAllocSession14StopAllocatingEv @ 2 NONAME + _ZN16ROOMAllocSession15StartAllocatingEv @ 3 NONAME + _ZN16ROOMAllocSession5ResetEv @ 4 NONAME + _ZN16ROOMAllocSession7ConnectEv @ 5 NONAME + _ZN16ROOMAllocSession9ConfigureE4TUidjjj @ 6 NONAME + _ZN16ROOMAllocSession9MemoryLowE4TUid @ 7 NONAME + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/group/bld.inf Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +PRJ_PLATFORMS +DEFAULT + +PRJ_TESTMMPFILES +t_oomallocserver.mmp +t_oomallocclient.mmp + +PRJ_TESTEXPORTS +../inc/t_oomclient.h ../../inc/t_oomclient.h diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/group/t_oomallocclient.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/group/t_oomallocclient.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include + +target t_oomclient.dll +targettype dll + +capability ALL -TCB + +// This is a SYSTEMINCLUDE macro containing the middleware +// layer specific include directories +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../inc + +//project server +sourcepath ..\clisrc\ + +source client.cpp + +library euser.lib diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/group/t_oomallocserver.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/group/t_oomallocserver.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include + +TARGET t_oomallocserver.exe +TARGETTYPE exe +UID 0 0x10286A3E + +// This is a SYSTEMINCLUDE macro containing the middleware +// layer specific include directories +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../inc + + +#ifdef ENABLE_ABIV2_MODE +DEBUGGABLE_UDEBONLY +#endif +SOURCEPATH ../srvsrc +SOURCE server.cpp +SOURCE CAllocManager.cpp + +library euser.lib diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/CAllocManager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/CAllocManager.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,131 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#ifndef CALLOCMANAGER_H +#define CALLOCMANAGER_H + +// INCLUDES +#include +#include + +// CLASS DECLARATION + +class CAllocSimulation : public CBase + { +public: + // Constructors and destructor + + /** + * Destructor. + */ + ~CAllocSimulation(); + + /** + * Two-phased constructor. + */ + static CAllocSimulation* NewL(TInt aAllocLimit, TInt aAllocInitial, + TInt aAllocRate, TUint aUid); + + /** + * Two-phased constructor. + */ + static CAllocSimulation* NewLC(TInt aAllocLimit, TInt aAllocInitial, + TInt aAllocRate, TUint aUid); + + void SimulationTick(); + void SetPaused(TBool aPaused); + void FreeMemory(); + + static TBool CompareTo(const TUint *aUid, const CAllocSimulation& aSelf); +private: + + /** + * Constructor for performing 1st stage construction + */ + CAllocSimulation(TInt aAllocLimit, TInt aAllocInitial, + TInt aAllocRate, TUint aUid); + + /** + * EPOC default constructor for performing 2nd stage construction + */ + void ConstructL(); + + TInt iAllocLimit; + TInt iAllocInitial; + TInt iAllocRate; + TUint iUid; + RChunk iChunk; + TBool iPaused; + TUint iAllocCurrent; + }; + +/** + * CCAllocManager + * + */ +class CAllocManager : public CBase + { +public: + // Constructors and destructor + + /** + * Destructor. + */ + ~CAllocManager(); + + /** + * Two-phased constructor. + */ + static CAllocManager* NewL(); + + /** + * Two-phased constructor. + */ + static CAllocManager* NewLC(); + + TInt Reset(); + TInt StartAllocating(); + TInt StopAllocating(); + void ConfigureL(TUint aPlugin, TUint aAllocRate, TUint aAllocInitial, TUint aAllocLimit); + TInt MemoryLow(TUint aPlugin); + TInt MemoryGood(TUint aPlugin); +private: + + /** + * Constructor for performing 1st stage construction + */ + CAllocManager(); + + /** + * EPOC default constructor for performing 2nd stage construction + */ + void ConstructL(); + + static TInt SimulationTickStatic(TAny *aPtr); + void SimulationTick(); + + TInt FindSimulation(TUint aUid); + + CPeriodic *iAllocationTimer; + RPointerArray iSimulations; + }; + +#endif // CALLOCMANAGER_H diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/clientserver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/clientserver.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#include + + +// server name + +_LIT(KAllocServerName,"t_oomAllocServer"); +_LIT(KAllocServerImg,"t_oomAllocServer"); +const TUid KServerUid3={0x10286A3E}; + +// A version must be specifyed when creating a session with the server + +const TUint KCountServMajorVersionNumber=0; +const TUint KCountServMinorVersionNumber=1; +const TUint KCountServBuildVersionNumber=1; + +IMPORT_C TInt StartThread(RThread& aServerThread); + + +// Function codes (opcodes) used in message passing between client and server +enum TAllocServRqst + { + EAllocServReset, + EAllocServConfig, + EAllocServStart, + EAllocServStop, + EAllocServMemoryLow, + EAllocServMemoryGood + }; + +enum TAllocServLeave +{ + ENonNumericString = 99 +}; diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/server.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/server.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include +#include "clientserver.h" +#include "callocmanager.h" + +enum TMyPanic + { + EPanicBadDescriptor, + EPanicIllegalFunction, + EPanicAlreadyReceiving + }; + +void PanicClient(const RMessagePtr2& aMessage,TMyPanic TMyPanic); + +class CShutdown : public CTimer + { + enum {KMyShutdownDelay=0x200000}; // approx 2s +public: + inline CShutdown(); + inline void ConstructL(); + inline void Start(); +private: + void RunL(); + }; + +class CMyServer : public CServer2 + { +public: + static CServer2* NewLC(); + void AddSession(); + void DropSession(); + void Send(const TDesC& aMessage); + CAllocManager& AllocManager(); + ~CMyServer(); +private: + CMyServer(); + void ConstructL(); + void DefinePropertiesL(); + CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; +private: + TInt iSessionCount; + CShutdown iShutdown; + CAllocManager *iAllocManager; + }; + +class CMySession : public CSession2 + { +public: + CMySession(); + void CreateL(); + void Send(const TDesC& aMessage); +private: + ~CMySession(); + inline CMyServer& Server(); + void ServiceL(const RMessage2& aMessage); + void ServiceError(const RMessage2& aMessage,TInt aError); + inline TBool ReceivePending() const; +private: + RMessagePtr2 iReceiveMsg; + TInt iReceiveLen; + }; + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/t_oomclient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/t_oomclient.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __T_CLIENT_H__ +#define __T_CLIENT_H__ + +#include + +class ROOMAllocSession : public RSessionBase + { +public: + IMPORT_C TInt Connect(); + IMPORT_C TInt Reset(); + IMPORT_C TInt StartAllocating(); + IMPORT_C TInt StopAllocating(); + IMPORT_C TInt Configure(TUid aPlugin, TUint aAllocRate, TUint aAllocInitial, TUint aAllocLimit); + IMPORT_C TInt MemoryLow(TUid aPlugin); + IMPORT_C TInt MemoryGood(TUid aPlugin); + }; + +#endif diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/srvsrc/CAllocManager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/srvsrc/CAllocManager.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,203 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include "CAllocManager.h" +#include +#include "t_oomdummyplugin_properties.h" + +const TInt KOneSecond = 1000000; + +CAllocManager::CAllocManager() + { + // No implementation required + } + +CAllocManager::~CAllocManager() + { + delete iAllocationTimer; + iSimulations.ResetAndDestroy(); + } + +CAllocManager* CAllocManager::NewLC() + { + CAllocManager* self = new (ELeave) CAllocManager(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CAllocManager* CAllocManager::NewL() + { + CAllocManager* self = CAllocManager::NewLC(); + CleanupStack::Pop(); // self; + return self; + } + +void CAllocManager::ConstructL() + { + iAllocationTimer = CPeriodic::NewL(CActive::EPriorityStandard); + } + +TInt CAllocManager::SimulationTickStatic(TAny *aPtr) + { + ((CAllocManager*)aPtr)->SimulationTick(); + return KErrNone; + } + +void CAllocManager::SimulationTick() + { + for(TInt i=iSimulations.Count()-1; i>=0; i--) + { + iSimulations[i]->SimulationTick(); + } + } + +TInt CAllocManager::Reset() + { + StopAllocating(); + iSimulations.ResetAndDestroy(); + return KErrNone; + } + +TInt CAllocManager::StartAllocating() + { + iAllocationTimer->Cancel(); + iAllocationTimer->Start(KOneSecond, KOneSecond, TCallBack(SimulationTickStatic, this)); + return KErrNone; + } + +TInt CAllocManager::StopAllocating() + { + iAllocationTimer->Cancel(); + return KErrNone; + } + +void CAllocManager::ConfigureL(TUint aPlugin, TUint aAllocRate, TUint aAllocInitial, TUint aAllocLimit) + { + TInt sim = FindSimulation(aPlugin); + if(sim>=0) + { + delete iSimulations[sim]; + iSimulations.Remove(sim); + } + CAllocSimulation* newsim = CAllocSimulation::NewLC(aAllocLimit, aAllocInitial, aAllocRate, aPlugin); + iSimulations.AppendL(newsim); + CleanupStack::Pop(newsim); + } + +TInt CAllocManager::MemoryLow(TUint aPlugin) + { + TInt sim = FindSimulation(aPlugin); + if(sim>=0) + { + iSimulations[sim]->SetPaused(ETrue); + iSimulations[sim]->FreeMemory(); + return KErrNone; + } + else return KErrNotFound; + } + +TInt CAllocManager::MemoryGood(TUint aPlugin) + { + TInt sim = FindSimulation(aPlugin); + if(sim>=0) + { + iSimulations[sim]->SetPaused(EFalse); + return KErrNone; + } + else return KErrNotFound; + } + +TInt CAllocManager::FindSimulation(TUint aUid) + { + return iSimulations.Find(aUid, CAllocSimulation::CompareTo); + } + +CAllocSimulation::CAllocSimulation(TInt aAllocLimit, TInt aAllocInitial, + TInt aAllocRate, TUint aUid) : + iAllocLimit(aAllocLimit), + iAllocInitial(aAllocInitial), + iAllocRate(aAllocRate), + iUid(aUid) + { + // No implementation required + } + +CAllocSimulation::~CAllocSimulation() + { + iChunk.Close(); + } + +CAllocSimulation* CAllocSimulation::NewLC(TInt aAllocLimit, TInt aAllocInitial, + TInt aAllocRate, TUint aUid) + { + CAllocSimulation* self = new (ELeave) CAllocSimulation(aAllocLimit, aAllocInitial, + aAllocRate, aUid); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CAllocSimulation* CAllocSimulation::NewL(TInt aAllocLimit, TInt aAllocInitial, + TInt aAllocRate, TUint aUid) + { + CAllocSimulation* self = CAllocSimulation::NewLC(aAllocLimit, aAllocInitial, + aAllocRate, aUid); + CleanupStack::Pop(); // self; + return self; + } + +void CAllocSimulation::ConstructL() + { + User::LeaveIfError(iChunk.CreateLocal(iAllocInitial, iAllocLimit)); + } + +void CAllocSimulation::SimulationTick() + { + if(!iPaused) + { + TUint allocnext = iAllocCurrent + iAllocRate; + if(allocnext < iAllocInitial) allocnext = iAllocInitial; + else if(allocnext > iAllocLimit) allocnext = iAllocLimit; + if(iAllocCurrent != allocnext && KErrNone == iChunk.Adjust(iAllocCurrent)) + { + iAllocCurrent = allocnext; + RProperty::Set(KUidOomPropertyCategory, iUid + KOOMDummyPluginCurrentAllocationBytes, iAllocCurrent); + } + } + } + +void CAllocSimulation::SetPaused(TBool aPaused) + { + iPaused = aPaused; + } + +void CAllocSimulation::FreeMemory() + { + iChunk.Adjust(0); + iAllocCurrent = 0; + RProperty::Set(KUidOomPropertyCategory, iUid + KOOMDummyPluginCurrentAllocationBytes, iAllocCurrent); + } + +TBool CAllocSimulation::CompareTo(const TUint* aUid, const CAllocSimulation& aSelf) + { + return *aUid==aSelf.iUid; + } + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/srvsrc/server.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/srvsrc/server.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,277 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include "server.h" +#include +#include "t_oomdummyplugin_properties.h" + +inline CShutdown::CShutdown() + :CTimer(-1) + {CActiveScheduler::Add(this);} +inline void CShutdown::ConstructL() + {CTimer::ConstructL();} +inline void CShutdown::Start() + {After(KMyShutdownDelay);} + +inline CMyServer::CMyServer() + :CServer2(CActive::EPriorityStandard, ESharableSessions) + {} + +inline CMySession::CMySession() + {} +inline CMyServer& CMySession::Server() + {return *static_cast(const_cast(CSession2::Server()));} +inline TBool CMySession::ReceivePending() const + {return !iReceiveMsg.IsNull();} + + +/////////////////////// + +void CMySession::CreateL() +// +// 2nd phase construct for sessions - called by the CServer framework +// + { + Server().AddSession(); + } + +CMySession::~CMySession() + { + Server().DropSession(); + } + +void CMySession::Send(const TDesC& aMessage) +// +// Deliver the message to the client, truncating if required +// If the write fails, panic the client, not the sender +// + { + if (ReceivePending()) + { + TPtrC m(aMessage); + if (iReceiveLenConstructL(); + return self; + } + +void CMyServer::ConstructL() +// +// 2nd phase construction - ensure the timer and server objects are running +// + { + StartL(KAllocServerName); + iShutdown.ConstructL(); + // ensure that the server still exits even if the 1st client fails to connect + iShutdown.Start(); + DefinePropertiesL(); + iAllocManager = CAllocManager::NewL(); + } + +_LIT_SECURITY_POLICY_PASS(KAlwaysPass); + +void CMyServer::DefinePropertiesL() + { + TInt err; + for(TUint i=KUidOOMDummyPluginFirstImplementation;i<=KUidOOMDummyPluginLastImplementation;i++) + { + err = RProperty::Define(KUidOomPropertyCategory, i + KOOMDummyPluginLowMemoryCount, RProperty::EInt, KAlwaysPass, KAlwaysPass); + if(err != KErrNone && err != KErrAlreadyExists) User::Leave(err); + err = RProperty::Define(KUidOomPropertyCategory, i + KOOMDummyPluginGoodMemoryCount, RProperty::EInt, KAlwaysPass, KAlwaysPass); + if(err != KErrNone && err != KErrAlreadyExists) User::Leave(err); + err = RProperty::Define(KUidOomPropertyCategory, i + KOOMDummyPluginCurrentAllocationBytes, RProperty::EInt, KAlwaysPass, KAlwaysPass); + if(err != KErrNone && err != KErrAlreadyExists) User::Leave(err); + err = RProperty::Define(KUidOomPropertyCategory, i + KOOMDummyPluginBytesRequested, RProperty::EInt, KAlwaysPass, KAlwaysPass); + if(err != KErrNone && err != KErrAlreadyExists) User::Leave(err); + } + } + +CSession2* CMyServer::NewSessionL(const TVersion&,const RMessage2&) const +// +// Cretae a new client session. This should really check the version number. +// + { + return new(ELeave) CMySession(); + } + +void CMyServer::AddSession() +// +// A new session is being created +// Cancel the shutdown timer if it was running +// + { + ++iSessionCount; + iShutdown.Cancel(); + } + +void CMyServer::DropSession() +// +// A session is being destroyed +// Start the shutdown timer if it is the last session. +// + { + if (--iSessionCount==0) + iShutdown.Start(); + } + +void CMyServer::Send(const TDesC& aMessage) +// +// Pass on the signal to all clients +// + { + iSessionIter.SetToFirst(); + CSession2* s; + while ((s=iSessionIter++)!=0) + static_cast(s)->Send(aMessage); + } + +CMyServer::~CMyServer() + { + delete iAllocManager; + } + +CAllocManager& CMyServer::AllocManager() + { + return *iAllocManager; + } + +void PanicClient(const RMessagePtr2& aMessage,TMyPanic aPanic) +// +// RMessage::Panic() also completes the message. This is: +// (a) important for efficient cleanup within the kernel +// (b) a problem if the message is completed a second time +// + { + _LIT(KPanic,"MyServer"); + aMessage.Panic(KPanic,aPanic); + } + +static void RunServerL() +// +// Perform all server initialisation, in particular creation of the +// scheduler and server and then run the scheduler +// + { + // naming the server thread after the server helps to debug panics + User::LeaveIfError(RThread::RenameMe(KAllocServerName)); + // + // create and install the active scheduler we need + CActiveScheduler* s=new(ELeave) CActiveScheduler; + CleanupStack::PushL(s); + CActiveScheduler::Install(s); + // + // create the server (leave it on the cleanup stack) + CMyServer::NewLC(); + // + // Initialisation complete, now signal the client + RProcess::Rendezvous(KErrNone); + // + // Ready to run + CActiveScheduler::Start(); + // + // Cleanup the server and scheduler + CleanupStack::PopAndDestroy(2); + } + +TInt E32Main() +// +// Server process entry-point +// + { + __UHEAP_MARK; + // + CTrapCleanup* cleanup=CTrapCleanup::New(); + TInt r=KErrNoMemory; + if (cleanup) + { + TRAP(r,RunServerL()); + delete cleanup; + } + // + __UHEAP_MARKEND; + return r; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/data/t_oomdummyapp.rls --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/data/t_oomdummyapp.rls Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +// LOCALISATION STRINGS + +// Caption string for app. +#define qtn_caption_string "t_oomdummyapp" + +// First item in "Options" menu pane +#define qtn_command1 "Message" + +// Second item in "Options" menu pane +#define qtn_command2 "Message from file" + +#define qtn_help "Help" + +#define qtn_about "About" + +// Third item in "Options" menu pane +#define qtn_exit "Exit" + +// When user requests ECommand1 event, text below is shown. +#define qtn_command1_text "OOM dummy app" + +#define qtn_loc_resource_file_1 "\\resource\\apps\\t_oomdummyapp_0xE6CFBA00" + +#define qtn_about_dialog_title "About" + +#define qtn_about_dialog_text "t_oomdummyapp Version 1.0.0\n\nAuthor: \n\nSupport: support@mycompany.com\n\n(c) Your copyright notice" + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/data/t_oomdummyapp.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/data/t_oomdummyapp.rss Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,188 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +// RESOURCE IDENTIFIER +NAME T_OO // 4 letter ID + + +// INCLUDES +#include +#include +#include +#include +#include "t_oomdummyapp.hrh" +#include "t_oomdummyapp.rls" + +// RESOURCE DEFINITIONS +// ----------------------------------------------------------------------------- +// +// Define the resource file signature +// This resource should be empty. +// +// ----------------------------------------------------------------------------- +// +RESOURCE RSS_SIGNATURE + { + } + +// ----------------------------------------------------------------------------- +// +// Default Document Name +// +// ----------------------------------------------------------------------------- +// +RESOURCE TBUF r_default_document_name + { + buf="T_OO"; + } + +// ----------------------------------------------------------------------------- +// +// Define default menu and CBA key. +// +// ----------------------------------------------------------------------------- +// +RESOURCE EIK_APP_INFO + { + menubar = r_menubar; + cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT; + } + + +// ----------------------------------------------------------------------------- +// +// r_menubar +// Main menubar +// +// ----------------------------------------------------------------------------- +// +RESOURCE MENU_BAR r_menubar + { + titles = + { + MENU_TITLE { menu_pane = r_menu; } + }; + } + + +// ----------------------------------------------------------------------------- +// +// r_menu +// Menu for "Options" +// +// ----------------------------------------------------------------------------- +// +RESOURCE MENU_PANE r_menu + { + items = + { + // added the new Options menu command here + MENU_ITEM + { + command = ECommand1; + txt = qtn_command1; + }, + MENU_ITEM + { + command = ECommand2; + txt = qtn_command2; + }, + MENU_ITEM + { + command = EHelp; + txt = qtn_help; + }, + MENU_ITEM + { + command = EAbout; + txt = qtn_about; + }, + MENU_ITEM + { + command = EAknSoftkeyExit; + txt = qtn_exit; + } + }; + } + +// ----------------------------------------------------------------------------- +// +// About dialog resource. +// +// ----------------------------------------------------------------------------- +// +RESOURCE DIALOG r_about_query_dialog + { + flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow; + buttons = R_AVKON_SOFTKEYS_OK_EMPTY; + items= + { + DLG_LINE + { + type = EAknCtPopupHeadingPane; + id = EAknMessageQueryHeaderId; + itemflags = EEikDlgItemNonFocusing; + control = AVKON_HEADING + { + }; + }, + DLG_LINE + { + type = EAknCtMessageQuery; + id = EAknMessageQueryContentId; + control = AVKON_MESSAGE_QUERY + { + }; + } + }; + } + + +// ----------------------------------------------------------------------------- +// +// Resources for messages. +// +// ----------------------------------------------------------------------------- +// +RESOURCE TBUF32 r_caption_string { buf=qtn_caption_string; } +RESOURCE TBUF32 r_about_dialog_title { buf=qtn_about_dialog_title; } +RESOURCE TBUF r_about_dialog_text { buf=qtn_about_dialog_text; } +RESOURCE TBUF r_command1_text { buf=qtn_command1_text; } + + +// ---------------------------------------------------------------------------- +// +// r_localisable_app_info +// +// ---------------------------------------------------------------------------- +// +RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info + { + short_caption = qtn_caption_string; + caption_and_icon = + CAPTION_AND_ICON_INFO + { + caption = qtn_caption_string; + + number_of_icons = 1; + icon_file = "\\resource\\apps\\t_oomdummyapp_0xE6CFBA00.mif"; + }; + } + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/data/t_oomdummyapp_reg.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/data/t_oomdummyapp_reg.rss Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include "t_oomdummyapp.hrh" +#include "t_oomdummyapp.rls" +#include +#include + +UID2 KUidAppRegistrationResourceFile +UID3 _UID3 + +RESOURCE APP_REGISTRATION_INFO + { + app_file="t_oomdummyapp_0xE6CFBA00"; + localisable_resource_file = qtn_loc_resource_file_1; + localisable_resource_id = R_LOCALISABLE_APP_INFO; + + embeddability=KAppNotEmbeddable; + newfile=KAppDoesNotSupportNewFile; + } + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/gfx/qgn_menu_t_oomdummyapp.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/gfx/qgn_menu_t_oomdummyapp.svg Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/group/Icons_scalable_dc.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/group/Icons_scalable_dc.mk Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,54 @@ +# ============================================================================ +# Name : Icons_scalable_dc.mk +# Part of : t_oomdummyapp +# +# Description: This is file for creating .mif file (scalable icon) +# +# ============================================================================ + + +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=$(EPOCROOT)epoc32\release\$(PLATFORM)\$(CFG)\Z +else +ZDIR=$(EPOCROOT)epoc32\data\z +endif + +TARGETDIR=$(ZDIR)\resource\apps +ICONTARGETFILENAME=$(TARGETDIR)\t_oomdummyapp_0xE6CFBA00.mif + +ICONDIR=..\gfx + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +# ---------------------------------------------------------------------------- +# NOTE: if you have JUSTINTIME enabled for your S60 3rd FP1 or newer SDK +# and this command crashes, consider adding "/X" to the command line. +# See +# ---------------------------------------------------------------------------- + +RESOURCE : $(ICONTARGETFILENAME) + +$(ICONTARGETFILENAME) : $(ICONDIR)\qgn_menu_t_oomdummyapp.svg + mifconv $(ICONTARGETFILENAME) \ + /c32 $(ICONDIR)\qgn_menu_t_oomdummyapp.svg + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/group/bld.inf Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +PRJ_PLATFORMS +DEFAULT + +PRJ_TESTMMPFILES + +gnumakefile icons_scalable_dc.mk +//gnumakefile ..\help\build_help.mk + +t_oomdummyapp.mmp diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/group/t_oomdummyapp.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/group/t_oomdummyapp.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include + +TARGET t_oomdummyapp_0xE6CFBA00.exe +TARGETTYPE exe +UID 0x100039CE 0xE6CFBA00 + +// This is a SYSTEMINCLUDE macro containing the middleware +// layer specific include directories +MW_LAYER_SYSTEMINCLUDE + +SOURCEPATH ../src +SOURCE t_oomdummyapp.cpp +SOURCE t_oomdummyappApplication.cpp +SOURCE t_oomdummyappAppView.cpp +SOURCE t_oomdummyappAppUi.cpp +SOURCE t_oomdummyappDocument.cpp +SOURCE CMsgHandler.cpp + +SOURCEPATH ../data + +START RESOURCE t_oomdummyapp.rss +HEADER +TARGET t_oomdummyapp_0xE6CFBA00 +TARGETPATH resource/apps +END //RESOURCE + +START RESOURCE t_oomdummyapp_reg.rss +TARGET t_oomdummyapp_0xE6CFBA00_reg +TARGETPATH /private/10003a3f/apps +END //RESOURCE + +USERINCLUDE ../inc +USERINCLUDE ../../inc +USERINCLUDE ../help + +LIBRARY euser.lib +LIBRARY apparc.lib +LIBRARY cone.lib +LIBRARY eikcore.lib +LIBRARY avkon.lib +LIBRARY commonengine.lib +LIBRARY efsrv.lib +LIBRARY estor.lib +LIBRARY aknnotify.lib +LIBRARY hlplch.lib +LIBRARY oommonitor.lib + +LANG SC + +VENDORID 0 +SECUREID 0xE6CFBA00 +CAPABILITY ReadUserData WriteDeviceData + +#ifdef ENABLE_ABIV2_MODE + DEBUGGABLE_UDEBONLY +#endif + +EPOCHEAPSIZE 0x1000 0x1000000 +EPOCSTACKSIZE 0x4000 + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/Custom.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/Custom.xml Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/build_help.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/build_help.mk Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,45 @@ +# ============================================================================ +# Name : build_help.mk +# Part of : t_oomdummyapp +# ============================================================================ +# Name : build_help.mk +# Part of : t_oomdummyapp +# +# Description: This make file will build the application help file (.hlp) +# +# ============================================================================ + +do_nothing : + @rem do_nothing + +# build the help from the MAKMAKE step so the header file generated +# will be found by cpp.exe when calculating the dependency information +# in the mmp makefiles. + +MAKMAKE : t_oomdummyapp_0xE6CFBA00.hlp +t_oomdummyapp_0xE6CFBA00.hlp : t_oomdummyapp.xml t_oomdummyapp.cshlp Custom.xml + cshlpcmp t_oomdummyapp.cshlp +ifeq (WINS,$(findstring WINS, $(PLATFORM))) + copy t_oomdummyapp_0xE6CFBA00.hlp $(EPOCROOT)epoc32\$(PLATFORM)\c\resource\help +endif + +BLD : do_nothing + +CLEAN : + del t_oomdummyapp_0xE6CFBA00.hlp + del t_oomdummyapp_0xE6CFBA00.hlp.hrh + +LIB : do_nothing + +CLEANLIB : do_nothing + +RESOURCE : do_nothing + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo t_oomdummyapp_0xE6CFBA00.hlp + +FINAL : do_nothing diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/t_oomdummyapp.cshlp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/t_oomdummyapp.cshlp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,19 @@ + + + + +0xE6CFBA00 + + + + + temp\ + + + + t_oomdummyapp.xml + + t_oomdummyapp_0xE6CFBA00.hlp + custom.xml + + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/t_oomdummyapp.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/t_oomdummyapp.xml Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,13 @@ + + + + + +t_oomdummyappGeneral Information +General Information + +General Information +

Insert your help here.

+

+
+
diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/CMsgHandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/CMsgHandler.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CMSGHANDLER_H +#define CMSGHANDLER_H + +#include // For CActive, link against: euser.lib +#include +#include "t_oomdummyappAppUi.h" + +class CMsgHandler : public CActive + { +public: + // Cancel and destroy + ~CMsgHandler(); + + // Two-phased constructor. + static CMsgHandler* NewL(Ct_oomdummyappAppUi& aOwner); + + // Two-phased constructor. + static CMsgHandler* NewLC(Ct_oomdummyappAppUi& aOwner); + +public: + // New functions + // Function for making the initial request + void StartL(); + +private: + // C++ constructor + CMsgHandler(Ct_oomdummyappAppUi& aOwner); + + // Second-phase constructor + void ConstructL(); + +private: + // From CActive + // Handle completion + void RunL(); + + // How to cancel me + void DoCancel(); + + // Override to handle leaves from RunL(). Default implementation causes + // the active scheduler to panic. + TInt RunError(TInt aError); + +private: + TInt iState; // State of the active object + RMsgQueue iMsgQueue; // messages from the harness + Ct_oomdummyappAppUi& iOwner; + + }; + +#endif // CMSGHANDLER_H diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyapp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyapp.hrh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __T_OOMDUMMYAPP_HRH__ +#define __T_OOMDUMMYAPP_HRH__ + +#define _UID3 0xE6CFBA00 + +// t_oomdummyapp enumerate command codes +enum Tt_oomdummyappIds + { + ECommand1 = 0x6001, // start value must not be 0 + ECommand2, + EHelp, + EAbout + }; + +#endif // __T_OOMDUMMYAPP_HRH__ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyapp.pan --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyapp.pan Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __T_OOMDUMMYAPP_PAN__ +#define __T_OOMDUMMYAPP_PAN__ + +/** t_oomdummyapp application panic codes */ +enum Tt_oomdummyappPanics + { + Et_oomdummyappUi = 1 + // add further panics here + }; + +inline void Panic(Tt_oomdummyappPanics aReason) + { + _LIT(applicationName, "t_oomdummyapp"); + User::Panic(applicationName, aReason); + } + +#endif // __T_OOMDUMMYAPP_PAN__ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappAppUi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappAppUi.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,104 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __T_OOMDUMMYAPPAPPUI_h__ +#define __T_OOMDUMMYAPPAPPUI_h__ + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class Ct_oomdummyappAppView; +class CMsgHandler; + +// CLASS DECLARATION +/** + * Ct_oomdummyappAppUi application UI class. + * Interacts with the user through the UI and request message processing + * from the handler class + */ +class Ct_oomdummyappAppUi : public CAknAppUi + { +public: + + void SetPriorityBusy(); + void SetPriorityHigh(); + void SetPriorityNormal(); + + // Constructors and destructor + + /** + * ConstructL. + * 2nd phase constructor. + */ + void ConstructL(); + + /** + * Ct_oomdummyappAppUi. + * C++ default constructor. This needs to be public due to + * the way the framework constructs the AppUi + */ + Ct_oomdummyappAppUi(); + + /** + * ~Ct_oomdummyappAppUi. + * Virtual Destructor. + */ + virtual ~Ct_oomdummyappAppUi(); + + void HandleHarnessCommandL(TInt aCommand); +private: + // Functions from base classes + + /** + * From CEikAppUi, HandleCommandL. + * Takes care of command handling. + * @param aCommand Command to be handled. + */ + void HandleCommandL(TInt aCommand); + + /** + * HandleStatusPaneSizeChange. + * Called by the framework when the application status pane + * size is changed. + */ + void HandleStatusPaneSizeChange(); + + /** + * From CCoeAppUi, HelpContextL. + * Provides help context for the application. + * size is changed. + */ + CArrayFix* HelpContextL() const; + +private: + // Data + + /** + * The application view + * Owned by Ct_oomdummyappAppUi + */ + Ct_oomdummyappAppView* iAppView; + CMsgHandler* iMsgHandler; + + }; + +#endif // __T_OOMDUMMYAPPAPPUI_h__ +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappAppView.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappAppView.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __T_OOMDUMMYAPPAPPVIEW_h__ +#define __T_OOMDUMMYAPPAPPVIEW_h__ + +// INCLUDES +#include + +// CLASS DECLARATION +class Ct_oomdummyappAppView : public CCoeControl + { +public: + // New methods + + /** + * NewL. + * Two-phased constructor. + * Create a Ct_oomdummyappAppView object, which will draw itself to aRect. + * @param aRect The rectangle this view will be drawn to. + * @return a pointer to the created instance of Ct_oomdummyappAppView. + */ + static Ct_oomdummyappAppView* NewL(const TRect& aRect); + + /** + * NewLC. + * Two-phased constructor. + * Create a Ct_oomdummyappAppView object, which will draw itself + * to aRect. + * @param aRect Rectangle this view will be drawn to. + * @return A pointer to the created instance of Ct_oomdummyappAppView. + */ + static Ct_oomdummyappAppView* NewLC(const TRect& aRect); + + /** + * ~Ct_oomdummyappAppView + * Virtual Destructor. + */ + virtual ~Ct_oomdummyappAppView(); + +public: + // Functions from base classes + + /** + * From CCoeControl, Draw + * Draw this Ct_oomdummyappAppView to the screen. + * @param aRect the rectangle of this view that needs updating + */ + void Draw(const TRect& aRect) const; + + /** + * From CoeControl, SizeChanged. + * Called by framework when the view size is changed. + */ + virtual void SizeChanged(); + +private: + // Constructors + + /** + * ConstructL + * 2nd phase constructor. + * Perform the second phase construction of a + * Ct_oomdummyappAppView object. + * @param aRect The rectangle this view will be drawn to. + */ + void ConstructL(const TRect& aRect); + + /** + * Ct_oomdummyappAppView. + * C++ default constructor. + */ + Ct_oomdummyappAppView(); + + }; + +#endif // __T_OOMDUMMYAPPAPPVIEW_h__ +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappApplication.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappApplication.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __T_OOMDUMMYAPPAPPLICATION_H__ +#define __T_OOMDUMMYAPPAPPLICATION_H__ + +// INCLUDES +#include +#include "t_oomdummyapp.hrh" + +// UID for the application; +// this should correspond to the uid defined in the mmp file +const TUid KUidt_oomdummyappApp = + { + _UID3 + }; + +// CLASS DECLARATION + +/** + * Ct_oomdummyappApplication application class. + * Provides factory to create concrete document object. + * An instance of Ct_oomdummyappApplication is the application part of the + * AVKON application framework for the t_oomdummyapp example application. + */ +class Ct_oomdummyappApplication : public CAknApplication + { +public: + Ct_oomdummyappApplication(TUid aUid, TUint aAlloc); + // Functions from base classes + + /** + * From CApaApplication, AppDllUid. + * @return Application's UID (KUidt_oomdummyappApp). + */ + TUid AppDllUid() const; + + ~Ct_oomdummyappApplication(); +protected: + // Functions from base classes + + /** + * From CApaApplication, CreateDocumentL. + * Creates Ct_oomdummyappDocument document object. The returned + * pointer in not owned by the Ct_oomdummyappApplication object. + * @return A pointer to the created document object. + */ + CApaDocument* CreateDocumentL(); + +private: + TUid iUID; + TUint iAlloc; + TAny* iMemory; + }; + +#endif // __T_OOMDUMMYAPPAPPLICATION_H__ +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappDocument.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappDocument.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __T_OOMDUMMYAPPDOCUMENT_h__ +#define __T_OOMDUMMYAPPDOCUMENT_h__ + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class Ct_oomdummyappAppUi; +class CEikApplication; + +// CLASS DECLARATION + +/** + * Ct_oomdummyappDocument application class. + * An instance of class Ct_oomdummyappDocument is the Document part of the + * AVKON application framework for the t_oomdummyapp example application. + */ +class Ct_oomdummyappDocument : public CAknDocument + { +public: + // Constructors and destructor + + /** + * NewL. + * Two-phased constructor. + * Construct a Ct_oomdummyappDocument for the AVKON application aApp + * using two phase construction, and return a pointer + * to the created object. + * @param aApp Application creating this document. + * @return A pointer to the created instance of Ct_oomdummyappDocument. + */ + static Ct_oomdummyappDocument* NewL(CEikApplication& aApp); + + /** + * NewLC. + * Two-phased constructor. + * Construct a Ct_oomdummyappDocument for the AVKON application aApp + * using two phase construction, and return a pointer + * to the created object. + * @param aApp Application creating this document. + * @return A pointer to the created instance of Ct_oomdummyappDocument. + */ + static Ct_oomdummyappDocument* NewLC(CEikApplication& aApp); + + /** + * ~Ct_oomdummyappDocument + * Virtual Destructor. + */ + virtual ~Ct_oomdummyappDocument(); + +public: + // Functions from base classes + + /** + * CreateAppUiL + * From CEikDocument, CreateAppUiL. + * Create a Ct_oomdummyappAppUi object and return a pointer to it. + * The object returned is owned by the Uikon framework. + * @return Pointer to created instance of AppUi. + */ + CEikAppUi* CreateAppUiL(); + +private: + // Constructors + + /** + * ConstructL + * 2nd phase constructor. + */ + void ConstructL(); + + /** + * Ct_oomdummyappDocument. + * C++ default constructor. + * @param aApp Application creating this document. + */ + Ct_oomdummyappDocument(CEikApplication& aApp); + + }; + +#endif // __T_OOMDUMMYAPPDOCUMENT_h__ +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappmsgs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappmsgs.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,8 @@ +#ifndef T_OOMDUMMAPPMSGS_H_ +#define T_OOMDUMMAPPMSGS_H_ + +const TInt KOomDummyAppSetBusy = 5; +const TInt KOomDummyAppSetNormalPriority = 6; +const TInt KOomDummyAppSetHighPriority = 7; + +#endif /*T_OOMDUMMAPPMSGS_H_*/ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/sis/backup_registration.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/sis/backup_registration.xml Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,5 @@ + + + + + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/sis/t_oomdummyapp_S60_3_X_v_1_0_0.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/sis/t_oomdummyapp_S60_3_X_v_1_0_0.pkg Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,37 @@ +; Installation file for t_oomdummyapp application +; +; This is an auto-generated PKG file by Carbide. +; This file uses variables specific to Carbide builds that will not work +; on command-line builds. If you want to use this generated PKG file from the +; command-line tools you will need to modify the variables with the appropriate +; values: $(EPOCROOT), $(PLATFORM), $(TARGET) +; +;Language - standard language definitions +&EN + +; standard SIS file header +#{"t_oomdummyapp"},(0xE6CFBA00),1,0,0 + +;Localised Vendor name +%{"Vendor-EN"} + +;Unique Vendor name +:"Vendor" + +;Supports Series 60 v 3.0 +[0x101F7961], 0, 0, 0, {"Series60ProductID"} + +;Files to install +;You should change the source paths to match that of your environment +; +"$(EPOCROOT)Epoc32\release\$(PLATFORM)\$(TARGET)\t_oomdummyapp_0xE6CFBA00.exe" -"!:\sys\bin\t_oomdummyapp_0xE6CFBA00.exe" +"$(EPOCROOT)Epoc32\data\z\resource\apps\t_oomdummyapp_0xE6CFBA00.rsc" -"!:\resource\apps\t_oomdummyapp_0xE6CFBA00.rsc" +"$(EPOCROOT)Epoc32\data\z\private\10003a3f\apps\t_oomdummyapp_0xE6CFBA00_reg.rsc" -"!:\private\10003a3f\import\apps\t_oomdummyapp_0xE6CFBA00_reg.rsc" +"$(EPOCROOT)Epoc32\data\z\resource\apps\t_oomdummyapp_0xE6CFBA00.mif" -"!:\resource\apps\t_oomdummyapp_0xE6CFBA00.mif" +"..\help\t_oomdummyapp_0xE6CFBA00.hlp" -"!:\resource\help\t_oomdummyapp_0xE6CFBA00.hlp" + +; Add any installation notes if applicable +;"t_oomdummyapp.txt" -"!:\private\E6CFBA00\t_oomdummyapp.txt" + +;required for application to be covered by backup/restore facility +"..\sis\backup_registration.xml" -"!:\private\E6CFBA00\backup_registration.xml" diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/CMsgHandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/CMsgHandler.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include "CMsgHandler.h" + +CMsgHandler::CMsgHandler(Ct_oomdummyappAppUi& aOwner) : + CActive(EPriorityStandard), // Standard priority + iOwner(aOwner) + { + } + +CMsgHandler* CMsgHandler::NewLC(Ct_oomdummyappAppUi& aOwner) + { + CMsgHandler* self = new (ELeave) CMsgHandler(aOwner); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +CMsgHandler* CMsgHandler::NewL(Ct_oomdummyappAppUi& aOwner) + { + CMsgHandler* self = CMsgHandler::NewLC(aOwner); + CleanupStack::Pop(); // self; + return self; + } + +void CMsgHandler::ConstructL() + { + User::LeaveIfError(iMsgQueue.Open(15)); // Initialize message queue from process parameters + CActiveScheduler::Add(this); // Add to scheduler + StartL(); + } + +CMsgHandler::~CMsgHandler() + { + Cancel(); // Cancel any request, if outstanding + iMsgQueue.Close(); // Destroy the RMsgQueue object + // Delete instance variables if any + } + +void CMsgHandler::DoCancel() + { + iMsgQueue.CancelDataAvailable(); + } + +void CMsgHandler::StartL() + { + Cancel(); // Cancel any request, just to be sure + iMsgQueue.NotifyDataAvailable(iStatus); + SetActive(); // Tell scheduler a request is active + } + +void CMsgHandler::RunL() + { + TInt command; + while(KErrNone==iMsgQueue.Receive(command)) + { + iOwner.HandleHarnessCommandL(command); + } + StartL(); + } + +TInt CMsgHandler::RunError(TInt aError) + { + return aError; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyapp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyapp.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +// INCLUDE FILES +#include +#include "t_oomdummyappApplication.h" + +_LIT(KFakeUidParam,"uid="); +_LIT(KAllocParam,"alloc="); +LOCAL_C CApaApplication* NewApplication() + { + TUid uid(KUidt_oomdummyappApp); + TUint alloc = 0; + //override uid from command line (add "uid=6789ABCD" anywhere) + TInt cmdsize = User::CommandLineLength(); + HBufC *cmdbuf = NULL; + if(cmdsize > 0) cmdbuf = HBufC::New(cmdsize); + if(cmdbuf) + { + TPtr cmdline(cmdbuf->Des()); + User::CommandLine(cmdline); + TLex lex(*cmdbuf); + while(!lex.Eos()) + { + lex.SkipSpaceAndMark(); + while(!lex.Eos() && lex.Get() != '=') + { + } + if(lex.MarkedToken().CompareF(KFakeUidParam) == 0) + { + lex.SkipSpaceAndMark(); + while(!lex.Eos() && lex.Get().IsHexDigit()) + { + } + TUint id; + TLex num(lex.MarkedToken()); + if(KErrNone==num.Val(id,EHex)) + { + RDebug::Printf("\tapp uid override %x", id); + uid = TUid::Uid(id); + } + } + else if(lex.MarkedToken().CompareF(KAllocParam) == 0) + { + lex.SkipSpaceAndMark(); + while(!lex.Eos() && lex.Get().IsHexDigit()) + { + } + TLex num(lex.MarkedToken()); + if(KErrNone!=num.Val(alloc,EHex)) + { + alloc = 0; + } + } + } + /* + TInt offset = cmdbuf->Find(KFakeUidParam); + if(offset >=0 && offset + 12 <= cmdbuf->Length()) + { + TLex lex(cmdbuf->Mid(offset+4,8)); + TUint id; + if(KErrNone==lex.Val(id,EHex)) + { + RDebug::Printf("\tapp uid override %x", id); + uid = TUid::Uid(id); + } + } + TInt offset = cmdbuf->Find(KAllocParam); + if(offset >=0 && offset + 12 <= cmdbuf->Length())*/ + delete cmdbuf; + } + return new Ct_oomdummyappApplication(uid, alloc); + } + +GLDEF_C TInt E32Main() + { + return EikStart::RunApplication(NewApplication); + } + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappAppUi.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappAppUi.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,271 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +//#include "t_oomdummyapp_0xE6CFBA00.hlp.hrh" +#include "t_oomdummyapp.hrh" +#include "t_oomdummyapp.pan" +#include "t_oomdummyappApplication.h" +#include "t_oomdummyappAppUi.h" +#include "t_oomdummyappAppView.h" +#include "CMsgHandler.h" +#include "t_oomdummyappmsgs.h" + +_LIT( KFileName, "C:\\private\\E6CFBA00\\t_oomdummyapp.txt" ); +_LIT( KText, "OOM dummy app"); + +// ============================ MEMBER FUNCTIONS =============================== + + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappAppUi::ConstructL() +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void Ct_oomdummyappAppUi::ConstructL() + { + // Initialise app UI with standard value. + BaseConstructL(CAknAppUi::EAknEnableSkin); + + // Create view object + iAppView = Ct_oomdummyappAppView::NewL(ClientRect()); + + // Create a file to write the text to + TInt err = CCoeEnv::Static()->FsSession().MkDirAll(KFileName); + if ((KErrNone != err) && (KErrAlreadyExists != err)) + { + return; + } + + RFile file; + err = file.Replace(CCoeEnv::Static()->FsSession(), KFileName, EFileWrite); + CleanupClosePushL(file); + if (KErrNone != err) + { + CleanupStack::PopAndDestroy(1); // file + return; + } + + RFileWriteStream outputFileStream(file); + CleanupClosePushL(outputFileStream); + outputFileStream << KText; + + CleanupStack::PopAndDestroy(2); // outputFileStream, file + + TRAP_IGNORE(iMsgHandler = CMsgHandler::NewL(*this)); //if not launched by test harness, the message queue won't exist + } +// ----------------------------------------------------------------------------- +// Ct_oomdummyappAppUi::Ct_oomdummyappAppUi() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +Ct_oomdummyappAppUi::Ct_oomdummyappAppUi() + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappAppUi::~Ct_oomdummyappAppUi() +// Destructor. +// ----------------------------------------------------------------------------- +// +Ct_oomdummyappAppUi::~Ct_oomdummyappAppUi() + { + if (iAppView) + { + delete iAppView; + iAppView = NULL; + } + delete iMsgHandler; + } + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappAppUi::HandleCommandL() +// Takes care of command handling. +// ----------------------------------------------------------------------------- +// +void Ct_oomdummyappAppUi::HandleCommandL(TInt aCommand) + { + switch (aCommand) + { + case EEikCmdExit: + case EAknSoftkeyExit: + Exit(); + break; + + case ECommand1: + { + + // Load a string from the resource file and display it + HBufC* textResource = StringLoader::LoadLC(R_COMMAND1_TEXT); + CAknInformationNote* informationNote; + + informationNote = new (ELeave) CAknInformationNote; + + // Show the information Note with + // textResource loaded with StringLoader. + informationNote->ExecuteLD(*textResource); + + // Pop HBuf from CleanUpStack and Destroy it. + CleanupStack::PopAndDestroy(textResource); + } + break; + case ECommand2: + { + RFile rFile; + + //Open file where the stream text is + User::LeaveIfError(rFile.Open(CCoeEnv::Static()->FsSession(), + KFileName, EFileStreamText));//EFileShareReadersOnly));// EFileStreamText)); + CleanupClosePushL(rFile); + + // copy stream from file to RFileStream object + RFileReadStream inputFileStream(rFile); + CleanupClosePushL(inputFileStream); + + // HBufC descriptor is created from the RFileStream object. + HBufC* fileData = HBufC::NewLC(inputFileStream, 32); + + CAknInformationNote* informationNote; + + informationNote = new (ELeave) CAknInformationNote; + // Show the information Note + informationNote->ExecuteLD(*fileData); + + // Pop loaded resources from the cleanup stack + CleanupStack::PopAndDestroy(3); // filedata, inputFileStream, rFile + } + break; + case EHelp: + { + + CArrayFix* buf = CCoeAppUi::AppHelpContextL(); + HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf); + } + break; + case EAbout: + { + + CAknMessageQueryDialog* dlg = new (ELeave) CAknMessageQueryDialog(); + dlg->PrepareLC(R_ABOUT_QUERY_DIALOG); + HBufC* title = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TITLE); + dlg->QueryHeading()->SetTextL(*title); + CleanupStack::PopAndDestroy(); //title + HBufC* msg = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TEXT); + dlg->SetMessageTextL(*msg); + CleanupStack::PopAndDestroy(); //msg + dlg->RunLD(); + } + break; + default: + Panic(Et_oomdummyappUi); + break; + } + } + +void Ct_oomdummyappAppUi::HandleHarnessCommandL(TInt aCommand) + { + switch(aCommand) + { + case 0: + Exit(); + break; + case 1: + ActivateTopViewL(); + break; + case KOomDummyAppSetBusy: + SetPriorityBusy(); + break; + case KOomDummyAppSetNormalPriority: + SetPriorityNormal(); + break; + case KOomDummyAppSetHighPriority: + SetPriorityHigh(); + break; + } + } + +void Ct_oomdummyappAppUi::SetPriorityBusy() + { + ROomMonitorSession oomSession; + oomSession.Connect(); + oomSession.SetOomPriority(ROomMonitorSession::EOomPriorityBusy); + oomSession.Close(); + } + +void Ct_oomdummyappAppUi::SetPriorityNormal() + { + ROomMonitorSession oomSession; + oomSession.Connect(); + oomSession.SetOomPriority(ROomMonitorSession::EOomPriorityNormal); + oomSession.Close(); + } + +void Ct_oomdummyappAppUi::SetPriorityHigh() + { + ROomMonitorSession oomSession; + oomSession.Connect(); + oomSession.SetOomPriority(ROomMonitorSession::EOomPriorityHigh); + oomSession.Close(); + } + + +// ----------------------------------------------------------------------------- +// Called by the framework when the application status pane +// size is changed. Passes the new client rectangle to the +// AppView +// ----------------------------------------------------------------------------- +// +void Ct_oomdummyappAppUi::HandleStatusPaneSizeChange() + { + iAppView->SetRect(ClientRect()); + } + +CArrayFix* Ct_oomdummyappAppUi::HelpContextL() const + { + // Note: Help will not work if the application uid3 is not in the + // protected range. The default uid3 range for projects created + // from this template (0xE0000000 - 0xEFFFFFFF) are not in the protected range so that they + // can be self signed and installed on the device during testing. + // Once you get your official uid3 from Symbian Ltd. and find/replace + // all occurrences of uid3 in your project, the context help will + // work. Alternatively, a patch now exists for the versions of + // HTML help compiler in SDKs and can be found here along with an FAQ: + // http://www3.symbian.com/faq.nsf/AllByDate/E9DF3257FD565A658025733900805EA2?OpenDocument + CArrayFixFlat* array = new (ELeave) CArrayFixFlat< + TCoeHelpContext> (1); + CleanupStack::PushL(array); + //array->AppendL(TCoeHelpContext(KUidt_oomdummyappApp, KGeneral_Information)); + CleanupStack::Pop(array); + return array; + } + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappAppView.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappAppView.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +// INCLUDE FILES +#include +#include "t_oomdummyappAppView.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappAppView::NewL() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +Ct_oomdummyappAppView* Ct_oomdummyappAppView::NewL(const TRect& aRect) + { + Ct_oomdummyappAppView* self = Ct_oomdummyappAppView::NewLC(aRect); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappAppView::NewLC() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +Ct_oomdummyappAppView* Ct_oomdummyappAppView::NewLC(const TRect& aRect) + { + Ct_oomdummyappAppView* self = new (ELeave) Ct_oomdummyappAppView; + CleanupStack::PushL(self); + self->ConstructL(aRect); + return self; + } + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappAppView::ConstructL() +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void Ct_oomdummyappAppView::ConstructL(const TRect& aRect) + { + // Create a window for this application view + CreateWindowL(); + + // Set the windows size + SetRect(aRect); + + // Activate the window, which makes it ready to be drawn + ActivateL(); + } + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappAppView::Ct_oomdummyappAppView() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +Ct_oomdummyappAppView::Ct_oomdummyappAppView() + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappAppView::~Ct_oomdummyappAppView() +// Destructor. +// ----------------------------------------------------------------------------- +// +Ct_oomdummyappAppView::~Ct_oomdummyappAppView() + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappAppView::Draw() +// Draws the display. +// ----------------------------------------------------------------------------- +// +void Ct_oomdummyappAppView::Draw(const TRect& /*aRect*/) const + { + // Get the standard graphics context + CWindowGc& gc = SystemGc(); + + // Gets the control's extent + TRect drawRect(Rect()); + + // Clears the screen + gc.Clear(drawRect); + + } + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappAppView::SizeChanged() +// Called by framework when the view size is changed. +// ----------------------------------------------------------------------------- +// +void Ct_oomdummyappAppView::SizeChanged() + { + DrawNow(); + } +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappApplication.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappApplication.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +// INCLUDE FILES +#include "t_oomdummyapp.hrh" +#include "t_oomdummyappDocument.h" +#include "t_oomdummyappApplication.h" + +// ============================ MEMBER FUNCTIONS =============================== + +Ct_oomdummyappApplication::Ct_oomdummyappApplication(TUid aUid, TUint aAlloc) : iUID(aUid), iAlloc(aAlloc) + { + + } + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappApplication::CreateDocumentL() +// Creates CApaDocument object +// ----------------------------------------------------------------------------- +// +CApaDocument* Ct_oomdummyappApplication::CreateDocumentL() + { + if(iAlloc > 0) iMemory = User::AllocL(iAlloc); + // Create an t_oomdummyapp document, and return a pointer to it + return Ct_oomdummyappDocument::NewL(*this); + } + +Ct_oomdummyappApplication::~Ct_oomdummyappApplication() + { + delete iMemory; + } + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappApplication::AppDllUid() +// Returns application UID +// ----------------------------------------------------------------------------- +// +TUid Ct_oomdummyappApplication::AppDllUid() const + { + // Return the UID for the t_oomdummyapp application + return iUID; + } + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappDocument.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappDocument.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +// INCLUDE FILES +#include "t_oomdummyappAppUi.h" +#include "t_oomdummyappDocument.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappDocument::NewL() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +Ct_oomdummyappDocument* Ct_oomdummyappDocument::NewL(CEikApplication& aApp) + { + Ct_oomdummyappDocument* self = NewLC(aApp); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappDocument::NewLC() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +Ct_oomdummyappDocument* Ct_oomdummyappDocument::NewLC(CEikApplication& aApp) + { + Ct_oomdummyappDocument* self = new (ELeave) Ct_oomdummyappDocument(aApp); + + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappDocument::ConstructL() +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void Ct_oomdummyappDocument::ConstructL() + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// Ct_oomdummyappDocument::Ct_oomdummyappDocument() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +Ct_oomdummyappDocument::Ct_oomdummyappDocument(CEikApplication& aApp) : + CAknDocument(aApp) + { + // No implementation required + } + +// --------------------------------------------------------------------------- +// Ct_oomdummyappDocument::~Ct_oomdummyappDocument() +// Destructor. +// --------------------------------------------------------------------------- +// +Ct_oomdummyappDocument::~Ct_oomdummyappDocument() + { + // No implementation required + } + +// --------------------------------------------------------------------------- +// Ct_oomdummyappDocument::CreateAppUiL() +// Constructs CreateAppUi. +// --------------------------------------------------------------------------- +// +CEikAppUi* Ct_oomdummyappDocument::CreateAppUiL() + { + // Create the application user interface, and return a pointer to it; + // the framework takes ownership of this object + return new (ELeave) Ct_oomdummyappAppUi; + } + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/data/t_oomdummyplugin.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/data/t_oomdummyplugin.rss Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,102 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#include +#include + +RESOURCE REGISTRY_INFO theInfo + { + dll_uid = 0x10286A33; + interfaces = + { + INTERFACE_INFO + { + interface_uid = KOomPluginInterfaceUidValue; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x10286A34; + version_no = 1; + display_name = "dummy 1"; + default_data = ""; + opaque_data = ""; + }, + IMPLEMENTATION_INFO + { + implementation_uid = 0x10286A35; + version_no = 1; + display_name = "dummy 2"; + default_data = ""; + opaque_data = ""; + }, + IMPLEMENTATION_INFO + { + implementation_uid = 0x10286A36; + version_no = 1; + display_name = "dummy 3"; + default_data = ""; + opaque_data = ""; + }, + IMPLEMENTATION_INFO + { + implementation_uid = 0x10286A37; + version_no = 1; + display_name = "dummy 4"; + default_data = ""; + opaque_data = ""; + }, + IMPLEMENTATION_INFO + { + implementation_uid = 0x10286A38; + version_no = 1; + display_name = "dummy 5"; + default_data = ""; + opaque_data = ""; + }, + IMPLEMENTATION_INFO + { + implementation_uid = 0x10286A39; + version_no = 1; + display_name = "dummy 6"; + default_data = ""; + opaque_data = ""; + }, + IMPLEMENTATION_INFO + { + implementation_uid = 0x10286A3A; + version_no = 1; + display_name = "dummy 7"; + default_data = ""; + opaque_data = ""; + }, + IMPLEMENTATION_INFO + { + implementation_uid = 0x10286A3B; + version_no = 1; + display_name = "dummy 8"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/group/bld.inf Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +PRJ_PLATFORMS +DEFAULT + +PRJ_TESTMMPFILES +t_oomdummyplugin.mmp + +PRJ_TESTEXPORTS +../inc/t_oomdummyplugin_properties.h ../../inc/t_oomdummyplugin_properties.h diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/group/t_oomdummyplugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/group/t_oomdummyplugin.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#include + +TARGET t_oomdummyplugin.dll +TARGETTYPE PLUGIN +// UID2 = 0x10009d8d for ECOM plugins. +// UID3 = the 'DLL UID' (see resource file) +UID 0x10009d8d 0x10286A33 +CAPABILITY CAP_GENERAL_DLL + +// This is a SYSTEMINCLUDE macro containing the middleware +// layer specific include directories +MW_LAYER_SYSTEMINCLUDE + +LIBRARY euser.lib +LIBRARY t_oomclient.lib +LIBRARY oommonitor.lib + +USERINCLUDE ../inc +USERINCLUDE ../../inc + + +SOURCEPATH ../data +RESOURCE t_oomdummyplugin.rss + +SOURCEPATH ../src +SOURCE ecom_entry.cpp +SOURCE dummyplugin.cpp + +#ifdef ENABLE_ABIV2_MODE +DEBUGGABLE +#endif diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/inc/debug.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef DEBUG_H_ +#define DEBUG_H_ + +#include + +#ifdef _DEBUG +#define TRACE_FUNC RDebug::Printf("\t%s[%x]", __PRETTY_FUNCTION__, iInstance); +#define TRACE_FUNC_ENTRY RDebug::Printf("\t+%s[%x]", __PRETTY_FUNCTION__, iInstance); +#define TRACE_FUNC_EXIT RDebug::Printf("\t-%s[%x]", __PRETTY_FUNCTION__, iInstance); +#else +#define TRACE_FUNC +#define TRACE_FUNC_ENTRY +#define TRACE_FUNC_EXIT +#endif + +#endif /* DEBUG_H_ */ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/inc/dummyplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/inc/dummyplugin.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef DUMMYPLUGIN_H_ +#define DUMMYPLUGIN_H_ + +#include +#include "t_oomclient.h" + +class CDummyOomPlugin : public COomMonitorPlugin + { +public: + static CDummyOomPlugin* NewL(TInt aInstance); + ~CDummyOomPlugin(); +private: + CDummyOomPlugin(TInt aInstance); + void ConstructL(); + //from COomMonitorPlugin + virtual void FreeRam(); + virtual void MemoryGood(); + +private: + TInt iInstance; + TInt iLowMemoryCallCount; + TInt iGoodMemoryCallCount; + ROOMAllocSession iAllocServer; + }; + + +/* +class CDummyOomPluginV2 : public COomMonitorPluginV2 + { +public: + static CDummyOomPluginV2* NewL(TInt aInstance); + ~CDummyOomPluginV2(); +private: + CDummyOomPluginV2(TInt aInstance); + void ConstructL(); + //from COomMonitorPlugin + virtual void FreeRam(TInt aBytesRequested); + virtual void MemoryGood(); + +private: + TInt iInstance; + TInt iLowMemoryCallCount; + TInt iGoodMemoryCallCount; + ROOMAllocSession iAllocServer; + }; +*/ + + +#endif diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/inc/t_oomdummyplugin_properties.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/inc/t_oomdummyplugin_properties.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef DUMMYPLUGIN_PROPETIES_H_ +#define DUMMYPLUGIN_PROPETIES_H_ + +const TUid KUidOomPropertyCategory = {0x10286A3E}; + +//The key is the UID of the implementation instance, i.e. 10286A34 To 10286A3D +const TInt KUidOOMDummyPluginFirstImplementation(0x10286A34); +const TInt KUidOOMDummyPluginLastImplementation(0x10286A3D); + +const TUint KOOMDummyPluginImplementationCount = 10; + +const TUint KOOMDummyPluginLowMemoryCount = 0; +const TUint KOOMDummyPluginGoodMemoryCount = 1 * KOOMDummyPluginImplementationCount; +const TUint KOOMDummyPluginCurrentAllocationBytes = 2 * KOOMDummyPluginImplementationCount; +const TUint KOOMDummyPluginBytesRequested = 3 * KOOMDummyPluginImplementationCount; + +#endif /* DUMMYPLUGIN_PROPETIES_H_ */ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/src/dummyplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/src/dummyplugin.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include +#include +#include "dummyplugin.h" +#include "debug.h" +#include "t_oomdummyplugin_properties.h" + +CDummyOomPlugin* CDummyOomPlugin::NewL(TInt aInstance) + { + CDummyOomPlugin* self = new(ELeave)CDummyOomPlugin(aInstance); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CDummyOomPlugin::CDummyOomPlugin(TInt aInstance) : +iInstance(aInstance) + { + + } + +void CDummyOomPlugin::ConstructL() + { + TRACE_FUNC_ENTRY; + //connect to alloc server + User::LeaveIfError(iAllocServer.Connect()); + TRACE_FUNC_EXIT; + } + +CDummyOomPlugin::~CDummyOomPlugin() + { + TRACE_FUNC; + } + +void CDummyOomPlugin::FreeRam() + { + TRACE_FUNC; + iLowMemoryCallCount++; + RProperty::Set(KUidOomPropertyCategory, iInstance + KOOMDummyPluginLowMemoryCount, iLowMemoryCallCount); + iAllocServer.MemoryLow(TUid::Uid(iInstance)); + } + +void CDummyOomPlugin::MemoryGood() + { + TRACE_FUNC; + iGoodMemoryCallCount++; + RProperty::Set(KUidOomPropertyCategory, iInstance + KOOMDummyPluginGoodMemoryCount, iGoodMemoryCallCount); + iAllocServer.MemoryGood(TUid::Uid(iInstance)); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/src/ecom_entry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/src/ecom_entry.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include +#include "dummyplugin.h" + +#define DECLARE_CREATE_INSTANCE(UID) CDummyOomPlugin* CreateInstance##UID() { return CDummyOomPlugin::NewL(UID); } +#define IMPLEMENTATION_INSTANCE(UID) IMPLEMENTATION_PROXY_ENTRY(UID, CreateInstance##UID) + +// #define DECLARE_CREATE_INSTANCEV2(UID) CDummyOomPluginV2* CreateInstance##UID() { return CDummyOomPluginV2::NewL(UID); } +// #define IMPLEMENTATION_INSTANCEV2(UID) IMPLEMENTATION_PROXY_ENTRY(UID, CreateInstance##UID) + +//ECOM factory functions +DECLARE_CREATE_INSTANCE(0x10286A34) +DECLARE_CREATE_INSTANCE(0x10286A35) +DECLARE_CREATE_INSTANCE(0x10286A36) +DECLARE_CREATE_INSTANCE(0x10286A37) +DECLARE_CREATE_INSTANCE(0x10286A38) +DECLARE_CREATE_INSTANCE(0x10286A39) +DECLARE_CREATE_INSTANCE(0x10286A3A) +DECLARE_CREATE_INSTANCE(0x10286A3B) +// DECLARE_CREATE_INSTANCEV2(0x10286A3C) +// DECLARE_CREATE_INSTANCEV2(0x10286A3D) + +// Define the private interface UIDs +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_INSTANCE(0x10286A34), + IMPLEMENTATION_INSTANCE(0x10286A35), + IMPLEMENTATION_INSTANCE(0x10286A36), + IMPLEMENTATION_INSTANCE(0x10286A37), + IMPLEMENTATION_INSTANCE(0x10286A38), + IMPLEMENTATION_INSTANCE(0x10286A39), + IMPLEMENTATION_INSTANCE(0x10286A3A), + IMPLEMENTATION_INSTANCE(0x10286A3B)// , + // IMPLEMENTATION_INSTANCEV2(0x10286A3C), + // IMPLEMENTATION_INSTANCEV2(0x10286A3D) + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/data/t_oomdummyplugin2.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/data/t_oomdummyplugin2.rss Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + + +#include +#include + +RESOURCE REGISTRY_INFO theInfo + { + dll_uid = 0x10286A81; + interfaces = + { + INTERFACE_INFO + { + interface_uid = KOomPluginInterfaceV2UidValue; + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x10286A3C; + version_no = 1; + display_name = "dummyv2 1"; + default_data = ""; + opaque_data = ""; + }, + IMPLEMENTATION_INFO + { + implementation_uid = 0x10286A3D; + version_no = 1; + display_name = "dummyv2 2"; + default_data = ""; + opaque_data = ""; + } + }; + } + }; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/group/bld.inf Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +PRJ_PLATFORMS +DEFAULT + +PRJ_TESTMMPFILES +t_oomdummyplugin2.mmp + +PRJ_TESTEXPORTS +../inc/t_oomdummyplugin_properties2.h ../../inc/t_oomdummyplugin_properties2.h diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/group/t_oomdummyplugin2.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/group/t_oomdummyplugin2.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#include + +TARGET t_oomdummyplugin2.dll +TARGETTYPE PLUGIN +// UID2 = 0x10009d8d for ECOM plugins. +// UID3 = the 'DLL UID' (see resource file) +UID 0x10009d8d 0x10286A81 +CAPABILITY CAP_GENERAL_DLL + +// This is a SYSTEMINCLUDE macro containing the middleware +// layer specific include directories +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../inc + +LIBRARY euser.lib +LIBRARY t_oomclient.lib +LIBRARY oommonitor.lib + +SOURCEPATH ../data +RESOURCE t_oomdummyplugin2.rss + +SOURCEPATH ../src +SOURCE ecom_entry2.cpp +SOURCE dummyplugin2.cpp + +#ifdef ENABLE_ABIV2_MODE +DEBUGGABLE +#endif diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/inc/debug.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef DEBUG_H_ +#define DEBUG_H_ + +#include + +#ifdef _DEBUG +#define TRACE_FUNC RDebug::Printf("\t%s[%x]", __PRETTY_FUNCTION__, iInstance); +#define TRACE_FUNC_ENTRY RDebug::Printf("\t+%s[%x]", __PRETTY_FUNCTION__, iInstance); +#define TRACE_FUNC_EXIT RDebug::Printf("\t-%s[%x]", __PRETTY_FUNCTION__, iInstance); +#else +#define TRACE_FUNC +#define TRACE_FUNC_ENTRY +#define TRACE_FUNC_EXIT +#endif + +#endif /* DEBUG_H_ */ diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/inc/dummyplugin2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/inc/dummyplugin2.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef DUMMYPLUGIN2_H_ +#define DUMMYPLUGIN2_H_ + +#include +#include "t_oomclient.h" + + + +class CDummyOomPluginV2 : public COomMonitorPluginV2 + { +public: + static CDummyOomPluginV2* NewL(TInt aInstance); + ~CDummyOomPluginV2(); +private: + CDummyOomPluginV2(TInt aInstance); + void ConstructL(); + //from COomMonitorPlugin + virtual void FreeRam(TInt aBytesRequested); + virtual void MemoryGood(); + +private: + TInt iInstance; + TInt iLowMemoryCallCount; + TInt iGoodMemoryCallCount; + ROOMAllocSession iAllocServer; + }; + + + +#endif diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/inc/t_oomdummyplugin_properties2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/inc/t_oomdummyplugin_properties2.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,21 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/src/dummyplugin2.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/src/dummyplugin2.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include +#include +#include "dummyplugin2.h" +#include "debug.h" +#include "t_oomdummyplugin_properties.h" + + +CDummyOomPluginV2* CDummyOomPluginV2::NewL(TInt aInstance) + { + CDummyOomPluginV2* self = new(ELeave)CDummyOomPluginV2(aInstance); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CDummyOomPluginV2::CDummyOomPluginV2(TInt aInstance) : +iInstance(aInstance) + { + + } + +void CDummyOomPluginV2::ConstructL() + { + TRACE_FUNC_ENTRY; + //connect to alloc server + User::LeaveIfError(iAllocServer.Connect()); + TRACE_FUNC_EXIT; + } + +CDummyOomPluginV2::~CDummyOomPluginV2() + { + TRACE_FUNC; + } + +void CDummyOomPluginV2::FreeRam(TInt aBytesRequested) + { + TRACE_FUNC; + iLowMemoryCallCount++; + RProperty::Set(KUidOomPropertyCategory, iInstance + KOOMDummyPluginLowMemoryCount, iLowMemoryCallCount); + TInt err = RProperty::Set(KUidOomPropertyCategory, iInstance + KOOMDummyPluginBytesRequested, aBytesRequested); + iAllocServer.MemoryLow(TUid::Uid(iInstance)); + } + +void CDummyOomPluginV2::MemoryGood() + { + TRACE_FUNC; + iGoodMemoryCallCount++; + RProperty::Set(KUidOomPropertyCategory, iInstance + KOOMDummyPluginGoodMemoryCount, iGoodMemoryCallCount); + iAllocServer.MemoryGood(TUid::Uid(iInstance)); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/src/ecom_entry2.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/src/ecom_entry2.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include +#include "dummyplugin2.h" + +#define DECLARE_CREATE_INSTANCEV2(UID) CDummyOomPluginV2* CreateInstance##UID() { return CDummyOomPluginV2::NewL(UID); } +#define IMPLEMENTATION_INSTANCEV2(UID) IMPLEMENTATION_PROXY_ENTRY(UID, CreateInstance##UID) + +//ECOM factory functions +DECLARE_CREATE_INSTANCEV2(0x10286A3C) +DECLARE_CREATE_INSTANCEV2(0x10286A3D) + +// Define the private interface UIDs +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_INSTANCEV2(0x10286A3C), + IMPLEMENTATION_INSTANCEV2(0x10286A3D) + }; + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + return ImplementationTable; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/group/bld.inf Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +PRJ_PLATFORMS +DEFAULT + +PRJ_TESTMMPFILES +t_oomharness.mmp diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/group/t_oomharness.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/group/t_oomharness.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#include + +TARGET t_oomharness.exe +TARGETTYPE exe +UID 0 0xEF1971CE + +// This is a SYSTEMINCLUDE macro containing the middleware +// layer specific include directories +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../inc + +SOURCEPATH ../src +SOURCE t_oomharness.cpp +SOURCE CDummyApplicationHandle.cpp + +LIBRARY euser.lib +LIBRARY t_oomclient.lib +LIBRARY hal.lib +LIBRARY oommonitor.lib + + +#ifdef ENABLE_ABIV2_MODE +DEBUGGABLE +#endif + +EPOCHEAPSIZE 0x4000 0x4000000 +CAPABILITY WriteDeviceData diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/CDummyApplicationHandle.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/CDummyApplicationHandle.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CDUMMYAPPLICATIONHANDLE_H +#define CDUMMYAPPLICATIONHANDLE_H + +// INCLUDES +#include +#include +#include + +// a few uids...use appuidlister to extract from the app_reg.rsc files +const TUid KUidAbout = {0x10005a22}; +const TUid KUidBLID = {0x101f85a0}; +const TUid KUidBrowserNG = {0x10008d39}; +const TUid KUidCalendar = {0x10005901}; +const TUid KUidClock = {0x10005903}; +const TUid KUidGallery = {0x101f8599}; +const TUid KUidPhonebook2 = {0x101f4cce}; +const TUid KUidProfileApp = {0x100058f8}; + +// CLASS DECLARATION + +/** + * CCDummyApplicationHandle + * A helper class for launching dummy apps and checking their status + */ +class CCDummyApplicationHandle : public CBase + { +public: + // Constructors and destructor + + /** + * Destructor. + */ + ~CCDummyApplicationHandle(); + + /** + * Two-phased constructor. + */ + static CCDummyApplicationHandle* NewL(TUid aUid, TInt aExtraMemoryAllocation = 0); + + /** + * Two-phased constructor. + */ + static CCDummyApplicationHandle* NewLC(TUid aUid, TInt aExtraMemoryAllocation = 0); + + inline RProcess& Process() { return iProcess; } + inline const TUid& Uid() { return iUid; } + + void SendMessage(TInt aMessage); + + void BringToForeground(); + + static TBool CompareTo(const TUid* aKey, const CCDummyApplicationHandle& aValue); +private: + + /** + * Constructor for performing 1st stage construction + */ + CCDummyApplicationHandle(TUid aUid); + + /** + * EPOC default constructor for performing 2nd stage construction + */ + void ConstructL(TInt aExtraMemoryAllocation = 0); + + RProcess iProcess; + //a channel for sending control messages to the dummy app... + RMsgQueue iMsgQueue; + TUid iUid; + }; + +#endif // CDUMMYAPPLICATIONHANDLE_H diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/cleanuputils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/cleanuputils.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + */ + +template +class CleanupResetAndDestroy + { +public: + inline static void PushL(T& aRef); +private: + static void ResetAndDestroy(TAny *aPtr); + }; + +template +inline void CleanupResetAndDestroyPushL(T& aRef); + + +#include "cleanuputils.inl" diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/cleanuputils.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/cleanuputils.inl Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +template +inline void CleanupResetAndDestroy::PushL(T& aRef) + { + CleanupStack::PushL(TCleanupItem(&ResetAndDestroy,&aRef)); + } + +template +void CleanupResetAndDestroy::ResetAndDestroy(TAny *aPtr) + { + static_cast(aPtr)->ResetAndDestroy(); + } + +template +inline void CleanupResetAndDestroyPushL(T& aRef) + { + CleanupResetAndDestroy::PushL(aRef); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/t_oomharness.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/t_oomharness.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,308 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef __T_OOMHARNESS_H__ +#define __T_OOMHARNESS_H__ + +// Include Files + +#include +#include +#include + +#include "CDummyApplicationHandle.h" +#include "t_oomclient.h" +#include + +const TTimeIntervalMicroSeconds32 KSettlingTime = 500000; + +// Function Prototypes + +GLDEF_C TInt E32Main(); + +class COomTestHarness : public CBase + { +public: + // Constructors and destructor + static COomTestHarness* NewLC(); + + ~COomTestHarness(); + + void StartL(); + +private: + +// Test setup functions... + + // Close any dummy apps + // Free all memory being eaten by the server + // Update the call counts on the plugins (add them if they're not there already) + void ResetL(); + + void EatMemoryL(TInt aKBytesToLeaveFree); + + // Set up the plugins and applications - this is the starting point for many test cases + // 5 applications are started with approx 1 MB used for each + // 1MB (approx) of memory is reserved for each one of the plugins + void CommonSetUpL(); + + void StartApplicationL(TInt32 aUid, TInt aInitialAllocationInKBs); + +// Results checking functions... + + // Returns KErrNone if we get the expected result + TInt AppIsRunning(TInt32 aUid, TBool aExpectedResult); + + // Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)? + // Returns KErrNone if we get the expected result + TInt PluginFreeRamCalledL(TInt32 aUid, TBool aExpectedResult); + + // Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)? + // Returns KErrNone if we get the expected result + TInt PluginMemoryGoodCalledL(TInt32 aUid, TBool aExpectedResult); + +// Utility functions + + // Wait a while for the system to settle down + inline void Settle(); + + TInt BringAppToForeground(TInt32 aUid); + + void EatMemoryUntilWeAreStuckUnderTheLowThresholdL(); + +// The tests... + + // Test normal application closure for a single app + // Start three applications + // The lowest priority app should be in the foregound + // ... with the next lowest behind it + // ... followed by the highest priority application at the back + // The middle application should be configured to eat 5MB of memory + // A low memory event is triggered and the middle application only should be closed + TInt AppCloseTest1L(); + + // Tests the idle time rule mechanism for app closure + // Start three applications + // The lowest priority app should be in the foregound + // ... with the next lowest behind it + // ... followed by the highest priority application at the back + // After an idle period the highest priority app is configured to become the lowest priority + // The middle and highest application should be configured to eat 5MB of memory + // A low memory event is triggered and the middle application only should be closed + // Note that this test should be the same as AppCloseTest1L, with the exception of the idle period which causes different apps to be closed + TInt AppCloseIdleTimeTest1L(); + + // Test system plugins and continue mode + // Simulate a low memory event + // Two system plugins should free enough memory, but four will be run because they work in "continue" mode + TInt PluginTest1L(); + + // Test application plugins + // Start two target apps + // Simulate a low memory event + // The one of the application plugins should now be run, displacing one of the system plugins + // The target apps are of sufficiently high priority that they will not be closed + TInt PluginTest2L(); + + // Test that the aBytesRequested is correctly passed to the FreeMemory function of V2 plugins + // Initialise P4 plugin to consume 5MB of memory + // No other plugins are configured to release memory + // Simulate a low memory event (go just below the low threshold) + // Check that the P4 plugin has been called + // Check that the P4 plugin has received a request for > 500K and less than <1500K + TInt PluginV2Test1L(); + + // Test simple prioritisation of application plugins + // Start two target applications + // Configure all plugins to consume 0.5MB + // Simulate a low memory event + // Some of the low priority app plugins with those target applications should be called + // The highest priority app with that target application should not be called (the lower priority plugins should free enough memory) + TInt AppPluginTest1L(); + + // Test simple prioritisation of application plugins + // Start two target applications + // Configure all plugins to consume 0.5MB + // The app plugin with the highest priority is configured to be assigned the lowest priority after an idle time + // Wait until the idle time rule applies + // Simulate a low memory event + // The plugin that initially had the highest priority (but now has the lowest priority) should be called + // Note that this test should be the same as AppPluginTest1L with the addition of the idle period + TInt AppPluginIdleTimeTest1L(); + + // Test idle time handling for plugins + // Start two target apps + // Simulate a low memory event + // The one of the application plugins should now be run, displacing one of the system plugins + // The target apps are of sufficiently high priority that they will not be closed + TInt PluginIdleTimeTest2L(); + + // Test the optional allocation mechanism + // Configure the plugins not to release any RAM when FreeRam is called + // Configure one priority 7 application to release 12MB when FreeRam is called + // Start this application (plus another one so it isn't in the foreground) + // Drop just below the good memory level + // Request an optional allocation of 10MB referencing a priority 8 plugin + // All of the plugins below P8 should be called + // The P7 application should be closed freeing the required memory + TInt OptionalAllocationTest1L(); + + + // Test the optional allocation mechanism - minimum requested RAM behaviour - successful request + // Configure the plugins not to release any RAM when FreeRam is called + // Configure one priority 7 application to release 5MB when FreeRam is called + // Start this application (plus another one so it isn't in the foreground) + // Drop just above the good memory level + // Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin + // All of the plugins below P8 should be called + // The P7 application should be closed freeing the required minimum amount memory + // The returned available memory should be about 5MB ( > 3MB and < 7MB ) + TInt OptionalAllocationTest2L(); + + // Test the optional allocation mechanism - minimum requested RAM behaviour - failed request + // Configure the plugins not to release any RAM when FreeRam is called + // Configure one priority 7 application to release 3MB when FreeRam is called + // Start this application (plus another one so it isn't in the foreground) + // Drop just above the good memory level + // Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin + // All of the plugins below P8 should be called + // The P7 application should be closed but it won't free enough memory + // The optional allocation should fail with KErrNoMemory + TInt OptionalAllocationTest3L(); + + + // Test the async optional allocation mechanism + // Configure the plugins not to release any RAM when FreeRam is called + // Configure one priority 7 application to release 12MB when FreeRam is called + // Start this application (plus another one so it isn't in the foreground) + // Drop just below the good memory level + // Request an optional allocation of 10MB referencing a priority 8 plugin + // All of the plugins below P8 should be called + // The P7 application should be closed freeing the required memory + TInt OptionalAllocationAsyncTest1L(); + + + // Test the async optional allocation mechanism - minimum requested RAM behaviour - successful request + // Configure the plugins not to release any RAM when FreeRam is called + // Configure one priority 7 application to release 5MB when FreeRam is called + // Start this application (plus another one so it isn't in the foreground) + // Drop just above the good memory level + // Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin + // All of the plugins below P8 should be called + // The P7 application should be closed freeing the required minimum amount memory + // The returned available memory should be about 5MB ( > 3MB and < 7MB ) + TInt OptionalAllocationAsyncTest2L(); + + // Test the async optional allocation mechanism - minimum requested RAM behaviour - failed request + // Configure the plugins not to release any RAM when FreeRam is called + // Configure one priority 7 application to release 3MB when FreeRam is called + // Start this application (plus another one so it isn't in the foreground) + // Drop just above the good memory level + // Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin + // All of the plugins below P8 should be called + // The P7 application should be closed but it won't free enough memory + // The optional allocation should fail with KErrNoMemory + TInt OptionalAllocationAsyncTest3L(); + + + // Test that force priority check applies (only) to selected priorities + // Setup three plugins (priorities 7, 8 & 9)to eat 5MB each + // The configuration file should force a check after priority 8 + // Drop just under the low threshold + // Plugins P7 & P8 should be called (P8 is called even though the P7 plugin freed enough memory) + // Plugin P9 should not be called because enou + TInt ForcePriorityCheck1L(); + + // Test the Busy API on the OOM server + // Start three applications + // Ensure that the lowest priority app is not in the foreground + // Call the busy API on the OOM monitor for the lowest priority app + // Simulate a low memory event by going just under the low threshold + // The busy application should not be closed + // The other (non-foreground) application should be closed + TInt BusyApplicationTest1L(); + + // Test the Normal-priority API on the OOM server + // Start three applications + // Ensure that the lowest priority app is not in the foreground + // Call the busy API on the OOM monitor for the lowest priority app + // Then call the not-busy API on the OOM monitor for the lowest priority app + // Simulate a low memory event by going just under the low threshold + // The lowest priority app should be closed (because it is no longer busy) + TInt NormalPriorityApplicationTest1L(); + + // Test that sync mode configuration is working for system plugins + // Configure three system plugins to release 5MB of memory each. + // The plugins are configured as follows + // Plugin 1: Priority 7, sync mode continue + // Plugin 2: Priority 8, sync mode check + // Plugin 3: Priority 9, sync mode continue + // Drop just under the low threshold + // Plugins 1 & 2 should be called (even though plugin 1 alone has freed enough RAM) + // Plugin 3 won't be called because the check on the priority 8 plugin discovers that enough RAM has been freed + TInt PluginSyncModeTest1L(); + + + // Start three applications + // One is set to NEVER_CLOSE, one is low priority, one is a dummy app to ensure that the first two are not in the foreground + // Configure applications not to release any memory + // Go just significantly under the low memory threshold + // Wait for the system to recover, if we have moved above the low memory threshold then go significantly under it again. Repeat this step until we no longer go above low. + // Check that the low priority application is closed + // Check that the NEVER_CLOSE application is not closed (even though we're still below the low theshold) + TInt NeverCloseTest1L(); + + TInt GetFreeMemory(); + + // Utility function which calls the async version of optional RAM request and makes it behave like the sync version + TInt RequestOptionalRamASyncWrapper(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable); + +private: + COomTestHarness(); + + void ConstructL(); + +private: + + struct TPluginCallCount + { + TInt iFreeRamCallCount; + TInt iMemoryGoodCallCount; + }; + + RHashMap iPluginCallCounts; + + RPointerArray iApps; + + ROOMAllocSession iAllocServer; + + RChunk iChunk; + TInt iChunkSize; + + ROomMonitorSession iOomSession; + }; + +#endif // __T_OOMHARNESS_H__ + +inline void COomTestHarness::Settle() + { + //wait for oom system to settle + User::After(KSettlingTime); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/sis/t_oomharness_EKA2.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/sis/t_oomharness_EKA2.pkg Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,24 @@ +; Installation file for Symbian OS 9.x for generic console application +; Installation file for t_oomharness EXE +; +; This is an auto-generated PKG file by Carbide. +; This file uses variables specific to Carbide builds that will not work +; on command-line builds. If you want to use this generated PKG file from the +; command-line tools you will need to modify the variables with the appropriate +; values: $(EPOCROOT), $(PLATFORM), $(TARGET) +; + +; +; UID is the exe's UID +; +#{"t_oomharness EXE"},(0xEF1971CE),1,0,0 + + +;Localised Vendor name +%{"Vendor-EN"} + +;Unique Vendor name +:"Vendor" + +"$(EPOCROOT)Epoc32\release\$(PLATFORM)\$(TARGET)\t_oomharness.exe" -"!:\sys\bin\t_oomharness.exe" + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/src/CDummyApplicationHandle.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/src/CDummyApplicationHandle.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include +#include "CDummyApplicationHandle.h" + +CCDummyApplicationHandle::CCDummyApplicationHandle(TUid aUid) +: iUid(aUid) + { + // No implementation required + } + +CCDummyApplicationHandle::~CCDummyApplicationHandle() + { + if(iMsgQueue.Handle()) + { + iMsgQueue.SendBlocking(0); + iMsgQueue.Close(); + } + iProcess.Close(); + } + +CCDummyApplicationHandle* CCDummyApplicationHandle::NewLC(TUid aUid, TInt aExtraMemoryAllocation) + { + CCDummyApplicationHandle* self = new (ELeave) CCDummyApplicationHandle(aUid); + CleanupStack::PushL(self); + self->ConstructL(aExtraMemoryAllocation); + return self; + } + +CCDummyApplicationHandle* CCDummyApplicationHandle::NewL(TUid aUid, TInt aExtraMemoryAllocation) + { + CCDummyApplicationHandle* self = CCDummyApplicationHandle::NewLC(aUid, aExtraMemoryAllocation); + CleanupStack::Pop(); // self; + return self; + } + +void CCDummyApplicationHandle::ConstructL(TInt aExtraMemoryAllocation) + { + TBuf<28> params; + params.Format(_L("uid=%08x alloc=%x"), iUid, aExtraMemoryAllocation); + User::LeaveIfError(iProcess.Create(_L("z:\\sys\\bin\\t_oomdummyapp_0xE6CFBA00.exe"), params)); + User::LeaveIfError(iMsgQueue.CreateGlobal(KNullDesC, 4)); + User::LeaveIfError(iProcess.SetParameter(15, iMsgQueue)); + iProcess.Resume(); + } + +void CCDummyApplicationHandle::SendMessage(TInt aMessage) + { + iMsgQueue.SendBlocking(aMessage); + } + +TBool CCDummyApplicationHandle::CompareTo(const TUid* aKey, const CCDummyApplicationHandle& aValue) + { + return aValue.iUid == *aKey; + } + +void CCDummyApplicationHandle::BringToForeground() + { + SendMessage(1); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/src/t_oomharness.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/src/t_oomharness.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,1715 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +// Include Files + +#include "t_oomharness.h" +#include "CDummyApplicationHandle.h" +#include "cleanuputils.h" +#include "t_oomdummyplugin_properties.h" +#include +#include +#include // Console +#include +#include +#include +#include +#include "t_oomdummyplugin_properties.h" +#include "../../t_oomdummyapp/inc/t_oomdummyappmsgs.h" + + +// Constants + +_LIT(KTextConsoleTitle, "Console"); +_LIT(KTextFailed, " failed, leave code = %d"); +_LIT(KTextPressAnyKey, " [press any key]\n"); + +const TInt KOomLowMemoryThreshold = 4096; +const TInt KOomJustUnderLowMemoryThreshold = 4000; +const TInt KOomSignificantlyUnderLowMemoryThreshold = 2024; +const TInt KOomJustAboveGoodMemoryThreshold = 5100; +const TInt KOomHarnessInitialEatenMemory = 1024; // Just eat 1K of memory initially, this can grow later + +const TInt KOomTestFirstIdlePeriod = 40000000; // 40 seconds + +const TInt KOomHarnessMaxEatenMemory = 64 * 1024 * 1024; + +// Global Variables + +LOCAL_D CConsoleBase* console; // write all messages to this + + +void COomTestHarness::StartL() + { + ResetL(); + + TInt err = KErrNone; + TBool testsFailed = EFalse; + + err = AppCloseTest1L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + err = AppCloseIdleTimeTest1L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + err = PluginTest1L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + + err = PluginTest2L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + err = AppPluginTest1L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + err = AppPluginIdleTimeTest1L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + err = OptionalAllocationTest1L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + err = OptionalAllocationTest2L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + err = OptionalAllocationTest3L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + err = PluginV2Test1L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + err = ForcePriorityCheck1L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + err = PluginSyncModeTest1L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + err = NeverCloseTest1L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + err = OptionalAllocationAsyncTest1L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + err = OptionalAllocationAsyncTest2L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + + err = OptionalAllocationAsyncTest3L(); + if (err != KErrNone) + testsFailed = ETrue; + + ResetL(); + +// if (err == KErrNone) +// err = BusyApplicationTest1L(); + + ResetL(); + +// if (err == KErrNone) +// err = NormalPriorityApplicationTest1L(); + + if (!testsFailed) + console->Printf(_L("All tests passed\n")); + else + console->Printf(_L("Tests failed\n")); + } + +// Test normal application closure for a single app +// Start three applications +// The lowest priority app should be in the foregound +// ... with the next lowest behind it +// ... followed by the highest priority application at the back +// The middle and highest priority application should be configured to eat 5MB of memory +// A low memory event is triggered and the middle application only should be closed +TInt COomTestHarness::AppCloseTest1L() + { + // The lowest priority app should be in the foregound + // ... with the next lowest behind it + // ... followed by the highest priority application at the back + StartApplicationL(0x101f8599, 5 * 1024); // P9 app + StartApplicationL(0x10005901, 5 * 1024); // P8 app, configure it to eat 5MB + StartApplicationL(0x10005a22, 0); // P7 app + + BringAppToForeground(0x10005a22); + + Settle(); + + // Go significantly under the low memory threshold + EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold); + + Settle(); + + TInt err = KErrNone; + + // The P8 application should be closed + err = AppIsRunning(0x10005901, EFalse); + + // The P7 app should still be running because it was in the foreground + if (err == KErrNone) + err = AppIsRunning(0x10005a22, ETrue); + + // The P9 app should still be running because the P8 application freed enough memory + if (err == KErrNone) + err = AppIsRunning(0x101f8599, ETrue); + + if (err == KErrNone) + console->Printf(_L("App Close Test 1 passed\n")); + else + console->Printf(_L("App Close Test 1 failed\n")); + + return err; + + } + +// Tests the idle time rule mechanism for app closure +// Start three applications +// The lowest priority app should be in the foregound +// ... with the next lowest behind it +// ... followed by the highest priority application at the back +// After an idle period the highest priority app is configured to become the lowest priority +// The middle and highest application should be configured to eat 5MB of memory +// A low memory event is triggered and the middle application only should be closed +// Note that this test should be the same as AppCloseTest1L, with the exception of the idle period which causes different apps to be closed +TInt COomTestHarness::AppCloseIdleTimeTest1L() + { + // The lowest priority app should be in the foregound + // ... with the next lowest behind it + // ... followed by the highest priority application at the back + StartApplicationL(0x101f8599, 5 * 1024); // P9 app (which becomes a P2 app after the idle time) + StartApplicationL(0x10005901, 5 * 1024); // P8 app, configure it to eat 5MB + StartApplicationL(0x10005a22, 0); // P7 app + + BringAppToForeground(0x10005a22); + + Settle(); + + // Wait for the first set of idle time rules to apply + User::After(KOomTestFirstIdlePeriod); + + // Go significantly under the low memory threshold + EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold); + + Settle(); + + // The first two system plugins should have been closed, releasing the required memory + // The following two system plugins won't be called (the app plugins will now take their place) + TInt err = KErrNone; + + // The P9 app should have become a P2 app after the idle period, therefore it should have been the first candidate for closure + if (err == KErrNone) + err = AppIsRunning(0x101f8599, EFalse); + + // The P8 application should still be running because the P9 app (that has become a P2 app) has freed the required memory + err = AppIsRunning(0x10005901, ETrue); + + // The P7 app should still be running because it was in the foreground + if (err == KErrNone) + err = AppIsRunning(0x10005a22, ETrue); + + if (err == KErrNone) + console->Printf(_L("App Close Idle Time Test 1 passed\n")); + else + console->Printf(_L("App Close Idle Time Test 1 failed\n")); + + return err; + + } + + + +TInt COomTestHarness::PluginTest1L() + { + // Configure the plugins to eat 0.5MB each: + for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++) + { + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000)); + } + + Settle(); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + Settle(); + + // The first four system plugins should have been run, releasing the required memory + // All four plugins should be called, even though the first two will release enough memory (this is because + // plugins are always run in continue mode) + TInt err = KErrNone; + + err = PluginFreeRamCalledL(KUidOOMDummyPluginFirstImplementation, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(KUidOOMDummyPluginFirstImplementation + 1, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(KUidOOMDummyPluginFirstImplementation + 2, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3C, ETrue); + + + // Finally check that the plugins have been notified of the final good memory state + if (err == KErrNone) + err = PluginMemoryGoodCalledL(KUidOOMDummyPluginFirstImplementation, ETrue); + + if (err == KErrNone) + err = PluginMemoryGoodCalledL(KUidOOMDummyPluginFirstImplementation + 1, ETrue); + + if (err == KErrNone) + err = PluginMemoryGoodCalledL(KUidOOMDummyPluginFirstImplementation + 2, ETrue); + + if (err == KErrNone) + err = PluginMemoryGoodCalledL(0x10286A3C, ETrue); + + if (err == KErrNone) + console->Printf(_L("Plugin Test 1 passed\n")); + else + console->Printf(_L("Plugin Test 1 failed\n")); + + return err; + } + + +// Test application plugins +// Start two target apps +// Simulate a low memory event +// The one of the application plugins should now be run, displacing one of the system plugins +// The target apps are of sufficiently high priority that they will not be closed +TInt COomTestHarness::PluginTest2L() + { + // Configure the plugins to eat 0.5MB each: + for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++) + { + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000)); + } + + // Start the two target applications (plus a third so that the target apps are not in the foreground) + StartApplicationL(0x10005901, 0); + StartApplicationL(0x10005a22, 0); + StartApplicationL(0x101f8599, 0); + + BringAppToForeground(0x101f8599); + + Settle(); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + Settle(); + + // The first two system plugins should have been closed, releasing the required memory + // The following two system plugins won't be called (the app plugins will now take their place) + TInt err = KErrNone; + + // The following plugins should be called... + // Application plugins: 10286A3A 10286A3B + // System plugins: 10286A3C(v2 plugin) 10286A34 + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3A, ETrue); + + // Plugins and apps with higher priorities will not be called/closed because 0x10286A3A is configured to check memory before running anything else + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3C, EFalse); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A34, EFalse); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A35, EFalse); + + if (err == KErrNone) + err = AppIsRunning(0x10005a22, ETrue); + + if (err == KErrNone) + err = AppIsRunning(0x10005901, ETrue); + + if (err == KErrNone) + err = AppIsRunning(0x101f8599, ETrue); + + + if (err == KErrNone) + console->Printf(_L("Plugin Test 2 passed\n")); + else + console->Printf(_L("Plugin Test 2 failed\n")); + + return err; + + } + + + +// Test that the aBytesRequested is correctly passed to the FreeMemory function of V2 plugins +// Initialise P4 plugin to consume 5MB of memory +// No other plugins are configured to release memory +// Simulate a low memory event (go just below the low threshold) +// Check that the P4 plugin has been called +// Check that the P4 plugin has received a request for > 500K and less than <1500K +TInt COomTestHarness::PluginV2Test1L() + { + // Configure the P4 V2 plugin to eat 5MB: + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A3C), 0, 0x500000, 0x500000)); + + Settle(); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + Settle(); + + // The first four system plugins should have been closed, releasing the required memory + // All four plugins should be called, even though the first two will release enough memory (this is because + // plugins are always run in continue mode) + TInt err = KErrNone; + + // Check that the P4 plugin has been called + err = PluginFreeRamCalledL(0x10286A3C, ETrue); + + // Check that the request for memory was about right + // Note: regular system variation makes it impossible to test for an exact number + TInt requestedMemory = 0; + err = RProperty::Get(KUidOomPropertyCategory, 0x10286A3C + KOOMDummyPluginBytesRequested, requestedMemory); + if ((requestedMemory < 512 * 1024) + || (requestedMemory > 1500 * 1024)) + err = KErrGeneral; + + // Check that the higher priority V2 plugin has not been called + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3D, EFalse); + + if (err == KErrNone) + console->Printf(_L("Plugin V2 Test 1 passed\n")); + else + console->Printf(_L("Plugin V2 Test 1 failed\n")); + + return err; + } + + +// Test simple prioritisation of application plugins +// Start two target applications +// Configure all plugins to consume 0.5MB +// Simulate a low memory event +// Some of the low priority app plugins with those target applications should be called +// The highest priority app with that target application should not be called (the lower priority plugins should free enough memory) +TInt COomTestHarness::AppPluginTest1L() + { + // Configure the plugins to eat 0.5MB each: + for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++) + { + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000)); + } + + // Start the two target applications (plus a third so that the target apps are not in the foreground) + StartApplicationL(0x10005901, 0); + StartApplicationL(0x10005a22, 0); + StartApplicationL(0x101f8599, 0); + + TInt err = KErrNone; + + // Check that all of the apps are running + if (err == KErrNone) + err = AppIsRunning(0x10005901, ETrue); + + if (err == KErrNone) + err = AppIsRunning(0x10005a22, ETrue); + + if (err == KErrNone) + err = AppIsRunning(0x101f8599, ETrue); + + if (err == KErrNone) + console->Printf(_L("Apps started\n")); + else + console->Printf(_L("Apps not started\n")); + + + + BringAppToForeground(0x101f8599); + + Settle(); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + Settle(); + + // The following application plugins should be called... + // Application plugins: 10286A3A 10286A3B + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3A, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + + // The following plugin should not be called because other plugins (including some unchecked system plugins) have freed enough memory + // 10286A38 + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A38, EFalse); + + if (err == KErrNone) + console->Printf(_L("App Plugin Test 1 passed\n")); + else + console->Printf(_L("App Plugin Test 1 failed\n")); + + return err; + + } + +// Test simple prioritisation of application plugins +// Start two target applications +// Configure all plugins to consume 0.5MB +// The app plugin with the highest priority is configured to be assigned the lowest priority after an idle time +// Wait until the idle time rule applies +// Simulate a low memory event +// The plugin that initially had the highest priority (but now has the lowest priority) should be called +// Note that this test should be the same as AppPluginTest1L with the addition of the idle period +TInt COomTestHarness::AppPluginIdleTimeTest1L() + { + // Configure the plugins to eat 0.5MB each: + for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++) + { + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000)); + } + + // Start the two target applications (plus a third so that the target apps are not in the foreground) + StartApplicationL(0x10005901, 0); + StartApplicationL(0x10005a22, 0); + StartApplicationL(0x101f8599, 0); + + BringAppToForeground(0x101f8599); + + TInt err = KErrNone; + + Settle(); + + User::After(KOomTestFirstIdlePeriod); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + Settle(); + + // The following application plugins should be called... + // Application plugins: 10286A3A 10286A3B + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3A, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + + // The following plugin should also be called (its priority was initially too high but has been reduced after the idle time) + // 10286A38 + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A38, ETrue); + + if (err == KErrNone) + console->Printf(_L("Plugin Idle Time Test 1 passed\n")); + else + console->Printf(_L("Plugin Idle Time Test 1 failed\n")); + + return err; + + } + + +// Test the optional allocation mechanism +// Configure the plugins not to release any RAM when FreeRam is called +// Configure one priority 7 application to release 12MB when FreeRam is called +// Start this application (plus another one so it isn't in the foreground) +// Drop just above the good memory level +// Request an optional allocation of 10MB referencing a priority 8 plugin +// All of the plugins below P8 should be called +// The P7 application should be closed freeing the required memory +TInt COomTestHarness::OptionalAllocationTest1L() + { + // Start an application (plus a second so that the first app is not in the foreground) + // The first application is set to consume 12MB of RAM + StartApplicationL(0x10005A22, 12 * 1024); + StartApplicationL(0x101F8599, 0); + + BringAppToForeground(0x101F8599); + + Settle(); + + // Go just above the good memory threshold + EatMemoryL(KOomJustAboveGoodMemoryThreshold); + + Settle(); + + // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8) + TInt bytesAvailable; + TInt err = iOomSession.RequestOptionalRam(10 * 1024 * 1024, 10 * 1024 * 1024, 0x10286A37, bytesAvailable); + + // Check that all system plugins below P8 have been called + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A34, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A35, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A36, ETrue); + + // This the P8 system plugin has not been called + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A37, EFalse); + + // Check that the low priority app plugin has been called + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + + // Check that the P7 application has been closed + if (err == KErrNone) + err = AppIsRunning(0x10005A22, EFalse); + + if (err == KErrNone) + console->Printf(_L("Optional Allocation Test 1 passed\n")); + else + console->Printf(_L("Optional Allocation Test 1 failed\n")); + + + return err; + } + + +// Test the optional allocation mechanism - minimum requested RAM behaviour - successful request +// Configure the plugins not to release any RAM when FreeRam is called +// Configure one priority 7 application to release 5MB when FreeRam is called +// Start this application (plus another one so it isn't in the foreground) +// Drop just above the good memory level +// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin +// All of the plugins below P8 should be called +// The P7 application should be closed freeing the required minimum amount memory +// The returned available memory should be about 5MB ( > 3MB and < 7MB ) +TInt COomTestHarness::OptionalAllocationTest2L() + { + // Start an application (plus a second so that the first app is not in the foreground) + // The first application is set to consume 5MB of RAM + StartApplicationL(0x10005A22, 5 * 1024); + StartApplicationL(0x101F8599, 0); + + BringAppToForeground(0x101F8599); + + Settle(); + + // Go just above the good memory threshold + EatMemoryL(KOomJustAboveGoodMemoryThreshold); + + Settle(); + + // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8) + // Say that 5MB is the minimum we need + TInt bytesAvailable; + TInt err = iOomSession.RequestOptionalRam(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable); + + if (err == KErrNone) + { + // Check that the reported bytes available is > 3MB and < 7MB + if ((bytesAvailable < 3 * 1024 * 1024) + || (bytesAvailable > 7 * 1024 * 1024)) + { + err = KErrGeneral; + } + } + + // Check that all system plugins below P8 have been called + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A34, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A35, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A36, ETrue); + + // This the P8 system plugin has not been called + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A37, EFalse); + + // Check that the low priority app plugin has been called + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + + // Check that the P7 application has been closed + if (err == KErrNone) + err = AppIsRunning(0x10005A22, EFalse); + + if (err == KErrNone) + console->Printf(_L("Optional Allocation Test 2 passed\n")); + else + console->Printf(_L("Optional Allocation Test 2 failed\n")); + + + return err; + } + + + +// Test the optional allocation mechanism - minimum requested RAM behaviour - failed request +// Configure the plugins not to release any RAM when FreeRam is called +// Configure one priority 7 application to release 3MB when FreeRam is called +// Start this application (plus another one so it isn't in the foreground) +// Drop just above the good memory level +// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin +// All of the plugins below P8 should be called +// The P7 application should be closed but it won't free enough memory +// The optional allocation should fail with KErrNoMemory +TInt COomTestHarness::OptionalAllocationTest3L() + { + // Start an application (plus a second so that the first app is not in the foreground) + // The first application is set to consume 5MB of RAM + StartApplicationL(0x10005A22, 3 * 1024); + StartApplicationL(0x101F8599, 0); + + BringAppToForeground(0x101F8599); + + Settle(); + + // Go just above the good memory threshold + EatMemoryL(KOomJustAboveGoodMemoryThreshold); + + Settle(); + + // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8) + // Say that 5MB is the minimum we need + TInt bytesAvailable; + TInt err = iOomSession.RequestOptionalRam(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable); + + // We expect an error because it has not been possible to free the minimum memory + if (err == KErrNoMemory) + { + err = KErrNone; + } + else + { + err = KErrGeneral; + } + + // Check that all system plugins below P8 have been called + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A34, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A35, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A36, ETrue); + + // This the P8 system plugin has not been called + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A37, EFalse); + + // Check that the low priority app plugin has been called + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + + // Check that the P7 application has been closed + if (err == KErrNone) + err = AppIsRunning(0x10005A22, EFalse); + + if (err == KErrNone) + console->Printf(_L("Optional Allocation Test 3 passed\n")); + else + console->Printf(_L("Optional Allocation Test 3 failed\n")); + + + return err; + } + + +// Test that force priority check applies (only) to selected priorities +// Setup three plugins (priorities 7, 8 & 9)to eat 5MB each +// The configuration file should force a check after priority 8 +// Drop just under the low threshold +// Plugins P7 & P8 should be called (P8 is called even though the P7 plugin freed enough memory) +// Plugin P9 should not be called because enou +TInt COomTestHarness::ForcePriorityCheck1L() + { + // Configure the P7, P8 and P9 plugins to eat 5MB each: + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A36), 0, 0x500000, 0x500000)); // P7 + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A37), 0, 0x500000, 0x500000)); // P8 + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A3D), 0, 0x500000, 0x500000)); // P9 + + Settle(); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + Settle(); + + TInt err = KErrNone; + + // The P7 plugin should have been called and is the first to release RAM + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A36, ETrue); + + // The P8 plugin should be called even though the P7 plugin has already released enough memory because the plugin runs in continue mode and there is no forced check + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A37, ETrue); + + // The P9 plugin should not be called because of the force priority check (the P7 & P8 plugins have already released plenty of RAM) + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3D, EFalse); + + if (err == KErrNone) + console->Printf(_L("Force Prioirty Check Test 1 passed\n")); + else + console->Printf(_L("Force Prioirty Check Test 1 failed\n")); + + return err; + + } + + + +// Test the Busy API on the OOM server +// Start three applications +// Ensure that the lowest priority app is not in the foreground +// Call the busy API on the OOM monitor for the lowest priority app +// Simulate a low memory event by going just under the low threshold +// The busy application should not be closed +// The other (non-foreground) application should be closed +TInt COomTestHarness::BusyApplicationTest1L() + { + // Start the two target applications (plus a third so that the target apps are not in the foreground) + StartApplicationL(0x10005901, 0); + StartApplicationL(0x101f8599, 0); + StartApplicationL(0x10005a22, 0); // Lowest priority app + + BringAppToForeground(0x101f8599); // TODO: this doesn't seem to be working - message not getting through to the dummy application + + Settle(); + + // Send the second app a message to make itself busy + TInt id = iApps.Find(TUid::Uid(0x10005a22), CCDummyApplicationHandle::CompareTo); + User::LeaveIfError(id); + iApps[id]->SendMessage(KOomDummyAppSetBusy); + + Settle(); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + Settle(); + + // The first four system plugins should have been closed, releasing the required memory + // All four plugins should be called, even though the first two will release enough memory (this is because + // plugins are always run in continue mode) + TInt err = KErrNone; + + // Check that the busy application is still running + if (err == KErrNone) + err = AppIsRunning(0x10005a22, ETrue); + + // Check that the higher priority but non-busy application has been close + if (err == KErrNone) + err = AppIsRunning(0x10005901, EFalse); + + if (err == KErrNone) + console->Printf(_L("Busy Application Test 1 passed\n")); + else + console->Printf(_L("Busy Application Test 1 failed\n")); + + return err; + } + + +// Test the NotBusy API on the OOM server +// Start three applications +// Ensure that the lowest priority app is not in the foreground +// Call the busy API on the OOM monitor for the lowest priority app +// Then call the not-busy API on the OOM monitor for the lowest priority app +// Simulate a low memory event by going just under the low threshold +// The lowest priority app should be closed (because it is no longer busy) +TInt COomTestHarness::NormalPriorityApplicationTest1L() + { + // Start the two target applications (plus a third so that the target apps are not in the foreground) + StartApplicationL(0x10005901, 0); + StartApplicationL(0x10005a22, 0); // Lowest priority app + StartApplicationL(0x101f8599, 0); + + BringAppToForeground(0x101f8599); + + Settle(); + + // Send the second app a message to make itself busy + TInt id = iApps.Find(TUid::Uid(0x10005a22), CCDummyApplicationHandle::CompareTo); + User::LeaveIfError(id); + // TODO: temp removed - needs to be put back +// iApps[id]->SendMessage(KOomDummyAppSetBusy); + + // Send the second app a message to make itself normal priority + id = iApps.Find(TUid::Uid(0x10005a22), CCDummyApplicationHandle::CompareTo); + User::LeaveIfError(id); + iApps[id]->SendMessage(KOomDummyAppSetNormalPriority); + + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + Settle(); + + // The first four system plugins should have been closed, releasing the required memory + // All four plugins should be called, even though the first two will release enough memory (this is because + // plugins are always run in continue mode) + TInt err = KErrNone; + + // Check that the no-longer-busy application has been closed + if (err == KErrNone) + err = AppIsRunning(0x10005a22, EFalse); + + if (err == KErrNone) + console->Printf(_L("Normal Priority Application Test 1 passed\n")); + else + console->Printf(_L("Normal Priority Application Test 2 failed\n")); + + return err; + } + + + +// Start three applications +// One is set to NEVER_CLOSE, one is low priority, one is a dummy app to ensure that the first two are not in the foreground +// Configure applications not to release any memory +// Go just significantly under the low memory threshold +// Wait for the system to recover, if we have moved above the low memory threshold then go significantly under it again. Repeat this step until we no longer go above low. +// Check that the low priority application is closed +// Check that the NEVER_CLOSE application is not closed (even though we're still below the low theshold) +TInt COomTestHarness::NeverCloseTest1L() + { + // Start the two target applications (plus a third so that the target apps are not in the foreground) + StartApplicationL(0x10005a22, 0); // Lowest priority app + StartApplicationL(0x10008d39, 0); // NEVER_CLOSE application + StartApplicationL(0x101f8599, 0); + + BringAppToForeground(0x101f8599); + + Settle(); + + EatMemoryUntilWeAreStuckUnderTheLowThresholdL(); + + Settle(); + + // The first four system plugins should have been closed, releasing the required memory + // All four plugins should be called, even though the first two will release enough memory (this is because + // plugins are always run in continue mode) + TInt err = KErrNone; + + // The NEVER_CLOSE app should still be running (even though we are still below the low threshold) + if (err == KErrNone) + err = AppIsRunning(0x10008d39, ETrue); + + // The low priority app should still be closed (even though we are still below the low threshold) + if (err == KErrNone) + err = AppIsRunning(0x10005a22, EFalse); + + if (err == KErrNone) + console->Printf(_L("Never Close Test 1 passed\n")); + else + console->Printf(_L("Never Close Test 2 failed\n")); + + return err; + } + + + + + +// Test that sync mode configuration is working for system plugins +// Configure three system plugins to release 5MB of memory each. +// The plugins are configured as follows +// Plugin 1: Priority 7, sync mode continue +// Plugin 2: Priority 8, sync mode check +// Plugin 3: Priority 9, sync mode continue +// Drop just under the low threshold +// Plugins 1 & 2 should be called (even though plugin 1 alone has freed enough RAM) +// Plugin 3 won't be called because the check on the priority 8 plugin discovers that enough RAM has been freed +TInt COomTestHarness::PluginSyncModeTest1L() + { + // Configure three plugins to eat 5MB each: + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A36), 0, 0x500000, 0x500000)); + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A37), 0, 0x500000, 0x500000)); + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A3D), 0, 0x500000, 0x500000)); + + Settle(); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + Settle(); + + // The first four system plugins should have been run, releasing the required memory + // All four plugins should be called, even though the first two will release enough memory (this is because + // plugins are always run in continue mode) + TInt err = KErrNone; + + // Check that the first two plugins have been called, but not the third + err = PluginFreeRamCalledL(0x10286A36, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A37, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3D, EFalse); + + if (err == KErrNone) + console->Printf(_L("Plugin Sync Mode Test 1 passed\n")); + else + console->Printf(_L("Plugin Sync Mode Test 1 failed\n")); + + return err; + } + + + + +// Test the optional allocation mechanism +// Configure the plugins not to release any RAM when FreeRam is called +// Configure one priority 7 application to release 12MB when FreeRam is called +// Start this application (plus another one so it isn't in the foreground) +// Drop just above the good memory level +// Request an optional allocation of 10MB referencing a priority 8 plugin +// All of the plugins below P8 should be called +// The P7 application should be closed freeing the required memory +TInt COomTestHarness::OptionalAllocationAsyncTest1L() + { + // Start an application (plus a second so that the first app is not in the foreground) + // The first application is set to consume 12MB of RAM + StartApplicationL(0x10005A22, 12 * 1024); + StartApplicationL(0x101F8599, 0); + + BringAppToForeground(0x101F8599); + + Settle(); + + // Go just above the good memory threshold + EatMemoryL(KOomJustAboveGoodMemoryThreshold); + + Settle(); + + // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8) + TInt bytesAvailable; + TInt err = RequestOptionalRamASyncWrapper(10 * 1024 * 1024, 10 * 1024 * 1024, 0x10286A37, bytesAvailable); + + // Check that all system plugins below P8 have been called + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A34, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A35, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A36, ETrue); + + // This the P8 system plugin has not been called + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A37, EFalse); + + // Check that the low priority app plugin has been called + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + + // Check that the P7 application has been closed + if (err == KErrNone) + err = AppIsRunning(0x10005A22, EFalse); + + if (err == KErrNone) + console->Printf(_L("Optional Allocation (Async) Test 1 passed\n")); + else + console->Printf(_L("Optional Allocation (Async) Test 1 failed\n")); + + + return err; + } + + +// Test the optional allocation mechanism - minimum requested RAM behaviour - successful request +// Configure the plugins not to release any RAM when FreeRam is called +// Configure one priority 7 application to release 5MB when FreeRam is called +// Start this application (plus another one so it isn't in the foreground) +// Drop just above the good memory level +// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin +// All of the plugins below P8 should be called +// The P7 application should be closed freeing the required minimum amount memory +// The returned available memory should be about 5MB ( > 3MB and < 7MB ) +TInt COomTestHarness::OptionalAllocationAsyncTest2L() + { + // Start an application (plus a second so that the first app is not in the foreground) + // The first application is set to consume 5MB of RAM + StartApplicationL(0x10005A22, 5 * 1024); + StartApplicationL(0x101F8599, 0); + + BringAppToForeground(0x101F8599); + + Settle(); + + // Go just above the good memory threshold + EatMemoryL(KOomJustAboveGoodMemoryThreshold); + + Settle(); + + // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8) + // Say that 5MB is the minimum we need + TInt bytesAvailable; + TInt err = RequestOptionalRamASyncWrapper(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable); + + if (err == KErrNone) + { + // Check that the reported bytes available is > 3MB and < 7MB + if ((bytesAvailable < 3 * 1024 * 1024) + || (bytesAvailable > 7 * 1024 * 1024)) + { + err = KErrGeneral; + } + } + + // Check that all system plugins below P8 have been called + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A34, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A35, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A36, ETrue); + + // This the P8 system plugin has not been called + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A37, EFalse); + + // Check that the low priority app plugin has been called + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + + // Check that the P7 application has been closed + if (err == KErrNone) + err = AppIsRunning(0x10005A22, EFalse); + + if (err == KErrNone) + console->Printf(_L("Optional Allocation (Async) Test 2 passed\n")); + else + console->Printf(_L("Optional Allocation (Async) Test 2 failed\n")); + + + return err; + } + + + +// Test the optional allocation mechanism - minimum requested RAM behaviour - failed request +// Configure the plugins not to release any RAM when FreeRam is called +// Configure one priority 7 application to release 3MB when FreeRam is called +// Start this application (plus another one so it isn't in the foreground) +// Drop just above the good memory level +// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin +// All of the plugins below P8 should be called +// The P7 application should be closed but it won't free enough memory +// The optional allocation should fail with KErrNoMemory +TInt COomTestHarness::OptionalAllocationAsyncTest3L() + { + // Start an application (plus a second so that the first app is not in the foreground) + // The first application is set to consume 5MB of RAM + StartApplicationL(0x10005A22, 3 * 1024); + StartApplicationL(0x101F8599, 0); + + BringAppToForeground(0x101F8599); + + Settle(); + + // Go just above the good memory threshold + EatMemoryL(KOomJustAboveGoodMemoryThreshold); + + Settle(); + + // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8) + // Say that 5MB is the minimum we need + TInt bytesAvailable; + TInt err = RequestOptionalRamASyncWrapper(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable); + + // We expect an error because it has not been possible to free the minimum memory + if (err == KErrNoMemory) + { + err = KErrNone; + } + else + { + err = KErrGeneral; + } + + // Check that all system plugins below P8 have been called + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A34, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A35, ETrue); + + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A36, ETrue); + + // This the P8 system plugin has not been called + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A37, EFalse); + + // Check that the low priority app plugin has been called + if (err == KErrNone) + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + + // Check that the P7 application has been closed + if (err == KErrNone) + err = AppIsRunning(0x10005A22, EFalse); + + if (err == KErrNone) + console->Printf(_L("Optional Allocation (Async) Test 3 passed\n")); + else + console->Printf(_L("Optional Allocation (Async) Test 3 failed\n")); + + + return err; + } + + + + +////////////////////////////////////////////////////////////////////////////// + + +TInt COomTestHarness::BringAppToForeground(TInt32 aUid) + { + //bring app to foreground + TInt id = iApps.Find(TUid::Uid(aUid), CCDummyApplicationHandle::CompareTo); + User::LeaveIfError(id); + iApps[id]->BringToForeground(); + User::After(KSettlingTime); + } + + +COomTestHarness* COomTestHarness::NewLC() + { + COomTestHarness* self = new (ELeave) COomTestHarness(); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +void COomTestHarness::ConstructL() + { + User::LeaveIfError(iAllocServer.Connect()); + User::LeaveIfError(iOomSession.Connect()); + + User::LeaveIfError(iChunk.CreateLocal(KOomHarnessInitialEatenMemory, KOomHarnessMaxEatenMemory)); + iChunkSize = KOomHarnessInitialEatenMemory; + + ResetL(); + } + + +COomTestHarness::~COomTestHarness() + { + iApps.ResetAndDestroy(); + iAllocServer.Close(); + iChunk.Close(); + iPluginCallCounts.Close(); + } + + +void COomTestHarness::ResetL() + { + Settle(); + + // Close any dummy apps + iApps.ResetAndDestroy(); + + Settle(); + + // Free all memory being eaten by the server + iChunk.Adjust(KOomHarnessInitialEatenMemory); // Just eat 1K of memory initially, this can grow later + iChunkSize = KOomHarnessInitialEatenMemory; + + User::LeaveIfError(iAllocServer.Reset()); + + // Wait for the system to settle before getting the call counts (freeing the memory could cause some more movement). + Settle(); + + // Update the call counts on the plugins (add them if they're not there already) + for (TInt pluginUid = KUidOOMDummyPluginFirstImplementation; pluginUid <= KUidOOMDummyPluginLastImplementation; pluginUid++) + { + TInt lowMemoryCount = 0; + RProperty::Get(KUidOomPropertyCategory, pluginUid + KOOMDummyPluginLowMemoryCount, lowMemoryCount); + + TInt goodMemoryCallCount = 0; + RProperty::Get(KUidOomPropertyCategory, pluginUid + KOOMDummyPluginGoodMemoryCount, goodMemoryCallCount); + + TPluginCallCount pluginCallCount; + pluginCallCount.iFreeRamCallCount = lowMemoryCount; + pluginCallCount.iMemoryGoodCallCount = goodMemoryCallCount; + + iPluginCallCounts.InsertL(pluginUid, pluginCallCount); + }; + } + +void COomTestHarness::EatMemoryL(TInt aKBytesToLeaveFree) + { + Settle(); + + TMemoryInfoV1Buf meminfo; + UserHal::MemoryInfo(meminfo); + TInt freeMem = meminfo().iFreeRamInBytes; + + // Resize the dummy chunk to consume the correct ammount of memory + iChunkSize = freeMem + iChunkSize - (aKBytesToLeaveFree * 1024); + TInt err = iChunk.Adjust(iChunkSize); + User::LeaveIfError(err); + } + +// Set up the plugins and applications - this is the starting point for many test cases +// 5 applications are started with approx 0.5 MB used for each +// 0.5MB (approx) of memory is reserved for each one of the plugins +void COomTestHarness::CommonSetUpL() + { + // Configure the plugins to eat 0.5MB each: + for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation; pluginIndex++) + { + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000)); + } + } + +void COomTestHarness::StartApplicationL(TInt32 aUid, TInt aInitialAllocationInKBs) + { + User::ResetInactivityTime(); + CCDummyApplicationHandle *app = CCDummyApplicationHandle::NewLC(TUid::Uid(aUid), aInitialAllocationInKBs * 1024); + iApps.AppendL(app); + CleanupStack::Pop(app); + Settle(); + } + +// Returns KErrNone if we get the expected result +TInt COomTestHarness::AppIsRunning(TInt32 aUid, TBool aExpectedResult) + { + TBool appRunning = ETrue; + + TInt id = iApps.Find(TUid::Uid(aUid), CCDummyApplicationHandle::CompareTo); + if (id < 0) + appRunning = EFalse; + else if(iApps[id]->Process().ExitType() != EExitPending) + appRunning = EFalse; + + TInt err = KErrNone; + + if (aExpectedResult != appRunning) + err = KErrGeneral; + + if (aExpectedResult != appRunning) + { + console->Printf(_L("Application running state not as expected %x \n"), aUid); + err = KErrGeneral; + } + + return err; + } + + +// Utility function which calls the async version of optional RAM request and makes it behave like the sync version +TInt COomTestHarness::RequestOptionalRamASyncWrapper(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable) + { + TInt err = KErrNone; + TRequestStatus status; + iOomSession.RequestOptionalRam(aBytesRequested, aMinimumBytesNeeded, aPluginId, status); + User::WaitForRequest(status); + + if (status.Int() < 0) + err = status.Int(); + else + aBytesAvailable = status.Int(); + + return err; + } + + +TInt COomTestHarness::GetFreeMemory() + { + User::CompressAllHeaps(); + + TInt current = 0; + HAL::Get( HALData::EMemoryRAMFree, current ); + + return current; + } + +// Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)? +// Returns KErrNone if we get the expected result +TInt COomTestHarness::PluginFreeRamCalledL(TInt32 aUid, TBool aExpectedResult) + { + TInt newLowMemoryCount = 0; + TInt err = RProperty::Get(KUidOomPropertyCategory, aUid + KOOMDummyPluginLowMemoryCount, newLowMemoryCount); + + if (err != KErrNone) + console->Printf(_L("Unable to get plugin FreeRam count\n")); + + TBool freeRamHasBeenCalledOnPlugin = EFalse; + TPluginCallCount* pluginCallCount = iPluginCallCounts.Find(aUid); + + if (pluginCallCount) + { + freeRamHasBeenCalledOnPlugin = (pluginCallCount->iFreeRamCallCount != newLowMemoryCount); + + if (freeRamHasBeenCalledOnPlugin) + { + // Update the list of old counts with the current value so we can see if it has changed next time this function is called + pluginCallCount->iFreeRamCallCount = newLowMemoryCount; + iPluginCallCounts.InsertL(aUid, *pluginCallCount); + } + } + else + { + console->Printf(_L("Unable to find call count.\n")); + err = KErrNotFound; + } + + if (aExpectedResult != freeRamHasBeenCalledOnPlugin) + { + console->Printf(_L("Plugin FreeRam count not as expected %x \n"), aUid); + err = KErrGeneral; + } + + return err; + } + +// Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)? +// Returns KErrNone if we get the expected result +TInt COomTestHarness::PluginMemoryGoodCalledL(TInt32 aUid, TBool aExpectedResult) + { + TInt newGoodMemoryCount = 0; + RProperty::Get(KUidOomPropertyCategory, aUid + KOOMDummyPluginGoodMemoryCount, newGoodMemoryCount); + + TBool memoryGoodHasBeenCalledOnPlugin = EFalse; + TPluginCallCount* pluginCallCount = iPluginCallCounts.Find(aUid); + + if (pluginCallCount) + { + memoryGoodHasBeenCalledOnPlugin = (pluginCallCount->iMemoryGoodCallCount != newGoodMemoryCount); + + if (memoryGoodHasBeenCalledOnPlugin) + { + // Update the list of old counts with the current value so we can see if it has changed next time this function is called + pluginCallCount->iMemoryGoodCallCount = newGoodMemoryCount; + iPluginCallCounts.InsertL(aUid, *pluginCallCount); + } + } + + TInt err = KErrNone; + + if (aExpectedResult != memoryGoodHasBeenCalledOnPlugin) + err = KErrGeneral; + + return err; + } + +void COomTestHarness::EatMemoryUntilWeAreStuckUnderTheLowThresholdL() + { + while (ETrue) + { + // Go significantly under the low memory threshold + EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold); + Settle(); + // If we are still under the memory threshold then the OOM monitor has not been able to recover, + // so our job here is done... + if (GetFreeMemory() < (KOomLowMemoryThreshold * 1024)) + break; + + // If memory has been released to take us above the low memory threshold then go again... + } + } + + +COomTestHarness::COomTestHarness() + { + // TODO + } + + +// Local Functions +LOCAL_C void MainL() + { + COomTestHarness* testHarness = COomTestHarness::NewLC(); + + testHarness->StartL(); + + CleanupStack::PopAndDestroy(testHarness); + } + +// Local Functions +LOCAL_C void OldMainL() + { + // + // add your program code here, example code below + // + const TInt implementations(KUidOOMDummyPluginLastImplementation-KUidOOMDummyPluginFirstImplementation+1); + TInt initialLowCount[implementations]; + TInt initialGoodCount[implementations]; + TInt finalLowCount[implementations]; + TInt finalGoodCount[implementations]; + TInt tmp; + TBuf<80> line; + TBool pass = ETrue; + ROOMAllocSession allocServer; + TMemoryInfoV1Buf meminfo; + //connect to alloc server + User::LeaveIfError(allocServer.Connect()); + CleanupClosePushL(allocServer); + //configure alloc server + User::LeaveIfError(allocServer.Reset()); +/* User::LeaveIfError(allocServer.Configure(TUid::Uid(KUidOOMDummyPluginFirstImplementation), 0x100000, 0x1000, 0x400000)); + User::LeaveIfError(allocServer.Configure(TUid::Uid(KUidOOMDummyPluginFirstImplementation+3), 0x100000, 0x1000, 0x400000)); + User::LeaveIfError(allocServer.StartAllocating()); + for(TInt i=0;i<5;i++) + { + UserHal::MemoryInfo(meminfo); + console->Printf(_L("free mem %d"), meminfo().iFreeRamInBytes); + User::After(1000000); + }*/ + //create dummy apps (note app with that UID *must* exist or apparc won't allow contruction due to missing app_reg.rsc) + RPointerArray apps; + CleanupResetAndDestroyPushL(apps); + CCDummyApplicationHandle *app = CCDummyApplicationHandle::NewLC(KUidCalendar, 0x100000); + apps.AppendL(app); + CleanupStack::Pop(app); + app = CCDummyApplicationHandle::NewLC(KUidClock, 0x100000); + apps.AppendL(app); + CleanupStack::Pop(app); + app = CCDummyApplicationHandle::NewLC(KUidAbout, 0x100000); + apps.AppendL(app); + CleanupStack::Pop(app); + + //wait for oom system to settle + User::After(KSettlingTime); + + //verify apps started OK + for(TInt i=0;iProcess().ExitType() != EExitPending) + { + pass = EFalse; + console->Printf(_L("app %x not running (status %d)\n"),apps[i]->Uid().iUid,apps[i]->Process().ExitType()); + } + } + + //bring calendar to foreground + TInt id = apps.Find(KUidCalendar, CCDummyApplicationHandle::CompareTo); + User::LeaveIfError(id); + apps[id]->BringToForeground(); + User::After(KSettlingTime); + + //eat memory to invoke low memory handler + UserHal::MemoryInfo(meminfo); + TInt freeMem = meminfo().iFreeRamInBytes; + TAny *ptr = User::Alloc(freeMem - 247 * 1024); + CleanupStack::PushL(ptr); + + //wait for oom system to settle + User::After(KSettlingTime); + + //verify some apps were closed + for(TInt i=0;iProcess().ExitType() != EExitPending) + { + console->Printf(_L("app %x not running (status %d)\n"),apps[i]->Uid().iUid,apps[i]->Process().ExitType()); + } + else + { + console->Printf(_L("app %x still running\n"),apps[i]->Uid().iUid); + } + } + + //release memory to invoke good memory handler + CleanupStack::PopAndDestroy(ptr); + + //wait for oom system to settle + User::After(KSettlingTime); + +/* console->Write(_L("Initial Counts\n")); + for(TInt id=0;idWrite(line); + } + //check status of dummy apps + User::After(2000000); + line.Format(_L("app1 %d app2 %d\n"), app1.ExitType(), app2.ExitType()); + console->Write(line); + if(app1.ExitType() != EExitPending || app2.ExitType() != EExitPending) pass = EFalse; + if(pass) + console->Write(_L("verdict: pass")); + else + console->Write(_L("verdict: fail")); + console->Getch(); + + UserHal::MemoryInfo(meminfo); + TInt freeMem = meminfo().iFreeRamInBytes; + TAny *ptr = User::Alloc(freeMem - 260000); + CleanupStack::PushL(ptr); + console->Write(_L("Counts after alloc\n")); + for(TInt id=0;idWrite(line); + if(finalLowCount[id] - initialLowCount[id] != 1) pass = EFalse; + } + //check status of dummy apps + User::After(2000000); + line.Format(_L("app1 %d app2 %d\n"), app1.ExitType(), app2.ExitType()); + console->Write(line); + if(app1.ExitType() == EExitPending || app2.ExitType() == EExitPending) pass = EFalse; + if(pass) + console->Write(_L("verdict: pass")); + else + console->Write(_L("verdict: fail")); + console->Getch(); + CleanupStack::PopAndDestroy(ptr); + console->Write(_L("Counts after free\n")); + for(TInt id=0;idWrite(line); + if(finalGoodCount[id] - initialGoodCount[id] != 1) pass = EFalse; + } + //check status of dummy apps + User::After(2000000); + line.Format(_L("app1 %d app2 %d\n"), app1.ExitType(), app2.ExitType()); + console->Write(line); + if(app1.ExitType() == EExitPending || app2.ExitType() == EExitPending) pass = EFalse;*/ + if(pass) + console->Write(_L("verdict: pass")); + else + console->Write(_L("verdict: fail")); + console->Getch(); + allocServer.Reset(); + CleanupStack::PopAndDestroy(2);//apps, allocServer + } + +LOCAL_C void DoStartL() + { + // Create active scheduler (to run active objects) + CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); + CleanupStack::PushL(scheduler); + CActiveScheduler::Install(scheduler); + + MainL(); + + // Delete active scheduler + CleanupStack::PopAndDestroy(scheduler); + } + +// Global Functions + +GLDEF_C TInt E32Main() + { + // Create cleanup stack + __UHEAP_MARK; + CTrapCleanup* cleanup = CTrapCleanup::New(); + + // Create output console + TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize( + KConsFullScreen, KConsFullScreen))); + if (createError) + return createError; + + // Run application code inside TRAP harness, wait keypress when terminated + TRAPD(mainError, DoStartL()); + if (mainError) + console->Printf(KTextFailed, mainError); + console->Printf(KTextPressAnyKey); + console->Getch(); + + delete console; + delete cleanup; + __UHEAP_MARKEND; + return KErrNone; + } + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/BWINS/t_oomharness_stifu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/BWINS/t_oomharness_stifu.def Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + ?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * LibEntryL(void) + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/EABI/t_oomharness_stifu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/EABI/t_oomharness_stifu.def Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,3 @@ +EXPORTS + _Z9LibEntryLv @ 1 NONAME + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/group/bld.inf Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +PRJ_PLATFORMS +// specify the platforms your component needs to be built for here +// defaults to WINS MARM so you can ignore this if you just build these +DEFAULT + +PRJ_TESTEXPORTS + +PRJ_TESTMMPFILES +t_oomharness_stif.mmp + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/group/t_oomharness_stif.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/group/t_oomharness_stif.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include + +//uncomment to enable tests which require CLIENT_REQUEST_QUEUE +macro CLIENT_REQUEST_QUEUE + +TARGET t_oomharness_stif.dll +TARGETTYPE dll +// First UID is DLL UID, Second UID is STIF Test Framework UID +UID 0x1000008D 0x101FB3E7 + +VENDORID VID_DEFAULT + +CAPABILITY ALL -TCB + +// This is a SYSTEMINCLUDE macro containing the middleware +// layer specific include directories +MW_LAYER_SYSTEMINCLUDE + +USERINCLUDE ../inc +USERINCLUDE ../../inc + + +SOURCEPATH ../src +SOURCE t_oomharness.cpp +SOURCE t_oomharnessCases.cpp +SOURCE CDummyApplicationHandle.cpp + +LIBRARY euser.lib +LIBRARY stiftestinterface.lib +LIBRARY stiftestengine.lib +LIBRARY t_oomclient.lib +LIBRARY hal.lib +LIBRARY oommonitor.lib + diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/inc/CDummyApplicationHandle.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/inc/CDummyApplicationHandle.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef CDUMMYAPPLICATIONHANDLE_H +#define CDUMMYAPPLICATIONHANDLE_H + +// INCLUDES +#include +#include +#include + +// a few uids...use appuidlister to extract from the app_reg.rsc files +// and mappings to uids not used by tests anymore +const TInt KOomTestAppUid = 0xE6CFBA01; // 0x101f8599 +const TInt KOomTestApp2Uid = 0xE6CFBA02; // 0x10005901 +const TInt KOomTestApp3Uid = 0xE6CFBA03; // 0x10005a22 +const TInt KOomTestApp4Uid = 0xE6CFBA04; // 0x101f4cd5 +const TInt KOomTestApp5Uid = 0xE6CFBA05; // 0x10005234 +const TInt KOomTestApp6Uid = 0xE6CFBA06; // 0x10207218 +const TInt KOomTestApp7Uid = 0xE6CFBA07; // 0x10008d39 +const TInt KOomTestApp8Uid = 0xE6CFBA08; // 0x10005903 +const TInt KOomTestApp9Uid = 0xE6CFBA09; // 0x101f4cce +const TInt KOomTestApp10Uid = 0xE6CFBA0A; // 0x101f4cd2 + +// CLASS DECLARATION + +/** + * CCDummyApplicationHandle + * A helper class for launching dummy apps and checking their status + */ +NONSHARABLE_CLASS ( CCDummyApplicationHandle ) : public CBase + { +public: + // Constructors and destructor + + /** + * Destructor. + */ + ~CCDummyApplicationHandle(); + + /** + * Two-phased constructor. + */ + static CCDummyApplicationHandle* NewL(TUid aUid, TInt aExtraMemoryAllocation = 0); + + /** + * Two-phased constructor. + */ + static CCDummyApplicationHandle* NewLC(TUid aUid, TInt aExtraMemoryAllocation = 0); + + inline RProcess& Process() { return iProcess; } + inline const TUid& Uid() { return iUid; } + + void SendMessage(TInt aMessage); + + void BringToForeground(); + + static TBool CompareTo(const TUid* aKey, const CCDummyApplicationHandle& aValue); +private: + + /** + * Constructor for performing 1st stage construction + */ + CCDummyApplicationHandle(TUid aUid); + + /** + * EPOC default constructor for performing 2nd stage construction + */ + void ConstructL(TInt aExtraMemoryAllocation = 0); + + RProcess iProcess; + //a channel for sending control messages to the dummy app... + RMsgQueue iMsgQueue; + TUid iUid; + }; + +#endif // CDUMMYAPPLICATIONHANDLE_H diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/inc/t_oomharness.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/inc/t_oomharness.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,681 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + +#ifndef T_OOMHARNESS_H +#define T_OOMHARNESS_H + +// INCLUDES +#include "StifTestModule.h" +#include +#include +#include +#include "CDummyApplicationHandle.h" +#include "t_oomclient.h" +#include +#include + +// CONSTANTS + +const TInt KSettlingTime = 2000000; +const TInt KOomHarnessInitialEatenMemory= 1024; // Just eat 1K of memory initially, this can grow later +const TInt KOomHarnessMaxEatenMemory = 64 * 1024 * 1024; + +const TInt KTimeout = 20000000; //20 secs + +enum TTestStates + { + // EInit: Test initialisation phase + ETestInit, + + // EPossiblePass: In the case of memorymonitor reporting EAboveTreshhold + ETestAbove, + + // EFail: All other cases including timeout + ETestBelow, + + ETestTimeout + }; + +// MACROS +// None + +// Logging path +_LIT( KT_OomHarnessLogPath, "\\logs\\testframework\\T_OomHarness\\" ); +// Log file +_LIT( KT_OomHarnessLogFile, "T_OomHarness.txt" ); +_LIT( KT_OomHarnessLogFileWithTitle, "T_OomHarness_[%S].txt" ); + +// Function pointer related internal definitions +// Rounding known bug in GCC +#define GETPTR & +#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0} +#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0} +#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c} +#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c} + +// FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +class COomTestHarness; +class CMemoryMonitorStatusWatcher; +class CMemoryMonitorTimeoutWatcher; + +// DATA TYPES +// None + +// A typedef for function that does the actual testing, +// function is a type +// TInt COomTestHarness:: ( TTestResult& aResult ) +typedef TInt (COomTestHarness::* TestFunction)(TTestResult&); + +// CLASS DECLARATION + +/** +* An internal structure containing a test case name and +* the pointer to function doing the test +* +* @lib ?library +* @since ?Series60_version +*/ +class TCaseInfoInternal + { + public: + const TText* iCaseName; + TestFunction iMethod; + TBool iIsOOMTest; + TInt iFirstMemoryAllocation; + TInt iLastMemoryAllocation; + }; + +// CLASS DECLARATION + +/** +* A structure containing a test case name and +* the pointer to function doing the test +* +* @lib ?library +* @since ?Series60_version +*/ +class TCaseInfo + { + public: + TPtrC iCaseName; + TestFunction iMethod; + TBool iIsOOMTest; + TInt iFirstMemoryAllocation; + TInt iLastMemoryAllocation; + + TCaseInfo( const TText* a ) : iCaseName( (TText*) a ) + { + }; + + }; + +// CLASS DECLARATION + +/** +* This a T_OomHarness class. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(COomTestHarness) : public CTestModuleBase + { + public: // Constructors and destructor + + + /** + * Two-phased constructor. + */ + static COomTestHarness* NewL(); + + /** + * Destructor. + */ + virtual ~COomTestHarness(); + + public: // New functions + // None + + public: // Functions from base classes + + /** + * From CTestModuleBase InitL is used to initialize the + * T_OomHarness. It is called once for every instance of + * TestModule T_OomHarness after its creation. + * @since ?Series60_version + * @param aIniFile Initialization file for the test module (optional) + * @param aFirstTime Flag is true when InitL is executed for first + * created instance of T_OomHarness. + * @return Symbian OS error code + */ + TInt InitL( TFileName& aIniFile, TBool aFirstTime ); + + /** + * From CTestModuleBase GetTestCasesL is used to inquiry test cases + * from T_OomHarness. + * @since ?Series60_version + * @param aTestCaseFile Test case file (optional) + * @param aTestCases Array of TestCases returned to test framework + * @return Symbian OS error code + */ + TInt GetTestCasesL( const TFileName& aTestCaseFile, + RPointerArray& aTestCases ); + + /** + * From CTestModuleBase RunTestCaseL is used to run an individual + * test case. + * @since ?Series60_version + * @param aCaseNumber Test case number + * @param aTestCaseFile Test case file (optional) + * @param aResult Test case result returned to test framework (PASS/FAIL) + * @return Symbian OS error code (test case execution error, which is + * not reported in aResult parameter as test case failure). + */ + TInt RunTestCaseL( const TInt aCaseNumber, + const TFileName& aTestCaseFile, + TTestResult& aResult ); + + /** + * From CTestModuleBase; OOMTestQueryL is used to specify is particular + * test case going to be executed using OOM conditions + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @param aFailureType OOM failure type (optional) + * @param aFirstMemFailure The first heap memory allocation failure value (optional) + * @param aLastMemFailure The last heap memory allocation failure value (optional) + * @return TBool + */ + virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TOOMFailureType& aFailureType, + TInt& /* aFirstMemFailure */, + TInt& /* aLastMemFailure */ ); + + /** + * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM + * test environment + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @return None + */ + virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ); + /** + * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM + * test environment + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @return None + */ + virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ); + + /** + * From CTestModuleBase; OOMHandleWarningL + * @param aTestCaseFile Test case file (optional) + * @param aCaseNumber Test case number (optional) + * @param aFailNextValue FailNextValue for OOM test execution (optional) + * @return None + */ + virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TInt& /* aFailNextValue */); + void AllocateMemoryL(TInt aKBytes); + + protected: // New functions + // None + + protected: // Functions from base classes + // None + + private: + + /** + * C++ default constructor. + */ + COomTestHarness(); + + /** + * By default Symbian 2nd phase constructor is private. + */ + void ConstructL(); + + // Prohibit copy constructor if not deriving from CBase. + // ?classname( const ?classname& ); + // Prohibit assigment operator if not deriving from CBase. + // ?classname& operator=( const ?classname& ); + + /** + * Function returning test case name and pointer to test case function. + * @since ?Series60_version + * @param aCaseNumber test case number + * @return TCaseInfo + */ + const TCaseInfo Case ( const TInt aCaseNumber ) const; + + // Test setup functions... + + // Close any dummy apps + // Free all memory being eaten by the server + // Update the call counts on the plugins (add them if they're not there already) + void ResetL(); + + void EatMemoryL(TInt aKBytesToLeaveFree); + + // Set up the plugins and applications - this is the starting point for many test cases + // 5 applications are started with approx 1 MB used for each + // 1MB (approx) of memory is reserved for each one of the plugins + void CommonSetUpL(); + + void StartApplicationL(TInt32 aUid, TInt aInitialAllocationInKBs); + + // Results checking functions... + + // Returns KErrNone if we get the expected result + TInt AppIsRunning(TInt32 aUid, TBool aExpectedResult); + + // Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)? + // Returns KErrNone if we get the expected result + TInt PluginFreeRamCalledL(TInt32 aUid, TBool aExpectedResult); + + // Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)? + // Returns KErrNone if we get the expected result + TInt PluginMemoryGoodCalledL(TInt32 aUid, TBool aExpectedResult); + + // Utility functions + + // Wait a while for the system to settle down + inline void Settle(); + + void BringAppToForeground(TInt32 aUid); + + + TInt GetFreeMemory(); + + // Utility function which calls the async version of optional RAM request and makes it behave like the sync version + TInt RequestOptionalRamASyncWrapper(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable); + + // Utility function which starts the memory monitor property watcher. + // The watcher stops the active scheduler when the monitor status changes + void StartMemoryMonitorStatusWatcher(TInt& aTestState); + + // Utility function which starts the timeout watcher and the active scheduler + // The watcher stops the active scheduler when the monitor status changes + // This function also cancels any pending requests when we are done + void StartTimerAndRunWatcher(TInt& aTestState); + + // The tests... + + // Test normal application closure for a single app + // Start three applications + // The lowest priority app should be in the foregound + // ... with the next lowest behind it + // ... followed by the highest priority application at the back + // The middle application should be configured to eat 5MB of memory + // A low memory event is triggered and the middle application only should be closed + TInt AppCloseTest1L(TTestResult& aResult); + + // Tests the idle time rule mechanism for app closure + // Start three applications + // The lowest priority app should be in the foregound + // ... with the next lowest behind it + // ... followed by the highest priority application at the back + // After an idle period the highest priority app is configured to become the lowest priority + // The middle and highest application should be configured to eat 5MB of memory + // A low memory event is triggered and the middle application only should be closed + // Note that this test should be the same as AppCloseTest1L, with the exception of the idle period which causes different apps to be closed + TInt AppCloseIdleTimeTest1L(TTestResult& aResult); + + //Tests the that window group z order is considered when closing apps. + //Start 3 apps of equal priority, ensuring their z order is known + //Starts another lower priority app and puts that in the foreground + //A low memory event is triggered such that only one app needs to be closed + //The closed app should be the one furthest from the foreground in the z order + TInt AppCloseEqualPrioritiesL(TTestResult& aResult); + + // Test system plugins and continue mode + // Simulate a low memory event + // Two system plugins should free enough memory, but four will be run because they work in "continue" mode + TInt PluginTest1L(TTestResult& aResult); + + // Test application plugins + // Start two target apps + // Simulate a low memory event + // The one of the application plugins should now be run, displacing one of the system plugins + // The target apps are of sufficiently high priority that they will not be closed + TInt PluginTest2L(TTestResult& aResult); + + // Test that the aBytesRequested is correctly passed to the FreeMemory function of V2 plugins + // Initialise P4 plugin to consume 5MB of memory + // No other plugins are configured to release memory + // Simulate a low memory event (go just below the low threshold) + // Check that the P4 plugin has been called + // Check that the P4 plugin has received a request for > 500K and less than <1500K + TInt PluginV2Test1L(TTestResult& aResult); + + // Test simple prioritisation of application plugins + // Start two target applications + // Configure all plugins to consume 0.5MB + // Simulate a low memory event + // Some of the low priority app plugins with those target applications should be called + // The highest priority app with that target application should not be called (the lower priority plugins should free enough memory) + TInt AppPluginTest1L(TTestResult& aResult); + + // Test simple prioritisation of application plugins + // Start two target applications + // Configure all plugins to consume 0.5MB + // The app plugin with the highest priority is configured to be assigned the lowest priority after an idle time + // Wait until the idle time rule applies + // Simulate a low memory event + // The plugin that initially had the highest priority (but now has the lowest priority) should be called + // Note that this test should be the same as AppPluginTest1L with the addition of the idle period + TInt AppPluginIdleTimeTest1L(TTestResult& aResult); + + // Test idle time handling for plugins + // Start two target apps + // Simulate a low memory event + // The one of the application plugins should now be run, displacing one of the system plugins + // The target apps are of sufficiently high priority that they will not be closed + TInt PluginIdleTimeTest2L(TTestResult& aResult); + + // Test the optional allocation mechanism + // Configure the plugins not to release any RAM when FreeRam is called + // Configure one priority 7 application to release 12MB when FreeRam is called + // Start this application (plus another one so it isn't in the foreground) + // Drop just below the good memory level + // Request an optional allocation of 10MB referencing a priority 8 plugin + // All of the plugins below P8 should be called + // The P7 application should be closed freeing the required memory + TInt OptionalAllocationTest1L(TTestResult& aResult); + + + // Test the optional allocation mechanism - minimum requested RAM behaviour - successful request + // Configure the plugins not to release any RAM when FreeRam is called + // Configure one priority 7 application to release 5MB when FreeRam is called + // Start this application (plus another one so it isn't in the foreground) + // Drop just above the good memory level + // Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin + // All of the plugins below P8 should be called + // The P7 application should be closed freeing the required minimum amount memory + // The returned available memory should be about 5MB ( > 3MB and < 7MB ) + TInt OptionalAllocationTest2L(TTestResult& aResult); + + // Test the optional allocation mechanism - minimum requested RAM behaviour - failed request + // Configure the plugins not to release any RAM when FreeRam is called + // Configure one priority 7 application to release 3MB when FreeRam is called + // Start this application (plus another one so it isn't in the foreground) + // Drop just above the good memory level + // Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin + // All of the plugins below P8 should be called + // The P7 application should be closed but it won't free enough memory + // The optional allocation should fail with KErrNoMemory + TInt OptionalAllocationTest3L(TTestResult& aResult); + + + // Test that force priority check applies (only) to selected priorities + // Setup three plugins (priorities 7, 8 & 9)to eat 5MB each + // The configuration file should force a check after priority 8 + // Drop just under the low threshold + // Plugins P7 & P8 should be called (P8 is called even though the P7 plugin freed enough memory) + // Plugin P9 should not be called because enou + TInt ForcePriorityCheck1L(TTestResult& aResult); + + // Test the Busy API on the OOM server + // Start three applications + // Ensure that the lowest priority app is not in the foreground + // Call the busy API on the OOM monitor for the lowest priority app + // Simulate a low memory event by going just under the low threshold + // The busy application should not be closed + // The other (non-foreground) application should be closed + TInt BusyApplicationTest1L(TTestResult& aResult); + + // Test the Normal-priority API on the OOM server + // Start three applications + // Ensure that the lowest priority app is not in the foreground + // Call the busy API on the OOM monitor for the lowest priority app + // Then call the not-busy API on the OOM monitor for the lowest priority app + // Simulate a low memory event by going just under the low threshold + // The lowest priority app should be closed (because it is no longer busy) + TInt NormalPriorityApplicationTest1L(TTestResult& aResult); + + // Test the async optional allocation mechanism + // Configure the plugins not to release any RAM when FreeRam is called + // Configure one priority 7 application to release 12MB when FreeRam is called + // Start this application (plus another one so it isn't in the foreground) + // Drop just below the good memory level + // Request an optional allocation of 10MB referencing a priority 8 plugin + // All of the plugins below P8 should be called + // The P7 application should be closed freeing the required memory + TInt OptionalAllocationAsyncTest1L(TTestResult& aResult); + + + // Test the async optional allocation mechanism - minimum requested RAM behaviour - successful request + // Configure the plugins not to release any RAM when FreeRam is called + // Configure one priority 7 application to release 5MB when FreeRam is called + // Start this application (plus another one so it isn't in the foreground) + // Drop just above the good memory level + // Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin + // All of the plugins below P8 should be called + // The P7 application should be closed freeing the required minimum amount memory + // The returned available memory should be about 5MB ( > 3MB and < 7MB ) + TInt OptionalAllocationAsyncTest2L(TTestResult& aResult); + + // Test the async optional allocation mechanism - minimum requested RAM behaviour - failed request + // Configure the plugins not to release any RAM when FreeRam is called + // Configure one priority 7 application to release 3MB when FreeRam is called + // Start this application (plus another one so it isn't in the foreground) + // Drop just above the good memory level + // Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin + // All of the plugins below P8 should be called + // The P7 application should be closed but it won't free enough memory + // The optional allocation should fail with KErrNoMemory + TInt OptionalAllocationAsyncTest3L(TTestResult& aResult); + + // Test that sync mode configuration is working for system plugins + // Configure three system plugins to release 5MB of memory each. + // The plugins are configured as follows + // Plugin 1: Priority 7, sync mode continue + // Plugin 2: Priority 8, sync mode check + // Plugin 3: Priority 9, sync mode continue + // Drop just under the low threshold + // Plugins 1 & 2 should be called (even though plugin 1 alone has freed enough RAM) + // Plugin 3 won't be called because the check on the priority 8 plugin discovers that enough RAM has been freed + TInt PluginSyncModeTest1L(TTestResult& aResult); + + + // Start three applications + // One is set to NEVER_CLOSE, one is low priority, one is a dummy app to ensure that the first two are not in the foreground + // Configure applications not to release any memory + // Go just significantly under the low memory threshold + // Wait for the system to recover, if we have moved above the low memory threshold then go significantly under it again. Repeat this step until we no longer go above low. + // Check that the low priority application is closed + // Check that the NEVER_CLOSE application is not closed (even though we're still below the low theshold) + TInt NeverCloseTest1L(TTestResult& aResult); + + TInt AppCloseTwoSessionsL(TTestResult& aResult); + + TInt CallIfTargetAppNotRunningTest1L(TTestResult& aResult); + + TInt AppCloseSpecificThresholdTest1L(TTestResult& aResult); + + // test that the plugins are left in the off state if a request for optional RAM + // cannot be granted + TInt PluginTestInsufficientMemoryFreedL(TTestResult& aResult); + + // test that the plugins are left in the off state if a request for optional RAM + // cannot be granted + // The test makes the optional RAM call from a state where memory is between the + // global low and good thresholds + TInt PluginTestInsufficientMemoryFreed2L(TTestResult& aResult); + + + public: // Data + // None + + protected: // Data + // None + + private: // Data + // Pointer to test (function) to be executed + TestFunction iMethod; + + // Pointer to logger + CStifLogger * iLog; + + // Normal logger + CStifLogger* iStdLog; + + // Test case logger + CStifLogger* iTCLog; + + // Flag saying if test case title should be added to log file name + TBool iAddTestCaseTitleToLogName; + + // ?one_line_short_description_of_data + //?data_declaration; + + // Reserved pointer for future extension + //TAny* iReserved; + + struct TPluginCallCount + { + TInt iFreeRamCallCount; + TInt iMemoryGoodCallCount; + }; + + RHashMap iPluginCallCounts; + + RPointerArray iApps; + + ROOMAllocSession iAllocServer; + + RChunk iChunk; + TInt iChunkSize; + + RChunk iDummyChunk; + TInt iDummyChunkSize; + + ROomMonitorSession iOomSession; + + //CActiveScheduler needed by the memory monitor watchers + CActiveScheduler* iScheduler; + + //The watchers + CMemoryMonitorStatusWatcher* iStatusWatcher; + CMemoryMonitorTimeoutWatcher* iTimeoutWatcher; + + + public: // Friend classes + // None + + protected: // Friend classes + // None + + private: // Friend classes + // None + + }; + +/** +* This CMemoryMonitorStatusWatcher class signals a client if the memorymonitor status becomes different from EFreeingMemory. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CMemoryMonitorStatusWatcher) : public CActive + { + public: + static CMemoryMonitorStatusWatcher* NewL(); + ~CMemoryMonitorStatusWatcher(); + void Start(TInt* aWatcherState); + private: + CMemoryMonitorStatusWatcher(); + void ConstructL(); + void DoCancel(); + void RunL(); + private: + RProperty iMonitorProperty; + TInt* iTestState; + }; + +/** +* This CMemoryMonitorTimeoutWatcher class signals a client if the memorymonitor takes too long to leave EFreeingMemory state. +* ?other_description_lines +* +* @lib ?library +* @since ?Series60_version +*/ +NONSHARABLE_CLASS(CMemoryMonitorTimeoutWatcher) : public CTimer + { +public: + static CMemoryMonitorTimeoutWatcher* NewL(); + ~CMemoryMonitorTimeoutWatcher(); + void Start(TInt* aTestState, const TTimeIntervalMicroSeconds32& aTimeout); + +private: + CMemoryMonitorTimeoutWatcher(); + void ConstructL(); + void DoCancel(); + void RunL(); +private: + TInt* iTestState; + }; + +struct TReturnStatus + { + TInt iId; + TBool iCompleted; + TInt iReturnStatus; + }; + + +NONSHARABLE_CLASS(CAsyncRequester) : public CActive + { +public: + static CAsyncRequester* NewL(RChunk aChunk, TInt aChunkSize); + ~CAsyncRequester(); + void Start(TInt aBytesToRequest, TReturnStatus* aReturnStatus); + +private: + CAsyncRequester(RChunk aChunk, TInt aChunkSize); + void ConstructL(); + void DoCancel(); + void RunL(); +private: + ROomMonitorSession iSession; + TReturnStatus* iReturnStatus; + RChunk iChunk; + TInt iChunkSize; + }; + + + +inline void COomTestHarness::Settle() + { + //wait for oom system to settle + User::After(TTimeIntervalMicroSeconds32(KSettlingTime)); + } + +#endif // T_OOMHARNESS_H + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/src/CDummyApplicationHandle.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/src/CDummyApplicationHandle.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include +#include "CDummyApplicationHandle.h" + +CCDummyApplicationHandle::CCDummyApplicationHandle(TUid aUid) +: iUid(aUid) + { + // No implementation required + } + +CCDummyApplicationHandle::~CCDummyApplicationHandle() + { + if(iMsgQueue.Handle()) + { + iMsgQueue.SendBlocking(0); + iMsgQueue.Close(); + } + iProcess.Close(); + } + +CCDummyApplicationHandle* CCDummyApplicationHandle::NewLC(TUid aUid, TInt aExtraMemoryAllocation) + { + CCDummyApplicationHandle* self = new (ELeave) CCDummyApplicationHandle(aUid); + CleanupStack::PushL(self); + self->ConstructL(aExtraMemoryAllocation); + return self; + } + +CCDummyApplicationHandle* CCDummyApplicationHandle::NewL(TUid aUid, TInt aExtraMemoryAllocation) + { + CCDummyApplicationHandle* self = CCDummyApplicationHandle::NewLC(aUid, aExtraMemoryAllocation); + CleanupStack::Pop(); // self; + return self; + } + +void CCDummyApplicationHandle::ConstructL(TInt aExtraMemoryAllocation) + { + TBuf<28> params; + params.Format(_L("uid=%08x alloc=%x"), iUid, aExtraMemoryAllocation); + User::LeaveIfError(iProcess.Create(_L("t_oomdummyapp_0xE6CFBA00.exe"), params)); + User::LeaveIfError(iMsgQueue.CreateGlobal(KNullDesC, 4)); + User::LeaveIfError(iProcess.SetParameter(15, iMsgQueue)); + iProcess.Resume(); + } + +void CCDummyApplicationHandle::SendMessage(TInt aMessage) + { + iMsgQueue.SendBlocking(aMessage); + } + +TBool CCDummyApplicationHandle::CompareTo(const TUid* aKey, const CCDummyApplicationHandle& aValue) + { + return aValue.iUid == *aKey; + } + +void CCDummyApplicationHandle::BringToForeground() + { + SendMessage(1); + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/src/t_oomharness.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/src/t_oomharness.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,584 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +// INCLUDE FILES +#include +#include "t_oomharness.h" +#include +#include "SettingServerClient.h" +#include + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS +// None + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ==================== LOCAL FUNCTIONS ======================================= + + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + This file (t_oomharness.cpp) contains all test framework related parts of + this test module. Actual test cases are implemented in file + t_oomharnesscases.cpp. + + COomTestHarness is an example of test module implementation. This example + uses hard coded test cases (i.e it does not have any test case + configuration file). + + Example uses function pointers to call test cases. This provides an easy + method to add new test cases. + + See function Cases in file t_oomharnesscases.cpp for instructions how to + add new test cases. It is not necessary to modify this file when adding + new test cases. + + To take this module into use, add following lines to test framework + initialisation file: + +# t_oomharness_stif +[New_Module] +ModuleName= t_oomharness_stif +[End_Module] + +------------------------------------------------------------------------------- +*/ + +// ================= MEMBER FUNCTIONS ========================================= + +/* +------------------------------------------------------------------------------- + + Class: COomTestHarness + + Method: COomTestHarness + + Description: C++ default constructor can NOT contain any code, that + might leave. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +COomTestHarness::COomTestHarness() + { + } + +/* +------------------------------------------------------------------------------- + + Class: COomTestHarness + + Method: ConstructL + + Description: Symbian 2nd phase constructor that can leave. + + Note: If OOM test case uses STIF Logger, then STIF Logger must be created + with static buffer size parameter (aStaticBufferSize). Otherwise Logger + allocates memory from heap and therefore causes error situations with OOM + testing. For more information about STIF Logger construction, see STIF + Users Guide. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +void COomTestHarness::ConstructL() + { + //Read logger settings to check whether test case name is to be + //appended to log file name. + RSettingServer settingServer; + TInt ret = settingServer.Connect(); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Struct to StifLogger settigs. + TLoggerSettings loggerSettings; + // Parse StifLogger defaults from STIF initialization file. + ret = settingServer.GetLoggerSettings(loggerSettings); + if(ret != KErrNone) + { + User::Leave(ret); + } + // Close Setting server session + settingServer.Close(); + iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle; + + // Constructing static buffer size logger, needed with OOM testing because + // normally logger allocates memory from heap! + iStdLog = CStifLogger::NewL( KT_OomHarnessLogPath, + KT_OomHarnessLogFile, + CStifLogger::ETxt, + CStifLogger::EFile, + ETrue, + ETrue, + ETrue, + EFalse, + ETrue, + EFalse, + 100 ); + iLog = iStdLog; + + // Sample how to use logging + _LIT( KLogInfo, "t_oomharness logging starts!" ); + iLog->Log( KLogInfo ); + + User::LeaveIfError(iAllocServer.Connect()); + User::LeaveIfError(iOomSession.Connect()); + + User::LeaveIfError(iChunk.CreateLocal(KOomHarnessInitialEatenMemory, KOomHarnessMaxEatenMemory)); + iChunkSize = KOomHarnessInitialEatenMemory; + + iScheduler = new (ELeave) CActiveScheduler; + CActiveScheduler::Install( iScheduler ); + + iStatusWatcher = CMemoryMonitorStatusWatcher::NewL(); + iTimeoutWatcher = CMemoryMonitorTimeoutWatcher::NewL(); + + ResetL(); + } + +/* +------------------------------------------------------------------------------- + + Class: COomTestHarness + + Method: NewL + + Description: Two-phased constructor. Constructs new COomTestHarness + instance and returns pointer to it. + + Parameters: None + + Return Values: COomTestHarness*: new object. + + Errors/Exceptions: Leaves if memory allocation fails or ConstructL leaves. + + Status: Approved + +------------------------------------------------------------------------------- +*/ +COomTestHarness* COomTestHarness::NewL() + { + COomTestHarness* self = new (ELeave) COomTestHarness; + + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +/* +------------------------------------------------------------------------------- + + Class: COomTestHarness + + Method: ~COomTestHarness + + Description: Destructor. + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved + +------------------------------------------------------------------------------- +*/ +COomTestHarness::~COomTestHarness() + { + iLog = NULL; + delete iStdLog; + iStdLog = NULL; + delete iTCLog; + iTCLog = NULL; + iApps.ResetAndDestroy(); + iAllocServer.Close(); + iChunk.Close(); + iPluginCallCounts.Close(); + delete iScheduler; + delete iStatusWatcher; + delete iTimeoutWatcher; + } + +/* +------------------------------------------------------------------------------- + Class: COomTestHarness + + Method: InitL + + Description: Method for test case initialization + + Parameters: None + + Return Values: None + + Errors/Exceptions: None + + Status: Approved +------------------------------------------------------------------------------- +*/ +TInt COomTestHarness::InitL( TFileName& /*aIniFile*/, + TBool /*aFirstTime*/ ) + { + return KErrNone; + + } + +/* +------------------------------------------------------------------------------- + + Class: COomTestHarness + + Method: GetTestCases + + Description: GetTestCases is used to inquire test cases + from the test module. Because this test module has hard coded test cases + (i.e cases are not read from file), paramter aConfigFile is not used. + + This function loops through all cases defined in Cases() function and + adds corresponding items to aTestCases array. + + Parameters: const TFileName& : in: Configuration file name. Not used + RPointerArray& aTestCases: out: + Array of TestCases. + + Return Values: KErrNone: No error + + Errors/Exceptions: Function leaves if any memory allocation operation fails + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TInt COomTestHarness::GetTestCasesL( const TFileName& /*aConfig*/, + RPointerArray& aTestCases ) + { + // Loop through all test cases and create new + // TTestCaseInfo items and append items to aTestCase array + for( TInt i = 0; Case(i).iMethod != NULL; i++ ) + { + // Allocate new TTestCaseInfo from heap for a testcase definition. + TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo(); + + // PushL TTestCaseInfo to CleanupStack. + CleanupStack::PushL( newCase ); + + // Set number for the testcase. + // When the testcase is run, this comes as a parameter to RunTestCaseL. + newCase->iCaseNumber = i; + + // Set title for the test case. This is shown in UI to user. + newCase->iTitle.Copy( Case(i).iCaseName ); + + // Append TTestCaseInfo to the testcase array. After appended + // successfully the TTestCaseInfo object is owned (and freed) + // by the TestServer. + User::LeaveIfError(aTestCases.Append ( newCase ) ); + + // Pop TTestCaseInfo from the CleanupStack. + CleanupStack::Pop( newCase ); + } + + return KErrNone; + + } + +/* +------------------------------------------------------------------------------- + + Class: COomTestHarness + + Method: RunTestCase + + Description: Run a specified testcase. + + Function runs a test case specified by test case number. Test case file + parameter is not used. + + If case number is valid, this function runs a test case returned by + function Cases(). + + Parameters: const TInt aCaseNumber: in: Testcase number + const TFileName& : in: Configuration file name. Not used + TTestResult& aResult: out: Testcase result + + Return Values: KErrNone: Testcase ran. + KErrNotFound: Unknown testcase + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TInt COomTestHarness::RunTestCaseL( const TInt aCaseNumber, + const TFileName& /* aConfig */, + TTestResult& aResult ) + { + // Return value + TInt execStatus = KErrNone; + + // Get the pointer to test case function + TCaseInfo tmp = Case ( aCaseNumber ); + + _LIT( KLogInfo, "Starting testcase [%S]" ); + iLog->Log( KLogInfo, &tmp.iCaseName); + + // Check that case number was valid + if ( tmp.iMethod != NULL ) + { + //Open new log file with test case title in file name + if(iAddTestCaseTitleToLogName) + { + //delete iLog; //Close currently opened log + //iLog = NULL; + //Delete test case logger if exists + if(iTCLog) + { + delete iTCLog; + iTCLog = NULL; + } + + TFileName logFileName; + TName title; + TestModuleIf().GetTestCaseTitleL(title); + + logFileName.Format(KT_OomHarnessLogFileWithTitle, &title); + + iTCLog = CStifLogger::NewL(KT_OomHarnessLogPath, + logFileName, + CStifLogger::ETxt, + CStifLogger::EFile, + ETrue, + ETrue, + ETrue, + EFalse, + ETrue, + EFalse, + 100); + iLog = iTCLog; + } + + // Valid case was found, call it via function pointer + iMethod = tmp.iMethod; + //execStatus = ( this->*iMethod )( aResult ); + TRAPD(err, execStatus = ( this->*iMethod )( aResult )); + if(iAddTestCaseTitleToLogName) + { + //Restore standard log and destroy test case logger + iLog = iStdLog; + delete iTCLog; //Close currently opened log + iTCLog = NULL; + } + User::LeaveIfError(err); + + } + else + { + // Valid case was not found, return error. + execStatus = KErrNotFound; + } + + // Return case execution status (not the result of the case execution) + return execStatus; + + } + +/* +------------------------------------------------------------------------------- + + Class: COomTestHarness + + Method: OOMTestQueryL + + Description: Checks test case information for OOM execution. + + Return Values: TBool + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +TBool COomTestHarness::OOMTestQueryL( const TFileName& /* aTestCaseFile */, + const TInt aCaseNumber, + TOOMFailureType& /* aFailureType */, + TInt& aFirstMemFailure, + TInt& aLastMemFailure ) + { + _LIT( KLogInfo, "COomTestHarness::OOMTestQueryL" ); + iLog->Log( KLogInfo ); + + aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation; + aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation; + + return Case( aCaseNumber ).iIsOOMTest; + } + +/* +------------------------------------------------------------------------------- + + Class: COomTestHarness + + Method: OOMTestInitializeL + + Description: Used to perform the test environment setup for a particular + OOM test case. Test Modules may use the initialization file to read + parameters for Test Module initialization but they can also have their own + configure file or some other routine to initialize themselves. + + NOTE: User may add implementation for OOM test environment initialization. + Usually no implementation is required. + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void COomTestHarness::OOMTestInitializeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ) + { + _LIT( KLogInfo, "COomTestHarness::OOMTestInitializeL" ); + iLog->Log( KLogInfo ); + + } + +/* +------------------------------------------------------------------------------- + + Class: COomTestHarness + + Method: OOMHandleWarningL + + Description: Used in OOM testing to provide a way to the derived TestModule + to handle warnings related to non-leaving or TRAPped allocations. + + In some cases the allocation should be skipped, either due to problems in + the OS code or components used by the code being tested, or even inside the + tested components which are implemented this way on purpose (by design), so + it is important to give the tester a way to bypass allocation failures. + + NOTE: User may add implementation for OOM test warning handling. Usually no + implementation is required. + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void COomTestHarness::OOMHandleWarningL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */, + TInt& /* aFailNextValue */ ) + { + _LIT( KLogInfo, "COomTestHarness::OOMHandleWarningL" ); + iLog->Log( KLogInfo ); + + } + +/* +------------------------------------------------------------------------------- + + Class: COomTestHarness + + Method: OOMTestFinalizeL + + Description: Used to perform the test environment cleanup for a particular OOM + test case. + + NOTE: User may add implementation for OOM test environment finalization. + Usually no implementation is required. + + Return Values: None + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +void COomTestHarness::OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, + const TInt /* aCaseNumber */ ) + { + _LIT( KLogInfo, "COomTestHarness::OOMTestFinalizeL" ); + iLog->Log( KLogInfo ); + + } + +// ========================== OTHER EXPORTED FUNCTIONS ========================= + +// ----------------------------------------------------------------------------- +// LibEntryL is a polymorphic Dll entry point +// Returns: CTestModuleBase*: Pointer to Test Module object +// ----------------------------------------------------------------------------- +// +EXPORT_C CTestModuleBase* LibEntryL() + { + return COomTestHarness::NewL(); + + } + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/src/t_oomharnesscases.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/src/t_oomharnesscases.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,3332 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +// INCLUDE FILES +#include //User::HAL +#include //RProperty +#include "t_oomharness.h" +#include "CDummyApplicationHandle.h" +#include "../../t_oomdummyapp/inc/t_oomdummyappmsgs.h" +#include "t_oomdummyplugin_properties.h" +#include + +// EXTERNAL DATA STRUCTURES +// None + +// EXTERNAL FUNCTION PROTOTYPES +// None + +// CONSTANTS +// None + +// MACROS +// None + +// LOCAL CONSTANTS AND MACROS + +const TInt KOomJustUnderLowMemoryThreshold = 4000; +const TInt KOomSignificantlyUnderLowMemoryThreshold = 2024; +const TInt KOomBetweenLowAndGoodThresholds = 4300; +const TInt KOomJustAboveGoodMemoryThreshold = 5100; + +const TInt KOomTestFirstIdlePeriod = 40000000; // 40 seconds + + +// MODULE DATA STRUCTURES +// None + +// LOCAL FUNCTION PROTOTYPES +// None + +// FORWARD DECLARATIONS +// None + +// ==================== LOCAL FUNCTIONS ======================================= + +/* +------------------------------------------------------------------------------- + + DESCRIPTION + + This module contains the implementation of COomTestHarness class + member functions that does the actual tests. + +------------------------------------------------------------------------------- +*/ + +// ============================ MEMBER FUNCTIONS =============================== + +/* +------------------------------------------------------------------------------- + + Class: COomTestHarness + + Method: Case + + Description: Returns a test case by number. + + This function contains an array of all available test cases + i.e pair of case name and test function. If case specified by parameter + aCaseNumber is found from array, then that item is returned. + + The reason for this rather complicated function is to specify all the + test cases only in one place. It is not necessary to understand how + function pointers to class member functions works when adding new test + cases. See function body for instructions how to add new test case. + + Parameters: const TInt aCaseNumber :in: Test case number + + Return Values: const TCaseInfo Struct containing case name & function + + Errors/Exceptions: None + + Status: Proposal + +------------------------------------------------------------------------------- +*/ +const TCaseInfo COomTestHarness::Case ( + const TInt aCaseNumber ) const + { + + /* + * To add new test cases, implement new test case function and add new + * line to KCases array specify the name of the case and the function + * doing the test case + * In practice, do following + * + * 1) Make copy of existing test case function and change its name + * and functionality. Note that the function must be added to + * OOMHard.cpp file and to OOMHard.h + * header file. + * + * 2) Add entry to following KCases array either by using: + * + * 2.1: FUNCENTRY or ENTRY macro + * ENTRY macro takes two parameters: test case name and test case + * function name. + * + * FUNCENTRY macro takes only test case function name as a parameter and + * uses that as a test case name and test case function name. + * + * Or + * + * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used + * only with OOM (Out-Of-Memory) testing! + * + * OOM_ENTRY macro takes five parameters: test case name, test case + * function name, TBool which specifies is method supposed to be run using + * OOM conditions, TInt value for first heap memory allocation failure and + * TInt value for last heap memory allocation failure. + * + * OOM_FUNCENTRY macro takes test case function name as a parameter and uses + * that as a test case name, TBool which specifies is method supposed to be + * run using OOM conditions, TInt value for first heap memory allocation + * failure and TInt value for last heap memory allocation failure. + */ + + static TCaseInfoInternal const KCases[] = + { + // To add new test cases, add new items to this array + + // NOTE: When compiled to GCCE, there must be Classname:: + // declaration in front of the method name, e.g. + // COomTestHarness::PrintTest. Otherwise the compiler + // gives errors. + + ENTRY( "App Close Test 1", COomTestHarness::AppCloseTest1L ), + ENTRY( "App Close Idle Time", COomTestHarness::AppCloseIdleTimeTest1L ), + ENTRY( "App Close Equal Priorities", COomTestHarness::AppCloseEqualPrioritiesL ), + ENTRY( "Plugin Test 1", COomTestHarness::PluginTest1L ), + ENTRY( "Plugin Test 2", COomTestHarness::PluginTest2L ), + ENTRY( "App Plugin Test 1", COomTestHarness::AppPluginTest1L ), + ENTRY( "App Plugin Idle Time Test 1", COomTestHarness::AppPluginIdleTimeTest1L ), + ENTRY( "Optional Allocation Test 1", COomTestHarness::OptionalAllocationTest1L ), + ENTRY( "Optional Allocation Test 2", COomTestHarness::OptionalAllocationTest2L ), + ENTRY( "Optional Allocation Test 3", COomTestHarness::OptionalAllocationTest3L ), + ENTRY( "Plugin V2 Test 1", COomTestHarness::PluginV2Test1L ), + ENTRY( "Force Priority Check Test 1", COomTestHarness::ForcePriorityCheck1L ), + ENTRY( "Plugin Sync Mode Test 1", COomTestHarness::PluginSyncModeTest1L ), + ENTRY( "Never Close Test 1", COomTestHarness::NeverCloseTest1L ), + ENTRY( "Optional Allocation Async Test 1", COomTestHarness::OptionalAllocationAsyncTest1L ), + ENTRY( "Optional Allocation Async Test 2", COomTestHarness::OptionalAllocationAsyncTest2L ), + ENTRY( "Optional Allocation Async Test 3", COomTestHarness::OptionalAllocationAsyncTest3L ), +#ifdef CLIENT_REQUEST_QUEUE + ENTRY( "App Close Two Client Sessions", COomTestHarness::AppCloseTwoSessionsL ), +#endif + ENTRY( "Call If Target App Not Running Test 1", COomTestHarness::CallIfTargetAppNotRunningTest1L ), +#ifdef __WINS__ + ENTRY( "App Close Specific Threshold Test 1", COomTestHarness::AppCloseSpecificThresholdTest1L ), +#endif + ENTRY( "Plugin Test Insufficient Memory Freed", COomTestHarness::PluginTestInsufficientMemoryFreedL ), + ENTRY( "Plugin Test Insufficient Memory Freed 2", COomTestHarness::PluginTestInsufficientMemoryFreed2L ), + }; + + // Verify that case number is valid + if( (TUint) aCaseNumber >= sizeof( KCases ) / + sizeof( TCaseInfoInternal ) ) + { + + // Invalid case, construct empty object + TCaseInfo null( (const TText*) L"" ); + null.iMethod = NULL; + null.iIsOOMTest = EFalse; + null.iFirstMemoryAllocation = 0; + null.iLastMemoryAllocation = 0; + return null; + + } + + // Construct TCaseInfo object and return it + TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName ); + tmp.iMethod = KCases[ aCaseNumber ].iMethod; + tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest; + tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation; + tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation; + return tmp; + + } + +TInt COomTestHarness::AppCloseTest1L(TTestResult& aResult) + { + ResetL(); + + // The lowest priority app should be in the foregound + // ... with the next lowest behind it + // ... followed by the highest priority application at the back + StartApplicationL(KOomTestAppUid, 5 * 1024); // P9 app + StartApplicationL(KOomTestApp2Uid, 5 * 1024); // P8 app, configure it to eat 5MB + StartApplicationL(KOomTestApp3Uid, 0); // P7 app + + BringAppToForeground(KOomTestApp3Uid); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + + StartMemoryMonitorStatusWatcher(memTestState); + + // Go significantly under the low memory threshold + EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold); + + //start timer, start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + + if (err == KErrNone && memTestState == ETestAbove) + { + err = AppIsRunning(KOomTestApp2Uid, EFalse); + + if (err != KErrNone) + { + _LIT( KResult ,"P8 App KOomTestApp2Uid incorrectly running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + if (err == KErrNone) + { + err = AppIsRunning(KOomTestApp3Uid, ETrue); + if (err != KErrNone) + { + // The P7 app should still be running because it was in the foreground + _LIT( KResult ,"(P7 App KOomTestApp3Uid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + if (err == KErrNone) + { + err = AppIsRunning(KOomTestAppUid, ETrue); + if (err != KErrNone) + { + // The P9 app should still be running because the P8 application freed enough memory + _LIT( KResult ,"P9 App KOomTestAppUid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + ResetL(); + return KErrNone; + } + +// Tests the idle time rule mechanism for app closure +// Start three applications +// The lowest priority app should be in the foregound +// ... with the next lowest behind it +// ... followed by the highest priority application at the back +// After an idle period the highest priority app is configured to become the lowest priority +// The middle and highest application should be configured to eat 5MB of memory +// A low memory event is triggered and the middle application only should be closed +// Note that this test should be the same as AppCloseTest1L, with the exception of the idle period which causes different apps to be closed +TInt COomTestHarness::AppCloseIdleTimeTest1L(TTestResult& aResult) + { + ResetL(); + + // The lowest priority app should be in the foregound + // ... with the next lowest behind it + // ... followed by the highest priority application at the back + StartApplicationL(KOomTestAppUid, 5 * 1024); // P9 app (which becomes a P2 app after the idle time) + StartApplicationL(KOomTestApp2Uid, 5 * 1024); // P8 app, configure it to eat 5MB + StartApplicationL(KOomTestApp3Uid, 0); // P7 app + + BringAppToForeground(KOomTestApp3Uid); + + // Wait for the first set of idle time rules to apply + User::After(KOomTestFirstIdlePeriod); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + StartMemoryMonitorStatusWatcher(memTestState); + + // Go significantly under the low memory threshold + EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold); + + //start timer, start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + + if (err == KErrNone && memTestState == ETestAbove) + { + err = AppIsRunning(KOomTestAppUid, EFalse); + + if (err != KErrNone) + { + // The P9 app should have become a P2 app after the idle period, therefore it should have been the first candidate for closure + _LIT( KResult ,"P9->P2 App KOomTestAppUid running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + if (err == KErrNone) + { + err = AppIsRunning(KOomTestApp2Uid, ETrue); + if (err != KErrNone) + { + // The P8 application should still be running because the P9 app (that has become a P2 app) has freed the required memory + _LIT( KResult ,"P8 App KOomTestApp2Uid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = AppIsRunning(KOomTestApp3Uid, ETrue); + if (err != KErrNone) + { + // The P7 app should still be running because it was in the foreground + _LIT( KResult ,"P7 App KOomTestApp3Uid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + +TInt COomTestHarness::AppCloseEqualPrioritiesL(TTestResult& aResult) + { + ResetL(); + + StartApplicationL(KOomTestApp4Uid, 3 * 1024); // P7 app1, configure it to eat 5MB + + Settle(); + + StartApplicationL(KOomTestApp3Uid, 3 * 1024); // P7 app2, configure it to eat 5MB + + Settle(); + + StartApplicationL(KOomTestApp5Uid, 3 * 1024); // P7 app3, configure it to eat 5MB + + Settle(); + + StartApplicationL(KOomTestAppUid, 0); //P9 app + + Settle(); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + + StartMemoryMonitorStatusWatcher(memTestState); + + // Go significantly under the low memory threshold + EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold); + + //start timer, start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + + + if (err == KErrNone && memTestState == ETestAbove) + { + err = AppIsRunning(KOomTestApp4Uid, EFalse); + if (err != KErrNone) + { + // The P7 app furthest to the back in the z order should be closed. + // This should release sufficient memory. + _LIT( KResult ,"P7 App KOomTestApp4Uid incorrectly running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + // the other 3 apps should all still be running + if (err == KErrNone) + { + err = AppIsRunning(KOomTestApp3Uid, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"App KOomTestApp3Uid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + if (err == KErrNone) + { + err = AppIsRunning(KOomTestApp5Uid, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"App KOomTestApp5Uid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + if (err == KErrNone) + { + err = AppIsRunning(KOomTestAppUid, ETrue); + if (err != KErrNone) + { + // The P9 app should still be running because the P8 application freed enough memory + _LIT( KResult ,"P9 App KOomTestAppUid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + +TInt COomTestHarness::PluginTest1L(TTestResult& aResult) + { + ResetL(); + + // Configure the plugins to eat 0.6MB each: + for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++) + { + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x96000, 0x96000)); + } + //start application so that plugin 0x10286A3A which does the check can be called + StartApplicationL(KOomTestApp2Uid, 0); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + + StartMemoryMonitorStatusWatcher(memTestState); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + //start timer, start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + + if (err == KErrNone && memTestState == ETestAbove) + { + // The first two app plugins should have been run, releasing + // the required memory. The second app plugin to be run - 10286A3A - has a check, + // so no other plugins should have run. + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A3B FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A3A, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A3A FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + // These two plugins should not be called + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A38, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A38 FreeRam incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A34, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A34 FreeRam incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + // Finally check that the plugins have been notified of the final good memory state + if (err == KErrNone) + { + err = PluginMemoryGoodCalledL(0x10286A3A, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3A MemoryGood not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginMemoryGoodCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3B MemoryGood not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginMemoryGoodCalledL(0x10286A34, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A34 MemoryGood incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // MemoryGood should not be called on this plugin because FreeMemory was never called on it + // 10286A38 + err = PluginMemoryGoodCalledL(0x10286A38, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A38 MemoryGood incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + +// Test application plugins +// Start two target apps +// Simulate a low memory event +// The one of the application plugins should now be run, displacing one of the system plugins +// The target apps are of sufficiently high priority that they will not be closed +TInt COomTestHarness::PluginTest2L(TTestResult& aResult) + { + ResetL(); + + // Configure the plugins to eat 0.5MB each: + for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++) + { + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000)); + } + + // Start the two target applications (plus a third so that the target apps are not in the foreground) + StartApplicationL(KOomTestApp2Uid, 0); + StartApplicationL(KOomTestApp3Uid, 0); + StartApplicationL(KOomTestAppUid, 0); + + BringAppToForeground(KOomTestAppUid); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + + StartMemoryMonitorStatusWatcher(memTestState); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + //start timer, start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + + if (err == KErrNone && memTestState == ETestAbove) + { + // The first two system plugins should have been closed, releasing the required memory + // The following two system plugins won't be called (the app plugins will now take their place) + + // The following plugins should be called... + // Application plugins: 10286A3A 10286A3B + // System plugins: 10286A3C(v2 plugin) 10286A34 + + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3B not called "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A3A, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3A not called "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // Plugins and apps with higher priorities will not be called/closed because 0x10286A3A is configured to check memory before running anything else + err = PluginFreeRamCalledL(0x10286A3C, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3C incorrectly called "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A34, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A34 incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // The following plugin should also be called (max_batch_size only applies to application closures, not running plugins) + // 10286A35 + err = PluginFreeRamCalledL(0x10286A35, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A35 incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = AppIsRunning(KOomTestApp3Uid, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"App KOomTestApp3Uid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = AppIsRunning(KOomTestApp2Uid, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"App KOomTestApp2Uid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = AppIsRunning(KOomTestAppUid, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin KOomTestAppUid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + + +// Test that the aBytesRequested is correctly passed to the FreeMemory function of V2 plugins +// Initialise P4 plugin to consume 5MB of memory +// No other plugins are configured to release memory +// Simulate a low memory event (go just below the low threshold) +// Check that the P4 plugin has been called +// Check that the P4 plugin has received a request for > 500K and less than <1500K +TInt COomTestHarness::PluginV2Test1L(TTestResult& aResult) + { + ResetL(); + + // Configure the P4 V2 plugin to eat 5MB: + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A3C), 0, 0x500000, 0x500000)); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + + StartMemoryMonitorStatusWatcher(memTestState); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + //start timer, start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + + if (err == KErrNone && memTestState == ETestAbove) + { + // The first four system plugins should have been closed, releasing the required memory + // All four plugins should be called, even though the first two will release enough memory (this is because + // plugins are always run in continue mode) + + // Check that the P4 plugin has been called + err = PluginFreeRamCalledL(0x10286A3C, ETrue); + + // Check that the request for memory was about right + // Note: regular system variation makes it impossible to test for an exact number + TInt requestedMemory = 0; + err = RProperty::Get(KUidOomPropertyCategory, 0x10286A3C + KOOMDummyPluginBytesRequested, requestedMemory); + if ((requestedMemory < 512 * 1024) || (requestedMemory > 1500 * 1024)) + { + _LIT( KResult ,"requestedMemory incorrect"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + if (err == KErrNone) + { + // Check that the higher priority V2 plugin has not been called + err = PluginFreeRamCalledL(0x10286A3D, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3D incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + +// Test simple prioritisation of application plugins +// Start two target applications +// Configure all plugins to consume 0.5MB +// Simulate a low memory event +// Some of the low priority app plugins with those target applications should be called +// The highest priority app with that target application should not be called (the lower priority plugins should free enough memory) +TInt COomTestHarness::AppPluginTest1L(TTestResult& aResult) + { + ResetL(); + + // Configure the plugins to eat 0.5MB each: + for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++) + { + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000)); + } + + // Start the two target applications (plus a third so that the target apps are not in the foreground) + StartApplicationL(KOomTestApp2Uid, 0); + StartApplicationL(KOomTestApp3Uid, 0); + StartApplicationL(KOomTestAppUid, 0); + + + TInt err = KErrNone; + + // Check that all of the apps are running + err = AppIsRunning(KOomTestApp2Uid, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"app KOomTestApp2Uid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + if (err == KErrNone) + { + err = AppIsRunning(KOomTestApp3Uid, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"app KOomTestApp3Uid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = AppIsRunning(KOomTestAppUid, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"app KOomTestAppUid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + // Now eat some memory till we are below treshhold and wait for the memory monitor to bring us above treshhold again + TInt memTestState = ETestInit; + + if (err == KErrNone) + { + BringAppToForeground(KOomTestAppUid); + + //start watchers + StartMemoryMonitorStatusWatcher(memTestState); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + //start timer, start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + + // fail tests if watchers failed or memory was not freed + if (memTestState != ETestAbove) + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + //if memteststate is not desired signal to other cases that they should not pass + if (err == KErrNone) + { + err = KErrGeneral; + } + } + } + + // Check plugins for memory free calls + // The following application plugins should be called... + // Application plugins: 10286A3A 10286A3B + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A3A, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3A FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3B FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // The following plugin should not be called because other plugins (including some unchecked system plugins) have freed enough memory + // 10286A38 + err = PluginFreeRamCalledL(0x10286A38, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A38 FreeRam incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + + ResetL(); + return KErrNone; + } + +// Test simple prioritisation of application plugins +// Start two target applications +// Configure all plugins to consume 0.5MB +// The app plugin with the highest priority is configured to be assigned the lowest priority after an idle time +// Wait until the idle time rule applies +// Simulate a low memory event +// The plugin that initially had the highest priority (but now has the lowest priority) should be called +// Note that this test should be the same as AppPluginTest1L with the addition of the idle period +TInt COomTestHarness::AppPluginIdleTimeTest1L(TTestResult& aResult) + { + ResetL(); + + // Configure the plugins to eat 0.5MB each: + for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++) + { + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000)); + } + + // Start the two target applications (plus a third so that the target apps are not in the foreground) + StartApplicationL(KOomTestApp2Uid, 0); + StartApplicationL(KOomTestApp3Uid, 0); + StartApplicationL(KOomTestAppUid, 0); + + BringAppToForeground(KOomTestAppUid); + + User::After(KOomTestFirstIdlePeriod); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + + StartMemoryMonitorStatusWatcher(memTestState); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + //start timer, start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + + if (err == KErrNone && memTestState == ETestAbove) + { + // The following application plugins should be called... + // Application plugins: 10286A3A 10286A3B + + err = PluginFreeRamCalledL(0x10286A3A, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3A FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3B FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // The following plugin should also be called (its priority was initially too high but has been reduced after the idle time) + // 10286A38 + err = PluginFreeRamCalledL(0x10286A38, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A38 FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + +// Test the optional allocation mechanism +// Configure the plugins not to release any RAM when FreeRam is called +// Configure one priority 7 application to release 12MB when FreeRam is called +// Start this application (plus another one so it isn't in the foreground) +// Drop just above the good memory level +// Request an optional allocation of 10MB referencing a priority 8 plugin +// All of the plugins below P8 should be called +// The P7 application should be closed freeing the required memory +TInt COomTestHarness::OptionalAllocationTest1L(TTestResult& aResult) + { + ResetL(); + + // Start an application (plus a second so that the first app is not in the foreground) + // The first application is set to consume 12MB of RAM + StartApplicationL(KOomTestApp3Uid, 12 * 1024); + StartApplicationL(KOomTestAppUid, 0); + + BringAppToForeground(KOomTestAppUid); + + // Go just above the good memory threshold + EatMemoryL(KOomJustAboveGoodMemoryThreshold); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + TInt bytesAvailable; + + StartMemoryMonitorStatusWatcher(memTestState); + + // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8) + err = iOomSession.RequestOptionalRam(10 * 1024 * 1024, 10 * 1024 * 1024, 0x10286A37, bytesAvailable); + + if(err == KErrNone) + { + //start timer, start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + } + + if (err == KErrNone && memTestState == ETestAbove) + { + // Check that all system plugins below P8 have been called + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A34, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A34 FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A35, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A35 FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A36, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A36 FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // This the P8 system plugin has not been called + err = PluginFreeRamCalledL(0x10286A37, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A37 FreeRam incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // Check that the low priority app plugin has been called + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"low prioirity app 0x10286A3B not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // Check that the P7 application has been closed + err = AppIsRunning(KOomTestApp3Uid, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"P7 app KOomTestApp3Uid not closed"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"RequestOptionalRam failed or Memory Still Below Treshhold or could not start watchers"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + +// Test the optional allocation mechanism - minimum requested RAM behaviour - successful request +// Configure the plugins not to release any RAM when FreeRam is called +// Configure one priority 7 application to release 5MB when FreeRam is called +// Start this application (plus another one so it isn't in the foreground) +// Drop just above the good memory level +// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin +// All of the plugins below P8 should be called +// The P7 application should be closed freeing the required minimum amount memory +// The returned available memory should be about 5MB ( > 3MB and < 7MB ) +TInt COomTestHarness::OptionalAllocationTest2L(TTestResult& aResult) + { + ResetL(); + + // Start an application (plus a second so that the first app is not in the foreground) + // The first application is set to consume 5MB of RAM + StartApplicationL(KOomTestApp3Uid, 5 * 1024); + StartApplicationL(KOomTestAppUid, 0); + + BringAppToForeground(KOomTestAppUid); + + // Go just above the good memory threshold + EatMemoryL(KOomJustAboveGoodMemoryThreshold); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + StartMemoryMonitorStatusWatcher(memTestState); + + // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8) + // Say that 5MB is the minimum we need + TInt bytesAvailable; + err = iOomSession.RequestOptionalRam(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable); + + if(err == KErrNone) + { + //start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + } + + if (err == KErrNone && memTestState == ETestAbove) + { + if (err == KErrNone) + { + // Check that the reported bytes available is > 3MB and < 7MB + if ((bytesAvailable < 3 * 1024 * 1024) + || (bytesAvailable > 7 * 1024 * 1024)) + { + _LIT( KResult ,"reported bytes not > 3MB and < 7MB"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + // Check that all system plugins below P8 have been called + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A34, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A34 FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { err = PluginFreeRamCalledL(0x10286A35, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A35 FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A36, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A36 FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // This the P8 system plugin has not been called + err = PluginFreeRamCalledL(0x10286A37, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A37 FreeRam incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // Check that the low priority app plugin has been called + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A3B FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // Check that the P7 application has been closed + err = AppIsRunning(KOomTestApp3Uid, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"P7 app KOomTestApp3Uid not closed"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"RequestOptionalRam failed or Memory Still Below Treshhold or could not start watchers"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + +// Test the optional allocation mechanism - minimum requested RAM behaviour - failed request +// Configure the plugins not to release any RAM when FreeRam is called +// Configure one priority 7 application to release 3MB when FreeRam is called +// Start this application (plus another one so it isn't in the foreground) +// Drop just above the good memory level +// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin +// All of the plugins below P8 should be called +// The P7 application should be closed but it won't free enough memory +// The optional allocation should fail with KErrNoMemory +TInt COomTestHarness::OptionalAllocationTest3L(TTestResult& aResult) + { + ResetL(); + + // Start an application (plus a second so that the first app is not in the foreground) + // The first application is set to consume 5MB of RAM + StartApplicationL(KOomTestApp3Uid, 3 * 1024); + StartApplicationL(KOomTestAppUid, 0); + + BringAppToForeground(KOomTestAppUid); + + // Go just above the good memory threshold + EatMemoryL(KOomJustAboveGoodMemoryThreshold); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + + StartMemoryMonitorStatusWatcher(memTestState); + + // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8) + // Say that 5MB is the minimum we need + TInt bytesAvailable; + err = iOomSession.RequestOptionalRam(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable); + // We expect an error because it has not been possible to free the minimum memory + if (err == KErrNoMemory) + { + err = KErrNone; + } + + if(err == KErrNone) + { + //start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + } + + if (err == KErrNone && memTestState == ETestAbove) + { + // Check that all system plugins below P8 have been called + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A34, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A34 FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A35, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A35 FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A36, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A36 FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // This the P8 system plugin has not been called + err = PluginFreeRamCalledL(0x10286A37, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A37 FreeRam incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // Check that the low priority app plugin has been called + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A3B FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // Check that the P7 application has been closed + err = AppIsRunning(KOomTestApp3Uid, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"P7 App KOomTestApp3Uid not closed"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"RequestOptionalRam failed or Memory Still Below Treshhold or could not start watchers"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + +// Test that force priority check applies (only) to selected priorities +// Setup three plugins (priorities 7, 8 & 9)to eat 5MB each +// The configuration file should force a check after priority 8 +// Drop just under the low threshold +// Plugins P7 & P8 should be called (P8 is called even though the P7 plugin freed enough memory) +// Plugin P9 should not be called because enou +TInt COomTestHarness::ForcePriorityCheck1L(TTestResult& aResult) + { + ResetL(); + + // Configure the P7, P8 and P9 plugins to eat 5MB each: + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A36), 0, 0x300000, 0x300000)); // P7 + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A37), 0, 0x300000, 0x300000)); // P8 + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A3D), 0, 0x300000, 0x300000)); // P9 + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + + StartMemoryMonitorStatusWatcher(memTestState); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + //start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + + if (err == KErrNone && memTestState == ETestAbove) + { + + // The P7 plugin should have been called and is the first to release RAM + err = PluginFreeRamCalledL(0x10286A36, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"P7 Plugin 0x10286A36 FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + if (err == KErrNone) + { + // The P8 plugin should be called even though the P7 plugin has already released enough memory because the plugin runs in continue mode and there is no forced check + err = PluginFreeRamCalledL(0x10286A37, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"P8 Plugin 0x10286A37 FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // The P9 plugin should not be called because of the force priority check (the P7 & P8 plugins have already released plenty of RAM) + err = PluginFreeRamCalledL(0x10286A3D, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"P9 Plugin 0x10286A3D FreeRam incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + + +// Test the Busy API on the OOM server +// Start three applications +// Ensure that the lowest priority app is not in the foreground +// Call the busy API on the OOM monitor for the lowest priority app +// Simulate a low memory event by going just under the low threshold +// The busy application should not be closed +// The other (non-foreground) application should be closed +TInt COomTestHarness::BusyApplicationTest1L(TTestResult& aResult) + { + ResetL(); + + // Start the two target applications (plus a third so that the target apps are not in the foreground) + StartApplicationL(KOomTestApp2Uid, 0); + StartApplicationL(KOomTestAppUid, 0); + StartApplicationL(KOomTestApp3Uid, 0); // Lowest priority app + + BringAppToForeground(KOomTestAppUid); // TODO: this doesn't seem to be working - message not getting through to the dummy application + + Settle(); + + // Send the second app a message to make itself busy + TInt id = iApps.Find(TUid::Uid(KOomTestApp3Uid), CCDummyApplicationHandle::CompareTo); + User::LeaveIfError(id); + iApps[id]->SendMessage(KOomDummyAppSetBusy); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + + StartMemoryMonitorStatusWatcher(memTestState); + + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + //start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + + if (err == KErrNone && memTestState == ETestAbove) + { + + // The first four system plugins should have been closed, releasing the required memory + // All four plugins should be called, even though the first two will release enough memory (this is because + // plugins are always run in continue mode) + + // Check that the busy application is still running + err = AppIsRunning(KOomTestApp3Uid, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"P7 App KOomTestApp3Uid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + if (err == KErrNone) + { + // Check that the higher priority but non-busy application has been close + err = AppIsRunning(KOomTestApp2Uid, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"P7 App KOomTestApp2Uid not closed"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + +// Test the NotBusy API on the OOM server +// Start three applications +// Ensure that the lowest priority app is not in the foreground +// Call the busy API on the OOM monitor for the lowest priority app +// Then call the not-busy API on the OOM monitor for the lowest priority app +// Simulate a low memory event by going just under the low threshold +// The lowest priority app should be closed (because it is no longer busy) +TInt COomTestHarness::NormalPriorityApplicationTest1L(TTestResult& aResult) + { + ResetL(); + + // Start the two target applications (plus a third so that the target apps are not in the foreground) + StartApplicationL(KOomTestApp2Uid, 0); + StartApplicationL(KOomTestApp3Uid, 0); // Lowest priority app + StartApplicationL(KOomTestAppUid, 0); + + BringAppToForeground(KOomTestAppUid); + + Settle(); + + // Send the second app a message to make itself busy + TInt id = iApps.Find(TUid::Uid(KOomTestApp3Uid), CCDummyApplicationHandle::CompareTo); + User::LeaveIfError(id); + // TODO: temp removed - needs to be put back +// iApps[id]->SendMessage(KOomDummyAppSetBusy); + + // Send the second app a message to make itself normal priority + id = iApps.Find(TUid::Uid(KOomTestApp3Uid), CCDummyApplicationHandle::CompareTo); + User::LeaveIfError(id); + iApps[id]->SendMessage(KOomDummyAppSetNormalPriority); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + + StartMemoryMonitorStatusWatcher(memTestState); + + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + //start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + + + if (err == KErrNone && memTestState == ETestAbove) + { + + // The first four system plugins should have been closed, releasing the required memory + // All four plugins should be called, even though the first two will release enough memory (this is because + // plugins are always run in continue mode) + + // Check that the no-longer-busy application has been closed + err = AppIsRunning(KOomTestApp3Uid, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"App KOomTestApp3Uid not closed"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + + +// Start three applications +// One is set to NEVER_CLOSE, one is low priority, one is a dummy app to ensure that the first two are not in the foreground +// Configure applications not to release any memory +// Go just significantly under the low memory threshold +// Wait for the system to recover, if we have moved above the low memory threshold then go significantly under it again. Repeat this step until we no longer go above low. +// Check that the low priority application is closed +// Check that the NEVER_CLOSE application is not closed (even though we're still below the low theshold) +TInt COomTestHarness::NeverCloseTest1L(TTestResult& aResult) + { + ResetL(); + + // Start the two target applications (plus a third so that the target apps are not in the foreground) + StartApplicationL(KOomTestApp3Uid, 0); // Lowest priority app + StartApplicationL(KOomTestApp7Uid, 0); // NEVER_CLOSE application + StartApplicationL(KOomTestAppUid, 0); + + BringAppToForeground(KOomTestAppUid); + + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + TInt attemps = 10; + + while (memTestState != ETestBelow && attemps > 0) + { + StartMemoryMonitorStatusWatcher(memTestState); + + // eat memory + EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold); + + //start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + attemps--; + } + + if (err == KErrNone && memTestState == ETestBelow) + { + + // The NEVER_CLOSE app should still be running (even though we are still below the low threshold) + err = AppIsRunning(KOomTestApp7Uid, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"NEVER_CLOSE app KOomTestApp7Uid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + if (err == KErrNone) + { + // The low priority app should still be closed (even though we are still below the low threshold) + err = AppIsRunning(KOomTestApp3Uid, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"low priority app KOomTestApp3Uid incorrectly running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Incorrectly Above Treshhold "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + + + + +// Test that sync mode configuration is working for system plugins +// Configure three system plugins to release 5MB of memory each. +// The plugins are configured as follows +// Plugin 1: Priority 7, sync mode continue +// Plugin 2: Priority 8, sync mode check +// Plugin 3: Priority 9, sync mode continue +// Drop just under the low threshold +// Plugins 1 & 2 should be called (even though plugin 1 alone has freed enough RAM) +// Plugin 3 won't be called because the check on the priority 8 plugin discovers that enough RAM has been freed +TInt COomTestHarness::PluginSyncModeTest1L(TTestResult& aResult) + { + ResetL(); + + // Configure three plugins to eat 5MB each: + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A36), 0, 0x300000, 0x300000)); + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A37), 0, 0x300000, 0x300000)); + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(0x10286A3D), 0, 0x300000, 0x300000)); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + + StartMemoryMonitorStatusWatcher(memTestState); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + //start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + + if (err == KErrNone && memTestState == ETestAbove) + { + + // The first four system plugins should have been run, releasing the required memory + // All four plugins should be called, even though the first two will release enough memory (this is because + // plugins are always run in continue mode) + + // Check that the first two plugins have been called, but not the third + err = PluginFreeRamCalledL(0x10286A36, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A36 Free Ram not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A37, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A37 Free Ram not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A3D, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3D Free Ram incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + + + +// Test the optional allocation mechanism +// Configure the plugins not to release any RAM when FreeRam is called +// Configure one priority 7 application to release 12MB when FreeRam is called +// Start this application (plus another one so it isn't in the foreground) +// Drop just above the good memory level +// Request an optional allocation of 10MB referencing a priority 8 plugin +// All of the plugins below P8 should be called +// The P7 application should be closed freeing the required memory +TInt COomTestHarness::OptionalAllocationAsyncTest1L(TTestResult& aResult) + { + ResetL(); + + // Start an application (plus a second so that the first app is not in the foreground) + // The first application is set to consume 12MB of RAM + StartApplicationL(KOomTestApp3Uid, 12 * 1024); + StartApplicationL(KOomTestAppUid, 0); + + BringAppToForeground(KOomTestAppUid); + + // Go just above the good memory threshold + EatMemoryL(KOomJustAboveGoodMemoryThreshold); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + TInt bytesAvailable; + + StartMemoryMonitorStatusWatcher(memTestState); + + // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8) + err = RequestOptionalRamASyncWrapper(10 * 1024 * 1024, 10 * 1024 * 1024, 0x10286A37, bytesAvailable); + + if (err == KErrNone) + { + //start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + } + + if (err == KErrNone && memTestState == ETestAbove) + { + // Check that all system plugins below P8 have been called + + err = PluginFreeRamCalledL(0x10286A34, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A34 Free Ram not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A35, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A35 Free Ram not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A36, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A36 Free Ram not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // This the P8 system plugin has not been called + err = PluginFreeRamCalledL(0x10286A37, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A37 Free Ram incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // Check that the low priority app plugin has been called + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3B Free Ram not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // Check that the P7 application has been closed + err = AppIsRunning(KOomTestApp3Uid, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"P7 App KOomTestApp3Uid incorrectly running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"RequestOptionalRam failed or Memory Still Below Treshhold or could not start watchers"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + +// Test the optional allocation mechanism - minimum requested RAM behaviour - successful request +// Configure the plugins not to release any RAM when FreeRam is called +// Configure one priority 7 application to release 5MB when FreeRam is called +// Start this application (plus another one so it isn't in the foreground) +// Drop just above the good memory level +// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin +// All of the plugins below P8 should be called +// The P7 application should be closed freeing the required minimum amount memory +// The returned available memory should be about 5MB ( > 3MB and < 7MB ) +TInt COomTestHarness::OptionalAllocationAsyncTest2L(TTestResult& aResult) + { + ResetL(); + + // Start an application (plus a second so that the first app is not in the foreground) + // The first application is set to consume 5MB of RAM + StartApplicationL(KOomTestApp3Uid, 5 * 1024); + StartApplicationL(KOomTestAppUid, 0); + + BringAppToForeground(KOomTestAppUid); + + // Go just above the good memory threshold + EatMemoryL(KOomJustAboveGoodMemoryThreshold); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + TInt bytesAvailable; + + StartMemoryMonitorStatusWatcher(memTestState); + + // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8) + // Say that 5MB is the minimum we need + err = RequestOptionalRamASyncWrapper(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable); + + if (err == KErrNone) + { + //start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + } + + if (err == KErrNone && memTestState == ETestAbove) + { + if (err == KErrNone) + { + // Check that the reported bytes available is > 3MB and < 7MB + if ((bytesAvailable < 3 * 1024 * 1024) + || (bytesAvailable > 7 * 1024 * 1024)) + { + _LIT( KResult ,"bytesAvailable not ( > 3MB and < 7MB )"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // Check that all system plugins below P8 have been called + + err = PluginFreeRamCalledL(0x10286A34, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A34 Free Ram not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A35, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A35 Free Ram not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A36, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A36 Free Ram not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // This the P8 system plugin has not been called + err = PluginFreeRamCalledL(0x10286A37, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A37 Free Ram incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // Check that the low priority app plugin has been called + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3B Free Ram not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // Check that the P7 application has been closed + err = AppIsRunning(KOomTestApp3Uid, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"P7 App KOomTestApp3Uid incorrectly running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"RequestOptionalRam failed or Memory Still Below Treshhold or could not start watchers"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + + + +// Test the optional allocation mechanism - minimum requested RAM behaviour - failed request +// Configure the plugins not to release any RAM when FreeRam is called +// Configure one priority 7 application to release 3MB when FreeRam is called +// Start this application (plus another one so it isn't in the foreground) +// Drop just above the good memory level +// Request an optional allocation of 10MB (5MB minimum) referencing a priority 8 plugin +// All of the plugins below P8 should be called +// The P7 application should be closed but it won't free enough memory +// The optional allocation should fail with KErrNoMemory +TInt COomTestHarness::OptionalAllocationAsyncTest3L(TTestResult& aResult) + { + ResetL(); + + // Start an application (plus a second so that the first app is not in the foreground) + // The first application is set to consume 5MB of RAM + StartApplicationL(KOomTestApp3Uid, 3 * 1024); + StartApplicationL(KOomTestAppUid, 0); + + BringAppToForeground(KOomTestAppUid); + + // Go just above the good memory threshold + EatMemoryL(KOomJustAboveGoodMemoryThreshold); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + + StartMemoryMonitorStatusWatcher(memTestState); + + // Request 10 MB of data, using the priority of the referenced plugin (constant priority 8) + // Say that 5MB is the minimum we need + TInt bytesAvailable; + + err = RequestOptionalRamASyncWrapper(10 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable); + // We expect an error because it has not been possible to free the minimum memory + if(err == KErrNoMemory) + { + err = KErrNone; + } + + if (err == KErrNone) + { + //start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + } + + if (err == KErrNone && memTestState == ETestAbove) + { + + if (err == KErrNone) + { + // Check that all system plugins below P8 have been called + + err = PluginFreeRamCalledL(0x10286A34, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A34 Free Ram not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A35, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A35 Free Ram not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A36, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A36 Free Ram not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // This the P8 system plugin has not been called + err = PluginFreeRamCalledL(0x10286A37, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A37 Free Ram incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // Check that the low priority app plugin has been called + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3B Free Ram not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // Check that the P7 application has been closed + err = AppIsRunning(KOomTestApp3Uid, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"P7 App KOomTestApp3Uid incorrectly running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"minimum memory unexpectedly freed or still below treshhold or could not start watchers"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + ResetL(); + return KErrNone; + } + + + + + + + +void COomTestHarness::BringAppToForeground(TInt32 aUid) + { + //bring app to foreground + TInt id = iApps.Find(TUid::Uid(aUid), CCDummyApplicationHandle::CompareTo); + User::LeaveIfError(id); + iApps[id]->BringToForeground(); + User::After(TTimeIntervalMicroSeconds32(KSettlingTime)); + } + + +void COomTestHarness::ResetL() + { + Settle(); + + // Close any dummy apps + iApps.ResetAndDestroy(); + + Settle(); + + // Free all memory being eaten by the server + iChunk.Adjust(KOomHarnessInitialEatenMemory); // Just eat 1K of memory initially, this can grow later + iChunkSize = KOomHarnessInitialEatenMemory; + + iDummyChunk.Close(); + iDummyChunkSize = 0; + + User::LeaveIfError(iAllocServer.Reset()); + + // Wait for the system to settle before getting the call counts (freeing the memory could cause some more movement). + Settle(); + + // Update the call counts on the plugins (add them if they're not there already) + for (TInt pluginUid = KUidOOMDummyPluginFirstImplementation; pluginUid <= KUidOOMDummyPluginLastImplementation; pluginUid++) + { + TInt lowMemoryCount = 0; + RProperty::Get(KUidOomPropertyCategory, pluginUid + KOOMDummyPluginLowMemoryCount, lowMemoryCount); + + TInt goodMemoryCallCount = 0; + RProperty::Get(KUidOomPropertyCategory, pluginUid + KOOMDummyPluginGoodMemoryCount, goodMemoryCallCount); + + TPluginCallCount pluginCallCount; + pluginCallCount.iFreeRamCallCount = lowMemoryCount; + pluginCallCount.iMemoryGoodCallCount = goodMemoryCallCount; + + iPluginCallCounts.InsertL(pluginUid, pluginCallCount); + }; + } + +void COomTestHarness::EatMemoryL(TInt aKBytesToLeaveFree) + { + Settle(); + + TMemoryInfoV1Buf meminfo; + UserHal::MemoryInfo(meminfo); + TInt freeMem = meminfo().iFreeRamInBytes; + + // Resize the dummy chunk to consume the correct ammount of memory + iChunkSize = freeMem + iChunkSize - (aKBytesToLeaveFree * 1024); + + if( iChunkSize > KOomHarnessMaxEatenMemory) + { + TInt dummy = (iChunkSize - KOomHarnessMaxEatenMemory)+ 2*1024*1024; + /* + if(dummy > (2 *1024 * 1024)) + { + //User::LeaveIfError(iDummyChunk.CreateLocal(KOomHarnessInitialEatenMemory, ((dummy-(2*1024*1024))); + dummy = dummy - 2*1024*1024; + } + */ + User::LeaveIfError(iDummyChunk.CreateLocal(KOomHarnessInitialEatenMemory, dummy)); + iDummyChunkSize = KOomHarnessInitialEatenMemory; + TInt err1 = iDummyChunk.Adjust(dummy-1024); + UserHal::MemoryInfo(meminfo); + freeMem = meminfo().iFreeRamInBytes; + iChunkSize = freeMem + KOomHarnessInitialEatenMemory - (aKBytesToLeaveFree * 1024); + } + + + TInt err = iChunk.Adjust(iChunkSize); + User::LeaveIfError(err); + } + +void COomTestHarness::AllocateMemoryL(TInt aKBytes) + { + TInt err = iChunk.Allocate(aKBytes * 1024); + User::LeaveIfError(err); + } + +// Set up the plugins and applications - this is the starting point for many test cases +// 5 applications are started with approx 0.5 MB used for each +// 0.5MB (approx) of memory is reserved for each one of the plugins +void COomTestHarness::CommonSetUpL() + { + // Configure the plugins to eat 0.5MB each: + for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation; pluginIndex++) + { + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000)); + } + } + +void COomTestHarness::StartApplicationL(TInt32 aUid, TInt aInitialAllocationInKBs) + { + User::ResetInactivityTime(); + CCDummyApplicationHandle *app = CCDummyApplicationHandle::NewLC(TUid::Uid(aUid), aInitialAllocationInKBs * 1024); + iApps.AppendL(app); + CleanupStack::Pop(app); + Settle(); + } + +// Returns KErrNone if we get the expected result +TInt COomTestHarness::AppIsRunning(TInt32 aUid, TBool aExpectedResult) + { + TBool appRunning = ETrue; + + TInt id = iApps.Find(TUid::Uid(aUid), CCDummyApplicationHandle::CompareTo); + if (id < 0) + appRunning = EFalse; + else if(iApps[id]->Process().ExitType() != EExitPending) + appRunning = EFalse; + + TInt err = KErrNone; + + if (aExpectedResult != appRunning) + err = KErrGeneral; + + if (aExpectedResult != appRunning) + { + err = KErrGeneral; + } + + return err; + } + +// Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)? +// Returns KErrNone if we get the expected result +TInt COomTestHarness::PluginFreeRamCalledL(TInt32 aUid, TBool aExpectedResult) + { + TInt newLowMemoryCount = 0; + TInt err = RProperty::Get(KUidOomPropertyCategory, aUid + KOOMDummyPluginLowMemoryCount, newLowMemoryCount); + + //handle error? + + TBool freeRamHasBeenCalledOnPlugin = EFalse; + TPluginCallCount* pluginCallCount = iPluginCallCounts.Find(aUid); + + if (pluginCallCount) + { + freeRamHasBeenCalledOnPlugin = (pluginCallCount->iFreeRamCallCount != newLowMemoryCount); + + if (freeRamHasBeenCalledOnPlugin) + { + // Update the list of old counts with the current value so we can see if it has changed next time this function is called + pluginCallCount->iFreeRamCallCount = newLowMemoryCount; + iPluginCallCounts.InsertL(aUid, *pluginCallCount); + } + } + else + { + err = KErrNotFound; + } + + if (aExpectedResult != freeRamHasBeenCalledOnPlugin) + { + err = KErrGeneral; + } + + return err; + } + +// Has FreeRam been called on this plugin since the last call to this function (or since the whole class has been reset)? +// Returns KErrNone if we get the expected result +TInt COomTestHarness::PluginMemoryGoodCalledL(TInt32 aUid, TBool aExpectedResult) + { + TInt newGoodMemoryCount = 0; + RProperty::Get(KUidOomPropertyCategory, aUid + KOOMDummyPluginGoodMemoryCount, newGoodMemoryCount); + + TBool memoryGoodHasBeenCalledOnPlugin = EFalse; + TPluginCallCount* pluginCallCount = iPluginCallCounts.Find(aUid); + + if (pluginCallCount) + { + memoryGoodHasBeenCalledOnPlugin = (pluginCallCount->iMemoryGoodCallCount != newGoodMemoryCount); + + if (memoryGoodHasBeenCalledOnPlugin) + { + // Update the list of old counts with the current value so we can see if it has changed next time this function is called + pluginCallCount->iMemoryGoodCallCount = newGoodMemoryCount; + iPluginCallCounts.InsertL(aUid, *pluginCallCount); + } + } + + TInt err = KErrNone; + + if (aExpectedResult != memoryGoodHasBeenCalledOnPlugin) + err = KErrGeneral; + + return err; + } + +// Utility function which calls the async version of optional RAM request and makes it behave like the sync version +TInt COomTestHarness::RequestOptionalRamASyncWrapper(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable) + { + TInt err = KErrNone; + TRequestStatus status; + iOomSession.RequestOptionalRam(aBytesRequested, aMinimumBytesNeeded, aPluginId, status); + User::WaitForRequest(status); + + if (status.Int() < 0) + err = status.Int(); + else + aBytesAvailable = status.Int(); + + return err; + } + +void COomTestHarness::StartMemoryMonitorStatusWatcher(TInt& aTestState) + { + iStatusWatcher->Start(&aTestState); + } + +void COomTestHarness::StartTimerAndRunWatcher(TInt& aTestState) + { + //start timer + iTimeoutWatcher->Start(&aTestState, KTimeout); + + //start active scheduler to catch mem monitor status changes + CActiveScheduler::Start(); + + //One of the active objects has fired. Cancelling all pending requests + iStatusWatcher->Cancel(); + iTimeoutWatcher->Cancel(); + } + +TInt COomTestHarness::GetFreeMemory() + { + User::CompressAllHeaps(); + + TInt current = 0; + HAL::Get( HALData::EMemoryRAMFree, current ); + + return current; + } + + +CMemoryMonitorStatusWatcher* CMemoryMonitorStatusWatcher::NewL() + { + CMemoryMonitorStatusWatcher* self = new (ELeave) CMemoryMonitorStatusWatcher(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); // self; + return self; + } + +CMemoryMonitorStatusWatcher::~CMemoryMonitorStatusWatcher() + { + Cancel(); + iMonitorProperty.Close(); + } + +void CMemoryMonitorStatusWatcher::Start(TInt* aTestState) + { + iMonitorProperty.Subscribe(iStatus); + SetActive(); + + iTestState = aTestState; + } + +CMemoryMonitorStatusWatcher::CMemoryMonitorStatusWatcher() : CActive(CActive::EPriorityStandard) + { + } + +void CMemoryMonitorStatusWatcher::ConstructL() + { + CActiveScheduler::Add(this); // Add to scheduler + User::LeaveIfError(iMonitorProperty.Attach(KOomMemoryMonitorStatusPropertyCategory, KOomMemoryMonitorStatusPropertyKey)); + } + +void CMemoryMonitorStatusWatcher::DoCancel() + { + iMonitorProperty.Cancel(); + } + +void CMemoryMonitorStatusWatcher::RunL() + { + iMonitorProperty.Subscribe(iStatus); + SetActive(); + + TInt monitorState = EFreeingMemory; + User::LeaveIfError(iMonitorProperty.Get(monitorState)); + + if (monitorState != EFreeingMemory) + { + //Do not reschedule - signal client that request has completed + Cancel(); + if(monitorState == EBelowTreshHold) + { + *iTestState = ETestBelow; + } + else + { + *iTestState = ETestAbove; + } + CActiveScheduler::Stop(); + } + } + +CMemoryMonitorTimeoutWatcher* CMemoryMonitorTimeoutWatcher::NewL() + { + CMemoryMonitorTimeoutWatcher* self = new (ELeave) CMemoryMonitorTimeoutWatcher(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); // self; + return self; + } + +CMemoryMonitorTimeoutWatcher::~CMemoryMonitorTimeoutWatcher() + { + Cancel(); + } + +void CMemoryMonitorTimeoutWatcher::Start(TInt* aTestState, const TTimeIntervalMicroSeconds32& aTimeout) + { + iTestState = aTestState; + After(aTimeout); + } + +void CMemoryMonitorTimeoutWatcher::ConstructL() + { + CTimer::ConstructL(); + CActiveScheduler::Add(this); // Add to scheduler + } + +CMemoryMonitorTimeoutWatcher::CMemoryMonitorTimeoutWatcher() : CTimer(CActive::EPriorityStandard) + { + } + +void CMemoryMonitorTimeoutWatcher::DoCancel() + { + CTimer::DoCancel(); + } + +void CMemoryMonitorTimeoutWatcher::RunL() + { + Cancel(); + *iTestState = ETestTimeout; + CActiveScheduler::Stop(); + } + +//////// + +CAsyncRequester* CAsyncRequester::NewL(RChunk aChunk, TInt aChunkSize) + { + CAsyncRequester* self = new (ELeave) CAsyncRequester(aChunk, aChunkSize); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); // self; + return self; + } + +CAsyncRequester::~CAsyncRequester() + { + Cancel(); + iSession.Close(); + } + +void CAsyncRequester::Start(TInt aBytesToRequest, TReturnStatus* aReturnStatus) + { + iReturnStatus = aReturnStatus; + //Request 2.8MB which will close KOomTestApp3Uid + iSession.RequestOptionalRam(aBytesToRequest, 0, 0x10286A3D, iStatus); + SetActive(); + } + +void CAsyncRequester::ConstructL() + { + User::LeaveIfError(iSession.Connect()); + CActiveScheduler::Add(this); // Add to scheduler + } + +CAsyncRequester::CAsyncRequester(RChunk aChunk, TInt aChunkSize) + : CActive(CActive::EPriorityStandard), + iChunk(aChunk), + iChunkSize(aChunkSize) + { + } + +void CAsyncRequester::DoCancel() + { + } + +void CAsyncRequester::RunL() + { + iReturnStatus->iCompleted = ETrue; + iReturnStatus->iReturnStatus = iStatus.Int(); + if (iReturnStatus->iId == 1) + { + TMemoryInfoV1Buf meminfo; + UserHal::MemoryInfo(meminfo); + TInt freeMem = meminfo().iFreeRamInBytes; + + // Resize the dummy chunk to consume the correct ammount of memory + iChunkSize = freeMem + iChunkSize - (KOomJustAboveGoodMemoryThreshold * 1024); + TInt err = iChunk.Adjust(iChunkSize); + User::LeaveIfError(err); + } + else + { + CActiveScheduler::Stop(); + } + } + +///////// + + +TInt COomTestHarness::AppCloseTwoSessionsL(TTestResult& aResult) + { + ResetL(); + + StartApplicationL(KOomTestApp2Uid, 3 * 1024); // P8 app to be closed + StartApplicationL(KOomTestAppUid, 3 * 1024); // P9 app should not be closed + StartApplicationL(KOomTestApp3Uid, 3 * 1024); // P7 app to be closed + StartApplicationL(KOomTestApp4Uid, 3 * 1024); // P7 app foreground should not be closed + + // Go just above the good memory threshold + EatMemoryL(KOomJustAboveGoodMemoryThreshold); + + Settle(); + + TInt err = KErrNone; + CAsyncRequester* req1 = CAsyncRequester::NewL(iChunk, iChunkSize); + CleanupStack::PushL(req1); + CAsyncRequester* req2 = CAsyncRequester::NewL(iChunk, iChunkSize); + CleanupStack::PushL(req2); + TReturnStatus status1; + status1.iId = 1; + TReturnStatus status2; + status2.iId = 2; + + TInt memTestState = ETestInit; + iTimeoutWatcher->Start(&memTestState, KTimeout); + + //This request should close KOomTestApp3Uid + //On return the active object will allocate the memory it requested + req1->Start(3 * 1024 * 1024, &status1); + + //The second request should be queued until the first request has completed, there will then be + //a pause for the memory to be allocated before the request is properly serviced. + req2->Start(3 * 1024 * 1024, &status2); + + CActiveScheduler::Start(); + + //The active scheduler is stopped, we should return here once both AOs have been completed. + iTimeoutWatcher->Cancel(); + + if (memTestState == ETestTimeout) + { + err = KErrTimedOut; + _LIT( KResult ,"Test has timed out, requests have not been completed"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + if (err == KErrNone) + { + err = AppIsRunning(KOomTestApp4Uid, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Foreground App KOomTestApp4Uid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + if (err == KErrNone) + { + err = AppIsRunning(KOomTestAppUid, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"P9 App KOomTestAppUid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + if (err == KErrNone) + { + err = AppIsRunning(KOomTestApp3Uid, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"P7 App KOomTestApp3Uid incorrectly running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + if (err == KErrNone) + { + err = AppIsRunning(KOomTestApp2Uid, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"P7 App KOomTestApp2Uid incorrectly running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + + CleanupStack::PopAndDestroy(2); + ResetL(); + return KErrNone; + } + + +TInt COomTestHarness::CallIfTargetAppNotRunningTest1L(TTestResult& aResult) + { + ResetL(); + + // Configure the plugins to eat 0.5MB each: + for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++) + { + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x80000, 0x80000)); + } + + StartApplicationL(KOomTestApp3Uid, 0); + + + TInt err = KErrNone; + + // Now eat some memory till we are below treshhold and wait for the memory monitor to bring us above treshhold again + TInt memTestState = ETestInit; + + //start watchers + StartMemoryMonitorStatusWatcher(memTestState); + + // Go just under the low memory threshold + EatMemoryL(KOomJustUnderLowMemoryThreshold); + + //start timer, start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + + // fail tests if watchers failed or memory was not freed + if (memTestState != ETestAbove) + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + //if memteststate is not desired signal to other cases that they should not pass + err = KErrGeneral; + } + + // The following application plugins should be called... + // Application plugins: 10286A3B + // The following application plugins should not be called... + // Application plugins: 10286A3A, 0x10286A38 + if (err == KErrNone) + { + //target app not running for this priority 3 app plugin + err = PluginFreeRamCalledL(0x10286A3A, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3A FreeRam incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + //target app is running for this priority 4 app plugin + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3B FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + //By the time we get to this priority 9 plugin, the app plugins and other sys plugins + // have freed enough memory and a sys plugin with "check ram" has been called + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A38, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A38 FreeRam incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + + ResetL(); + return KErrNone; + } + +//Test that an app that has an app_specific_thresholds but no close_app can still be closed +// +//This test only works on emulator. On hw there are many more apps started which have default priority +//and these are closed before KOomTestApp8Uid as they are behind it in the z order, freeing sufficient memory +//before we would get to KOomTestApp8Uid +TInt COomTestHarness::AppCloseSpecificThresholdTest1L(TTestResult& aResult) + { + ResetL(); + + StartApplicationL(KOomTestApp8Uid, 5 * 1024); // app with app_specific_thresholds but no close_app + StartApplicationL(KOomTestApp3Uid, 0); // P7 foreground app. Will not be closed + + BringAppToForeground(KOomTestApp3Uid); + + //start watchers + TInt memTestState = ETestInit; + TInt err = KErrNone; + + StartMemoryMonitorStatusWatcher(memTestState); + + // Go significantly under the low memory threshold + EatMemoryL(KOomSignificantlyUnderLowMemoryThreshold); + + //start timer, start scheduler & stop watchers when done + StartTimerAndRunWatcher(memTestState); + + if (memTestState == ETestAbove) + { + err = AppIsRunning(KOomTestApp8Uid, EFalse); + + if (err != KErrNone) + { + _LIT( KResult ,"P8 App KOomTestApp2Uid incorrectly running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + if (err == KErrNone) + { + err = AppIsRunning(KOomTestApp3Uid, ETrue); + if (err != KErrNone) + { + // The P7 app should still be running because it was in the foreground + _LIT( KResult ,"(P7 App KOomTestApp3Uid not running"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + } + else + { + _LIT( KResult ,"Watchers failed to start or Application Timeout or Memory Still Below Treshhold "); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // case was not executed or case was executed but never finished or failed + } + + ResetL(); + return KErrNone; + } + +TInt COomTestHarness::PluginTestInsufficientMemoryFreedL(TTestResult& aResult) + { + ResetL(); + + // Configure the plugins to eat 1kB each: + for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++) + { + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x400, 0x400)); + } + + //start watchers + TInt err = KErrNone; + TInt bytesAvailable; + + // Go significantly under the low memory threshold + EatMemoryL(KOomJustAboveGoodMemoryThreshold); + + // Request 5 MB of data, using the priority of the referenced plugin (constant priority 8) + err = iOomSession.RequestOptionalRam(5 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable); + + // There should be nothing that can be done to free this memory + if (err == KErrNoMemory) + { + err = KErrNone; + } + else + { + _LIT( KResult ,"There should not have been actions available to successfully complete request"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + //Check a couple of plugins that should have been called + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A36, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A36 FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A3B FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + // This plugin should not be called as it is priority 9 + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A3D, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A3D FreeRam incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + //This plugins should not be called as the target app is not running + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A3A, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A3A FreeRam incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + // MemoryGood should have been called on all plugins which were run as the request to + // go below memory was triggered by an optional RAM request + if (err == KErrNone) + { + err = PluginMemoryGoodCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3B MemoryGood not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginMemoryGoodCalledL(0x10286A3C, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3C MemoryGood not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // MemoryGood should not be called on this plugin because FreeMemory was never called on it + err = PluginMemoryGoodCalledL(0x10286A37, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A37 MemoryGood incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + + ResetL(); + return KErrNone; + } + +TInt COomTestHarness::PluginTestInsufficientMemoryFreed2L(TTestResult& aResult) + { + ResetL(); + + // Configure the plugins to eat 1kB each: + for (TInt pluginIndex = KUidOOMDummyPluginFirstImplementation; pluginIndex <= KUidOOMDummyPluginLastImplementation - 2; pluginIndex++) + { + User::LeaveIfError(iAllocServer.Configure(TUid::Uid(pluginIndex), 0, 0x400, 0x400)); + } + + //start watchers + TInt err = KErrNone; + TInt bytesAvailable; + + // Go significantly under the low memory threshold + EatMemoryL(KOomBetweenLowAndGoodThresholds); + + // Request 5 MB of data, using the priority of the referenced plugin (constant priority 8) + err = iOomSession.RequestOptionalRam(5 * 1024 * 1024, 5 * 1024 * 1024, 0x10286A37, bytesAvailable); + + // There should be nothing that can be done to free this memory + if (err == KErrNoMemory) + { + err = KErrNone; + } + else + { + _LIT( KResult ,"There should not have been actions available to successfully complete request"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + + //Check a couple of plugins that should have been called + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A36, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A36 FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A3B FreeRam not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + // This plugin should not be called as it is priority 9 + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A3D, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A3D FreeRam incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + //This plugins should not be called as the target app is not running + if (err == KErrNone) + { + err = PluginFreeRamCalledL(0x10286A3A, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"Plugin 0x10286A3A FreeRam incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + // MemoryGood should have been called on all plugins which were run as the request to + // go below memory was triggered by an optional RAM request + if (err == KErrNone) + { + err = PluginMemoryGoodCalledL(0x10286A3B, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3B MemoryGood not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + err = PluginMemoryGoodCalledL(0x10286A3C, ETrue); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A3C MemoryGood not called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + // MemoryGood should not be called on this plugin because FreeMemory was never called on it + err = PluginMemoryGoodCalledL(0x10286A37, EFalse); + if (err != KErrNone) + { + _LIT( KResult ,"plugin 0x10286A37 MemoryGood incorrectly called"); + aResult.iResultDes.Copy( KResult ); + aResult.iResult = KErrGeneral; + // Case was executed but failed + } + } + + if (err == KErrNone) + { + _LIT( KDescription , "Test case passed"); + aResult.SetResult( KErrNone, KDescription ); + } + + ResetL(); + return KErrNone; + } + +// ================= OTHER EXPORTED FUNCTIONS ================================= + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/data/t_oomtestapp.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/data/t_oomtestapp.rss Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,171 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +// RESOURCE IDENTIFIER +NAME T_OT // 4 letter ID + +// INCLUDES +#include +#include +#include +#include +#include +#include +#include "t_oomtestappcmd.hrh" + +// RESOURCE DEFINITIONS +RESOURCE RSS_SIGNATURE + { + } + +RESOURCE TBUF r_default_document_name + { + buf="T_OT"; + } + +RESOURCE EIK_APP_INFO + { + menubar = r_menubar; + cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT; + } + +RESOURCE MENU_BAR r_menubar + { + titles = + { + MENU_TITLE { menu_pane = r_menu; } + }; + } + +RESOURCE MENU_PANE r_menu + { + items = + { + MENU_ITEM + { + command = EOomTestAppSelectConfig; + txt = "Select config xml"; + }, + MENU_ITEM + { + command = EOomTestAppToggleSystem; + txt = "Toggle system"; + }, + MENU_ITEM + { + command = EOomTestAppAllocMemory; + txt = "Alloc memory"; + }, + MENU_ITEM + { + command = EOomTestAppFreeMemory; + txt = "Free memory"; + }, + MENU_ITEM + { + command = EOomTestAppAllocMemWithPermission; + txt = "Alloc memory with permission"; + }, + MENU_ITEM + { + command = EOomTestAppSetPriority; + cascade = r_priority_menu; + txt = "Set priority"; + }, + MENU_ITEM + { + command = EAknSoftkeyExit; + txt = "Exit"; + } + }; + } + +RESOURCE MENU_PANE r_priority_menu + { + items = + { + MENU_ITEM + { + command = EOomTestAppSetPriorityNormal; + txt = "Normal"; + }, + MENU_ITEM + { + command = EOomTestAppSetPriorityHigh; + txt = "High"; + }, + MENU_ITEM + { + command = EOomTestAppSetPriorityBusy; + txt = "Busy"; + } + }; + } + +RESOURCE MEMORYSELECTIONDIALOG r_memory_selection + { + title = ""; + softkey_1 = "Ok"; + } + +RESOURCE FILESELECTIONDIALOG r_file_selection + { + title = "Select xml"; + softkey_1_file = "Select"; + softkey_1_folder = "Open"; + softkey_2_root_level = "Cancel"; + softkey_2_subfolder = "Back"; + filters = + { + FILTER + { + filter_type = EFilenameFilter; + filter_style = EInclusiveFilter; + filter_data = { "*.xml" }; + } + }; + } + +RESOURCE DIALOG r_alloc_query + { + flags = EAknGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_DATA_QUERY + { + layout = ENumberLayout; + label = "KBs to allocate"; + control = AVKON_INTEGER_EDWIN + { + maxlength=10; + min = 0; + max = 0x7fffffff; // KMaxTInt + }; + }; + } + }; + } + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/data/t_oomtestapp_reg.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/data/t_oomtestapp_reg.rss Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include +#include "t_oomtestapp.hrh" + +UID2 KUidAppRegistrationResourceFile +UID3 T_OOM_TESTAPP_UID + +RESOURCE APP_REGISTRATION_INFO + { + app_file = T_OOM_TESTAPP_NAME_STRING; + } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/bld.inf Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +PRJ_PLATFORMS +DEFAULT + +PRJ_TESTMMPFILES +t_oomtestapp.mmp +t_oomtestapp2.mmp +t_oomtestapp3.mmp +t_oomtestapp4.mmp +t_oomtestapp5.mmp +t_oomtestapp6.mmp +t_oomtestapp7.mmp +t_oomtestapp8.mmp +t_oomtestapp9.mmp +t_oomtestapp10.mmp diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/oomtestapps.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/oomtestapps.pkg Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,50 @@ +;Languages +&EN + +#{"t_oomtestapps"},(0x101FB3E7),1,0,0,TYPE=SA + +;Localised Vendor name +%{"t_oomtestapps EN"} + +; Vendor name +: "t_oomtestapps" + +"\epoc32\release\armv5\urel\t_oomtestapp.exe"-"!:\sys\bin\t_oomtestapp.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp.rsc"-"!:\resource\apps\t_oomtestapp.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp2.exe"-"!:\sys\bin\t_oomtestapp2.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp2.rsc"-"!:\resource\apps\t_oomtestapp2.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp2_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp2_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp3.exe"-"!:\sys\bin\t_oomtestapp3.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp3.rsc"-"!:\resource\apps\t_oomtestapp3.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp3_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp3_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp4.exe"-"!:\sys\bin\t_oomtestapp4.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp4.rsc"-"!:\resource\apps\t_oomtestapp4.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp4_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp4_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp5.exe"-"!:\sys\bin\t_oomtestapp5.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp5.rsc"-"!:\resource\apps\t_oomtestapp5.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp5_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp5_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp6.exe"-"!:\sys\bin\t_oomtestapp6.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp6.rsc"-"!:\resource\apps\t_oomtestapp6.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp6_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp6_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp7.exe"-"!:\sys\bin\t_oomtestapp7.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp7.rsc"-"!:\resource\apps\t_oomtestapp7.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp7_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp7_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp8.exe"-"!:\sys\bin\t_oomtestapp8.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp8.rsc"-"!:\resource\apps\t_oomtestapp8.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp8_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp8_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp9.exe"-"!:\sys\bin\t_oomtestapp9.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp9.rsc"-"!:\resource\apps\t_oomtestapp9.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp9_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp9_reg.rsc" + +"\epoc32\release\armv5\urel\t_oomtestapp10.exe"-"!:\sys\bin\t_oomtestapp10.exe" +"\epoc32\data\z\resource\apps\t_oomtestapp10.rsc"-"!:\resource\apps\t_oomtestapp10.rsc" +"\epoc32\data\z\private\10003a3f\apps\t_oomtestapp10_reg.rsc"-"!:\private\10003a3f\import\apps\t_oomtestapp10_reg.rsc" diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/oomtestapps.sisx Binary file sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/oomtestapps.sisx has changed diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp.mmh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp.mmh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#include + +TARGET T_OOM_TESTAPP_NAME_EXE +TARGETTYPE exe +EPOCHEAPSIZE 0x10000 0x4000000 // Min 64KB, Max 64MB +UID 0x100039CE T_OOM_TESTAPP_UID +CAPABILITY WriteDeviceData AllFiles + +SOURCEPATH ../src +SOURCE t_oomtestappapplication.cpp +SOURCE t_oomtestappappview.cpp +SOURCE t_oomtestappappui.cpp +SOURCE t_oomtestappdocument.cpp + +SOURCEPATH ../data +START RESOURCE t_oomtestapp.rss +HEADER +TARGET T_OOM_TESTAPP_NAME +TARGETPATH resource/apps +END + +START RESOURCE t_oomtestapp_reg.rss +TARGET T_OOM_TESTAPP_NAME_REG +TARGETPATH /private/10003a3f/apps +END + +MW_LAYER_SYSTEMINCLUDE +T_OOM_TEST_APPDEFS_INCLUDE +USERINCLUDE ../inc + +LIBRARY euser.lib +LIBRARY apparc.lib +LIBRARY cone.lib +LIBRARY eikcore.lib +LIBRARY avkon.lib +LIBRARY efsrv.lib +LIBRARY oommonitor.lib +LIBRARY commondialogs.lib + +// End of File \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs +#include "../inc/appdefs/t_oomtestapp.hrh" +#include "t_oomtestapp.mmh" + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp10.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp10.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs10 +#include "../inc/appdefs10/t_oomtestapp.hrh" +#include "t_oomtestapp.mmh" + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp2.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp2.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + + +#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs2 +#include "../inc/appdefs2/t_oomtestapp.hrh" +#include "t_oomtestapp.mmh" + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp3.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp3.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs3 +#include "../inc/appdefs3/t_oomtestapp.hrh" +#include "t_oomtestapp.mmh" + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp4.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp4.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs4 +#include "../inc/appdefs4/t_oomtestapp.hrh" +#include "t_oomtestapp.mmh" + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp5.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp5.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs5 +#include "../inc/appdefs5/t_oomtestapp.hrh" +#include "t_oomtestapp.mmh" + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp6.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp6.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs6 +#include "../inc/appdefs6/t_oomtestapp.hrh" +#include "t_oomtestapp.mmh" + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp7.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp7.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs7 +#include "../inc/appdefs7/t_oomtestapp.hrh" +#include "t_oomtestapp.mmh" + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp8.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp8.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs8 +#include "../inc/appdefs8/t_oomtestapp.hrh" +#include "t_oomtestapp.mmh" + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp9.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp9.mmp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#define T_OOM_TEST_APPDEFS_INCLUDE USERINCLUDE ../inc/appdefs9 +#include "../inc/appdefs9/t_oomtestapp.hrh" +#include "t_oomtestapp.mmh" + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs/t_oomtestapp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs/t_oomtestapp.hrh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef T_OOMTESTAPP_HRH +#define T_OOMTESTAPP_HRH + +#define T_OOM_TESTAPP_NAME t_oomtestapp +#define T_OOM_TESTAPP_NAME_EXE t_oomtestapp.exe +#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp" +#define T_OOM_TESTAPP_NAME_REG t_oomtestapp_reg +#define T_OOM_TESTAPP_UID 0xE6CFBA01 + +#endif // T_OOMTESTAPP_HRH + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs10/t_oomtestapp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs10/t_oomtestapp.hrh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef T_OOMTESTAPP_HRH +#define T_OOMTESTAPP_HRH + +#define T_OOM_TESTAPP_NAME t_oomtestapp10 +#define T_OOM_TESTAPP_NAME_EXE t_oomtestapp10.exe +#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp10" +#define T_OOM_TESTAPP_NAME_REG t_oomtestapp10_reg +#define T_OOM_TESTAPP_UID 0xE6CFBA0A + +#endif // T_OOMTESTAPP_HRH + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs2/t_oomtestapp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs2/t_oomtestapp.hrh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef T_OOMTESTAPP_HRH +#define T_OOMTESTAPP_HRH + +#define T_OOM_TESTAPP_NAME t_oomtestapp2 +#define T_OOM_TESTAPP_NAME_EXE t_oomtestapp2.exe +#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp2" +#define T_OOM_TESTAPP_NAME_REG t_oomtestapp2_reg +#define T_OOM_TESTAPP_UID 0xE6CFBA02 + +#endif // T_OOMTESTAPP_HRH + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs3/t_oomtestapp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs3/t_oomtestapp.hrh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef T_OOMTESTAPP_HRH +#define T_OOMTESTAPP_HRH + +#define T_OOM_TESTAPP_NAME t_oomtestapp3 +#define T_OOM_TESTAPP_NAME_EXE t_oomtestapp3.exe +#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp3" +#define T_OOM_TESTAPP_NAME_REG t_oomtestapp3_reg +#define T_OOM_TESTAPP_UID 0xE6CFBA03 + +#endif // T_OOMTESTAPP_HRH + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs4/t_oomtestapp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs4/t_oomtestapp.hrh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef T_OOMTESTAPP_HRH +#define T_OOMTESTAPP_HRH + +#define T_OOM_TESTAPP_NAME t_oomtestapp4 +#define T_OOM_TESTAPP_NAME_EXE t_oomtestapp4.exe +#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp4" +#define T_OOM_TESTAPP_NAME_REG t_oomtestapp4_reg +#define T_OOM_TESTAPP_UID 0xE6CFBA04 + +#endif // T_OOMTESTAPP_HRH + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs5/t_oomtestapp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs5/t_oomtestapp.hrh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef T_OOMTESTAPP_HRH +#define T_OOMTESTAPP_HRH + +#define T_OOM_TESTAPP_NAME t_oomtestapp5 +#define T_OOM_TESTAPP_NAME_EXE t_oomtestapp5.exe +#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp5" +#define T_OOM_TESTAPP_NAME_REG t_oomtestapp5_reg +#define T_OOM_TESTAPP_UID 0xE6CFBA05 + +#endif // T_OOMTESTAPP_HRH + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs6/t_oomtestapp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs6/t_oomtestapp.hrh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef T_OOMTESTAPP_HRH +#define T_OOMTESTAPP_HRH + +#define T_OOM_TESTAPP_NAME t_oomtestapp6 +#define T_OOM_TESTAPP_NAME_EXE t_oomtestapp6.exe +#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp6" +#define T_OOM_TESTAPP_NAME_REG t_oomtestapp6_reg +#define T_OOM_TESTAPP_UID 0xE6CFBA06 + +#endif // T_OOMTESTAPP_HRH + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs7/t_oomtestapp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs7/t_oomtestapp.hrh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef T_OOMTESTAPP_HRH +#define T_OOMTESTAPP_HRH + +#define T_OOM_TESTAPP_NAME t_oomtestapp7 +#define T_OOM_TESTAPP_NAME_EXE t_oomtestapp7.exe +#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp7" +#define T_OOM_TESTAPP_NAME_REG t_oomtestapp7_reg +#define T_OOM_TESTAPP_UID 0xE6CFBA07 + +#endif // T_OOMTESTAPP_HRH + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs8/t_oomtestapp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs8/t_oomtestapp.hrh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef T_OOMTESTAPP_HRH +#define T_OOMTESTAPP_HRH + +#define T_OOM_TESTAPP_NAME t_oomtestapp8 +#define T_OOM_TESTAPP_NAME_EXE t_oomtestapp8.exe +#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp8" +#define T_OOM_TESTAPP_NAME_REG t_oomtestapp8_reg +#define T_OOM_TESTAPP_UID 0xE6CFBA08 + +#endif // T_OOMTESTAPP_HRH + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs9/t_oomtestapp.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs9/t_oomtestapp.hrh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +#ifndef T_OOMTESTAPP_HRH +#define T_OOMTESTAPP_HRH + +#define T_OOM_TESTAPP_NAME t_oomtestapp9 +#define T_OOM_TESTAPP_NAME_EXE t_oomtestapp9.exe +#define T_OOM_TESTAPP_NAME_STRING "t_oomtestapp9" +#define T_OOM_TESTAPP_NAME_REG t_oomtestapp9_reg +#define T_OOM_TESTAPP_UID 0xE6CFBA09 + +#endif // T_OOMTESTAPP_HRH + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappapplication.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappapplication.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,52 @@ +/* + ============================================================================ + Name : t_oomtestappApplication.h + Author : + Copyright : Your copyright notice + Description : Declares main application class. + ============================================================================ + */ + +#ifndef __T_OOMTESTAPPAPPLICATION_H__ +#define __T_OOMTESTAPPAPPLICATION_H__ + +// INCLUDES +#include + +// CLASS DECLARATION + +/** + * Ct_oomtestappApplication application class. + * Provides factory to create concrete document object. + * An instance of Ct_oomtestappApplication is the application part of the + * AVKON application framework for the t_oomtestapp example application. + */ +class Ct_oomtestappApplication : public CAknApplication + { +public: + Ct_oomtestappApplication(); + // Functions from base classes + + /** + * From CApaApplication, AppDllUid. + * @return Application's UID + */ + TUid AppDllUid() const; + + ~Ct_oomtestappApplication(); +protected: + // Functions from base classes + + /** + * From CApaApplication, CreateDocumentL. + * Creates Ct_oomtestappDocument document object. The returned + * pointer in not owned by the Ct_oomtestappApplication object. + * @return A pointer to the created document object. + */ + CApaDocument* CreateDocumentL(); + +private: + }; + +#endif // __T_OOMTESTAPPAPPLICATION_H__ +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappappui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappappui.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,92 @@ +/* + ============================================================================ + Name : t_oomtestappAppUi.h + Author : + Copyright : Your copyright notice + Description : Declares UI class for application. + ============================================================================ + */ + +#ifndef __T_OOMTESTAPPAPPUI_h__ +#define __T_OOMTESTAPPAPPUI_h__ + +// INCLUDES +#include +#include + +// FORWARD DECLARATIONS +class Ct_oomtestappAppView; + +const TInt KKiloByte = 1024; + +// CLASS DECLARATION +/** + * Ct_oomtestappAppUi application UI class. + * Interacts with the user through the UI and request message processing + * from the handler class + */ +class Ct_oomtestappAppUi : public CAknAppUi + { +public: + + // Constructors and destructor + + /** + * ConstructL. + * 2nd phase constructor. + */ + void ConstructL(); + + /** + * Ct_oomtestappAppUi. + * C++ default constructor. This needs to be public due to + * the way the framework constructs the AppUi + */ + Ct_oomtestappAppUi(); + + /** + * ~Ct_oomtestappAppUi. + * Virtual Destructor. + */ + virtual ~Ct_oomtestappAppUi(); + + TInt AllocatedHeap() const; + + TPtrC Priority() const; + +private: + // Functions from base classes + + /** + * From CEikAppUi, HandleCommandL. + * Takes care of command handling. + * @param aCommand Command to be handled. + */ + void HandleCommandL(TInt aCommand); + + /** + * HandleStatusPaneSizeChange. + * Called by the framework when the application status pane + * size is changed. + */ + void HandleStatusPaneSizeChange(); + +private: + // Data + + /** + * The application view + * Owned by Ct_oomtestappAppUi + */ + Ct_oomtestappAppView* iAppView; + + ROomMonitorSession iOomSession; + + TAny* iMem; + + ROomMonitorSession::TOomPriority iPriority; + + }; + +#endif // __T_OOMTESTAPPAPPUI_h__ +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappappview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappappview.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,81 @@ +/* + ============================================================================ + Name : t_oomtestappAppView.h + Author : + Copyright : Your copyright notice + Description : Declares view class for application. + ============================================================================ + */ + +#ifndef __T_OOMTESTAPPAPPVIEW_h__ +#define __T_OOMTESTAPPAPPVIEW_h__ + +// INCLUDES +#include + +class Ct_oomtestappAppUi; + +// CLASS DECLARATION +class Ct_oomtestappAppView : public CCoeControl + { +public: + // New methods + + /** + * NewL. + * Two-phased constructor. + * Create a Ct_oomtestappAppView object, which will draw itself to aRect. + * @param aRect The rectangle this view will be drawn to. + * @return a pointer to the created instance of Ct_oomtestappAppView. + */ + static Ct_oomtestappAppView* NewL(const TRect& aRect, Ct_oomtestappAppUi& aAppUi); + + /** + * ~Ct_oomtestappAppView + * Virtual Destructor. + */ + virtual ~Ct_oomtestappAppView(); + +public: + // Functions from base classes + + /** + * From CCoeControl, Draw + * Draw this Ct_oomtestappAppView to the screen. + * @param aRect the rectangle of this view that needs updating + */ + void Draw(const TRect& aRect) const; + + /** + * From CoeControl, SizeChanged. + * Called by framework when the view size is changed. + */ + virtual void SizeChanged(); + +private: + // Constructors + + /** + * ConstructL + * 2nd phase constructor. + * Perform the second phase construction of a + * Ct_oomtestappAppView object. + * @param aRect The rectangle this view will be drawn to. + */ + void ConstructL(const TRect& aRect); + + /** + * Ct_oomtestappAppView. + * C++ default constructor. + */ + Ct_oomtestappAppView( Ct_oomtestappAppUi& aAppUi ); + +private: + Ct_oomtestappAppUi& iAppUi; + + const CFont* iFont; // not own + + }; + +#endif // __T_OOMTESTAPPAPPVIEW_h__ +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappcmd.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappcmd.hrh Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,27 @@ +/* +============================================================================ + Name : t_oomtestappcmd.hrh + Author : + Copyright : Your copyright notice + Description : This file contains all the resources for the t_oomtestapp. +============================================================================ +*/ + + +#ifndef T_OOMTESTAPPCMD_HRH +#define T_OOMTESTAPPCMD_HRH + +enum TOomTestAppCmds + { + EOomTestAppSelectConfig = 1000, + EOomTestAppToggleSystem, + EOomTestAppAllocMemory, + EOomTestAppFreeMemory, + EOomTestAppAllocMemWithPermission, + EOomTestAppSetPriority, + EOomTestAppSetPriorityNormal, + EOomTestAppSetPriorityHigh, + EOomTestAppSetPriorityBusy + }; + +#endif // T_OOMTESTAPPCMD_HRH diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappdocument.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappdocument.h Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,91 @@ +/* + ============================================================================ + Name : t_oomtestappDocument.h + Author : + Copyright : Your copyright notice + Description : Declares document class for application. + ============================================================================ + */ + +#ifndef __T_OOMTESTAPPDOCUMENT_h__ +#define __T_OOMTESTAPPDOCUMENT_h__ + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class Ct_oomtestappAppUi; +class CEikApplication; + +// CLASS DECLARATION + +/** + * Ct_oomtestappDocument application class. + * An instance of class Ct_oomtestappDocument is the Document part of the + * AVKON application framework for the t_oomtestapp example application. + */ +class Ct_oomtestappDocument : public CAknDocument + { +public: + // Constructors and destructor + + /** + * NewL. + * Two-phased constructor. + * Construct a Ct_oomtestappDocument for the AVKON application aApp + * using two phase construction, and return a pointer + * to the created object. + * @param aApp Application creating this document. + * @return A pointer to the created instance of Ct_oomtestappDocument. + */ + static Ct_oomtestappDocument* NewL(CEikApplication& aApp); + + /** + * NewLC. + * Two-phased constructor. + * Construct a Ct_oomtestappDocument for the AVKON application aApp + * using two phase construction, and return a pointer + * to the created object. + * @param aApp Application creating this document. + * @return A pointer to the created instance of Ct_oomtestappDocument. + */ + static Ct_oomtestappDocument* NewLC(CEikApplication& aApp); + + /** + * ~Ct_oomtestappDocument + * Virtual Destructor. + */ + virtual ~Ct_oomtestappDocument(); + +public: + // Functions from base classes + + /** + * CreateAppUiL + * From CEikDocument, CreateAppUiL. + * Create a Ct_oomtestappAppUi object and return a pointer to it. + * The object returned is owned by the Uikon framework. + * @return Pointer to created instance of AppUi. + */ + CEikAppUi* CreateAppUiL(); + +private: + // Constructors + + /** + * ConstructL + * 2nd phase constructor. + */ + void ConstructL(); + + /** + * Ct_oomtestappDocument. + * C++ default constructor. + * @param aApp Application creating this document. + */ + Ct_oomtestappDocument(CEikApplication& aApp); + + }; + +#endif // __T_OOMTESTAPPDOCUMENT_h__ +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappapplication.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappapplication.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +// INCLUDE FILES +#include +#include "t_oomtestappDocument.h" +#include "t_oomtestappApplication.h" +#include "t_oomtestapp.hrh" + +// ============================ MEMBER FUNCTIONS =============================== + +Ct_oomtestappApplication::Ct_oomtestappApplication() + { + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappApplication::CreateDocumentL() +// Creates CApaDocument object +// ----------------------------------------------------------------------------- +// +CApaDocument* Ct_oomtestappApplication::CreateDocumentL() + { + return Ct_oomtestappDocument::NewL(*this); + } + +Ct_oomtestappApplication::~Ct_oomtestappApplication() + { + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappApplication::AppDllUid() +// Returns application UID +// ----------------------------------------------------------------------------- +// +TUid Ct_oomtestappApplication::AppDllUid() const + { + // Return the UID for the t_oomtestapp application + return TUid::Uid( T_OOM_TESTAPP_UID ); + } + +EXPORT_C CApaApplication* NewApplication() + { + return new Ct_oomtestappApplication; + } + +GLDEF_C TInt E32Main() + { + return EikStart::RunApplication(NewApplication); + } + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappappui.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappappui.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,260 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +// INCLUDE FILES +#include +#include +#include +#include +#include +#include +#include "t_oomtestappcmd.hrh" +#include "t_oomtestappApplication.h" +#include "t_oomtestappAppUi.h" +#include "t_oomtestappAppView.h" + +_LIT( KOomConfigTargetFile, "c:\\private\\10207218\\oomconfig.xml" ); +_LIT( KOomPriorityNormal, "normal" ); +_LIT( KOomPriorityHigh, "high" ); +_LIT( KOomPriorityBusy, "busy" ); +const TInt KInitialAllocSize = 2048; + +// --------------------------------------------------------------------------- +// AskPathL +// --------------------------------------------------------------------------- +// +static TBool AskPathL( TDes& aPath ) + { + TParsePtr parse( aPath ); + TPtrC rootFolder = parse.DriveAndPath(); + TBool ret = AknCommonDialogsDynMem::RunSelectDlgLD( + AknCommonDialogsDynMem::EMemoryTypePhone | + AknCommonDialogsDynMem::EMemoryTypeMMC, + aPath, + rootFolder, + R_MEMORY_SELECTION, + R_FILE_SELECTION ); + return ret; + } + + +// ============================ MEMBER FUNCTIONS =============================== + + +// ----------------------------------------------------------------------------- +// Ct_oomtestappAppUi::ConstructL() +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void Ct_oomtestappAppUi::ConstructL() + { + // Initialise app UI with standard value. + BaseConstructL(CAknAppUi::EAknEnableSkin); + + User::LeaveIfError( iOomSession.Connect() ); + + // Create view object + iAppView = Ct_oomtestappAppView::NewL(ClientRect(), *this); + + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappAppUi::Ct_oomtestappAppUi() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +Ct_oomtestappAppUi::Ct_oomtestappAppUi() + { + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappAppUi::~Ct_oomtestappAppUi() +// Destructor. +// ----------------------------------------------------------------------------- +// +Ct_oomtestappAppUi::~Ct_oomtestappAppUi() + { + delete iAppView; + iOomSession.Close(); + User::Free(iMem); + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappAppUi::HandleCommandL() +// Takes care of command handling. +// ----------------------------------------------------------------------------- +// +void Ct_oomtestappAppUi::HandleCommandL(TInt aCommand) + { + switch (aCommand) + { + case EOomTestAppSelectConfig: + { + TFileName fileName; + if ( AskPathL( fileName ) ) + { + RFs& fs( iEikonEnv->FsSession() ); + fs.MkDirAll( KOomConfigTargetFile ); // Ignore error + CFileMan* fileMan = CFileMan::NewL( fs ); + CleanupStack::PushL( fileMan ); + User::LeaveIfError( fileMan->Copy( fileName, KOomConfigTargetFile ) ); + CleanupStack::PopAndDestroy( fileMan ); + } + break; + } + case EOomTestAppToggleSystem: + { + iEikonEnv->SetSystem( !(iEikonEnv->IsSystem()) ); + iAppView->DrawDeferred(); + break; + } + case EOomTestAppAllocMemory: + { + TInt size(KInitialAllocSize); + CAknNumberQueryDialog* query = CAknNumberQueryDialog::NewL(size); + if ( query->ExecuteLD( R_ALLOC_QUERY ) ) + { + User::Free(iMem); + iMem = NULL; + size *= KKiloByte; + iMem = User::AllocL(size); + iAppView->DrawDeferred(); + } + break; + } + case EOomTestAppFreeMemory: + { + User::Free(iMem); + iMem = NULL; + iAppView->DrawDeferred(); + break; + } + case EOomTestAppAllocMemWithPermission: + { + TInt size(KInitialAllocSize); + CAknNumberQueryDialog* query = CAknNumberQueryDialog::NewL(size); + if ( query->ExecuteLD( R_ALLOC_QUERY ) ) + { + User::Free(iMem); + iMem = NULL; + size *= KKiloByte; + if ( iPriority != ROomMonitorSession::EOomPriorityBusy ) + { + // Prevent OOM to close this app while it is freeing memory + iOomSession.SetOomPriority(ROomMonitorSession::EOomPriorityBusy); + } + iOomSession.RequestFreeMemory( size ); + if ( iPriority != ROomMonitorSession::EOomPriorityBusy ) + { + // Allow OOM to close this app again + iOomSession.SetOomPriority(iPriority); + } + iMem = User::AllocL(size); + iAppView->DrawDeferred(); + } + break; + } + case EOomTestAppSetPriorityNormal: + { + iPriority = ROomMonitorSession::EOomPriorityNormal; + iOomSession.SetOomPriority(iPriority); + iAppView->DrawDeferred(); + break; + } + case EOomTestAppSetPriorityHigh: + { + iPriority = ROomMonitorSession::EOomPriorityHigh; + iOomSession.SetOomPriority(iPriority); + iAppView->DrawDeferred(); + break; + } + case EOomTestAppSetPriorityBusy: + { + iPriority = ROomMonitorSession::EOomPriorityBusy; + iOomSession.SetOomPriority(iPriority); + iAppView->DrawDeferred(); + break; + } + case EEikCmdExit: + case EAknSoftkeyExit: // Fall through + { + Exit(); + break; + } + default: + { + break; + } + } + } + +// ----------------------------------------------------------------------------- +// Called by the framework when the application status pane +// size is changed. Passes the new client rectangle to the +// AppView +// ----------------------------------------------------------------------------- +// +void Ct_oomtestappAppUi::HandleStatusPaneSizeChange() + { + iAppView->SetRect(ClientRect()); + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappAppUi::AllocatedHeap +// ----------------------------------------------------------------------------- +// +TInt Ct_oomtestappAppUi::AllocatedHeap() const + { + TInt ret( 0 ); + RHeap& heap( User::Heap() ); + heap.AllocSize( ret ); + return ret; + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappAppUi::Priority +// ----------------------------------------------------------------------------- +// +TPtrC Ct_oomtestappAppUi::Priority() const + { + switch ( iPriority ) + { + case ROomMonitorSession::EOomPriorityNormal: + { + return KOomPriorityNormal(); + } + case ROomMonitorSession::EOomPriorityHigh: + { + return KOomPriorityHigh(); + } + case ROomMonitorSession::EOomPriorityBusy: + { + return KOomPriorityBusy(); + } + default: + { + break; + } + } + return KNullDesC(); + } + + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappappview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappappview.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +// INCLUDE FILES +#include +#include +#include +#include "t_oomtestappAppUi.h" +#include "t_oomtestappAppView.h" + +_LIT( KTextSystemOn, "System on" ); +_LIT( KTextSystemOff, "System off" ); +const TInt KTextBufferSize = 100; + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// Ct_oomtestappAppView::NewL() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +Ct_oomtestappAppView* Ct_oomtestappAppView::NewL(const TRect& aRect, Ct_oomtestappAppUi& aAppUi) + { + Ct_oomtestappAppView* self = new ( ELeave ) Ct_oomtestappAppView( aAppUi ); + CleanupStack::PushL(self); + self->ConstructL( aRect ); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappAppView::ConstructL() +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void Ct_oomtestappAppView::ConstructL(const TRect& aRect) + { + // Create a window for this application view + CreateWindowL(); + + // Set the windows size + SetRect(aRect); + + iFont = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont ); + + // Activate the window, which makes it ready to be drawn + ActivateL(); + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappAppView::Ct_oomtestappAppView() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +Ct_oomtestappAppView::Ct_oomtestappAppView( Ct_oomtestappAppUi& aAppUi ) : + iAppUi( aAppUi ) + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappAppView::~Ct_oomtestappAppView() +// Destructor. +// ----------------------------------------------------------------------------- +// +Ct_oomtestappAppView::~Ct_oomtestappAppView() + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappAppView::Draw() +// Draws the display. +// ----------------------------------------------------------------------------- +// +void Ct_oomtestappAppView::Draw(const TRect& /*aRect*/) const + { + // Get the standard graphics context + CWindowGc& gc = SystemGc(); + + // Gets the control's extent + TRect drawRect(Rect()); + + // Clears the screen + gc.Clear(drawRect); + + gc.UseFont(iFont); + + TBuf buffer; + TInt allocSize( iAppUi.AllocatedHeap() / KKiloByte ); + TPtrC priority( iAppUi.Priority() ); + if ( CEikonEnv::Static()->IsSystem() ) + { + buffer.Format( _L("%S : Heap %d KB : Priority %S"), + &(KTextSystemOn()), allocSize, &priority ); + } + else + { + buffer.Format( _L("%S : Heap %d KB : Priority %S"), + &(KTextSystemOff()), allocSize, &priority ); + } + TPoint textPos( 0, drawRect.Height() / 2 ); + gc.DrawText( buffer, textPos ); + gc.DiscardFont(); + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappAppView::SizeChanged() +// Called by framework when the view size is changed. +// ----------------------------------------------------------------------------- +// +void Ct_oomtestappAppView::SizeChanged() + { + DrawDeferred(); + } + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappdocument.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappdocument.cpp Fri Feb 19 22:58:54 2010 +0200 @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + + + +// INCLUDE FILES +#include "t_oomtestappAppUi.h" +#include "t_oomtestappDocument.h" + +// ============================ MEMBER FUNCTIONS =============================== + +// ----------------------------------------------------------------------------- +// Ct_oomtestappDocument::NewL() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +Ct_oomtestappDocument* Ct_oomtestappDocument::NewL(CEikApplication& aApp) + { + Ct_oomtestappDocument* self = NewLC(aApp); + CleanupStack::Pop(self); + return self; + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappDocument::NewLC() +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +Ct_oomtestappDocument* Ct_oomtestappDocument::NewLC(CEikApplication& aApp) + { + Ct_oomtestappDocument* self = new (ELeave) Ct_oomtestappDocument(aApp); + + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappDocument::ConstructL() +// Symbian 2nd phase constructor can leave. +// ----------------------------------------------------------------------------- +// +void Ct_oomtestappDocument::ConstructL() + { + // No implementation required + } + +// ----------------------------------------------------------------------------- +// Ct_oomtestappDocument::Ct_oomtestappDocument() +// C++ default constructor can NOT contain any code, that might leave. +// ----------------------------------------------------------------------------- +// +Ct_oomtestappDocument::Ct_oomtestappDocument(CEikApplication& aApp) : + CAknDocument(aApp) + { + // No implementation required + } + +// --------------------------------------------------------------------------- +// Ct_oomtestappDocument::~Ct_oomtestappDocument() +// Destructor. +// --------------------------------------------------------------------------- +// +Ct_oomtestappDocument::~Ct_oomtestappDocument() + { + // No implementation required + } + +// --------------------------------------------------------------------------- +// Ct_oomtestappDocument::CreateAppUiL() +// Constructs CreateAppUi. +// --------------------------------------------------------------------------- +// +CEikAppUi* Ct_oomtestappDocument::CreateAppUiL() + { + // Create the application user interface, and return a pointer to it; + // the framework takes ownership of this object + return new (ELeave) Ct_oomtestappAppUi; + } + +// End of File diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/public/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/adv/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/public/adv/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/adv/conf/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/public/adv/conf/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/adv/data/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/public/adv/data/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/adv/group/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/public/adv/group/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/adv/init/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/public/adv/init/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/BWINS/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/public/basic/BWINS/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/BWINS/MT_OomMonitorU.DEF --- a/sysresmonitoring/oommonitor/tsrc/public/basic/BWINS/MT_OomMonitorU.DEF Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -EXPORTS - ?CreateTestSuiteL@@YAPAVMEUnitTest@@XZ @ 1 NONAME ; class MEUnitTest * __cdecl CreateTestSuiteL(void) diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/public/basic/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/EABI/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/public/basic/EABI/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/EABI/MT_OomMonitorU.DEF --- a/sysresmonitoring/oommonitor/tsrc/public/basic/EABI/MT_OomMonitorU.DEF Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - _Z16CreateTestSuiteLv @ 1 NONAME - diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_COomMonitorPlugin.cpp --- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_COomMonitorPlugin.cpp Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,180 +0,0 @@ -/* -* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// CLASS HEADER -#include "MT_COomMonitorPlugin.h" - -// EXTERNAL INCLUDES -#include -#include -#include -#include - - - -MT_COomMonitorPlugin* MT_COomMonitorPlugin::NewL() - { - MT_COomMonitorPlugin* self = MT_COomMonitorPlugin::NewLC(); - CleanupStack::Pop(); - - return self; - } - -MT_COomMonitorPlugin* MT_COomMonitorPlugin::NewLC() - { - MT_COomMonitorPlugin* self = new( ELeave ) MT_COomMonitorPlugin(); - CleanupStack::PushL( self ); - - self->ConstructL(); - - return self; - } - -// Destructor (virtual by CBase) -MT_COomMonitorPlugin::~MT_COomMonitorPlugin() - { - } - -// Default constructor -MT_COomMonitorPlugin::MT_COomMonitorPlugin() - { - } - -// Second phase construct -void MT_COomMonitorPlugin::ConstructL() - { - // The ConstructL from the base class CEUnitTestSuiteClass must be called. - // It generates the test case table. - CEUnitTestSuiteClass::ConstructL(); - } - -// METHODS - -void MT_COomMonitorPlugin::BasicSetupL( ) - { - iMonitor = CMemoryMonitor::NewL(); - } - - -void MT_COomMonitorPlugin::BasicTeardown( ) - { - delete iMonitor; - iMonitor = NULL; - } - -void MT_COomMonitorPlugin::SetupL( ) - { - BasicSetupL(); - - const TUid KMyAppUid = { 0x01234567}; - iCOomMonitorPlugin = CAppOomMonitorPlugin::NewL( KMyAppUid ); - } - - -void MT_COomMonitorPlugin::Teardown( ) - { - BasicTeardown(); - - delete iCOomMonitorPlugin; - iCOomMonitorPlugin = NULL; - } - - -void MT_COomMonitorPlugin::T_CAppOomMonitorPlugin_NewLL( ) - { - const TUid KMyAppUid = { 0x01234567}; - CAppOomMonitorPlugin* plugin = CAppOomMonitorPlugin::NewL( KMyAppUid ); - CleanupStack::PushL( plugin ); - - EUNIT_ASSERT_DESC( plugin, "CAppOomMonitorPlugin instance not created!" ); - CleanupStack::PopAndDestroy( plugin ); - } - -void MT_COomMonitorPlugin::T_COomMonitorPlugin_FreeRamL( ) - { - // private function in CAppOomMonitorPlugin, couldn't be tested - //iCOomMonitorPlugin->FreeRam( ); - } - -void MT_COomMonitorPlugin::T_COomMonitorPlugin_MemoryGoodL( ) - { - // private function in CAppOomMonitorPlugin, couldn't be tested - //iCOomMonitorPlugin->MemoryGood( ); - } - -void MT_COomMonitorPlugin::T_COomMonitorPlugin_FsSessionL( ) - { - iCOomMonitorPlugin->FsSession( ); - } - -void MT_COomMonitorPlugin::T_COomMonitorPlugin_WsSessionL( ) - { - iCOomMonitorPlugin->WsSession( ); - } - -void MT_COomMonitorPlugin::T_COomMonitorPlugin_ExtensionInterfaceL( ) - { - CTestOomMonitorPlugin* plugin = new(ELeave) CTestOomMonitorPlugin; - CleanupStack::PushL(plugin); - plugin->ConstructL(); - - const TUid KTestUid = { 0x01234567 }; // a nonsense UID for testing - TAny* any = NULL; - plugin->ExtensionInterface( KTestUid, any ); - - CleanupStack::PopAndDestroy(plugin); - } - - -// TEST TABLE -EUNIT_BEGIN_TEST_TABLE( - MT_COomMonitorPlugin, - "COomMonitorPlugin test suite", - "MODULE" ) - -EUNIT_TEST( - "NewL - test", - "COomMonitorPlugin", - "CAppOomMonitorPlugin NewL and COomMonitorPlugin Constructor, Destructor", - "FUNCTIONALITY", - BasicSetupL, T_CAppOomMonitorPlugin_NewLL, BasicTeardown) - -EUNIT_TEST( - "FsSession - test", - "COomMonitorPlugin", - "FsSession", - "FUNCTIONALITY", - SetupL, T_COomMonitorPlugin_FsSessionL, Teardown) - -EUNIT_TEST( - "WsSession - test", - "COomMonitorPlugin", - "WsSession", - "FUNCTIONALITY", - SetupL, T_COomMonitorPlugin_WsSessionL, Teardown) - -EUNIT_TEST( - "ExtensionInterface - test", - "COomMonitorPlugin", - "ExtensionInterface", - "FUNCTIONALITY", - SetupL, T_COomMonitorPlugin_ExtensionInterfaceL, Teardown) - -EUNIT_END_TEST_TABLE - -// END OF FILE diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_COomMonitorPlugin.h --- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_COomMonitorPlugin.h Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,122 +0,0 @@ -/* -* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __MT_COOMMONITORPLUGIN_H__ -#define __MT_COOMMONITORPLUGIN_H__ - -// EXTERNAL INCLUDES -#include -#include -#include - -// INTERNAL INCLUDES - - -// FORWARD DECLARATIONS - - -// CLASS DEFINITION -NONSHARABLE_CLASS( MT_COomMonitorPlugin ) - : public CEUnitTestSuiteClass - { - public: // Constructors and destructors - - /** - * Two phase construction - */ - static MT_COomMonitorPlugin* NewL(); - static MT_COomMonitorPlugin* NewLC(); - /** - * Destructor - */ - ~MT_COomMonitorPlugin(); - - private: // Constructors and destructors - - MT_COomMonitorPlugin(); - void ConstructL(); - - private: // New methods - - - void SetupL(); - - void Teardown(); - - void BasicSetupL(); - - void BasicTeardown(); - - void T_CAppOomMonitorPlugin_NewLL(); - - void T_COomMonitorPlugin_FreeRamL(); - - void T_COomMonitorPlugin_MemoryGoodL(); - - void T_COomMonitorPlugin_FsSessionL(); - - void T_COomMonitorPlugin_WsSessionL(); - - void T_COomMonitorPlugin_ExtensionInterfaceL(); - - - private: // Data - - CAppOomMonitorPlugin* iCOomMonitorPlugin; - CMemoryMonitor* iMonitor; - - EUNIT_DECLARE_TEST_TABLE; - - }; - - -NONSHARABLE_CLASS( CTestOomMonitorPlugin ) : public COomMonitorPlugin - { -public: - CTestOomMonitorPlugin() - { - } - - ~CTestOomMonitorPlugin() - { - } - - void ConstructL() - { - COomMonitorPlugin::ConstructL(); - } - -public: - void FreeRam() - { - } - - void MemoryGood() - { - } - - void ExtensionInterface(TUid aInterfaceId, TAny*& aImplementaion) - { - COomMonitorPlugin::ExtensionInterface(aInterfaceId, aImplementaion); - } - }; - - -#endif // __MT_COOMMONITORPLUGIN_H__ - -// End of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor.cpp --- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor.cpp Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/* -* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// CLASS HEADER -#include "MT_OomMonitor.h" - -// EXTERNAL INCLUDES -#include -#include -#include - -// INTERNAL INCLUDES - - -// CONSTRUCTION -MT_OomMonitor* MT_OomMonitor::NewL() - { - MT_OomMonitor* self = MT_OomMonitor::NewLC(); - CleanupStack::Pop(); - - return self; - } - -MT_OomMonitor* MT_OomMonitor::NewLC() - { - MT_OomMonitor* self = new( ELeave ) MT_OomMonitor(); - CleanupStack::PushL( self ); - - self->ConstructL(); - - return self; - } - -// Destructor (virtual by CBase) -MT_OomMonitor::~MT_OomMonitor() - { - } - -// Default constructor -MT_OomMonitor::MT_OomMonitor() - { - } - -// Second phase construct -void MT_OomMonitor::ConstructL() - { - // The ConstructL from the base class CEUnitTestSuiteClass must be called. - // It generates the test case table. - CEUnitTestSuiteClass::ConstructL(); - } - -// METHODS - -void MT_OomMonitor::EmptySetupL( ) - { - } - -void MT_OomMonitor::EmptyTeardown( ) - { - } - -void MT_OomMonitor::SetupL( ) - { - iROomMonitorSession.Connect(); - } - - -void MT_OomMonitor::Teardown( ) - { - iROomMonitorSession.Close(); - } - - -void MT_OomMonitor::T_ROomMonitorSession_ConnectL( ) - { - EUNIT_ASSERT_DESC( iROomMonitorSession.Connect( ) == KErrNone, "Session should have been connected"); - iROomMonitorSession.Close(); - } - -void MT_OomMonitor::T_ROomMonitorSession_RequestFreeMemoryL( ) - { - TInt rtn = iROomMonitorSession.RequestFreeMemory( 1024 ); - EUNIT_ASSERT_DESC( rtn == KErrNone || rtn == KErrNoMemory, "OOM monitor should free 1024 bytes"); - } - -void MT_OomMonitor::T_ROomMonitorSession_RequestFreeMemory2L( ) - { - TRequestStatus status; - iROomMonitorSession.RequestFreeMemory( 1024, status ); - User::WaitForRequest( status ); - EUNIT_ASSERT_DESC( status == KErrNone || status == KErrNoMemory, "OOM monitor should free 1024 bytes"); - } - -void MT_OomMonitor::T_ROomMonitorSession_CancelRequestFreeMemoryL( ) - { - TRequestStatus status; - iROomMonitorSession.RequestFreeMemory( 1024, status ); - iROomMonitorSession.CancelRequestFreeMemory( ); - User::WaitForRequest( status ); - } - -void MT_OomMonitor::T_ROomMonitorSession_ThisAppIsNotExitingL( ) - { - iROomMonitorSession.ThisAppIsNotExiting( 1 ); - } - - -// TEST TABLE -EUNIT_BEGIN_TEST_TABLE( - MT_OomMonitor, - "ROomMonitorSession test suite", - "MODULE" ) - -EUNIT_TEST( - "Connect - test", - "ROomMonitorSession", - "Connect", - "FUNCTIONALITY", - EmptySetupL, T_ROomMonitorSession_ConnectL, EmptyTeardown) - -EUNIT_TEST( - "RequestFreeMemory -synchronous test", - "ROomMonitorSession", - "RequestFreeMemory - synchronous version", - "FUNCTIONALITY", - SetupL, T_ROomMonitorSession_RequestFreeMemoryL, Teardown) - -EUNIT_TEST( - "RequestFreeMemory - asynchronous test", - "ROomMonitorSession", - "RequestFreeMemory - asynchronous version", - "FUNCTIONALITY", - SetupL, T_ROomMonitorSession_RequestFreeMemory2L, Teardown) - -EUNIT_TEST( - "CancelRequestFreeMemory - test", - "ROomMonitorSession", - "CancelRequestFreeMemory", - "FUNCTIONALITY", - SetupL, T_ROomMonitorSession_CancelRequestFreeMemoryL, Teardown) - -EUNIT_TEST( - "ThisAppIsNotExiting -test", - "ROomMonitorSession", - "ThisAppIsNotExiting", - "FUNCTIONALITY", - SetupL, T_ROomMonitorSession_ThisAppIsNotExitingL, Teardown) - - -EUNIT_END_TEST_TABLE - -// END OF FILE diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor.h --- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor.h Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* -* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef __MT_OOMMONITOR_H__ -#define __MT_OOMMONITOR_H__ - -// EXTERNAL INCLUDES -#include -#include -#include - -// INTERNAL INCLUDES - - -// FORWARD DECLARATIONS - - -// CLASS DEFINITION -/** - * Auto-generated EUnit test suite - * - */ -NONSHARABLE_CLASS( MT_OomMonitor ) - : public CEUnitTestSuiteClass - { - public: // Constructors and destructors - - /** - * Two phase construction - */ - static MT_OomMonitor* NewL(); - static MT_OomMonitor* NewLC(); - /** - * Destructor - */ - ~MT_OomMonitor(); - - private: // Constructors and destructors - - MT_OomMonitor(); - void ConstructL(); - - private: // New methods - - void EmptySetupL(); - - void EmptyTeardown(); - - void SetupL(); - - void Teardown(); - - void T_ROomMonitorSession_ConnectL(); - - void T_ROomMonitorSession_RequestFreeMemoryL(); - - void T_ROomMonitorSession_RequestFreeMemory2L(); - - void T_ROomMonitorSession_CancelRequestFreeMemoryL(); - - void T_ROomMonitorSession_ThisAppIsNotExitingL(); - - - private: // Data - - ROomMonitorSession iROomMonitorSession; - EUNIT_DECLARE_TEST_TABLE; - - }; - -#endif // __MT_OOMMONITOR_H__ - -// End of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor_DllMain.cpp --- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor_DllMain.cpp Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* -* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -// CLASS HEADER -#include "MT_OomMonitor.h" -#include "MT_COomMonitorPlugin.h" - -// EXTERNAL INCLUDES -#include - -EXPORT_C MEUnitTest* CreateTestSuiteL() - { - CEUnitTestSuite* rootSuite = CEUnitTestSuite::NewLC( _L("OomMonitor API tests") ); - - rootSuite->AddL( MT_OomMonitor::NewLC() ); - CleanupStack::Pop(); - - rootSuite->AddL( MT_COomMonitorPlugin::NewLC() ); - CleanupStack::Pop(); - - CleanupStack::Pop( rootSuite ); - return rootSuite; - } -/* -#ifndef EKA2 -GLDEF_C TInt E32Dll( TDllReason ) - { - return KErrNone; - } -#endif -*/ -// END OF FILE diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/stub_MemoryMonitor.cpp --- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/stub_MemoryMonitor.cpp Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include - -CMemoryMonitor* CMemoryMonitor::NewL() - { - CMemoryMonitor* self = new(ELeave) CMemoryMonitor(); - CleanupStack::PushL(self); - self->ConstructL(); - CleanupStack::Pop(self); - return self; - } - -CMemoryMonitor::CMemoryMonitor():iCurrentTask(iWs) - { - SetMemoryMonitorTls(this); - } - -void CMemoryMonitor::ConstructL() - { - - } - -CMemoryMonitor::~CMemoryMonitor() - { - } diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/conf/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/public/basic/conf/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/data/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/public/basic/data/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/group/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/public/basic/group/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/group/MT_OomMonitor.mmp --- a/sysresmonitoring/oommonitor/tsrc/public/basic/group/MT_OomMonitor.mmp Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* -* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include - -TARGET MT_OomMonitor.dll -TARGETTYPE dll -UID 0x1000af5a 0x01700000 - -CAPABILITY ALL -TCB -DRM -VENDORID VID_DEFAULT - -SOURCEPATH ../MT_OomMonitor -SOURCE MT_OomMonitor.cpp -SOURCE MT_COomMonitorPlugin.cpp -SOURCE stub_MemoryMonitor.cpp - -// Sources required by the test suite -SOURCEPATH ../MT_OomMonitor -SOURCE MT_OomMonitor_DllMain.cpp - -USERINCLUDE ../MT_OomMonitor - -MW_LAYER_SYSTEMINCLUDE - -SYSTEMINCLUDE /epoc32/include/Digia/EUnit - -// System include folders required by the tested code - - -LIBRARY EUnit.lib -LIBRARY EUnitUtil.lib -LIBRARY euser.lib -LIBRARY oommonitor.lib -LIBRARY ws32.lib -LIBRARY apgrfx.lib // TApaTask - -// End of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/group/bld.inf --- a/sysresmonitoring/oommonitor/tsrc/public/basic/group/bld.inf Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/* -* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -PRJ_PLATFORMS - ARMV5 GCCE WINSCW - -PRJ_EXPORTS - -PRJ_MMPFILES - - -PRJ_TESTMMPFILES -MT_OomMonitor.mmp - - -// End of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/init/Distribution.Policy.S60 --- a/sysresmonitoring/oommonitor/tsrc/public/basic/init/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 sysresmonitoring/oommonitor/tsrc/public/basic/test.xml --- a/sysresmonitoring/oommonitor/tsrc/public/basic/test.xml Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ - - - oommonitor Automated Tests - - - - - - - - - - - - - - - - - - - makedir - - - - - - - - - install - - - - - - - - - - - execute - - - - - - - - makedir - - - - - - - - execute - - - - - - - - - - - execute - - - - - - - - - fetch-log - - - - - - - - - - - ATS3Drop/images/sydo_oommonitor_ats3_image.fpsx - ATS3Drop/images/sydo_oommonitor_ats3_image_udaerase.fpsx - - ATS3Drop/armv5_urel/MT_OomMonitor.dll - - - - SendEmailAction - - - - - - - - - - FileStoreAction - - - - - diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/Distribution.Policy.S60 --- a/systemsettings/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/GSAccessoryPlugin/Distribution.Policy.S60 --- a/systemsettings/GSAccessoryPlugin/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/GSAccessoryPlugin/cenrep/Distribution.Policy.S60 --- a/systemsettings/GSAccessoryPlugin/cenrep/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/GSAccessoryPlugin/conf/distribution.policy.s60 --- a/systemsettings/GSAccessoryPlugin/conf/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/GSAccessoryPlugin/data/Distribution.Policy.S60 --- a/systemsettings/GSAccessoryPlugin/data/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/GSAccessoryPlugin/group/distribution.policy.s60 --- a/systemsettings/GSAccessoryPlugin/group/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/GSAccessoryPlugin/inc/Distribution.Policy.S60 --- a/systemsettings/GSAccessoryPlugin/inc/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/GSAccessoryPlugin/loc/Distribution.Policy.S60 --- a/systemsettings/GSAccessoryPlugin/loc/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/GSAccessoryPlugin/rom/distribution.policy.s60 --- a/systemsettings/GSAccessoryPlugin/rom/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/GSAccessoryPlugin/src/Distribution.Policy.S60 --- a/systemsettings/GSAccessoryPlugin/src/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/group/Distribution.Policy.S60 --- a/systemsettings/group/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/gssensorplugin/Distribution.Policy.S60 --- a/systemsettings/gssensorplugin/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/gssensorplugin/cenrep/Distribution.Policy.S60 --- a/systemsettings/gssensorplugin/cenrep/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/gssensorplugin/conf/Distribution.Policy.S60 --- a/systemsettings/gssensorplugin/conf/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/gssensorplugin/data/Distribution.Policy.S60 --- a/systemsettings/gssensorplugin/data/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/gssensorplugin/group/Distribution.Policy.S60 --- a/systemsettings/gssensorplugin/group/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/gssensorplugin/inc/Distribution.Policy.S60 --- a/systemsettings/gssensorplugin/inc/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/gssensorplugin/loc/Distribution.Policy.S60 --- a/systemsettings/gssensorplugin/loc/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/gssensorplugin/rom/Distribution.Policy.S60 --- a/systemsettings/gssensorplugin/rom/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/gssensorplugin/src/Distribution.Policy.S60 --- a/systemsettings/gssensorplugin/src/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 systemsettings/inc/Distribution.Policy.S60 --- a/systemsettings/inc/Distribution.Policy.S60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/Include/distribution.policy.s60 --- a/tzpcside/tzcompiler/Include/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/Release/Data/distribution.policy.s60 --- a/tzpcside/tzcompiler/Release/Data/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/Release/distribution.policy.s60 --- a/tzpcside/tzcompiler/Release/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/Source/distribution.policy.s60 --- a/tzpcside/tzcompiler/Source/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/documentation/SGL.GT0197.232 App-Services Tz 9.1 How-To Create the Tz Database.doc Binary file tzpcside/tzcompiler/documentation/SGL.GT0197.232 App-Services Tz 9.1 How-To Create the Tz Database.doc has changed diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/documentation/distribution.policy.s60 --- a/tzpcside/tzcompiler/documentation/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/group/distribution.policy.s60 --- a/tzpcside/tzcompiler/group/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/documentation/TestTzCompiler Description Document.doc Binary file tzpcside/tzcompiler/test/integration/TzCompilerTests/documentation/TestTzCompiler Description Document.doc has changed diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/documentation/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/documentation/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/group/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/group/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/inc/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/inc/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/src/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/src/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test1/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test1/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test10/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test10/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test11/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test11/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test12/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test12/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test13/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test13/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test2/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test2/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test3/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test3/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test4/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test4/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test5/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test5/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test6/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test6/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test7/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test7/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test8/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test8/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test9/distribution.policy.s60 --- a/tzpcside/tzcompiler/test/integration/TzCompilerTests/testdata/Test9/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzservices/tzdatabase/data/distribution.policy.s60 --- a/tzservices/tzdatabase/data/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzservices/tzdatabase/group/distribution.policy.s60 --- a/tzservices/tzdatabase/group/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzservices/tzloc/bwins/distribution.policy.s60 --- a/tzservices/tzloc/bwins/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzservices/tzloc/documentation/SGL.GT0284.216 - Time Zone Services CR1606 How-To.doc Binary file tzservices/tzloc/documentation/SGL.GT0284.216 - Time Zone Services CR1606 How-To.doc has changed diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzservices/tzloc/documentation/distribution.policy.s60 --- a/tzservices/tzloc/documentation/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzservices/tzloc/eabi/distribution.policy.s60 --- a/tzservices/tzloc/eabi/distribution.policy.s60 Tue Feb 02 10:12:00 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -7 \ No newline at end of file diff -r 2e3d3ce01487 -r 0fdb7f6b0309 tzservices/tzloc/group/backup_registration.xml --- a/tzservices/tzloc/group/backup_registration.xml Tue Feb 02 10:12:00 2010 +0200 +++ b/tzservices/tzloc/group/backup_registration.xml Fri Feb 19 22:58:54 2010 +0200 @@ -1,10 +1,10 @@