--- a/appfw/apparchitecture/apgrfx/APGWGNAM.CPP Fri May 14 16:01:13 2010 +0300
+++ b/appfw/apparchitecture/apgrfx/APGWGNAM.CPP Thu May 27 13:01:09 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1997-2010 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"
@@ -9,6 +9,7 @@
// Nokia Corporation - initial contribution.
//
// Contributors:
+// NTT DOCOMO, INC. -- Fix CApaWindowGroupName::AppUid() cannot handle UID with 0 prefix
//
// Description:
//
@@ -513,7 +514,7 @@
{
start++;
TInt end=FindDelimiter(EEndUid);
- if ((end-start) == KUidBufLength)
+ if (0<end && (end-start)<=KUidBufLength)
{
TBuf<KUidBufLength> uidBuf=iBuf->Mid(start, end-start);
TLex lex(uidBuf);
--- a/appfw/apparchitecture/aplist/aplappregfinder.cpp Fri May 14 16:01:13 2010 +0300
+++ b/appfw/apparchitecture/aplist/aplappregfinder.cpp Thu May 27 13:01:09 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2004-2010 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"
@@ -187,8 +187,13 @@
const TDriveName driveName = currentDrive.iUnit.Name();
regFileNameParser.Set(entry.iName, &appFolderOnDrive, &driveName);
- // If the appliation is located on a removable drive...
- if (currentDrive.iAttribs&KDriveAttRemovable)
+ // Apparc will call sidchecker to verify if an application is a valid registered application.
+ // Apparc will call sidchecker in the following conditions
+ // 1. If the current drive is a removable drive
+ // 2. If the current drive is not
+ // a) an internal read-only drive
+ // b) the system drive
+ if(currentDrive.iAttribs&KDriveAttRemovable || ((currentDrive.iUnit != iFs.GetSystemDrive()) && (currentDrive.iAttribs&KDriveAttInternal) && !(currentDrive.iAttribs&KDriveAttRom)))
{
// ...then verify that there is a valid Secure ID (SID) for the appliation
// to protect against untrusted applications.
--- a/appfw/apparchitecture/group/apparc.iby Fri May 14 16:01:13 2010 +0300
+++ b/appfw/apparchitecture/group/apparc.iby Thu May 27 13:01:09 2010 +0300
@@ -17,6 +17,37 @@
#ifndef __APPARC_IBY__
#define __APPARC_IBY__
+#ifdef __TEXTSHELL_OBY__
+
+#include <openenv.iby>
+#include <scr.iby>
+#include <sts.iby>
+file=ABI_DIR\BUILD_DIR\sisregistryclient.dll sys\bin\sisregistryclient.dll
+file=ABI_DIR\BUILD_DIR\sisregistryserver.exe sys\bin\sisregistryserver.exe
+file=ABI_DIR\BUILD_DIR\plan.dll sys\bin\plan.dll
+file=ABI_DIR\BUILD_DIR\siscontroller.dll sys\bin\siscontroller.dll
+file=ABI_DIR\BUILD_DIR\apprscparser.dll sys\bin\apprscparser.dll
+file=ABI_DIR\BUILD_DIR\swtypereginfo.dll sys\bin\swtypereginfo.dll
+file=ABI_DIR\BUILD_DIR\swidataprovider.dll sys\bin\swidataprovider.dll
+file=ABI_DIR\BUILD_DIR\securitymanager.dll sys\bin\securitymanager.dll
+file=ABI_DIR\BUILD_DIR\sislauncherclient.dll sys\bin\sislauncherclient.dll
+file=ABI_DIR\BUILD_DIR\sislauncherserver.exe sys\bin\sislauncherserver.exe
+file=ABI_DIR\BUILD_DIR\swiobserverclient.dll sys\bin\swiobserverclient.dll
+file=ABI_DIR\BUILD_DIR\uissclient.dll sys\bin\uissclient.dll
+#include <asnpkcs.iby>
+#include <filetokens.iby>
+#include <certman.iby>
+#include <ocsp.iby>
+file=ABI_DIR\BUILD_DIR\devinfosupportclient.dll sys\bin\devinfosupportclient.dll
+file=ABI_DIR\BUILD_DIR\devinfosupportcommon.dll sys\bin\devinfosupportcommon.dll
+file=ABI_DIR\BUILD_DIR\ocspsupportclient.dll sys\bin\ocspsupportclient.dll
+file=ABI_DIR\BUILD_DIR\ocspsupport.exe sys\bin\ocspsupport.exe
+file=ABI_DIR\BUILD_DIR\swiobserver.exe sys\bin\swiobserver.exe
+file=ABI_DIR\BUILD_DIR\Http.dll System\Libs\Http.dll
+file=ABI_DIR\BUILD_DIR\httputils.dll System\Libs\httputils.dll
+
+#endif
+
REM Application Architecture
file=ABI_DIR\BUILD_DIR\apparc.dll System\Libs\apparc.dll
--- a/appfw/apparchitecture/inc/apaapp.h Fri May 14 16:01:13 2010 +0300
+++ b/appfw/apparchitecture/inc/apaapp.h Thu May 27 13:01:09 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1997-2010 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"
@@ -19,11 +19,6 @@
#ifndef __APAAPP_H__
#define __APAAPP_H__
-#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
-#if !defined(__APAID_PARTNER_H__)
-#include "apaidpartner.h"
-#endif
-#endif //SYMBIAN_ENABLE_SPLIT_HEADERS
#include <e32std.h>
#include <e32base.h>
#include <apadef.h>
--- a/appfw/apparchitecture/tef/T_WgnamStep.CPP Fri May 14 16:01:13 2010 +0300
+++ b/appfw/apparchitecture/tef/T_WgnamStep.CPP Thu May 27 13:01:09 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2005-2010 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"
@@ -201,6 +201,16 @@
TEST(apaWindowGroupName->AppUid()==uid);
INFO_PRINTF1(_L("\n"));
// User::After(2000000);
+
+ // RDebug::Print(_L("Block 5a"));
+ INFO_PRINTF1(_L("Test setting appUid starting with 0"));
+ const TUid uid1={ 0x00000111 };
+ PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
+ INFO_PRINTF2(_L("Setting app uid to %x\n"), uid1.iUid);
+ apaWindowGroupName->SetAppUid(uid1);
+ PrintWindowGroupName(apaWindowGroupName->WindowGroupName());
+ TEST(apaWindowGroupName->AppUid()==uid1);
+ INFO_PRINTF1(_L("\n"));
// test setting caption
// RDebug::Print(_L("Block 6"));
--- a/applaunchservices/applaunchplugins/test/tapstart/group/apstarttest_apstart.iby Fri May 14 16:01:13 2010 +0300
+++ b/applaunchservices/applaunchplugins/test/tapstart/group/apstarttest_apstart.iby Thu May 27 13:01:09 2010 +0300
@@ -21,9 +21,9 @@
data=ABI_DIR\BUILD_DIR\tapstart_server.exe sys\bin\tapstart_server.exe
-data=DATAZ_\apstarttest\apstarttest_apstart_run.bat \apstarttest_apstart_run.bat
+//data=DATAZ_\apstarttest\apstarttest_apstart_run.bat \apstarttest_apstart_run.bat
-data=DATAZ_\apstarttest\apstarttest_apstart.script \apstarttest\apstarttest_apstart.script
+//data=DATAZ_\apstarttest\apstarttest_apstart.script \apstarttest\apstarttest_apstart.script
#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/applaunchservices/applaunchplugins/test/tapstart/group/apstarttest_apstart.pkg Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,29 @@
+;
+; 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:
+;
+
+;Languages
+&EN
+
+
+;Localised Vendor name
+%{"apstarttest_apstart.pkg EN"}
+
+; Vendor name
+: "apstarttest_apstart"
+
+
+"\epoc32\data\z\apstarttest\apstarttest_apstart_run.bat"-"c:\apstarttest_apstart_run.bat"
+"\epoc32\data\z\apstarttest\apstarttest_apstart.script"-"c:\apstarttest\apstarttest_apstart.script"
--- a/appsupport_plat/oom_monitor_api/inc/oommonitor.h Fri May 14 16:01:13 2010 +0300
+++ b/appsupport_plat/oom_monitor_api/inc/oommonitor.h Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 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"
@@ -16,11 +16,10 @@
*/
-#include <e32hashtab.h>
-#include <f32file.h>
+#ifndef OOMMONITOR_H
+#define OOMMONITOR_H
+
#include <w32std.h>
-#include <apgtask.h>
-#include <e32property.h>
/**
* Creates thread for OOM watchers.
@@ -28,248 +27,4 @@
*/
IMPORT_C void CreateOOMWatcherThreadL();
-// ---------------------------------------------------------
-// CMemoryMonitor
-// ---------------------------------------------------------
-//
-class COutOfMemoryWatcher;
-class CSubscribeHelper;
-class COomMonitorPlugin;
-class COomPlugins;
-class CAppCloseTimer;
-class CAppCloseWatcher;
-class CMemoryMonitorServer;
-class CWservEventReceiver;
-class RResourceFile;
-class CApaWindowGroupName;
-
-NONSHARABLE_CLASS(CMemoryMonitor) : public CBase
- {
-public:
- static CMemoryMonitor* NewL();
- ~CMemoryMonitor();
-
-public: // event handlers
- void FreeMemThresholdCrossedL();
- void CloseAppEvent();
- void AppNotExiting(TInt aWgId);
- void StartFreeSomeRamL(TInt aTargetFree);
- void HandleFocusedWgChangeL();
-
-private:
- CMemoryMonitor();
- void ConstructL();
- void CloseAppsFinished(TBool aMemoryGood);
- static TInt WatchdogStatusStatusChanged(TAny* aPtr);
- void HandleWatchdogStatusCallBackL();
- void ColapseWindowGroupTree();
- void SetPluginMemoryGood(TBool aSetToGood);
- void GetWgsToCloseL();
- TBool FreeMemoryAboveThreshold();
- void CancelAppCloseWatchers();
- TInt AppCloseOrder(TInt aWgIndex, TInt aWgId);
- void CloseNextApp();
- void ReadAppResourceArrayL(RResourceFile& aResFile, TInt aResId, TInt aOrderBase, TInt aOrderInc);
- void RestartAppCloser();
-
-public:
- // All members are owned
- // generally useful sessions
- RFs iFs;
- RWsSession iWs;
-
-private:
- // All members are owned, except where stated
- // parameters for OOM watcher.
- TInt iLowThreshold;
- TInt iGoodThreshold;
- TInt iMaxExitTime; // Time we wait for application exit gracefully, after this we'll try to shut next application down.
- TInt iRamPluginRunTime; // Time we wait for plugins to free RAM before we start to shut apps.
-
- // parameters for app close order
- enum TAppCloseOrderConstants
- {
- ECloseFirst = -1000000, // apps to close first are given an order around negative one million
- ECloseNormal = 0, // apps to close normally are given an order around zero
- ECloseLast = 1000000, // apps to close last are given an order around one million
- ENeverClose = 1000000000 // one billion signals apps that should never be closed
- };
- typedef RHashMap<TInt, TInt> RAppCloseOrderMap; // maps app UID to close order
- RAppCloseOrderMap iAppCloseOrderMap;
-
- // internal
- CApaWindowGroupName* iWgName;
- HBufC* iWgNameBuf; // owned by iWgName
-
- // app closer state
- TBool iAppCloserRunning;
- TInt iCurrentTarget;
- TApaTask iCurrentTask;
- RArray<RWsSession::TWindowGroupChainInfo> iWgIds;
- TInt iNextAppToClose;
- TBool iMemoryAboveThreshold;
-
- // event receivers
- CAppCloseTimer* iAppCloseTimer;
- CAppCloseWatcher* iAppCloseWatcher;
- COutOfMemoryWatcher* iOOMWatcher;
- CWservEventReceiver* iWservEventReceiver;
-
- // parameters for P&S watcher.
- RProperty iWatchdogStatusProperty;
- CSubscribeHelper* iWatchdogStatusSubscriber;
-
- // Plugin support
- COomPlugins* iPlugins;
- TBool iPluginMemoryGood;
-
- // Server
- CMemoryMonitorServer* iServer;
- };
-
-
-
-NONSHARABLE_CLASS(COutOfMemoryWatcher) : public CActive
- {
-public:
- static COutOfMemoryWatcher* NewL(CMemoryMonitor& aLafShutdown, TInt aLowThreshold, TInt aGoodThreshold);
- ~COutOfMemoryWatcher();
- void Start();
-private:
- COutOfMemoryWatcher(CMemoryMonitor& aLafShutdown);
- void ConstructL(TInt aLowThreshold, TInt aGoodThreshold);
-private: // from CActive
- void DoCancel();
- void RunL();
-private: // data
- RChangeNotifier iChangeNotifier;
- CMemoryMonitor& iLafShutdown;
- };
-
-NONSHARABLE_CLASS(CSubscribeHelper) : public CActive
- {
-public:
- CSubscribeHelper(TCallBack aCallBack, RProperty& aProperty);
- ~CSubscribeHelper();
-
-public: // New functions
- void SubscribeL();
- void StopSubscribe();
-
-private: // from CActive
- void RunL();
- void DoCancel();
-
-private:
- TCallBack iCallBack;
- RProperty& iProperty;
- };
-
-
-NONSHARABLE_CLASS(COomPlugins) : public CBase
- {
-public:
- COomPlugins();
- ~COomPlugins();
- void ConstructL();
-
-public:
- void FreeRam();
- void MemoryGood();
-
-private:
- struct TPlugin
- {
- TPlugin();
- COomMonitorPlugin* iImpl;
- TUid iDtorUid;
- };
-
-private:
- RArray<TPlugin> iPlugins;
- };
-
-
-NONSHARABLE_CLASS(CAppCloseTimer) : public CTimer
- {
-public:
- static CAppCloseTimer* NewL(CMemoryMonitor& aMonitor);
-private:
- CAppCloseTimer(CMemoryMonitor& aMonitor);
- void RunL();
-private:
- CMemoryMonitor& iMonitor;
- };
-
-
-NONSHARABLE_CLASS(CAppCloseWatcher) : public CActive
- {
-public:
- CAppCloseWatcher(CMemoryMonitor& aMonitor);
- ~CAppCloseWatcher();
- void Start(const TApaTask& aTask);
-private:
- void DoCancel();
- void RunL();
-private:
- CMemoryMonitor& iMonitor;
- RThread iThread;
- TProcessPriority iOriginalProcessPriority;
- };
-
-
-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;
- };
-
-
-NONSHARABLE_CLASS(CMemoryMonitorServer) : public CServer2
- {
-public:
- static CMemoryMonitorServer* NewL(CMemoryMonitor& aMonitor);
- ~CMemoryMonitorServer();
-
- CMemoryMonitor& Monitor();
- void CloseAppsFinished(TBool aMemoryGood);
-
-private:
- CMemoryMonitorServer(CMemoryMonitor& aMonitor);
- void ConstructL();
- CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const;
- TInt RunError(TInt aError);
-
-private:
- CMemoryMonitor& iMonitor;
- };
-
-
-NONSHARABLE_CLASS(CMemoryMonitorSession) : public CSession2
- {
-public:
- CMemoryMonitorSession();
- void CreateL();
- void CloseAppsFinished(TBool aMemoryGood);
-
-private:
- ~CMemoryMonitorSession();
- CMemoryMonitorServer& Server();
- CMemoryMonitor& Monitor();
- void ServiceL(const RMessage2& aMessage);
-
-private:
- RMessagePtr2 iRequestFreeRam;
- };
-
-
+#endif // OOMMONITOR_H
--- a/appsupport_plat/oom_monitor_api/inc/oommonitorsession.h Fri May 14 16:01:13 2010 +0300
+++ b/appsupport_plat/oom_monitor_api/inc/oommonitorsession.h Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 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"
@@ -21,50 +21,125 @@
#include <e32std.h>
+const TInt KOomMaxAllocationWithoutPermission = 1048576;
+const TUid KOomMemoryMonitorStatusPropertyCategory = {0x10207218};
+const TUint32 KOomMemoryMonitorStatusPropertyKey = 0;
+enum TMemoryMonitorStatusPropertyValues
+ {
+ // Above Treshhold: Free Ram is above good treshhold point and memory monitor isn't freeing any memory
+ EAboveTreshHold,
+
+ // Freeing Memory: Memory monitor is in the middle of freeing memory
+ EFreeingMemory,
+
+ // Below Treshhold: Memory monitor has tried to free some RAM but total memory is still below treshhold and memory monitor has given up freeing more memory.
+ EBelowTreshHold
+ };
class ROomMonitorSession : public RSessionBase
- {
+ {
+public:
+
+ /** Defines the application priorities of OOM monitor. */
+ enum TOomPriority
+ {
+ /**
+ * Application can be closed if needed.
+ */
+ EOomPriorityNormal = 0,
+
+ /**
+ * Application should not be closed if possible.
+ */
+ EOomPriorityHigh,
+
+ /**
+ * Application is busy and should not be closed.
+ */
+ EOomPriorityBusy
+ };
+
public:
- /**
- * Connects a new session.
- * Sessions must be connected before any other APIs can be used.
- * When the client has finished using a session, Close() must be called.
- * @return KErrNone if successful, error code otherwise.
- */
- IMPORT_C TInt Connect();
- /**
- * Request that the OOM monitor attempts to free some memory.
- * This function may take several seconds to execute, depending on
- * the memory state. It will not return until the attempt to recover
- * memory has completed.
- * @param aBytesRequested The number of bytes of free memory that the client requests.
- * @return KErrNone if the request memory is free. KErrNoMemory if that
- * amount of memory could not be recovered. Other error codes may
- * also be returned.
- */
- IMPORT_C TInt RequestFreeMemory(TInt aBytesRequested);
- /**
- * Request that the OOM monitor attempts to free some memory.
- * This is an asynchronous version of the request for free memory.
- * @param aBytesRequested The number of bytes of free memory that the client requests.
- * @param aStatus will be completed when the attempt to recover memory
- * has finished. This may take several seconds, depending on
- * the memory state. On completion, aStatus will be set to
- * KErrNone if the request memory is free. KErrNoMemory if that
- * amount of memory could not be recovered. Other error codes may
- * also be set.
- */
- IMPORT_C void RequestFreeMemory(TInt aBytesRequested, TRequestStatus& aStatus);
- /**
- * Cancels the asynchronous request for free memory.
- */
- IMPORT_C void CancelRequestFreeMemory();
- /**
- * Notifiy the OOM monitor that this application is not responding
- * to the EEikCmdExit request to exit the application.
- * This function is used by the Avkon framework's app shutter.
- * @param aWgId the window group identifier of the app that is not exiting.
- */
- IMPORT_C void ThisAppIsNotExiting(TInt aWgId);
- };
+ /**
+ * Connects a new session.
+ * Sessions must be connected before any other APIs can be used.
+ * When the client has finished using a session, Close() must be called.
+ * @return KErrNone if successful, error code otherwise.
+ */
+ IMPORT_C TInt Connect();
+
+ /**
+ * Request that the OOM monitor attempts to free some paged memory.
+ * This function may take several seconds to execute, depending on
+ * the memory state. It will not return until the attempt to recover
+ * memory has completed.
+ * @param aBytesRequested The number of bytes of free memory that the client requests.
+ * @return KErrNone if the request memory is free. KErrNoMemory if that
+ * amount of memory could not be recovered. Other error codes may
+ * also be returned.
+ */
+ IMPORT_C TInt RequestFreeMemory(TInt aBytesRequested);
+
+ /**
+ * Request that the OOM monitor attempts to free some paged memory.
+ * This is an asynchronous version of the request for free paged memory.
+ * @param aBytesRequested The number of bytes of free memory that the client requests.
+ * @param aStatus will be completed when the attempt to recover memory
+ * has finished. This may take several seconds, depending on
+ * the memory state. On completion, aStatus will be set to
+ * KErrNone if the request memory is free. KErrNoMemory if that
+ * amount of memory could not be recovered. Other error codes may
+ * also be set.
+ */
+ IMPORT_C void RequestFreeMemory(TInt aBytesRequested, TRequestStatus& aStatus);
+
+ /**
+ * Request that the OOM monitor attempts to free some memory for an optional allocation.
+ * The passed in plugin ID is used to determine the priority for this allocation.
+ * Lower priority OOM actions may be executed to free enough RAM for this allocation.
+ * This function may take several seconds to execute, depending on
+ * the memory state. It will not return until the attempt to recover
+ * memory has completed.
+ * @param aBytesRequested The number of bytes of free memory that the client requests.
+ * @param aPluginId The ID of the plugin that may delete the allocation in event of low memory.
+ * @return KErrNone if the request memory is free. KErrNoMemory if that
+ * amount of memory could not be recovered. Other error codes may
+ * also be returned.
+ */
+ IMPORT_C TInt RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TInt& aBytesAvailable);
+
+ /**
+ * Request that the OOM monitor attempts to free some memory for an optional allocation.
+ * The passed in plugin ID is used to determine the priority for this allocation.
+ * Lower priority OOM actions may be executed to free enough RAM for this allocation.
+ * This function may take several seconds to execute, depending on
+ * the memory state. It will not return until the attempt to recover
+ * memory has completed.
+ * @param aBytesRequested The number of bytes of free memory that the client requests.
+ * @param aPluginId The ID of the plugin that may delete the allocation in event of low memory.
+ * @param aStatus The TRequestStatus (completes with the number of bytes freed (aStatus >= 0) or an error (aStatus <= 0))
+ * @return None
+ */
+ IMPORT_C void RequestOptionalRam(TInt aBytesRequested, TInt aMinimumBytesNeeded, TInt aPluginId, TRequestStatus& aStatus);
+
+ /**
+ * Cancels the asynchronous request for free memory.
+ */
+ IMPORT_C void CancelRequestFreeMemory();
+
+ /**
+ * Notify the OOM monitor that this application is not responding
+ * to the EEikCmdExit request to exit the application.
+ * This function is used by the Avkon framework's app shutter.
+ * @param aWgId the window group identifier of the app that is not exiting.
+ */
+ IMPORT_C void ThisAppIsNotExiting(TInt aWgId);
+
+ /**
+ * Notify the OOM monitor that this application has the specified priority
+ * @param aPriority the priority of the application
+ */
+ IMPORT_C void SetOomPriority(TOomPriority aPriority);
+
+ };
#endif // R_OOMMONITORSESSION_H
--- a/appsupport_plat/oom_monitor_plugin_api/inc/oommonitorplugin.h Fri May 14 16:01:13 2010 +0300
+++ b/appsupport_plat/oom_monitor_plugin_api/inc/oommonitorplugin.h Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 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"
@@ -99,6 +99,44 @@
};
+class COomMonitorPluginV2 : public COomMonitorPlugin
+ {
+public: // From COomMonitorPlugin
+ /**
+ * FreeRam is called when the system RAM level becomes
+ * low. This plugin is requested to help free some RAM.
+ *
+ * Note that OomMonitorV2 will not call this version of the function so it does not need to be implemented.
+ */
+ IMPORT_C virtual void FreeRam();
+
+ /**
+ * MemoryGood is called when the system RAM level becomes
+ * good after being low.The plugin may take this opportunity
+ * to start using RAM again.
+ * Nb It is assumed that the plugin will not immediately
+ * cause a large increase in memory use, but that memory may be
+ * used over time, otherwise the plugin may cause oscillation
+ * between low and good memory states.
+ */
+ virtual void MemoryGood() = 0;
+
+public:
+ /**
+ * FreeRam is called when the system RAM level becomes
+ * low. This plugin is requested to help free some RAM.
+ * Note that it is desirable to delete all memory associated with this plugin if
+ * not using a disconnected chunk. The reason for this is that by only releasing a small amount
+ * of the memory you reduce the chances of that memory being at the end of the chunk and therefore
+ * reduce the likelihood of it being released to the system.
+ * @param aBytesToFree The minimum number of bytes of free memory that the plugin should try to free.
+ */
+ virtual void FreeRam(TInt aBytesToFree) = 0;
+
+ };
+
+
+
/**
* CAppOomMonitorPlugin is a specialised OOM monitor plugin
* that sends messages to applications when the memory state
--- a/appsupport_plat/oom_monitor_plugin_api/inc/oommonitorplugin.hrh Fri May 14 16:01:13 2010 +0300
+++ b/appsupport_plat/oom_monitor_plugin_api/inc/oommonitorplugin.hrh Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 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"
@@ -22,4 +22,6 @@
#define KOomPluginInterfaceUidValue 0x10281eea
#define KOomPluginInterfaceUid (TUid::Uid(KOomPluginInterfaceUidValue))
+#define KOomPluginInterfaceV2UidValue 0x10286A80
+#define KOomPluginInterfaceV2Uid (TUid::Uid(KOomPluginInterfaceV2UidValue))
#endif // OOMMONITORPLUGIN_HRH
--- a/appsupport_plat/secondary_display_accfw_api/group/bld.inf Fri May 14 16:01:13 2010 +0300
+++ b/appsupport_plat/secondary_display_accfw_api/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 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"
@@ -24,4 +24,4 @@
PRJ_EXPORTS
-../inc/secondarydisplay/SecondaryDisplayAccFwAPI.h MW_LAYER_PLATFORM_EXPORT_PATH(secondarydisplay/SecondaryDisplayAccFwAPI.h)
+../inc/secondarydisplay/SecondaryDisplayAccFwAPI.h MW_LAYER_PLATFORM_EXPORT_PATH(SecondaryDisplay/SecondaryDisplayAccFwAPI.h)
--- a/appsupport_plat/secondary_display_sysap_api/group/bld.inf Fri May 14 16:01:13 2010 +0300
+++ b/appsupport_plat/secondary_display_sysap_api/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 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"
@@ -24,4 +24,4 @@
PRJ_EXPORTS
-../inc/secondarydisplay/SecondaryDisplaySysApAPI.h MW_LAYER_PLATFORM_EXPORT_PATH(secondarydisplay/SecondaryDisplaySysApAPI.h)
+../inc/secondarydisplay/SecondaryDisplaySysApAPI.h MW_LAYER_PLATFORM_EXPORT_PATH(SecondaryDisplay/SecondaryDisplaySysApAPI.h)
--- a/commonappservices/alarmserver/Client/Source/ASCliSession.cpp Fri May 14 16:01:13 2010 +0300
+++ b/commonappservices/alarmserver/Client/Source/ASCliSession.cpp Thu May 27 13:01:09 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1999-2010 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"
@@ -742,6 +742,7 @@
*/
EXPORT_C void RASCliSession::GetAvailableCategoryListL(RArray<TAlarmCategory>& aCategories) const
{
+ CleanupClosePushL(aCategories);
// First step is to build the transfer buffer in the server
// and get the size (in bytes) so that we know
// how big to make the client-side (corresponding) temporary one.
@@ -768,6 +769,8 @@
//
stream.Close();
CleanupStack::PopAndDestroy(2, buffer);
+ // relieve the ownership of the array to the caller
+ CleanupStack::Pop(&aCategories);
}
@@ -1328,6 +1331,7 @@
*/
void RASCliSession::FetchAlarmIdsFromBufferL(RArray<TAlarmId>& aAlarmIds, TInt aBufferSize) const
{
+ CleanupClosePushL(aAlarmIds);
CBufBase* buffer = FetchTransferBufferLC(aBufferSize);
// The buffer just contains serialized TAlarmId's so we need to
@@ -1344,6 +1348,8 @@
}
//
CleanupStack::PopAndDestroy(2, buffer);
+ // relieve the ownership of the array to the caller
+ CleanupStack::Pop(&aAlarmIds);
}
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/commonappservices/alarmserver/Group/TEF_AlarmServerCIT.pkg Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,28 @@
+;
+; 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:
+;
+
+;Languages
+&EN
+
+
+;Localised Vendor name
+%{"TEF_AlarmServerCIT.pkg EN"}
+
+; Vendor name
+: "TEF_AlarmServerCIT"
+
+
+"\epoc32\data\C\CITAlarmServer\scripts\TestCITAlarmServer.script"-"c:\CITAlarmServer\scripts\TestCITAlarmServer.script"
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/commonappservices/alarmserver/Group/alarmserverunittestserver.pkg Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,39 @@
+;
+; 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:
+;
+
+;Languages
+&EN
+
+
+;Localised Vendor name
+%{"alarmserverunittestserver.pkg EN"}
+
+; Vendor name
+: "alarmserverunittestserver"
+
+"\epoc32\data\z\testdata\scripts\TEAlarmServer.script"-"c:\testdata\scripts\TEAlarmServer.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_loop.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_man.script"-"c:\testdata\scripts\TEAlarmServer_man.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_man_TC3.script"-"c:\testdata\scripts\TEAlarmServer_man_TC3.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_man_exceptTC3.script"-"c:\testdata\scripts\TEAlarmServer_man_exceptTC3.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_repeat.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_stop.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_disabled.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_disordered.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_ini.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_invalid.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_apc_norsc.script"-"c:\testdata\scripts\TEAlarmServer_apc.script"
+"\epoc32\data\z\testdata\scripts\TEAlarmServer_man_exceptTC3.script"-"c:\testdata\scripts\TEAlarmServer_man.script"
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/commonappservices/alarmserver/Test/Integration/TestCITAlarmServer/group/TEF_AlarmServerCIT.pkg Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,28 @@
+;
+; 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:
+;
+
+;Languages
+&EN
+
+
+;Localised Vendor name
+%{"TEF_AlarmServerCIT.pkg EN"}
+
+; Vendor name
+: "TEF_AlarmServerCIT"
+
+
+"\epoc32\data\C\CITAlarmServer\scripts\TestCITAlarmServer.script"-"c:\CITAlarmServer\scripts\TestCITAlarmServer.script"
\ No newline at end of file
--- a/contextframework/cfwplugins/ApplicationStateSourcePlugIn/group/bld.inf Fri May 14 16:01:13 2010 +0300
+++ b/contextframework/cfwplugins/ApplicationStateSourcePlugIn/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -10,13 +10,17 @@
* Nokia Corporation - initial contribution.
*
* Contributors:
-* NTT DOCOMO, INC - BUG 2365
+*
*
* Description:
*
*/
+/*
+*NTT DOCOMO, INC - BUG 2365
+*/
+
#include <platform_paths.hrh>
PRJ_PLATFORMS
--- a/contextframework/cfwplugins/PSStateSourcePlugIn/group/bld.inf Fri May 14 16:01:13 2010 +0300
+++ b/contextframework/cfwplugins/PSStateSourcePlugIn/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -10,13 +10,17 @@
* Nokia Corporation - initial contribution.
*
* Contributors:
-* NTT DOCOMO, INC - BUG 2365
+*
*
* Description: Build information file for project PSStateSourcePlugIn
*
*/
+/*
+*NTT DOCOMO, INC - BUG 2365
+*/
+
#include <platform_paths.hrh>
PRJ_PLATFORMS
--- a/contextframework/cfwplugins/sensorsourceplugin/group/bld.inf Fri May 14 16:01:13 2010 +0300
+++ b/contextframework/cfwplugins/sensorsourceplugin/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -10,12 +10,15 @@
* Nokia Corporation - initial contribution.
*
* Contributors:
-* NTT DOCOMO, INC - BUG 2365
+*
*
* Description: Build information file for project SensorSourcePlugin
*
*/
+/*
+*NTT DOCOMO, INC - BUG 2365
+*/
#include <platform_paths.hrh>
--- a/coreapplicationuis/ATCmdPlugin/sis/atcmdplugin.pkg Fri May 14 16:01:13 2010 +0300
+++ b/coreapplicationuis/ATCmdPlugin/sis/atcmdplugin.pkg Thu May 27 13:01:09 2010 +0300
@@ -11,8 +11,9 @@
;
; Contributors:
;
-; Description:
+; Description: ?Description
;
+
; ExtAtCmdHandler.pkg
;
;Language - standard language definitions
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/data/10275117.rss Fri May 14 16:01:13 2010 +0300
+++ /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: ECOM plugin resource file for GS RFS plugin.
-*
-*/
-
-
-#include <ecom/registryinfo.rh>
-
-RESOURCE REGISTRY_INFO theInfo
- {
- dll_uid = 0x10275117; // Plugin dll UID
- interfaces =
- {
- INTERFACE_INFO
- {
- interface_uid = 0x10207236; // UID for CGSPluginInterface - do not change.
- implementations =
- {
- IMPLEMENTATION_INFO
- {
- implementation_uid = 0x10275118; // Plugin UID
- version_no = 1;
- display_name = "GS RFS Plugin"; // Plugin debug name
- default_data = "0x10283317"; // Parent UID
- opaque_data = "40"; // Order number
- }
- };
- }
- };
- }
-
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/data/GSRFSPluginRsc.rss Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/*
-* Copyright (c) 2005-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:
-* Resource file for GSRFSPlugin
-*
-*/
-
-
-// RESOURCE IDENTIFIER
-NAME GRFS // 4 letter ID
-
-// INCLUDES
-
-#include <avkon.rsg>
-#include <avkon.mbg>
-#include <EIKCORE.rsg>
-#include <eikon.rsg>
-#include <avkon.loc>
-#include "gsrfsplugin.hrh"
-#include "gsrfsplugin.loc"
-#include <uikon.rh>
-
-
-// CONSTANTS
-
-// RESOURCE DEFINITIONS
-
-//----------------------------------------------------
-//
-//
-// Needed or loading the resource fails!
-//
-//----------------------------------------------------
-//
-RESOURCE RSS_SIGNATURE
- {
- }
-
-#include "gscommonresources.rss"
-RESOURCE TBUF
- {
- buf="GRFS";
- }
-
-//----------------------------------------------------
-//
-// EIK_APP_INFO
-// It contains application information.
-//
-//----------------------------------------------------
-//
-RESOURCE EIK_APP_INFO
- {
- }
-
-//----------------------------------------------------
-// r_rfs_factory_settings
-//
-// Orig. factory settings caption for plugin
-//----------------------------------------------------
-//
-RESOURCE TBUF r_rfs_factory_settings
- {
- buf = qtn_set_folder_original_settings;
- }
-
-//----------------------------------------------------
-// r_rfs_factory_settings_title
-//
-// Factory settings view title.
-//----------------------------------------------------
-//
-RESOURCE TITLE_PANE r_rfs_factory_settings_title
- {
- txt = qtn_set_folder_original_settings;
- }
-
-
-//----------------------------------------------------
-// r_rfs_factory_settings_view
-//
-// Factory settings view.
-//----------------------------------------------------
-//
-RESOURCE MENU_BAR r_gs_menubar_exit_help
- {
- titles =
- {
- MENU_TITLE
- {
- menu_pane = r_gs_menu_item_exit;
- },
- MENU_TITLE
- {
- menu_pane = r_gs_menu_item_help;
- }
- };
- }
-
-
-RESOURCE CBA r_gs_rfs_softkeys_options_back__exit
- {
- buttons =
- {
- CBA_BUTTON {id=EAknSoftkeyOptions; txt = text_softkey_option;},
- CBA_BUTTON {id=EAknSoftkeyBack; txt = text_softkey_back; }
- };
- }
-
-RESOURCE AVKON_VIEW r_rfs_factory_settings_view
- {
- menubar = r_gs_menubar_exit_help;
- cba = r_gs_rfs_softkeys_options_back__exit;
- }
-
-
-
-//----------------------------------------------------
-// r_rfs_factory_settings_lbx
-//
-// Factory settings view's listbox.
-//----------------------------------------------------
-
-//
-RESOURCE GS_FEATURE_ARRAY r_rfs_factory_settings_lbx
- {
- items =
- {
- GS_FEATURE
- {
- txt = " \t"qtn_rfs_orig_settings"\t\t";
- item = EGSSettIdOptNormalRfs;
-
- },
- GS_FEATURE
- {
- txt = " \t"qtn_rfs_erase_all_data"\t\t";
- item = EGSSettIdOptDeepRfs;
- }
- };
- }
-
-//End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/group/GSRFSPlugin.mmp Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
-* Copyright (c) 2005-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: Project specification file.
-*
-*/
-
-
-#include <data_caging_paths.hrh> // For RESOURCE_FILES_DIR
-#include <platform_paths.hrh>
-
-CAPABILITY CAP_ECOM_PLUGIN
-TARGET gsrfsplugin.dll
-TARGETTYPE PLUGIN
-UID 0x10009D8D 0x10275117
-VENDORID VID_DEFAULT
-
-
-SOURCEPATH ../src
-SOURCE GSRFSPluginImplementationTable.cpp
-SOURCE GSRFSPlugin.cpp
-SOURCE GSRFSPluginContainer.cpp
-
-//User include paths
-USERINCLUDE ../inc
-USERINCLUDE ../data // For *.rh
-USERINCLUDE ../../../inc // for gsrfsplugin.loc
-
-
-//System include paths
-APP_LAYER_SYSTEMINCLUDE /epoc32/include/ecom
-APP_LAYER_SYSTEMINCLUDE /epoc32/include/cshelp
-
-//System include paths
-MW_LAYER_SYSTEMINCLUDE
-
-SOURCEPATH ../data
-
-START RESOURCE 10275117.rss
-TARGET gsrfsplugin.rsc
-END
-
-START RESOURCE GSRFSPluginRsc.rss
-TARGETPATH RESOURCE_FILES_DIR
-HEADER
-LANGUAGE_IDS
-END
-
-LIBRARY euser.lib
-LIBRARY ecom.lib
-LIBRARY efsrv.lib
-LIBRARY avkon.lib
-LIBRARY bafl.lib
-LIBRARY cone.lib
-LIBRARY eikcoctl.lib
-LIBRARY eikcore.lib
-LIBRARY egul.lib
-LIBRARY ws32.lib
-LIBRARY rfs.lib
-LIBRARY gsecomplugin.lib
-LIBRARY commonengine.lib
-LIBRARY fbscli.lib
-LIBRARY aknicon.lib
-LIBRARY aknskins.lib
-
-LIBRARY hlplch.lib
-LIBRARY gsframework.lib
-LIBRARY gslistbox.lib
-
-
-DOCUMENT 10275117.rss
-
-// End of File
\ No newline at end of file
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/group/GSRFSPluginIcons.mk Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-#
-# Copyright (c) 2007 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:
-#
-
-
-ifeq (WINS,$(findstring WINS, $(PLATFORM)))
-ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
-else
-ZDIR=\epoc32\data\z
-endif
-
-# ----------------------------------------------------------------------------
-# Configure these
-# ----------------------------------------------------------------------------
-
-TARGETDIR=$(ZDIR)\resource\apps
-HEADERDIR=\epoc32\include
-ICONTARGETFILENAME=$(TARGETDIR)\GSRFSPlugin.mif
-HEADERFILENAME=$(HEADERDIR)\GSRFSPlugin.mbg
-
-do_nothing :
- @rem do_nothing
-
-MAKMAKE : do_nothing
-
-BLD : do_nothing
-
-CLEAN : do_nothing
-
-LIB : do_nothing
-
-CLEANLIB : do_nothing
-
-# ----------------------------------------------------------------------------
-# Configure these.
-#
-# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatiNetworky by
-# MifConv if the mask detph is defined.
-#
-# NOTE 2: Usually, source paths should not be included in the bitmap
-# definitions. MifConv searches for the icons in all icon directories in a
-# predefined order, which is currently \s60\icons, \s60\bitmaps2, \s60\bitmaps.
-# The directory \s60\icons is included in the search only if the feature flag
-# __SCALABLE_ICONS is defined.
-# ----------------------------------------------------------------------------
-
-RESOURCE :
- mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
- /c8,8 qgn_prop_set_gene_phone.bmp
-
-FREEZE : do_nothing
-
-SAVESPACE : do_nothing
-
-RELEASABLES :
- @echo $(HEADERFILENAME)&& \
- @echo $(ICONTARGETFILENAME)
-
-FINAL : do_nothing
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/group/bld.inf Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-/*
-* Copyright (c) 2005 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: This file provides the information required for building
-* GS RFS Plugin.
-*
-*/
-
-#include <platform_paths.hrh>
-
-PRJ_PLATFORMS
-DEFAULT
-
-PRJ_EXPORTS
-../loc/gsrfsplugin.loc MW_LAYER_LOC_EXPORT_PATH(gsrfsplugin.loc)
-
-PRJ_EXTENSIONS
-START EXTENSION s60/mifconv
- OPTION TARGETFILE GSRFSPlugin.mif
- OPTION HEADERFILE GSRFSPlugin.mbg
- OPTION SOURCES -c8,8 qgn_prop_set_gene_phone
-END
-
-
-PRJ_MMPFILES
-//gnumakefile GSRFSPluginIcons.mk
-GSRFSPlugin.mmp
-
-// End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/GSRFSPlugin.h Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +0,0 @@
-/*
-* Copyright (c) 2005-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: GS Restore Factory Settings plugin
-*
-*/
-
-
-#ifndef GSRFSPLUGIN_H
-#define GSRFSPLUGIN_H
-
-// Includes
-#include <aknsettingpage.h>
-#include <gsbaseview.h>
-#include <ConeResLoader.h>
-#include <gsplugininterface.h>
-
-// Classes referenced
-class CRfsHandler;
-class CGSRFSPluginContainer;
-class CAknViewAppUi;
-
-// Constants
-const TUid KGSRFSPluginUid = { 0x10275117 };
-
-
-// Class Declaration
-/**
- *
- * @since Series60_3.1
- */
-class CGSRFSPlugin : public CGSBaseView
- {
-public: // Constructors and destructor
-
- /**
- * Symbian OS two-phased constructor
- * @return
- */
- static CGSRFSPlugin* NewL( TAny* aInitParams );
-
- /**
- * Destructor.
- */
- ~CGSRFSPlugin();
-
-public: // From CAknView
-
- /**
- * See base class.
- *
- * This function is used also for identifying the plugin so be sure to
- * return correct UID.
- */
- TUid Id() const;
-
- /**
- * See base class.
- */
- void HandleClientRectChange();
-
- /**
- * See base class.
- */
- void DoActivateL( const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage );
-
- /**
- * See base class.
- */
- void DoDeactivate();
-
- /**
- * See base class.
- */
- void HandleCommandL( TInt aCommand );
-
-
-public: // From CGSPluginInterface
-
- /**
- * See base class.
- */
- void GetCaptionL( TDes& aCaption ) const;
-
- /**
- * See base class.
- */
- TInt PluginProviderCategory() const;
-
- /**
- * See base class.
- */
- CGulIcon* CreateIconL( const TUid aIconType );
-
-protected: // New
-
- /**
- * C++ default constructor.
- */
- CGSRFSPlugin();
-
- /**
- * Symbian OS default constructor.
- */
- void ConstructL();
-
- void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
-
-private: // from CGSBaseView
-
- void NewContainerL();
-
- void HandleListBoxSelectionL();
-
-private: // Data
-
- // Resource loader
- RConeResourceLoader iResourceLoader;
- };
-
-#endif // GSRFSPLUGIN_H
-
-// End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/GSRFSPluginContainer.h Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
-* Copyright (c) 2007-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:
-*
-*/
-
-#ifndef GSRFSPLUGINCONTAINER_H
-#define GSRFSPLUGINCONTAINER_H
-
-// INCLUDES
-#include <gsbasecontainer.h>
-#include "gssettingid.h"
-
-// CLASS DECLARATION
-class CGSRFSPlugin;
-class CGSListBoxItemTextArray;
-
-
-class CGSRFSPluginContainer : public CGSBaseContainer
- {
-public:
-
- /**
- * C++ default constructor.
- */
- CGSRFSPluginContainer( CGSRFSPlugin* aGSRFSPlugin );
-
- /**
- * By default Symbian OS constructor is private.
- */
- void ConstructL(const TRect& aRect);
-
- /**
- * Destructor.
- */
- ~CGSRFSPluginContainer();
-
-public: // new methods
-
- TInt CurrentFeatureId() const;
-
-protected: // from CGSBaseContainer
-
- void ConstructListBoxL( TInt aResLbxId );
-
-private: // from CCoeControl
-
- void GetHelpContext( TCoeHelpContext& aContext ) const;
-
-private: // data
-
- CGSRFSPlugin* iGSRFSPlugin; // not own
- CGSListBoxItemTextArray* iListboxItemArray;
- };
-
-
-#endif // GSRFSPLUGINCONTAINER_H
-
-// End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/GSRFSPluginTraces.h Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +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: Includes some common defines used in the startup application
-*
-*/
-
-
-#ifndef STARTUPDEFINES_H
-#define STARTUPDEFINES_H
-
-//CONSTANTS
-_LIT( KAppName, "GSRFSPlugin" ); // The application name
-
-// MACROS
-
-#define PANIC(aPanic) User::Panic( KAppName, aPanic )
-
-#define TRACE_ADDPREFIX(aText) (TPtrC((const TText *)L"GSRFSPlugin: \"" L##aText L"\""))
-
-#ifdef _DEBUG
-#define TRACES(aMsg) RDebug::Print( TRACE_ADDPREFIX(aMsg) )
-#define TRACES1(aFormat,aP1) RDebug::Print( TRACE_ADDPREFIX(aFormat),(aP1) )
-#define TRACES2(aFormat,aP1,aP2) RDebug::Print( TRACE_ADDPREFIX(aFormat),(aP1),(aP2) )
-#define TRACES3(aFormat,aP1,aP2,aP3) RDebug::Print( TRACE_ADDPREFIX(aFormat),(aP1),(aP2),(aP3) )
-#else
-#define TRACES(aMsg)
-#define TRACES1(aFormat,aP1)
-#define TRACES2(aFormat,aP1,aP2)
-#define TRACES3(aFormat,aP1,aP2,aP3)
-#endif
-#endif // STARTUPDEFINES_H
-
-// End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/gscommonresources.rss Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,187 +0,0 @@
-/*
-* Copyright (c) 2005-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: Common resources for internal GS plugins. This .rss is
-* included by other .rss files. This should not be compiled
- alone.
-*
-*/
-
-// RESOURCE IDENTIFIER
-//NAME GSCR // 4 letter ID
-
-// INCLUDES
-#include <gs.loc> // Common localized GS strings
-#include <gscommon.rh> // Common GS resource structures
-
-#include <bldvariant.hrh>
-#include <eikon.rh>
-#include <eikon.rsg>
-#include <avkon.rh>
-#include <avkon.loc>
-
-// CONSTANTS
-
-// -----------------------------------------------------------------------------
-//
-// r_gs_menubar_change_exit
-// GS menu with 'change' and 'exit' items.
-//
-// -----------------------------------------------------------------------------
-//
-RESOURCE MENU_BAR r_gs_menubar_change_exit
- {
- titles =
- {
- MENU_TITLE
- {
- menu_pane = r_gs_menu_item_exit;
- },
- MENU_TITLE
- {
- menu_pane = r_gs_menu_item_help;
- },
- MENU_TITLE
- {
- menu_pane = r_gs_menu_item_change;
- }
- };
- }
-
-// -----------------------------------------------------------------------------
-//
-// r_gs_menubar_open_exit
-// GS menu with 'Open' and 'Exit' items.
-//
-// -----------------------------------------------------------------------------
-//
-RESOURCE MENU_BAR r_gs_menubar_open_exit
- {
- titles =
- {
- MENU_TITLE
- {
- menu_pane = r_gs_menu_item_exit;
- },
- MENU_TITLE
- {
- menu_pane = r_gs_menu_item_help;
- },
- MENU_TITLE
- {
- menu_pane = r_gs_menu_item_open;
- }
- };
- }
-
-//----------------------------------------------------
-//
-// r_gs_menu_item_open
-// Open item.
-//
-//----------------------------------------------------
-
-RESOURCE MENU_PANE r_gs_menu_item_open
- {
- items =
- {
- MENU_ITEM
- {
- command = EAknSoftkeyOpen;
- txt = qtn_set_options_open;
- }
- };
- }
-
-
-// -----------------------------------------------------------------------------
-//
-// r_gs_menu_item_exit
-//
-// -----------------------------------------------------------------------------
-//
-RESOURCE MENU_PANE r_gs_menu_item_exit
- {
- items =
- {
- MENU_ITEM
- {
- command = EAknCmdExit;
- txt = qtn_options_exit;
- }
- };
- }
-
-
-// -----------------------------------------------------------------------------
-//
-// r_gs_menu_item_change
-// Change item.
-//
-// -----------------------------------------------------------------------------
-//
-RESOURCE MENU_PANE r_gs_menu_item_change
- {
- items =
- {
- MENU_ITEM
- {
- command = EGSCmdAppChange;
- txt = qtn_set_options_change;
- }
- };
- }
-
-// -----------------------------------------------------------------------------
-//
-// r_gs_menu_item_help
-// Change item.
-//
-// -----------------------------------------------------------------------------
-//
-RESOURCE MENU_PANE r_gs_menu_item_help
- {
- items =
- {
- MENU_ITEM
- {
- command = EAknCmdHelp;
- txt = qtn_options_help;
- }
- };
- }
-
-
-// -----------------------------------------------------------------------------
-//
-// r_setting_listbox
-// Common listbox editor resource for setting pages.
-//
-// -----------------------------------------------------------------------------
-//
-RESOURCE LISTBOX r_setting_listbox
- {
- flags = EEikListBoxMultipleSelection;
- }
-
-
-// -----------------------------------------------------------------------------
-//
-// r_gs_cba_exit
-// Exit text for RSK
-//
-// -----------------------------------------------------------------------------
-//
-RESOURCE TBUF r_gs_cba_exit { buf = text_softkey_exit; }
-
-//End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/inc/gsrfsplugin.hrh Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +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: GS Restore Factory Settings plugin
-*
-*/
-
-
-#ifndef GSRFSPLUGIN_HRH
-#define GSRFSPLUGIN_HRH
-
-enum TSettingId
- {
- EGSSettIdOptNormalRfs,
- EGSSettIdOptDeepRfs
- };
-
-#endif // GSRFSPLUGIN_HRH
-
-//End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/loc/gsrfsplugin.loc Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +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:
-* Localization strings for Plugin
-*
-*/
-
-
-// LOCALISATION STRINGS
-
-
-//d:Text of a list item in general setting list view's list
-//d:Item restores factory settings
-//l:list_setting_pane_t1
-#define qtn_set_folder_original_settings "Factory settings"
-
-
-//d:displays menu options for reset (full / partial)
-//l:title_pane_t2/opt9
-#define qtn_rfs_title_factory_conf "Factory settings"
-
-
-//d:restores factory settings (normal rfs)
-//l:list_setting_pane_t1
-#define qtn_rfs_orig_settings "Restore"
-
-
-//d:erases all data (deep rfs)
-//l:list_setting_pane_t1
-#define qtn_rfs_erase_all_data "Delete data and restore"
-
-
-// End of File
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/src/GSRFSPlugin.cpp Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,244 +0,0 @@
-/*
-* Copyright (c) 2005-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:
-* GS RFS Plugin
-*
-*/
-
-
-// SYSTEM INCLUDES
-#include <aknViewAppUi.h>
-#include <bautils.h>
-#include <rfsHandler.h>
-#include <gsprivatepluginproviderids.h>
-#include <StringLoader.h>
-#include <GSRFSPluginRsc.rsg>
-#include <GSRFSPlugin.mbg>
-
-#include <hlplch.h>
-#include <gscommon.hrh>
-#include <gsfwviewuids.h>
-#include "GSRFSPlugin.h"
-#include "GSRFSPluginTraces.h"
-#include "GSRFSPluginContainer.h"
-#include "gsrfsplugin.hrh"
-
-// Constants
-_LIT( KGSRFSPluginResourceFileName, "z:GSRFSPluginRsc.rsc" );
-
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::CGSRFSPlugin()
-// Constructor
-// ---------------------------------------------------------------------------
-CGSRFSPlugin::CGSRFSPlugin()
- :iResourceLoader( *iCoeEnv )
- {
- TRACES("CGSRFSPlugin::CGSRFSPlugin()");
- }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::~CGSRFSPlugin()
-// Destructor
-// ---------------------------------------------------------------------------
-CGSRFSPlugin::~CGSRFSPlugin()
- {
- TRACES("CGSRFSPlugin::~CGSRFSPlugin()");
- iResourceLoader.Close();
- TRACES("CGSRFSPlugin::~CGSRFSPlugin(): End");
- }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::ConstructL(const TRect& aRect)
-// Symbian OS two-phased constructor
-// ---------------------------------------------------------------------------
-void CGSRFSPlugin::ConstructL()
- {
- TRACES("CGSRFSPlugin::ConstructL()");
-
- // Find the resource file
- TParse parse;
- parse.Set( KGSRFSPluginResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
- TFileName fileName( parse.FullName() );
-
- // Get language of resource file
- BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
-
- // Open resource file
- iResourceLoader.OpenL( fileName );
-
- BaseConstructL( R_RFS_FACTORY_SETTINGS_VIEW );
-
- TRACES("CGSRFSPlugin::ConstructL(): End");
- }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::NewL()
-// Static constructor
-// ---------------------------------------------------------------------------
-CGSRFSPlugin* CGSRFSPlugin::NewL( TAny* /*aInitParams*/ )
- {
- TRACES("CGSRFSPlugin::NewL()");
- CGSRFSPlugin* self = new( ELeave ) CGSRFSPlugin();
- CleanupStack::PushL( self );
- self->ConstructL();
- CleanupStack::Pop( self );
- TRACES("CGSRFSPlugin::NewL(): End");
- return self;
- }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::Id()
-// ---------------------------------------------------------------------------
-TUid CGSRFSPlugin::Id() const
- {
- return KGSRFSPluginUid;
- }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::DoActivateL()
-// ---------------------------------------------------------------------------
-void CGSRFSPlugin::DoActivateL( const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage )
- {
- TRACES("CGSRFSPlugin::DoActivateL()");
- CGSBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );
- }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::DoDeactivate()
-// ---------------------------------------------------------------------------
-void CGSRFSPlugin::DoDeactivate()
- {
- TRACES("CGSRFSPlugin::DoDeactivate()");
- CGSBaseView::DoDeactivate();
- }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::HandleCommandL()
-// ---------------------------------------------------------------------------
-void CGSRFSPlugin::HandleCommandL( TInt aCommand )
- {
- TRACES("CGSRFSPlugin::HandleCommandL()");
- switch ( aCommand )
- {
- case EAknSoftkeyBack:
- {
- iAppUi->ActivateLocalViewL( KGSDeviceManagementPluginUid );
- break;
- }
- case EAknCmdHelp:
- {
- HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), iAppUi->AppHelpContextL() );
- break;
- }
- default:
- {
- iAppUi->HandleCommandL( aCommand );
- break;
- }
- }
- }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::GetCaptionL()
-// ---------------------------------------------------------------------------
-void CGSRFSPlugin::GetCaptionL( TDes& aCaption ) const
- {
- // the resource file is already opened
- HBufC* result = StringLoader::LoadL( R_RFS_FACTORY_SETTINGS );
- aCaption.Copy( *result );
- delete result;
- }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::PluginProviderCategory()
-// ---------------------------------------------------------------------------
-TInt CGSRFSPlugin::PluginProviderCategory() const
- {
- return KGSPluginProviderInternal;
- }
-
-// -----------------------------------------------------------------------------
-// CGSNetworkPlugin::CreateIconL()
-// -----------------------------------------------------------------------------
-CGulIcon* CGSRFSPlugin::CreateIconL( const TUid aIconType )
- {
- CGulIcon* icon;
- TParse* fp = new( ELeave ) TParse();
- CleanupStack::PushL( fp );
- _LIT( KGSRFSPluginIconDirAndName, "z:gsrfsplugin.mbm");
- fp->Set( KGSRFSPluginIconDirAndName, &KDC_BITMAP_DIR, NULL );
-
- if( aIconType == KGSIconTypeLbxItem )
- {
- icon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), KAknsIIDQgnPropSetGenePhone,
- fp->FullName(),EMbmGsrfspluginQgn_prop_set_gene_phone,
- EMbmGsrfspluginQgn_prop_set_gene_phone_mask );
- }
- else
- {
- icon = CGSPluginInterface::CreateIconL( aIconType );
- }
-
- CleanupStack::PopAndDestroy( fp );
-
- return icon;
- }
-
-// -----------------------------------------------------------------------------
-// CGSRFSPlugin::DynInitMenuPaneL()
-//
-// Dynamically handle help item if not supported
-// -----------------------------------------------------------------------------
-void CGSRFSPlugin::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
- {
- if( aResourceId == R_GS_MENU_ITEM_HELP )
- {
- User::LeaveIfNull( aMenuPane );
- aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse );
- }
- }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::NewContainerL()
-//
-// Creates new iContainer.
-// ---------------------------------------------------------------------------
-void CGSRFSPlugin::NewContainerL()
- {
- iContainer = new( ELeave ) CGSRFSPluginContainer( this );
- }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPlugin::HandleListBoxSelectionL()
-// ---------------------------------------------------------------------------
-void CGSRFSPlugin::HandleListBoxSelectionL()
- {
- CGSRFSPluginContainer *pluginContainer = static_cast<CGSRFSPluginContainer*>( iContainer );
- const TInt currentFeatureId = pluginContainer->CurrentFeatureId();
-
- CRfsHandler* iRfsHandler = new ( ELeave ) CRfsHandler;
- CleanupStack :: PushL(iRfsHandler);
-
- TRfsType rfsType = ERfsNormal;
- if ( currentFeatureId == EGSSettIdOptDeepRfs )
- {
- rfsType = ERfsDeep;
- }
- iRfsHandler->ActivateRfsL( rfsType );
-
- CleanupStack :: PopAndDestroy(iRfsHandler);
- }
-
-// End of file
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/src/GSRFSPluginContainer.cpp Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
-* Copyright (c) 2007-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:
-*
-*/
-
-
-// INCLUDES
-#include <AknUtils.h>
-#include <AknsDrawUtils.h>
-#include <AknsFrameBackgroundControlContext.h>
-#include <bldvariant.hrh>
-#include <GSRFSPluginRsc.rsg>
-#include <aknlists.h>
-#include <StringLoader.h>
-#include <csxhelp/cp.hlp.hrh>
-#include <gsfwviewuids.h>
-#include <gslistbox.h>
-#include <settingsinternalcrkeys.h>
-#include "GSRFSPluginContainer.h"
-#include "GSRFSPluginTraces.h"
-#include "GSRFSPlugin.h"
-#include "gsrfsplugin.hrh"
-
-
-// ---------------------------------------------------------
-// CGSRFSPluginContainer::CGSRFSPluginContainer()
-// ---------------------------------------------------------
-CGSRFSPluginContainer::CGSRFSPluginContainer( CGSRFSPlugin* aGSRFSPlugin )
- :iGSRFSPlugin( aGSRFSPlugin )
- {
- TRACES("CGSRFSPluginContainer::CGSRFSPluginContainer()");
- }
-
-// -----------------------------------------------------------------------------
-// CGSRFSPluginContainer::ConstructL
-//
-// -----------------------------------------------------------------------------
-void CGSRFSPluginContainer::ConstructL(const TRect& aRect)
- {
- TRACES("CGSRFSPluginContainer::ConstructL()");
-
- iListBox = new( ELeave ) CAknSettingStyleListBox;
- BaseConstructL( aRect, R_RFS_FACTORY_SETTINGS_TITLE, R_RFS_FACTORY_SETTINGS_LBX );
- }
-
-// -----------------------------------------------------------------------------
-// CGSRFSPluginContainer::~CGSRFSPluginContainer
-//
-// -----------------------------------------------------------------------------
-CGSRFSPluginContainer::~CGSRFSPluginContainer()
- {
- TRACES("CGSRFSPluginContainer::~CGSRFSPluginContainer()");
- delete iListboxItemArray;
- TRACES("CGSRFSPluginContainer::~CGSRFSPluginContainer(): End");
- }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPluginContainer::CurrentFeatureId()
-//
-// Return the feature id of selected listitem
-// ---------------------------------------------------------------------------
-TInt CGSRFSPluginContainer::CurrentFeatureId( ) const
- {
- return iListboxItemArray->CurrentFeature( );
- }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPluginContainer::ConstructListBoxL()
-//
-// Construct the listbox from resource array.
-// ---------------------------------------------------------------------------
-void CGSRFSPluginContainer::ConstructListBoxL( TInt aResLbxId )
- {
- iListBox->ConstructL( this, EAknListBoxSelectionList );
-
- iListboxItemArray = CGSListBoxItemTextArray::NewL( aResLbxId, *iListBox, *iCoeEnv );
-
- iListBox->Model()->SetItemTextArray( iListboxItemArray );
- iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
- }
-
-// ---------------------------------------------------------------------------
-// CGSRFSPluginContainer::GetHelpContext() const
-//
-// Gets help context
-// ---------------------------------------------------------------------------
-void CGSRFSPluginContainer::GetHelpContext( TCoeHelpContext& aContext ) const
- {
- aContext.iMajor = KUidGS;
- // TODO: The following statement should be un-commented and assigned with
- // the RFS helper text UID once available from concerned team
- // aContext.iContext = KSET_HLP_WLAN_SETTINGS;
- }
-
-// End of File
-
--- a/coreapplicationuis/Rfs/Plugins/GSRFSPlugin/src/GSRFSPluginImplementationTable.cpp Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
-* Copyright (c) 2005 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:
-* ECOM proxy table for this plugin
-*
-*/
-
-
-// System includes
-#include <e32std.h>
-#include <ecom/implementationproxy.h>
-#include "GSRFSPluginTraces.h"
-
-// User includes
-#include "GSRFSPlugin.h"
-
-// Constants
-const TImplementationProxy KGSRFSPluginImplementationTable[] =
- {
- IMPLEMENTATION_PROXY_ENTRY( 0x10275118, CGSRFSPlugin::NewL )
- };
-
-
-// ---------------------------------------------------------------------------
-// ImplementationGroupProxy
-// Gate/factory function
-//
-// ---------------------------------------------------------------------------
-//
-EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
- TInt& aTableCount )
- {
- TRACES("ImplementationGroupProxy()");
- aTableCount = sizeof( KGSRFSPluginImplementationTable )
- / sizeof( TImplementationProxy );
- TRACES("ImplementationGroupProxy(): End");
- return KGSRFSPluginImplementationTable;
- }
-
-// End of File
--- a/coreapplicationuis/Rfs/group/bld.inf Fri May 14 16:01:13 2010 +0300
+++ b/coreapplicationuis/Rfs/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 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"
@@ -23,7 +23,6 @@
PRJ_EXPORTS
../loc/rfs.loc MW_LAYER_LOC_EXPORT_PATH(rfs.loc)
-../Plugins/GSRFSPlugin/loc/gsrfsplugin.loc MW_LAYER_LOC_EXPORT_PATH(gsrfsplugin.loc)
../rom/rfs.iby CORE_MW_LAYER_IBY_EXPORT_PATH(rfs.iby)
../rom/rfsResources.iby LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(rfsResources.iby)
../rom/rfs_variant.iby CUSTOMER_MW_LAYER_IBY_EXPORT_PATH(rfs_variant.iby)
@@ -32,12 +31,5 @@
PRJ_MMPFILES
rfs.mmp
rfsMain.mmp
-../Plugins/GSRFSPlugin/group/GSRFSPlugin.mmp
../Plugins/rfscustcmd/group/rfscustcmd.mmp
-PRJ_EXTENSIONS
-START EXTENSION s60/mifconv
- OPTION TARGETFILE GSRFSPlugin.mif
- OPTION HEADERFILE GSRFSPlugin.mbg
- OPTION SOURCES -c8,8 qgn_prop_set_gene_phone
-END
--- a/coreapplicationuis/Rfs/rom/rfs.iby Fri May 14 16:01:13 2010 +0300
+++ b/coreapplicationuis/Rfs/rom/rfs.iby Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 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"
@@ -21,9 +21,6 @@
file=ABI_DIR\BUILD_DIR\RFS.DLL SHARED_LIB_DIR\RFS.DLL
file=ABI_DIR\BUILD_DIR\RfsServer.exe PROGRAMS_DIR\RfsServer.exe
-ECOM_PLUGIN(GSRFSPlugin.dll,10275117.rsc)
-SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,GSRFSPlugin)
-
file=ABI_DIR\BUILD_DIR\rfscustcmd.dll SHARED_LIB_DIR\rfscustcmd.dll
#endif
--- a/coreapplicationuis/Rfs/rom/rfsResources.iby Fri May 14 16:01:13 2010 +0300
+++ b/coreapplicationuis/Rfs/rom/rfsResources.iby Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009-2010 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"
@@ -21,5 +21,4 @@
//Resource file(s) for RFS
data=DATAZ_\RESOURCE_FILES_DIR\Rfs.rsc RESOURCE_FILES_DIR\Rfs.rsc
-data=DATAZ_\RESOURCE_FILES_DIR\GSRFSPluginRsc.RSC RESOURCE_FILES_DIR\GSRFSPluginRsc.RSC
#endif
\ No newline at end of file
--- a/coreapplicationuis/advancedtspcontroller/group/bld.inf Fri May 14 16:01:13 2010 +0300
+++ b/coreapplicationuis/advancedtspcontroller/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -10,7 +10,7 @@
* Nokia Corporation - initial contribution.
*
* Contributors:
-* NTT DOCOMO, INC - BUG 2365
+*
*
* Description: Bld.inf file for Symbian's Remote Control framework related
* plug-ins that are used to deliver messages (e.g. accessory key
@@ -18,6 +18,9 @@
*
*/
+/*
+*NTT DOCOMO, INC - BUG 2365
+*/
#include <platform_paths.hrh>
Binary file coreapplicationuis/rfsplugins/StarterRFSPlugin/conf/starterrfsplugin.confml has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/filehandling/fileconverterfw/group/ConarcTest.pkg Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,31 @@
+;
+; 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:
+;
+
+;Languages
+&EN
+
+
+;Localised Vendor name
+%{"ConarcTest.pkg EN"}
+
+; Vendor name
+: "ConarcTest"
+
+
+"\epoc32\data\z\conarctest\conarctest_run.bat"-"c:\conarctest_run.bat"
+"\epoc32\data\z\conarctest\conarctest_t_b64cnv.script"-"c:\conarctest\conarctest_t_b64cnv.script"
+"\epoc32\data\z\conarctest\conarctest_t_cnf.script"-"c:\conarctest\conarctest_t_cnf.script"
+"\epoc32\data\z\conarctest\conarctest_t_loadecomcnv.script"-"c:\conarctest\conarctest_t_loadecomcnv.script"
--- a/printingsupport/printinguisupport/inc/PRNSETUP.H Fri May 14 16:01:13 2010 +0300
+++ b/printingsupport/printinguisupport/inc/PRNSETUP.H Thu May 27 13:01:09 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1997-2010 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"
@@ -29,10 +29,6 @@
#include <prninf.h>
#endif
-#ifndef SYMBIAN_ENABLE_MIXED_HEADERS
-#include <printinguisupport/prnpath.h>
-#endif
-
/**
@publishedAll
@released */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/data/ssyreference_config_template.xml Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,149 @@
+<!-- ssyreference_config_template.xml -->
+<!-- SsyReference configuration file template -->
+<!-- ************************************************************* -->
+<!-- * NOTE. DO NOT LEAVE ANY COMMENTS IN THE ACTUAL CONFIG FILE * -->
+<!-- ************************************************************* -->
+<SsyReferenceConfig>
+ <SsyGeneralInformation>
+ <!-- General information for SSY itself -->
+ <Properties>
+ <!-- General properties of the sensor -->
+ <!-- TSensrvProperty. Each property has its own item defined in here -->
+
+ <!-- Property example 1 -->
+ <PropertyItem PropertyId="TSensrvPropertyId"
+ ItemIndex="Item index in channel data structure"
+ PropertyValue="Value of the property"
+ MaxValue="Maximum value of data"
+ MinValue="Minimum value of data"
+ ReadOnly="Read only or modifiable"
+ PropertyType="TSensrvPropertyType">
+ </PropertyItem>
+ <!-- Property example 2 -->
+ <PropertyItem PropertyId="TSensrvPropertyId"
+ ItemIndex="Item index in channel data structure"
+ PropertyValue="Value of the property"
+ MaxValue="Maximum value of data"
+ MinValue="Minimum value of data"
+ ReadOnly="Read only or modifiable"
+ PropertyType="TSensrvPropertyType">
+ </PropertyItem>
+ </Properties>
+ </SsyGeneralInformation>
+ <ChannelInformationGroup ChannelCount="2">
+ <!-- Channel definitions. Each channel item contains all information of one channel -->
+ <!-- Channel example 1 -->
+ <ChannelItem
+ ChannelId="This value is updated runtime when Sensrv has defined channel IDs"
+ ContextType="TSensrvContextType"
+ Quantity="TSensrvQuantity"
+ ChannelType="TSensrvChannelTypeId"
+ Location="Location of the sensor"
+ Vendor="Vendor ID"
+ DataTypeId="data type ID identifies data type defined here. See sensrvchanneldatatypes.h">
+ <!-- One channel definition. Each channel has its own item block -->
+ <!-- TSensrvChannelInfo. Contains information of this channel; Context type, Quantity etc. -->
+
+ <!-- Contains properties of this channel. -->
+ <Properties>
+ <!-- TSensrvProperty. Each property has its own item defined in here -->
+ <!-- Property example 3 -->
+ <PropertyItem PropertyId="TSensrvPropertyId"
+ ItemIndex="Item index in channel data structure"
+ PropertyValue="Value of the property"
+ MaxValue="Maximum value of data"
+ MinValue="Minimum value of data"
+ ReadOnly="Read only or modifiable"
+ PropertyType="TSensrvPropertyType">
+ </PropertyItem>
+ <!-- Property example 4 -->
+ <PropertyItem PropertyId="TSensrvPropertyId"
+ ItemIndex="Item index in channel data structure"
+ PropertyValue="Value of the property"
+ MaxValue="Maximum value of data"
+ MinValue="Minimum value of data"
+ ReadOnly="Read only or modifiable"
+ PropertyType="TSensrvPropertyType">
+ </PropertyItem>
+ </Properties>
+
+ <!-- Channel data. Information of generated data by this channel. -->
+ <!-- There may be several different (yet same type) data items. Next data item is added to -->
+ <!-- buffer after the previous data items (all according to count) are added and last Interval is passed -->
+
+ <ChannelData StartIntervalMs="Time in milliseconds to start filling buffer after StartChannelData()">
+ <ChannelDataItem DataTypeId="data type ID identifies data type defined here. See sensrvchanneldatatypes.h" count="Number of this data items to be added into buffer (with the same values)"
+ IntervalMs="Time in milliseconds after next data item is added into buffer">
+ <!-- Content of this channel item is dependent on the type of this channel. It must be one and only one of the following -->
+ <SsyRefChannelDataAxis XAxis="Integer value of X Axis" YAxis="Integer value of Y Axis" ZAxis="Integer value of Z Axis" ><!-- This type has DataTypeID 0x00010001 --></SsyRefChannelDataAxis>
+ <SsyRefChannelDataTapping Direction="direction of tapping"><!-- This type has DataTypeID 0x00010002 --></SsyRefChannelDataTapping>
+ </ChannelDataItem>
+
+ <!-- Next channel data item -->
+ <ChannelDataItem DataTypeId="data type ID identifies data type defined here. See sensrvchanneldatatypes.h" count="Number of this data items to be added into buffer (with the same values)"
+ IntervalMs="Time in milliseconds after next data item is added into buffer">
+ <!-- Content of this channel item is dependent on the type of this channel. It must be one and only one of the following -->
+ <SsyRefChannelDataAxis XAxis="Integer value of X Axis" YAxis="Integer value of Y Axis" ZAxis="Integer value of Z Axis" ><!-- This type has DataTypeID 0x00010001 --></SsyRefChannelDataAxis>
+ <SsyRefChannelDataTapping Direction="direction of tapping"><!-- This type has DataTypeID 0x00010002 --></SsyRefChannelDataTapping>
+ </ChannelDataItem>
+ </ChannelData>
+ </ChannelItem>
+ <!-- Channel example 2 -->
+ <ChannelItem
+ ChannelId="This value is updated runtime when Sensrv has defined channel IDs"
+ ContextType="TSensrvContextType"
+ Quantity="TSensrvQuantity"
+ ChannelType="TSensrvChannelTypeId"
+ Location="Location of the sensor"
+ Vendor="Vendor ID"
+ DataTypeId="data type ID identifies data type defined here. See sensrvchanneldatatypes.h">
+ <!-- One channel definition. Each channel has its own item block -->
+ <!-- TSensrvChannelInfo. Contains information of this channel; Context type, Quantity etc. -->
+
+ <!-- Contains properties of this channel. -->
+ <Properties>
+ <!-- TSensrvProperty. Each property has its own item defined in here -->
+ <!-- Property example 5 -->
+ <PropertyItem PropertyId="TSensrvPropertyId"
+ ItemIndex="Item index in channel data structure"
+ PropertyValue="Value of the property"
+ MaxValue="Maximum value of data"
+ MinValue="Minimum value of data"
+ ReadOnly="Read only or modifiable"
+ PropertyType="TSensrvPropertyType">
+ </PropertyItem>
+
+ <!-- Property example 6 -->
+ <PropertyItem PropertyId="TSensrvPropertyId"
+ ItemIndex="Item index in channel data structure"
+ PropertyValue="Value of the property"
+ MaxValue="Maximum value of data"
+ MinValue="Minimum value of data"
+ ReadOnly="Read only or modifiable"
+ PropertyType="TSensrvPropertyType">
+ </PropertyItem>
+ </Properties>
+
+ <!-- Channel data. Information of generated data by this channel. -->
+ <!-- There may be several different (yet same type) data items. Next data item is added to -->
+ <!-- buffer after the previous data items (all according to count) are added and last Interval is passed -->
+
+ <ChannelData StartIntervalMs="Time in milliseconds to start filling buffer after StartChannelData()">
+ <ChannelDataItem DataTypeId="data type ID identifies data type defined here. See sensrvchanneldatatypes.h" count="Number of this data items to be added into buffer (with the same values)"
+ IntervalMs="Time in milliseconds after next data item is added into buffer">
+ <!-- Content of this channel item is dependent on the type of this channel. It must be one and only one of the following -->
+ <SsyRefChannelDataAxis XAxis="Integer value of X Axis" YAxis="Integer value of Y Axis" ZAxis="Integer value of Z Axis" ><!-- This type has DataTypeID 0x00010001 --></SsyRefChannelDataAxis>
+ <SsyRefChannelDataTapping Direction="direction of tapping"><!-- This type has DataTypeID 0x00010002 --></SsyRefChannelDataTapping>
+ </ChannelDataItem>
+
+ <!-- Next channel data item -->
+ <ChannelDataItem DataTypeId="data type ID identifies data type defined here. See sensrvchanneldatatypes.h" count="Number of this data items to be added into buffer (with the same values)"
+ IntervalMs="Time in milliseconds after next data item is added into buffer">
+ <!-- Content of this channel item is dependent on the type of this channel. It must be one and only one of the following -->
+ <SsyRefChannelDataAxis XAxis="Integer value of X Axis" YAxis="Integer value of Y Axis" ZAxis="Integer value of Z Axis" ><!-- This type has DataTypeID 0x00010001 --></SsyRefChannelDataAxis>
+ <SsyRefChannelDataTapping Direction="direction of tapping"><!-- This type has DataTypeID 0x00010002 --></SsyRefChannelDataTapping>
+ </ChannelDataItem>
+ </ChannelData>
+ </ChannelItem>
+ </ChannelInformationGroup>
+</SsyReferenceConfig>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/data/ssyreferenceconfig.xml Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,144 @@
+<!-- ssyreferenceconfig.xml -->
+<!-- SSY reference configuration file-->
+<SsyReferenceConfig>
+ <SsyGeneralInformation>
+ </SsyGeneralInformation>
+ <ChannelInformationGroup ChannelCount="2">
+ <ChannelItem
+ ChannelId="5"
+ ContextType="2"
+ Quantity="11"
+ ChannelType="0x10205081"
+ Location="NoLoc"
+ Vendor="SsyRefVendor"
+ DataTypeId="0x1020507F">
+ <Properties>
+ <PropertyItem PropertyId="0x00000002"
+ ItemIndex="0"
+ PropertyValue="100"
+ MaxValue="150"
+ MinValue="0"
+ ReadOnly="0"
+ PropertyType="1">
+ <!-- Channel property, data rate, mandatory for all channels, see KSensrvPropIdDataRate -->
+ </PropertyItem>
+ <PropertyItem PropertyId="0x00000004"
+ ItemIndex="0"
+ PropertyValue="1"
+ MaxValue="0"
+ MinValue="0"
+ ReadOnly="1"
+ PropertyType="1">
+ <!-- Channel property, availability of the channel, mandatory for all channels, see KSensrvPropIdAvailability -->
+ </PropertyItem>
+ </Properties>
+ <ChannelData StartIntervalMs="3000">
+ <ChannelDataItem DataTypeId="0x1020507F" count="1" IntervalMs="3000">
+ <SsyRefChannelDataTapping Direction="0x01"></SsyRefChannelDataTapping>
+ </ChannelDataItem>
+ <ChannelDataItem DataTypeId="0x1020507F" count="1" IntervalMs="5000">
+ <SsyRefChannelDataTapping Direction="0x02"></SsyRefChannelDataTapping>
+ </ChannelDataItem>
+ </ChannelData>
+ </ChannelItem>
+ <ChannelItem
+ ChannelId="2"
+ ContextType="2"
+ Quantity="10"
+ ChannelType="0x1020507E"
+ Location="Event%d"
+ Vendor="SsyRefVendor"
+ DataTypeId="0x1020507E">
+ <Properties>
+ <!-- First four properties has same property Id, they are grouped to array property -->
+ <!-- First is array info -2, which tells currently selected property, value = 1 -->
+ <!-- Max and Min values tells max and min property array indexes, not the actual values -->
+ <!-- Array index is mandatory only for array type of properties, by default it is -1 -->
+ <PropertyItem PropertyId="0x00000002"
+ ArrayIndex="-2"
+ ItemIndex="0"
+ PropertyValue="1"
+ MaxValue="2"
+ MinValue="0"
+ ReadOnly="0"
+ PropertyType="1">
+ <!-- Channel property, data rate, mandatory for all channels, see KSensrvPropIdDataRate -->
+ </PropertyItem>
+ <PropertyItem PropertyId="0x00000002"
+ ArrayIndex="0"
+ ItemIndex="0"
+ PropertyValue="10"
+ MaxValue="0"
+ MinValue="0"
+ ReadOnly="1"
+ PropertyType="1">
+ <!-- Channel property, data rate, mandatory for all channels, see KSensrvPropIdDataRate -->
+ </PropertyItem>
+ <PropertyItem PropertyId="0x00000002"
+ ArrayIndex="1"
+ ItemIndex="0"
+ PropertyValue="30"
+ MaxValue="0"
+ MinValue="0"
+ ReadOnly="1"
+ PropertyType="1">
+ <!-- Channel property, data rate, mandatory for all channels, see KSensrvPropIdDataRate -->
+ </PropertyItem>
+ <PropertyItem PropertyId="0x00000002"
+ ArrayIndex="2"
+ ItemIndex="0"
+ PropertyValue="50"
+ MaxValue="0"
+ MinValue="0"
+ ReadOnly="1"
+ PropertyType="1">
+ <!-- Channel property, data rate, mandatory for all channels, see KSensrvPropIdDataRate -->
+ </PropertyItem>
+ <PropertyItem PropertyId="0x00000004"
+ ItemIndex="0"
+ PropertyValue="1"
+ MaxValue="0"
+ MinValue="0"
+ ReadOnly="1"
+ PropertyType="1">
+ <!-- Channel property, availability of the channel, mandatory for all channels, see KSensrvPropIdAvailability -->
+ </PropertyItem>
+ <PropertyItem PropertyId="0x00000005"
+ ItemIndex="1"
+ PropertyValue="14.56"
+ MaxValue="128"
+ MinValue="1"
+ ReadOnly="0"
+ PropertyType="2">
+ <!-- Channel item property, measure range for X-axis (item index = 1), see KSensrvPropIdMeasureRange -->
+ </PropertyItem>
+ <PropertyItem PropertyId="0x00000005"
+ ItemIndex="2"
+ PropertyValue="20.65"
+ MaxValue="256"
+ MinValue="1"
+ ReadOnly="0"
+ PropertyType="2">
+ <!-- Channel item property, measure range for Y-axis (item index = 2), see KSensrvPropIdMeasureRange -->
+ </PropertyItem>
+ <PropertyItem PropertyId="0x00000005"
+ ItemIndex="3"
+ PropertyValue="10.56"
+ MaxValue="128"
+ MinValue="1"
+ ReadOnly="0"
+ PropertyType="2">
+ <!-- Channel item property, measure range for Z-axis (item index = 3), see KSensrvPropIdMeasureRange -->
+ </PropertyItem>
+ </Properties>
+ <ChannelData StartIntervalMs="5000">
+ <ChannelDataItem DataTypeId="0x1020507E" count="3" IntervalMs="4000">
+ <SsyRefChannelDataAxis XAxis="-50" YAxis="-32" ZAxis="44" ></SsyRefChannelDataAxis>
+ </ChannelDataItem>
+ <ChannelDataItem DataTypeId="0x1020507E" count="4" IntervalMs="5000">
+ <SsyRefChannelDataAxis XAxis="22" YAxis="49" ZAxis="55" ></SsyRefChannelDataAxis>
+ </ChannelDataItem>
+ </ChannelData>
+ </ChannelItem>
+ </ChannelInformationGroup>
+</SsyReferenceConfig>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,48 @@
+// bld.inf
+
+// Copyright (c) 2006-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:
+//
+
+
+
+PRJ_PLATFORMS
+ DEFAULT
+
+PRJ_EXPORTS
+ ssyreference.iby /epoc32/rom/include/ssyreference.iby
+
+ // Export config to SensorServers private folder.
+ // For emulator use.
+ ../data/ssyreferenceconfig.xml /epoc32/release/winscw/udeb/z/refssy/ssyreferenceconfig.xml
+ ../data/ssyreferenceconfig.xml /epoc32/release/winscw/urel/z/refssy/ssyreferenceconfig.xml
+
+ // For hardware use.
+ ../data/ssyreferenceconfig.xml /epoc32/data/z/refssy/ssyreferenceconfig.xml
+
+#ifdef SYMBIAN_OLD_EXPORT_LOCATION
+ ../inc/ssyreferenceaccelerometer.h /epoc32/include/sensors/channels/ssyreferenceaccelerometer.h
+#endif
+#ifdef SYMBIAN_OLD_EXPORT_LOCATION
+ ../inc/ssyreferencemagnetometer.h /epoc32/include/sensors/channels/ssyreferencemagnetometer.h
+#endif
+#ifdef SYMBIAN_OLD_EXPORT_LOCATION
+ ../inc/ssyreferenceorientation.h /epoc32/include/sensors/channels/ssyreferenceorientation.h
+#endif
+#ifdef SYMBIAN_OLD_EXPORT_LOCATION
+ ../inc/ssyreferenceproximity.h /epoc32/include/sensors/channels/ssyreferenceproximity.h
+#endif
+
+PRJ_MMPFILES
+ ssyreferenceplugin.mmp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/group/ssyreference.iby Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,27 @@
+// ssyreference.iby
+
+// Copyright (c) 2006-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:
+//
+
+
+
+#ifndef SSYREFERENCE_IBY
+#define SSYREFERENCE_IBY
+
+#include <gmxml.iby>
+
+ECOM_PLUGIN(ssyreferenceplugin.dll, ssyreferenceplugin.rsc)
+data=DATAZ_\refssy\ssyreferenceconfig.xml \refssy\ssyreferenceconfig.xml
+#endif // SSYREFERENCE_IBY
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/group/ssyreferenceplugin.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,58 @@
+// ssyreferenceplugin.mmp
+
+// Copyright (c) 2006-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 <sensors/spi/sensrvresource.hrh>
+
+TARGET ssyreferenceplugin.dll
+TARGETTYPE plugin
+VENDORID 0x70000001
+
+// ECom Dll recognition UID followed by the unique UID for this dll
+UID 0x10009D8D 0x10205089
+
+CAPABILITY SENSOR_PLUGIN_CAPABILITIES
+
+SOURCEPATH ../src
+SOURCE ssyreferencechanneldataprovider.cpp
+SOURCE ssyreferencecontrol.cpp
+SOURCE ssyreferencepropertyprovider.cpp
+SOURCE ssyreferencechannel.cpp
+SOURCE ssyreferenceconfig.cpp
+SOURCE ssyreferencecmdhandler.cpp
+SOURCE ecomentrypoint.cpp
+
+USERINCLUDE ../src
+
+SYSTEMINCLUDE /epoc32/include
+SYSTEMINCLUDE /epoc32/include/ecom
+SYSTEMINCLUDE /epoc32/include/sensors
+SYSTEMINCLUDE /epoc32/include/sensors/spi
+SYSTEMINCLUDE /epoc32/include/sensors/channels
+
+// The resource name should have to be same as the third UID above
+START RESOURCE ../src/10205089.rss
+TARGET ssyreferenceplugin.rsc
+END
+
+LIBRARY euser.lib
+LIBRARY ecom.lib
+LIBRARY sensrvutil.lib
+LIBRARY xmlparser.lib // for XML parser
+LIBRARY efsrv.lib
+LIBRARY xmldom.lib
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/group/syslibs_sensors_ssyreference.history.xml Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<relnotes schema="1.0.0" name="Reference SSY">
+ <purpose>
+ Referencey SSY for testing the Sensors Framework.
+ </purpose>
+
+ <deliverystep number="1120" name="PREQ2039: Base Services: Sensor Server (tr2.1.5 Prototype)" osproject="Sphinx" revision="002">
+ <preq number="2039" title="Sensor server">
+ Update to Sensors framework as part of the Core OS 2 project.
+ </preq>
+ <milestone project="GT0461" number="3.2"/>
+ </deliverystep>
+ <deliverystep number="1105" name="PREQ2039: Base Services: Sensor Server (TR2 Prototype)" osproject="Sphinx" revision="001">
+ <preq number="2039" title="Sensor server">
+ Adding Reference SSY to Symbian OS as part of the Core OS 2 project.
+ </preq>
+ <cr number="1603" title="Bring PREQ2039 (Sensor server) into the scope of Sphinx"/>
+ <milestone project="GT0461" number="3.1"/>
+ </deliverystep>
+
+</relnotes>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/group/syslibs_sensors_ssyreference.mrp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,26 @@
+#
+# 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:
+#
+
+component syslibs_sensors_ssyreference
+
+source \sf\mw\appsupport\sensorsupport\testsensor
+
+exports \sf\mw\appsupport\sensorsupport\testsensor\group
+binary \sf\mw\appsupport\sensorsupport\testsensor\group all
+
+notes_source \component_defs\release.src
+
+ipr T
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/inc/ssyreferenceaccelerometer.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,256 @@
+// ssyreferenceaccelerometer.h
+
+/*
+* Copyright (c) 2008-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:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalAll Sensor framework Reference SSY header file
+ @test
+*/
+
+
+#ifndef SSYREFERENCEACCELEROMETER_H
+#define SSYREFERENCEACCELEROMETER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <sensors/sensrvtypes.h>
+
+
+// ACCELEROMETER RELATED CHANNELS
+
+/**
+* - Name: Accelerometer XYZ-axis data channel type
+* - Type: Rawdata
+* - Datatype: TSensrvAccelerometerAxisData
+* - Description: Accelerometer x-, y-, z-axis data
+*/
+const TSensrvChannelTypeId KSensrvChannelTypeIdAccelerometerXYZAxisData = 0x1020507E;
+
+// ACCELEROMETER RELATED PROPERTIES
+
+/**
+* - Name: Axis active
+* - Type: TInt
+* - Scope: Channel item property
+* - Mandatory: No
+* - Capability: None
+* - Description: Indicates is sensor axis activated.
+* Value is one if the axis is activated, zero otherwise.
+*/
+const TSensrvPropertyId KSensrvPropIdAxisActive = 0x00001001;
+
+/**
+* - Name: Axis threshold value
+* - Type: TReal
+* - Scope: Channel item property
+* - Mandatory: No
+* - Capability: None
+* - Description: Threshold value for a sensor channel
+*/
+const TSensrvPropertyId KSensrvPropIdAxisThresholdValue = 0x00001002;
+
+// ACCELEROMETER RELATED DATATYPES
+
+/**
+* Accelerometer axis data type
+*/
+class TSensrvAccelerometerAxisData
+ {
+public:
+ /**
+ * Channel data type Id number
+ */
+ static const TSensrvChannelDataTypeId KDataTypeId = 0x1020507E;
+
+ /**
+ * Channel data type index numbers
+ */
+ enum TSensrvAccelerometerAxisDataIndexes
+ {
+ ETimeStamp = 0,
+ EAxisX,
+ EAxisY,
+ EAxisZ
+ };
+
+public:
+ /**
+ * - Item name: Sampling time.
+ * - Item Index: 0
+ * - Conditions: None
+ * - Description: Timestamp for a sample.
+ */
+ TTime iTimeStamp;
+
+ /**
+ * - Item name: Accelerometer x-axis
+ * - Item Index: 1
+ * - Conditions: Single limit and range
+ * - Description: Accelerometer values from x-axis
+ */
+ TInt iAxisX;
+
+ /**
+ * - Item name: Accelerometer y-axis
+ * - Item Index: 2
+ * - Conditions: Single limit and range
+ * - Description: Accelerometer values from y-axis
+ */
+ TInt iAxisY;
+
+ /**
+ * - Item name: Accelerometer z-axis
+ * - Item Index: 3
+ * - Conditions: Single limit and range
+ * - Description: Accelerometer values from z-axis
+ */
+ TInt iAxisZ;
+ };
+
+
+// TAPPING RELATED CHANNELS
+
+/**
+* - Name: Wakeup event channel type
+* - Type: Event
+* - Datatype: TSensrvTappingData
+* - Description: Wakeup events
+*/
+const TSensrvChannelTypeId KSensrvChannelTypeIdAccelerometerWakeupData = 0x1020507F;
+
+/**
+* - Name: Double tapping event channel type
+* - Type: Event
+* - Datatype: TSensrvTappingData
+* - Description: Double tapping events
+*/
+const TSensrvChannelTypeId KSensrvChannelTypeIdAccelerometerDoubleTappingData = 0x10205081;
+
+// TAPPING RELATED PROPERTIES
+
+/**
+* - Name: Tapping axis active
+* - Type: TInt
+* - Scope: Channel item property
+* - Mandatory: No
+* - Capability: None
+* - Description: Indicates is sensor axis activated.
+* Value is one if the axis is activated, zero otherwise.
+*/
+const TSensrvPropertyId KSensrvPropIdTappingAxisActive = 0x00001001;
+
+/**
+* - Name: Tapping axis threshold value
+* - Type: TReal
+* - Scope: Channel item property
+* - Mandatory: No
+* - Capability: None
+* - Description: Threshold value for a sensor channel
+*/
+const TSensrvPropertyId KSensrvPropIdTappingAxisThresholdValue = 0x00001002;
+
+/**
+* - Name: Tap duration in milliseconds
+* - Type: TInt
+* - Scope: Channel property
+* - Mandatory: No
+* - Capability: None
+* - Description: Tapping duration setting
+*/
+const TSensrvPropertyId KSensrvPropIdTapDurationValue = 0x00001003;
+
+/**
+* - Name: Double tap latency
+* - Type: TInt
+* - Scope: Channel property
+* - Mandatory: No
+* - Capability: None
+* - Description: Double tap latency in milliseconds
+*/
+const TSensrvPropertyId KSensrvPropIdDblTapLatency = 0x00001004;
+
+/**
+* - Name: Double tap interval
+* - Type: TInt
+* - Scope: Channel property
+* - Mandatory: No
+* - Capability: None
+* - Description: Double tap interval in milliseconds
+*/
+const TSensrvPropertyId KSensrvPropIdDblTapInterval = 0x00001005;
+
+
+
+// TAPPING RELATED DATATYPES
+
+/**
+* Direction of the tapping data. If direction (plus or minus) is not known,
+* direction is, for example in x-axis case
+* KSensrvAccelerometerDirectionXplus | KSensrvAccelerometerDirectionXminus
+*/
+const TUint8 KSensrvAccelerometerDirectionXplus = 0x01;
+const TUint8 KSensrvAccelerometerDirectionXminus = 0x02;
+const TUint8 KSensrvAccelerometerDirectionYplus = 0x04;
+const TUint8 KSensrvAccelerometerDirectionYminus = 0x08;
+const TUint8 KSensrvAccelerometerDirectionZplus = 0x10;
+const TUint8 KSensrvAccelerometerDirectionZminus = 0x20;
+
+/**
+* Tapping data type
+*/
+class TSensrvTappingData
+ {
+public:
+ /**
+ * Channel data type Id number
+ */
+ static const TSensrvChannelDataTypeId KDataTypeId = 0x1020507F;
+
+ /**
+ * Channel data type index numbers
+ */
+ enum TSensrvAccelerometerAxisDataIndexes
+ {
+ ETimeStamp = 0,
+ EDirection
+ };
+
+public:
+ /**
+ * - Item name: Sampling time.
+ * - Item Index: 0
+ * - Conditions: None
+ * - Description: Timestamp for a sample.
+ */
+ TTime iTimeStamp;
+
+ /**
+ * - Item name: Tapping direction bitmask
+ * - Item Index: 1
+ * - Conditions: Binary
+ * - Description: Direction bitmask of the tapping event.
+ * See constant definitions above.
+ */
+ TUint32 iDirection;
+ };
+
+#endif //SSYREFERENCEACCELEROMETER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/inc/ssyreferencemagnetometer.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,170 @@
+// ssyreferencemagnetometer.h
+
+/*
+* Copyright (c) 2008-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:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalAll Sensor framework Reference SSY header file
+ @test
+*/
+
+
+#ifndef SSYREFERENCEMAGNETOMETER_H
+#define SSYREFERENCEMAGNETOMETER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <sensors/sensrvtypes.h>
+
+
+// MAGNETOMETER RELATED CHANNELS
+
+/**
+* - Name: Magnetometer XYZ-axis data channel type
+* - Type: Rawdata
+* - Datatype: TSensrvMagnetometerAxisData
+* - Description: Magnetometer x-, y-, z-axis data
+*/
+const TSensrvChannelTypeId KSensrvChannelTypeIdMagnetometerXYZAxisData = 0x2000BEE0;
+
+
+// MAGNETOMETER RELATED PROPERTIES
+
+/**
+* - Name: Name of the property
+* - Type: Defines type of the property (TInt/TReal/TBuf)
+* - Scope: Defines a property scope. Property can be defined for a channel,
+* for a specific item in a channel or for a server related to
+* channel.
+* - Mandatory: Defines is property mandatory
+* - Capability: Capabilities needed to set this property
+* - Description: Description of the property
+*/
+
+/**
+* - Name: Auto calibration active
+* - Type: TInt
+* - Scope: Channel item property
+* - Mandatory: No
+* - Capability: None
+* - Description: Indicates is auto calibration active.
+* Value is one if calibration is activated, zero otherwise.
+*/
+const TSensrvPropertyId KSensrvPropAutoCalibrationActive = 0x00001006;
+
+/**
+* - Name: Calibration status
+* - Type: TInt
+* - Scope: Channel item property
+* - Mandatory: No
+* - Capability: None
+* - Description: Indicates the calibration level.
+* Calibration level scales between minimum and maximum value.
+* Maximum indicates that calibration level is at its best
+* level. Minimum indicates that calibration is undefined.
+*/
+const TSensrvPropertyId KSensrvPropCalibrationLevel = 0x00001007;
+
+// MAGNETOMETER RELATED DATATYPES
+
+/**
+* Magnetometer axis data type
+*/
+class TSensrvMagnetometerAxisData
+ {
+public:
+ /**
+ * Channel data type Id number
+ */
+ static const TSensrvChannelDataTypeId KDataTypeId = 0x2000BEE0;
+
+ /**
+ * Channel data type index numbers
+ */
+ enum TSensrvMagnetometerAxisDataIndexes
+ {
+ ETimeStamp = 0,
+ EAxisX,
+ EAxisY,
+ EAxisZ
+ };
+
+public:
+
+ /**
+ * - Item name: Sampling time.
+ * - Item Index: 0
+ * - Conditions: None
+ * - Description: Timestamp for a sample.
+ */
+ TTime iTimeStamp;
+
+ /**
+ * - Item name: Magnetometer x-axis
+ * - Item Index: 1
+ * - Conditions: Single limit and range
+ * - Description: Magnetometer values from x-axis
+ */
+ TInt iAxisXRaw;
+
+ /**
+ * - Item name: Magnetometer y-axis
+ * - Item Index: 2
+ * - Conditions: Single limit and range
+ * - Description: Magnetometer values from y-axis
+ */
+ TInt iAxisYRaw;
+
+ /**
+ * - Item name: Magnetometer z-axis
+ * - Item Index: 3
+ * - Conditions: Single limit and range
+ * - Description: Magnetometer values from z-axis
+ */
+ TInt iAxisZRaw;
+
+ /**
+ * - Item name: Magnetometer x-axis
+ * - Item Index: 1
+ * - Conditions: Single limit and range
+ * - Description: Magnetometer values from x-axis
+ */
+ TInt iAxisXCalibrated;
+
+ /**
+ * - Item name: Magnetometer y-axis
+ * - Item Index: 2
+ * - Conditions: Single limit and range
+ * - Description: Magnetometer values from y-axis
+ */
+ TInt iAxisYCalibrated;
+
+ /**
+ * - Item name: Magnetometer z-axis
+ * - Item Index: 3
+ * - Conditions: Single limit and range
+ * - Description: Magnetometer values from z-axis
+ */
+ TInt iAxisZCalibrated;
+ };
+
+#endif //SSYREFERENCEMAGNETOMETER_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/inc/ssyreferenceorientation.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,172 @@
+// ssyreferenceorientation.h
+
+/*
+* Copyright (c) 2008-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:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalAll Sensor framework Reference SSY header file
+ @test
+*/
+
+
+#ifndef SSYREFERENCEORIENTATION_H
+#define SSYREFERENCEORIENTATION_H
+
+// INCLUDES
+#include <e32base.h>
+#include <sensors/sensrvtypes.h>
+
+
+// ORIENTATION RELATED CHANNELS
+
+/**
+* - Name: Orientation event channel type
+* - Type: Event
+* - Datatype: TSensrvOrientationData
+* - Description: Orientation events
+*/
+const TSensrvChannelTypeId KSensrvChannelTypeIdOrientationData = 0x10205088;
+
+/**
+* - Name: Rotation event channel type
+* - Type: Event
+* - Datatype: TSensrvRotationData
+* - Description: Rotation events
+*/
+const TSensrvChannelTypeId KSensrvChannelTypeIdRotationData = 0x10205089;
+
+// ORIENTATION RELATED DATATYPES
+
+class TSensrvOrientationData
+ {
+public:
+ /**
+ * Channel data type Id number
+ */
+ static const TSensrvChannelDataTypeId KDataTypeId = 0x10205088;
+
+ /**
+ * Channel data type index numbers
+ */
+ enum TSensrvOrientationEventIndexes
+ {
+ ETimeStamp = 0,
+ EDeviceOrientation
+ };
+
+ /**
+ * Possible device orientations
+ */
+ enum TSensrvDeviceOrientation
+ {
+ EOrientationUndefined = 0,
+ EOrientationDisplayUp,
+ EOrientationDisplayDown,
+ EOrientationDisplayLeftUp,
+ EOrientationDisplayRightUp,
+ EOrientationDisplayUpwards,
+ EOrientationDisplayDownwards
+ };
+
+public:
+
+ /**
+ * - Item name: Sampling time
+ * - Item Index: 0
+ * - Description: Timestamp for a sample
+ */
+ TTime iTimeStamp;
+
+ /**
+ * - Item name: Device orientation
+ * - Item Index: 1
+ * - Description: Contains one of the six basic orientations of the device
+ */
+ TSensrvDeviceOrientation iDeviceOrientation;
+ };
+
+
+class TSensrvRotationData
+ {
+public:
+ /**
+ * Channel data type Id number
+ */
+ static const TSensrvChannelDataTypeId KDataTypeId = 0x10205089;
+
+ /**
+ * Rotation axis value equals -1 when it cannot be defined.
+ * The undefined situation varies depending on the sensor type.
+ * In the case of an accelerometer, the rotation value cannot be defined
+ * when the corresponding axis is parallel to the gravitational force or
+ * the device is in motion. In the case of a magnetometer, there are
+ * difficulties in measuring values, when the axis is parallel to the
+ * magnetic field.
+ */
+ static const TInt KSensrvRotationUndefined = -1;
+
+ /**
+ * Channel data type index numbers
+ */
+ enum TSensrvRotationDataIndexes
+ {
+ ETimeStamp = 0,
+ EDeviceRotationAboutXAxis,
+ EDeviceRotationAboutYAxis,
+ EDeviceRotationAboutZAxis,
+ };
+
+public:
+ /**
+ * - Item name: Sampling time.
+ * - Item Index: 0
+ * - Description: Timestamp for a sample
+ */
+ TTime iTimeStamp;
+
+ /**
+ * - Item name: Rotation about x-axis
+ * - Item Index: 1
+ * - Description: Positive rotation in Cartesian coordinate system about the x-axis.
+ * If the value cannot be defined it is set to KSensrvRotationUndefined.
+ */
+ TInt iDeviceRotationAboutXAxis;
+
+ /**
+ * - Item name: Rotation about y-axis
+ * - Item Index: 2
+ * - Description: Positive rotation in Cartesian coordinate system about the y-axis.
+ * If the value cannot be defined it is set to KSensrvRotationUndefined.
+ */
+ TInt iDeviceRotationAboutYAxis;
+
+
+ /**
+ * - Item name: Rotation about z-axis
+ * - Item Index: 3
+ * - Description: Positive rotation in Cartesian coordinate system about the z-axis.
+ * If the value cannot be defined it is set to KSensrvRotationUndefined.
+ */
+ TInt iDeviceRotationAboutZAxis;
+ };
+
+#endif //SSYREFERENCEORIENTATION_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/inc/ssyreferenceproximity.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,101 @@
+// ssyreferenceproximity.h
+
+/*
+* Copyright (c) 2008-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:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalAll Sensor framework Reference SSY header file
+ @test
+*/
+
+
+#ifndef SSYREFERENCEPROXIMITY_H
+#define SSYREFERENCEPROXIMITY_H
+
+// INCLUDES
+#include <e32base.h>
+#include <sensors/sensrvtypes.h>
+
+
+// PROXIMITY RELATED CHANNELS
+
+/**
+* - Name: Proximity data channel
+* - Type: Event
+* - Datatype: TSensrvProximityMonitorData
+* - Description: Proximity status
+*/
+const TSensrvChannelTypeId KSensrvChannelTypeIdProximityMonitor = 0x2000E585;
+
+// PROXIMITY RELATED DATATYPES
+
+/**
+* Proximity monitoring data type
+*/
+class TSensrvProximityData
+ {
+public:
+ /**
+ * Channel data type Id number
+ */
+ static const TSensrvChannelDataTypeId KDataTypeId = 0x2000E585;
+
+ /**
+ * Channel data type index numbers
+ */
+ enum TSensrvProximityDataIndexes
+ {
+ ETimeStamp = 0,
+ EState
+ };
+
+ /**
+ * Possible values for proximito state
+ */
+ enum TProximityState
+ {
+ EProximityUndefined = 0,
+ EProximityIndiscernible,
+ EProximityDiscernible
+ };
+
+public:
+
+ /**
+ * - Item name: Sampling time.
+ * - Item Index: 0
+ * - Conditions: None
+ * - Description: Timestamp for a sample.
+ */
+ TTime iTimeStamp;
+
+ /**
+ * - Item name: Proximity state
+ * - Item Index: 0
+ * - Conditions: None
+ * - Description: -
+ */
+ TProximityState iProximityState;
+
+};
+
+#endif //SSYREFERENCEPROXIMITY_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/10205089.rss Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,80 @@
+// 10205089.rss
+
+// Copyright (c) 2006-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 <sensors/spi/sensrvresource.hrh>
+#include <ecom/registryinfov2.rh>
+
+// RESOURCE DEFINITIONS
+// -----------------------------------------------------------------------------
+//
+// Declares info for SSYReference ECom plugin
+//
+// -----------------------------------------------------------------------------
+
+RESOURCE REGISTRY_INFO SSYReferencePlugin
+ {
+ // UID for the DLL. See ssyreferenceplugin.mmp
+ resource_format_version = RESOURCE_FORMAT_VERSION_2;
+ dll_uid = 0x10205089;
+ interfaces =
+ {
+ INTERFACE_INFO
+ {
+ // UID of interface that is implemented
+ interface_uid = KSsyControlInterfaceUid;
+ implementations =
+ {
+ BINARY_IMPLEMENTATION_INFO
+ {
+ implementation_uid = 0x10205088;
+ version_no = 1;
+ display_name = "SSYReferencePlugin";
+ default_data = {
+ // Double tap channel
+ 0x01, // ChannelInfoVersion
+ 0x2E, // ChannelInfoLength
+ 0x1E, // Flags
+ 0x81, 0x50, 0x20, 0x10, // ChannelType
+ 0x02, 0x00, 0x00, 0x00, // ContextType
+ 0x0B, 0x00, 0x00, 0x00, // Quantity
+ 0x05, 0x4e, 0x6f, 0x4c, 0x6f, 0x63, // Location: NoLoc
+ 0x0C, 0x53, 0x73, 0x79, 0x52, 0x65, 0x66, 0x56, 0x65, 0x6E, 0x64, 0x6F, 0x72, // VendorId: SsyRefVendor
+ 0x7F, 0x50, 0x20, 0x10, // ChannelDataTypeId
+ 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // ChannelSecurityPolicy
+
+ // Accelerometer channel
+ 0x01, // ChannelInfoVersion
+ 0x30, // ChannelInfoLength
+ 0x1E, // Flags
+ 0x7E, 0x50, 0x20, 0x10, // ChannelType
+ 0x02, 0x00, 0x00, 0x00, // ContextType
+ 0x0A, 0x00, 0x00, 0x00, // Quantity
+ 0x07, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x25, 0x64, // Location
+ 0x0C, 0x53, 0x73, 0x79, 0x52, 0x65, 0x66, 0x56, 0x65, 0x6E, 0x64, 0x6F, 0x72, // VendorId: SsyRefVendor
+ 0x7E, 0x50, 0x20, 0x10, // ChannelDataTypeId
+ 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF // ChannelSecurityPolicy
+
+ };
+ opaque_data = {};
+ }
+ };
+ }
+ };
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ecomentrypoint.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,40 @@
+// ecomentrypoint.cpp
+
+// Copyright (c) 2006-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 FILES
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+#include "ssyreferencecontrol.h"
+
+// Define the interface UIDs
+const TImplementationProxy ImplementationTable[] =
+ {
+ IMPLEMENTATION_PROXY_ENTRY( 0x10205088,
+ CSsyReferenceControl::NewL )
+ };
+
+// The one and only exported function that is the ECom entry point
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy
+ (TInt& aTableCount)
+ {
+ aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+
+ return ImplementationTable;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencechannel.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,443 @@
+// ssyreferencechannel.cpp
+
+// Copyright (c) 2006-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 <sensors/spi/ssycallback.h> // MSsyCallback
+#include "ssyreferencechannel.h"
+#include "ssyreferencecontrol.h" // SSY Control
+#include "ssyreferencepropertyprovider.h" // iChannelPropertyProvider
+#include "ssyreferencechanneldataprovider.h" // iChannelDataProvider
+#include "ssyreferencetrace.h"
+#include "ssyreferencecmdhandler.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel C++ constructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceChannel::CSsyReferenceChannel( CSsyReferenceControl& aSsyControl, TSensrvChannelInfo aChannelInfo ) :
+ iSsyControl( aSsyControl ),
+ iChannelInfo( aChannelInfo ),
+ iState( ESsyReferenceChannelIdle )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::CSsyReferenceChannel()" ) ) );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::CSsyReferenceChannel() - return" ) ) );
+ }
+
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannel::ConstructL()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ConstructL()" ) ) );
+
+ // Create command handler
+ iCmdHandler = CSsyReferenceCmdHandler::NewL( *this );
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ConstructL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::NewL
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceChannel* CSsyReferenceChannel::NewL( CSsyReferenceControl& aSsyControl, TSensrvChannelInfo aChannelInfo )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::NewL()" ) ) );
+ CSsyReferenceChannel* self = new ( ELeave ) CSsyReferenceChannel( aSsyControl, aChannelInfo );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::NewL() - return" ) ) );
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceChannel::~CSsyReferenceChannel()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::~CSsyReferenceChannel()" ) ) );
+
+ // In case channel is not closed before destruction, providers are not deleted
+ if ( iChannelDataProvider )
+ {
+ delete iChannelDataProvider;
+ iChannelDataProvider = NULL;
+ }
+
+ if ( iChannelPropertyProvider )
+ {
+ delete iChannelPropertyProvider;
+ iChannelPropertyProvider = NULL;
+ }
+
+ if ( iCmdHandler )
+ {
+ delete iCmdHandler;
+ iCmdHandler = NULL;
+ }
+
+ iProperties.Reset();
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::~CSsyReferenceChannel() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::ChannelId
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceChannel::ChannelId()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ChannelId() - %i" ), iChannelInfo.iChannelId ) );
+ return iChannelInfo.iChannelId;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::SsyControl
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceControl& CSsyReferenceChannel::SsyControl() const
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::SsyControl()" ) ) );
+ return iSsyControl;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::SsyCmdHandler
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceCmdHandler& CSsyReferenceChannel::CommandHandler() const
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::SsyCmdHandler()" ) ) );
+ return *iCmdHandler;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::FindPropertyL
+// ---------------------------------------------------------------------------
+//
+TSensrvProperty& CSsyReferenceChannel::FindPropertyL(
+ const TSensrvPropertyId aPropertyId,
+ TInt aItemIndex,
+ TInt aArrayIndex )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::FindPropertyL()" ) ) );
+ TSensrvProperty* property = NULL;
+ TBool propertyFound( EFalse );
+
+ // Search property
+ for ( TInt i = 0; i < iProperties.Count() && !propertyFound; i++ )
+ {
+ property = static_cast<TSensrvProperty*>( &iProperties[i] );
+
+ // Compare property IDs and array index
+ if ( property->GetPropertyId() == aPropertyId )
+ {
+ // Compare item index if it is given
+ if ( ( KErrNotFound == aItemIndex ) || ( property->PropertyItemIndex() == aItemIndex ) )
+ {
+ // Correct property ID is found, now check is it array type of property.
+ // Either array indexes must match or propertys array index has to be array info
+ if ( ( property->GetArrayIndex() == aArrayIndex ) ||
+ ( ( property->GetArrayIndex() == ESensrvArrayPropertyInfo ) &&
+ ( ESensrvSingleProperty == aArrayIndex ) ) )
+ {
+ // Correct array index found
+ propertyFound = ETrue;
+ }
+ }
+ }
+ }
+
+ // Leave if not found
+ if ( !propertyFound )
+ {
+ iSsyControl.FindPropertyL( aPropertyId, aArrayIndex, *property );
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::FindPropertyL() - return" ) ) );
+ return *property;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::FindAndUpdatePropertyL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannel::FindAndUpdatePropertyL( const TSensrvProperty& aProperty )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::FindAndUpdatePropertyL()" ) ) );
+ TBool propertyFound( EFalse );
+
+ // Search property
+ for ( TInt i = 0; i < iProperties.Count() && !propertyFound; i++ )
+ {
+ // Compare property IDs
+ if ( iProperties[i].GetPropertyId() == aProperty.GetPropertyId() )
+ {
+ // Compare item index if it is given
+ if ( ( KErrNotFound != aProperty.PropertyItemIndex() ) &&
+ ( iProperties[i].PropertyItemIndex() == aProperty.PropertyItemIndex() ) )
+ {
+ // Property found -> update if possible
+ if ( iProperties[i].ReadOnly() )
+ {
+ User::Leave( KErrAccessDenied );
+ }
+ // If modifiable, get type and update value
+ switch ( iProperties[i].PropertyType() )
+ {
+ case ESensrvIntProperty:
+ {
+ TInt value( 0 );
+ aProperty.GetValue( value );
+ iProperties[i].SetValue( value );
+ break;
+ }
+ case ESensrvRealProperty:
+ {
+ TReal value( 0 );
+ aProperty.GetValue( value );
+ iProperties[i].SetValue( (TReal) value );
+ break;
+ }
+ case ESensrvBufferProperty:
+ {
+ TBuf8<20> propValue;
+ aProperty.GetValue( propValue );
+ iProperties[i].SetValue( propValue );
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ propertyFound = ETrue;
+ }
+ }
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::FindPropertyL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::GetProperties
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannel::GetProperties( RSensrvPropertyList& aPropertyList )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::GetProperties()" ) ) );
+ // Copy properties one by one to param aPropertyList
+ TInt propCount( iProperties.Count() );
+ RSensrvPropertyList propList( propCount );
+
+ for ( TInt i = 0; i < propCount; i++ )
+ {
+ propList.Append( iProperties[i] );
+ }
+
+ aPropertyList = propList;
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::GetProperties() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::UpdateState
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannel::UpdateState( const TSsyReferenceChannelState aNewState )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::UpdateState() - %i" ), aNewState ) );
+ iState = aNewState;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::ProcessResponse
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannel::ProcessResponse( TSsyReferenceMsg* aMessage )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ProcessResponse()" ) ) );
+
+ if ( aMessage )
+ {
+ switch ( aMessage->Function() )
+ {
+ case ESsyReferenceOpenChannelResp:
+ {
+ // Open channel specific handling here
+ TRAPD( err, HandleOpenChannelRespL( aMessage->Error() ) );
+ if ( KErrNone != err )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ProcessResponse() - Error opening channel: %i" ), err ) );
+ }
+ break;
+ }
+ case ESsyReferenceDataItemReceived:
+ {
+ // Send data item to data provider
+ TRAPD( err, iChannelDataProvider->ChannelDataReceivedL( aMessage ) );
+ if ( KErrNone != err )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ProcessResponse() - Error receiving data: %i" ), err ) );
+ }
+ break;
+ }
+ case ESsyReferenceCloseChannelResp:
+ {
+ // Close channel specific handling here
+ HandleCloseChannelResp();
+ break;
+ }
+ default:
+ {
+ // This command was not intended to process here, try Control class
+ iSsyControl.ProcessResponse( aMessage );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ProcessResponse() - Unknown function" ) ) );
+ }
+ }
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::ProcessResponse() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::OpenChannel
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceChannel::OpenChannel()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::OpenChannel()" ) ) );
+
+ TInt err( KErrAlreadyExists );
+
+ // Check that this channel is not already open
+ if ( ESsyReferenceChannelIdle == iState )
+ {
+ // Update state and issue request. Will continue in HandleOpenChannelResp
+ UpdateState( ESsyReferenceChannelOpening );
+
+ // Create message with function spesific information
+ // and pass it to command handler
+ err = iCmdHandler->ProcessCommand( TSsyReferenceMsg( ChannelId(), ESsyReferenceOpenChannel ) );
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::OpenChannel() - return" ) ) );
+ return err;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::HandleOpenChannelResp
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannel::HandleOpenChannelRespL( const TInt aError )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::HandleOpenChannelResp()" ) ) );
+
+ // Open channel asynhronously and complete request with MSsyCallback::ChannelOpened() when
+ // channel is opened.
+
+ // Create instance of the data provider of this channel
+ iChannelDataProvider = CSsyReferenceChannelDataProvider::NewL( *this );
+ // Create instance of the property provider of this channel
+ iChannelPropertyProvider = CSsyReferencePropertyProvider::NewL( *this );
+
+ TInt error( aError );
+
+ // If channel opening succeeds, update state to Open
+ if ( KErrNone == aError )
+ {
+ // Update state to Open
+ UpdateState( ESsyReferenceChannelOpen );
+ // Get channel properties
+ TRAP( error, iSsyControl.SsyConfig().GetChannelPropertiesL( ChannelId(), iProperties ) );
+ }
+ else
+ {
+ // Channel opening failed, back to idle
+ UpdateState( ESsyReferenceChannelIdle );
+ }
+
+ // Complete transaction
+ iSsyControl.SsyCallback().ChannelOpened( ChannelId(),
+ error,
+ iChannelDataProvider,
+ iChannelPropertyProvider );
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::HandleOpenChannelResp() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::CloseChannel
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceChannel::CloseChannel()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::CloseChannel()" ) ) );
+
+ TInt err( KErrNotFound );
+
+ // Check that this channel is open
+ if ( ESsyReferenceChannelOpen == iState )
+ {
+ // Update state and issue request. Will continue in HandleCloseChannelResp
+ UpdateState( ESsyReferenceChannelClosing );
+ // Create message with function spesific information
+ // and pass it to command handler
+ err = iCmdHandler->ProcessCommand( TSsyReferenceMsg( ChannelId(), ESsyReferenceCloseChannel ) );
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::CloseChannel() - return" ) ) );
+ return err;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannel::HandleCloseChannelResp
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannel::HandleCloseChannelResp()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::HandleCloseChannelResp()" ) ) );
+
+ // Close channel and complete request with MSsyCallback::ChannelClosed() when
+ // channel is closed.
+
+ // Delete providers
+ delete iChannelDataProvider;
+ iChannelDataProvider = NULL;
+
+ delete iChannelPropertyProvider;
+ iChannelPropertyProvider = NULL;
+
+ // Update state to idle
+ UpdateState( ESsyReferenceChannelIdle );
+
+ // Reset properties
+ iProperties.Reset();
+
+ // Complete transaction
+ iSsyControl.SsyCallback().ChannelClosed( ChannelId() );
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannel::HandleCloseChannelResp() - return" ) ) );
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencechannel.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,228 @@
+// ssyreferencechannel.h
+
+/*
+* Copyright (c) 2006-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:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef SSYREFERENCECHANNEL_H
+#define SSYREFERENCECHANNEL_H
+
+#include <e32base.h>
+#include <sensors/sensrvtypes.h>
+#include "ssyreferenceconfig.h"
+
+class CSsyReferenceControl;
+class CSsyReferenceChannelDataProvider;
+class CSsyReferencePropertyProvider;
+class CSsyReferenceCmdHandler;
+
+/**
+ * Main control class for SSY. Controls sensor basic functionality and provides mandatory
+ * ECOM interface specific things.
+ */
+class CSsyReferenceChannel : public CBase
+ {
+
+public:
+
+ /**
+ * Enumeration of the state of this channel
+ */
+ enum TSsyReferenceChannelState
+ {
+ ESsyReferenceChannelIdle, // Channel created, not opened
+ ESsyReferenceChannelOpening, // Processing channel opening
+ ESsyReferenceChannelOpen, // Channel is open
+ ESsyReferenceChannelReceiving, // Channel is receiving data
+ ESsyReferenceChannelClosing // Processing channel closing. After this state is idle
+ };
+
+public:
+
+ /**
+ * Two-phase constructor
+ *
+ * @param[in] aSsyControl Reference to SSY control instance.
+ * @param[in] aChannelInfo Information of this channel
+ * @return Pointer to created CSsyReferenceControl object
+ */
+ static CSsyReferenceChannel* NewL( CSsyReferenceControl& aSsyControl, TSensrvChannelInfo aChannelInfo );
+
+ /**
+ * Virtual destructor
+ */
+ virtual ~CSsyReferenceChannel();
+
+ /**
+ * Request for SSY to open a sensor channel asynchronously.
+ * Response to the request is delivered through MSsyCallback::ChannelOpened().
+ * Initilizes SSY (and the sensor) to be ready for other control commands via
+ * data and property providers. Multiple OpenChannel()-requests can be
+ * active for different channels at the same time.
+ *
+ * @return Symbian error code
+ */
+ TInt OpenChannel();
+
+ /**
+ * Request to close a sensor channel asynchronously.
+ * Response to the request is delivered through MSsyCallback::ChannelClosed().
+ * Multiple CloseChannel()-requests can be active for different channels
+ * at the same time.
+ *
+ * @return Symbian error code
+ */
+ TInt CloseChannel();
+
+ /**
+ * Returns ID of this channel
+ */
+ TInt ChannelId();
+
+ /**
+ * Handles response directed to this channel
+ *
+ * @param[in] aMessage Contains information of the response
+ */
+ void ProcessResponse( TSsyReferenceMsg* aMessage );
+
+ /**
+ * Updates the state of this channel
+ *
+ * @param[in] aNewState State to update this channel
+ */
+ void UpdateState( const TSsyReferenceChannelState aNewState );
+
+ /**
+ * Reference to SsyControl
+ */
+ CSsyReferenceControl& SsyControl() const;
+
+ /**
+ * Reference to command handler
+ */
+ CSsyReferenceCmdHandler& CommandHandler() const;
+
+ /**
+ * Search property of given property id from the channel properties and
+ * returns reference to that. Leaves with KErrNotFound if property is not found
+ *
+ * @param[in] aPropertyId Property ID to locate
+ * @param[in] aItemIndex Item index if this search conserns specific property
+ * @param[in] aArrayIndex Indicates array index of property
+ */
+ TSensrvProperty& FindPropertyL( const TSensrvPropertyId aPropertyId,
+ TInt aItemIndex = KErrNotFound,
+ TInt aArrayIndex = ESensrvSingleProperty );
+
+ /**
+ * Search property of given property id from the channel properties and
+ * update property values, if not read only
+ *
+ * @param[in] aProperty Property to find and update
+ */
+ void FindAndUpdatePropertyL( const TSensrvProperty& aProperty );
+
+
+ /**
+ * Copies properties to param PropertyList
+ *
+ * @param[in, out] aPropertyList List where to copy properties
+ */
+ void GetProperties( RSensrvPropertyList& aPropertyList );
+
+private:
+
+ /**
+ * C++ constructor.
+ *
+ * @param[in] aSsyControl Reference to SSY Control instance.
+ * @param[in] aChannelInfo Information of this channel
+ */
+ CSsyReferenceChannel( CSsyReferenceControl& aSsyControl, TSensrvChannelInfo aChannelInfo );
+
+ /**
+ * Symbian 2nd phase constructor.
+ */
+ void ConstructL();
+
+ /**
+ * Handles response for OpenChannel and completes transaction by calling
+ * MSsyCallback::ChannelOpened
+ *
+ * @param[in] aError Error code indicating the channel opening status
+ */
+ void HandleOpenChannelRespL( const TInt aError );
+
+ /**
+ * Handles response for CloseChannel and completes transaction by calling
+ * MSsyCallback::ChannelClosed
+ */
+ void HandleCloseChannelResp();
+
+ /**
+ * Handles response for StartChannelData. Loops all channel data items and sends
+ * each item to ChannelDataProvider
+ */
+ void HandleDataReceivedResp();
+
+private: // data
+
+ /**
+ * Reference to SSY Control to send responses to Sensor Server
+ */
+ CSsyReferenceControl& iSsyControl;
+
+ /**
+ * Pointer to CSsyReferenceChannelDataProvider owned by this channel
+ */
+ CSsyReferenceChannelDataProvider* iChannelDataProvider;
+
+ /**
+ * Pointer to CSsyReferencePropertyProvider owned by this channel
+ */
+ CSsyReferencePropertyProvider* iChannelPropertyProvider;
+
+ /**
+ * Pointer to command handler
+ */
+ CSsyReferenceCmdHandler* iCmdHandler;
+
+ /**
+ * Information of this channel
+ */
+ TSensrvChannelInfo iChannelInfo;
+
+ /**
+ * State of this channel. See CSsyReferenceChannel::TSsyReferenceChannelState
+ */
+ TInt iState;
+
+ /**
+ * Property list of this channel
+ */
+ RSensrvPropertyList iProperties;
+ };
+
+#endif // SSYREFERENCECHANNEL_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencechanneldataprovider.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,269 @@
+// ssyreferencechanneldataprovider.cpp
+
+// Copyright (c) 2006-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 "ssyreferencechanneldataprovider.h"
+#include "ssyreferencetrace.h"
+#include "ssyreferencechannel.h"
+#include "ssyreferencecontrol.h"
+#include "ssyreferencecmdhandler.h"
+#include <sensors/spi/ssycallback.h>
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider C++ constructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceChannelDataProvider::CSsyReferenceChannelDataProvider( CSsyReferenceChannel& aChannel ) :
+ iChannel( aChannel )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::CSsyReferenceChannelDataProvider()" ) ) );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::CSsyReferenceChannelDataProvider() - return" ) ) );
+ }
+
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::ConstructL()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::ConstructL()" ) ) );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::ConstructL() - return" ) ) );
+ }
+
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider::NewL
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceChannelDataProvider* CSsyReferenceChannelDataProvider::NewL( CSsyReferenceChannel& aChannel )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::NewL()" ) ) );
+ CSsyReferenceChannelDataProvider* self = new ( ELeave ) CSsyReferenceChannelDataProvider( aChannel );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::NewL() - return" ) ) );
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceChannelDataProvider::~CSsyReferenceChannelDataProvider()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::~CSsyReferenceChannelDataProvider()" ) ) );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::~CSsyReferenceChannelDataProvider() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider::StartChannelDataL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::StartChannelDataL(
+ const TSensrvChannelId aChannelId,
+ TUint8* aBuffer,
+ TInt aCount )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::StartChannelDataL()" ) ) );
+
+ if ( iChannel.ChannelId() != aChannelId )
+ {
+ User::Leave( KErrNotFound );
+ }
+
+ // Store buffer pointer
+ iDataBuffer = aBuffer;
+ iMaxCount = aCount;
+ iDataCount = 0;
+
+ // Udpate channel state
+ iChannel.UpdateState( CSsyReferenceChannel::ESsyReferenceChannelReceiving );
+
+ // Start receiving
+ iChannel.CommandHandler().ProcessCommand( TSsyReferenceMsg( aChannelId, ESsyReferenceStartChannelData ) );
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::StartChannelDataL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider::StopChannelDataL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::StopChannelDataL( const TSensrvChannelId aChannelId )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::StopChannelDataL()" ) ) );
+
+ // Leave if wrong channel
+ if ( iChannel.ChannelId() != aChannelId )
+ {
+ User::Leave( KErrNotFound );
+ }
+
+ // Udpate channel state
+ iChannel.UpdateState( CSsyReferenceChannel::ESsyReferenceChannelOpen );
+
+ // Stop receiving
+ iChannel.CommandHandler().ProcessCommand( TSsyReferenceMsg( aChannelId, ESsyReferenceStopChannelData ) );
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::StopChannelDataL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider::ForceBufferFilledL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::ForceBufferFilledL( const TSensrvChannelId aChannelId )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::ForceBufferFilledL()" ) ) );
+
+ // Leave if wrong channel
+ if ( iChannel.ChannelId() != aChannelId )
+ {
+ User::Leave( KErrNotFound );
+ }
+
+ // Send current buffer. Channel keeps receiveing
+ SendBufferFilled();
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::ForceBufferFilledL() - return" ) ) );
+ }
+
+// -----------------------------------------------------------------------------
+// CSensrvTestCases::GetChannelDataProviderInterfaceL
+// -----------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::GetChannelDataProviderInterfaceL( TUid /*aInterfaceUid*/,
+ TAny*& aInterface )
+ {
+ aInterface = NULL;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider::ChannelDataReceived
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::ChannelDataReceivedL( TSsyReferenceMsg* aMessage )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::ChannelDataReceived()" ) ) );
+
+ // Get base class from message
+ TSsyRefChannelDataBase* dataItemBase = aMessage->DataItem();
+
+ if ( !dataItemBase )
+ {
+ User::Leave( KErrArgument );
+ }
+
+ // get size of the object
+ TInt size( dataItemBase->Size() );
+
+ // First, resolve data item type
+ switch ( dataItemBase->ChannelDataType() )
+ {
+ case TSsyRefChannelDataBase::ESsyRefChannelTypeTapping:
+ {
+ // Cast data item base to tapping data item
+ TSsyRefChannelDataTapping* tappingData = static_cast<TSsyRefChannelDataTapping*>( dataItemBase );
+ TSensrvTappingData senSrvTapping;
+ senSrvTapping.iTimeStamp = tappingData->Timestamp();
+ senSrvTapping.iDirection = tappingData->Direction();
+
+ // Add mapped data item into buffer
+ AddDataToBuffer( reinterpret_cast<TUint8*>( &senSrvTapping ), size );
+ break;
+ }
+ case TSsyRefChannelDataBase::ESsyRefChannelTypeAxis:
+ {
+ // Cast data item base to Axis data item
+ TSsyRefChannelDataAxis* axisData = static_cast<TSsyRefChannelDataAxis*>( dataItemBase );
+ TSensrvAccelerometerAxisData senSrvAxis;
+ senSrvAxis.iTimeStamp = axisData->Timestamp();
+ senSrvAxis.iAxisX = axisData->XAxis();
+ senSrvAxis.iAxisY = axisData->YAxis();
+ senSrvAxis.iAxisZ = axisData->ZAxis();
+
+ // Add data to buffer
+ AddDataToBuffer( reinterpret_cast<TUint8*>( &senSrvAxis ), size );
+ break;
+ }
+ case TSsyRefChannelDataBase::ESsyRefChannelTypeProximity:
+ {
+ // Cast data item base to tapping data item
+ TSsyRefChannelDataProximity* proximityData = static_cast<TSsyRefChannelDataProximity*>( dataItemBase );
+ TSensrvProximityData senSrvProximity;
+ senSrvProximity.iProximityState = ( TSensrvProximityData::TProximityState ) proximityData->ProximityState();
+
+ // Add mapped data item into buffer
+ AddDataToBuffer( reinterpret_cast<TUint8*>( &senSrvProximity ), size );
+ break;
+ }
+ default:
+ {
+ // Unknown data item -> Leave
+ User::Leave( KErrUnknown );
+ }
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::ChannelDataReceived() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider::AddDataToBuffer
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::AddDataToBuffer( TUint8* aData, const TInt aSize )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::AddDataToBuffer()" ) ) );
+ // Write data to buffer. If buffer is full, send notification to SensorServer
+
+ // Write data bytes one by one to buffer pointer. The actual buffer is in Sensor Server
+ for ( TInt i = 0; i < aSize; i++ )
+ {
+ *iDataBuffer++ = *aData++;
+ }
+
+ // Increase number of items count
+ iDataCount++;
+
+ // Check is maximum data count received
+ if ( iDataCount == iMaxCount )
+ {
+ // Send BufferFilled notification to Sensor server
+ SendBufferFilled();
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::AddDataToBuffer() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceChannelDataProvider::SendBufferFilled
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceChannelDataProvider::SendBufferFilled()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::SendBufferFilled()" ) ) );
+ // Send BufferFilled notification to Sensor server
+ iChannel.SsyControl().SsyCallback().BufferFilled( iChannel.ChannelId(), iDataCount, iDataBuffer, iMaxCount );
+ iDataCount = 0;
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceChannelDataProvider::SendBufferFilled() - return" ) ) );
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencechanneldataprovider.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,149 @@
+// ssyreferencechanneldataprovider.h
+
+/*
+* Copyright (c) 2006-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:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef SSYREFERENCECHANNELDATAPROVIDER_H
+#define SSYREFERENCECHANNELDATAPROVIDER_H
+
+#include <sensors/spi/ssychanneldataprovider.h>
+
+class CSsyReferenceChannel;
+class TSsyReferenceMsg;
+
+/**
+ * Channel data provider implementation.
+ */
+class CSsyReferenceChannelDataProvider : public CBase, public MSsyChannelDataProvider
+ {
+
+public:
+
+ /**
+ * Two-phase constructor
+ *
+ * @param[in] aChannel Reference to channel this provider belongs to
+ * @return Pointer to created CSsyReferenceControl object
+ */
+ static CSsyReferenceChannelDataProvider* NewL( CSsyReferenceChannel& aChannel );
+
+ /**
+ * Virtual destructor
+ */
+ virtual ~CSsyReferenceChannelDataProvider();
+
+// from base class MSsyChannelDataProvider
+
+ /**
+ * From MSsyChannelDataProvider
+ * Starts asynchronous data listening. Multiple OpenChannel()-requests
+ * can be active for different channels at the same time.
+ *
+ * @param[in] aBuffer Pointer to a data buffer
+ * @param[in] aCount Indicates data buffer size as a count of the data objects.
+ */
+ void StartChannelDataL( const TSensrvChannelId aChannelId, TUint8* aBuffer, TInt aCount );
+
+ /**
+ * From MSsyChannelDataProvider
+ * Stops asynchronous data listening. The data buffer is not valid after call of
+ * this function.
+ */
+ void StopChannelDataL( const TSensrvChannelId aChannelId );
+
+ /**
+ * From MSsyChannelDataProvider
+ * Forces SSY to call BufferFilled() regardless of how many data items have been
+ * written to buffer. Even if no data items have yet been written, BufferFilled()
+ * must be called.
+ */
+ void ForceBufferFilledL( const TSensrvChannelId aChannelId );
+
+ /**
+ * Returns a pointer to a specified interface - to allow future extension
+ * of this class without breaking binary compatibility
+ *
+ * @param aInterfaceUid Identifier of the interface to be retrieved
+ * @param aInterface A reference to a pointer that retrieves the specified interface.
+ */
+ void GetChannelDataProviderInterfaceL( TUid aInterfaceUid, TAny*& aInterface );
+
+ /**
+ * Channel data item received
+ *
+ * @param[in] aMessage Contains channel item
+ */
+ void ChannelDataReceivedL( TSsyReferenceMsg* aMessage );
+
+private:
+
+ /**
+ * C++ constructor.
+ * @param[in] aChannel Reference to channel this provider belongs to
+ */
+ CSsyReferenceChannelDataProvider( CSsyReferenceChannel& aChannel );
+
+ /**
+ * Symbian 2nd phase constructor.
+ */
+ void ConstructL();
+
+ /**
+ * Adds data into buffer.
+ *
+ *@param[in] aData Data to add to buffer
+ *@param[in] aSize Size of data
+ */
+ void AddDataToBuffer( TUint8* aData, const TInt aSize );
+
+ /**
+ * Sends BufferFilled notification to MSsyCallback
+ */
+ void SendBufferFilled();
+
+private: // data
+
+ /**
+ * Reference to channel for which this provider belongs to
+ */
+ CSsyReferenceChannel& iChannel;
+
+ /**
+ * Pointer to data buffer in Sensor Server side
+ */
+ TUint8* iDataBuffer;
+
+ /**
+ * Maximum requested data items
+ */
+ TInt iMaxCount;
+
+ /**
+ * Number of items in buffer
+ */
+ TInt iDataCount;
+ };
+
+#endif // SSYREFERENCECHANNELDATAPROVIDER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencecmdhandler.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,367 @@
+// ssyreferencecmdhandler.cpp
+
+// Copyright (c) 2006-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 <e32property.h>
+#include "ssyreferencecmdhandler.h"
+#include "ssyreferencecontrol.h"
+#include "ssyreferencechannel.h"
+#include "ssyreferencetrace.h"
+
+// ======== CONSTANTS ========
+const TInt KSsyRefShortDelay = 100;
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler C++ constructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceCmdHandler::CSsyReferenceCmdHandler( CSsyReferenceChannel& aSsyChannel ) :
+ CActive( EPriorityNormal ),
+ iSsyChannel( aSsyChannel )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::CSsyReferenceCmdHandler()" ) ) );
+ CActiveScheduler::Add( this );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::CSsyReferenceCmdHandler() - return" ) ) );
+ }
+
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceCmdHandler::ConstructL()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::ConstructL()" ) ) );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::ConstructL() - return" ) ) );
+ }
+
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::NewL
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceCmdHandler* CSsyReferenceCmdHandler::NewL( CSsyReferenceChannel& aSsyChannel )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::NewL()" ) ) );
+ CSsyReferenceCmdHandler* self = new ( ELeave ) CSsyReferenceCmdHandler( aSsyChannel );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::NewL() - return" ) ) );
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceCmdHandler::~CSsyReferenceCmdHandler()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::~CSsyReferenceCmdHandler()" ) ) );
+
+ if ( iMessage )
+ {
+ // Send ProcessResponse
+ iMessage->SetError( KErrCancel );
+ iSsyChannel.ProcessResponse( iMessage );
+ delete iMessage;
+ iMessage = NULL;
+ }
+
+ if ( iTimer )
+ {
+ iTimer->Cancel();
+ delete iTimer;
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::~CSsyReferenceCmdHandler() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::ProcessCommand
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceCmdHandler::ProcessCommand( TSsyReferenceMsg aMessage )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::ProcessCommand()" ) ) );
+ TInt err( KErrAlreadyExists );
+
+ // Special case, when channel is reciving, iMessage is not deleted after ProcessCommand
+ if ( aMessage.Function() == ESsyReferenceStopChannelData )
+ {
+ // Stop 'receiving'. No need to handle this asynchronously
+ if ( iTimer )
+ {
+ iTimer->Cancel();
+ delete iTimer;
+ iTimer = NULL;
+ }
+
+ iDataItemArray.Reset();
+ iDataItemPtr = 0;
+ err = KErrNone;
+ // No need to send ProcessResponse either
+ delete iMessage;
+ iMessage = NULL;
+ }
+ else if ( !iMessage )
+ {
+ iMessage = new TSsyReferenceMsg( aMessage );
+ if(iMessage)
+ {
+ switch( aMessage.Function() )
+ {
+ case ESsyReferenceStartChannelData:
+ {
+ // Get channel data items and start 'receiving'
+ IssueRequest();
+ err = KErrNone;
+ break;
+ }
+ case ESsyReferenceOpenChannel:
+ {
+ // Open channel specific handling here
+ IssueRequest();
+ err = KErrNone;
+ break;
+ }
+ case ESsyReferenceCloseChannel:
+ {
+ // Close channel specific handling here
+ IssueRequest();
+ err = KErrNone;
+ break;
+ }
+ default:
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::ProcessCommand() - Unknown function" ) ) );
+ err = KErrNotFound;
+ }
+ }
+ }
+ else
+ {
+ err = KErrNoMemory;
+ }
+ }
+ else
+ {
+ err = KErrUnknown;
+ }
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::ProcessCommand() - return" ) ) );
+ return err;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::IssueRequest
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceCmdHandler::IssueRequest( TInt aError )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::IssueRequest()" ) ) );
+ // Provides synchronous function calls to be handled as asynchronous
+ if ( !IsActive() )
+ {
+ TRequestStatus *s = &iStatus;
+ User::RequestComplete( s, aError );
+ SetActive();
+ }
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::IssueRequest() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::SendResponse
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceCmdHandler::SendResponse( TInt aError )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::SendResponse()" ) ) );
+ // Send response to channel
+ if ( iMessage )
+ {
+ iMessage->SetError( aError );
+ iSsyChannel.ProcessResponse( iMessage );
+ delete iMessage;
+ iMessage = NULL;
+ }
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::SendResponse() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::RunL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceCmdHandler::RunL()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::RunL() - %i" ), iStatus.Int() ) );
+
+ TInt err( iStatus.Int() );
+
+ if ( iMessage )
+ {
+ switch( iMessage->Function() )
+ {
+ case ESsyReferenceStartChannelData:
+ {
+ TInt startInterval( 0 );
+
+ // Get all Channel data information from config file
+ iSsyChannel.SsyControl().SsyConfig().
+ GetChannelDataInformationL( iMessage->ChannelId(), iDataItemArray, startInterval );
+
+ // Check that channel data items were found
+ if ( iDataItemArray.Count() )
+ {
+ // If interval is zero, set small interval
+ if ( startInterval == 0 )
+ {
+ startInterval = KSsyRefShortDelay;
+ }
+
+ // wait that interval
+ if ( iTimer )
+ {
+ iTimer->Cancel();
+ delete iTimer;
+ iTimer = NULL;
+ }
+
+ // Reset pointer
+ iDataItemPtr = 0;
+
+ // Start timer and continue processing in callback function
+ iTimer = CPeriodic::NewL( EPriorityNormal );
+ iTimer->Start( startInterval * 1000, 0, TCallBack( DataItemCallback, this ) );
+ }
+ break;
+ }
+ case ESsyReferenceOpenChannel:
+ {
+ // Open channel response specific handling here
+ iMessage->SetFunction( ESsyReferenceOpenChannelResp );
+ SendResponse();
+ break;
+ }
+ case ESsyReferenceCloseChannel:
+ {
+ // Close channel response specific handling here
+ iMessage->SetFunction( ESsyReferenceCloseChannelResp );
+ SendResponse();
+ break;
+ }
+ default:
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::ProcessCommand() - Unknown function" ) ) );
+ err = KErrNotFound;
+ }
+ }
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::RunL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceCmdHandler::DoCancel()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::DoCancel()" ) ) );
+
+ // Handle cancel for this channel. Cancel any ongoing requests
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::DoCancel() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceCmdHandler::RunError( TInt /*aError*/ )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::RunError()" ) ) );
+
+ // Handle possible errors here and return KErrNone to prevent SSY from panic
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::RunError() - return" ) ) );
+ return KErrNone;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::DataItemCallback
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceCmdHandler::DataItemCallback( TAny* aThis )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::DataItemCallback()" ) ) );
+ return static_cast<CSsyReferenceCmdHandler*>( aThis )->GenerateChannelDataItem();
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceCmdHandler::GenerateChannelDataItem
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceCmdHandler::GenerateChannelDataItem()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::GenerateChannelDataItem()" ) ) );
+
+ // Get next item from list and set pointer to next item
+ TSsyRefChannelDataBase dataItem = iDataItemArray[iDataItemPtr++];
+
+ // Get next item interval from data item
+ TInt nextInterval( dataItem.Interval() );
+
+ // Set timestamp to data item
+ TTime time;
+ time.HomeTime();
+ dataItem.SetTimestamp( time );
+
+ // If interval is zero, set small interval
+ if ( nextInterval == 0 )
+ {
+ nextInterval = KSsyRefShortDelay;
+ }
+
+ // Add data item to message
+ iMessage->SetDataItem( &dataItem );
+
+ // If in last data item, set pointer back to first item
+ if ( iDataItemArray.Count() == iDataItemPtr )
+ {
+ iDataItemPtr = 0;
+ }
+
+ // Send response and start new timer
+ iMessage->SetFunction( ESsyReferenceDataItemReceived );
+ iSsyChannel.ProcessResponse( iMessage );
+
+ if ( iTimer )
+ {
+ delete iTimer;
+ iTimer = NULL;
+ }
+
+ TRAP_IGNORE( iTimer = CPeriodic::NewL( EPriorityNormal );
+ iTimer->Start( nextInterval * 1000, 0, TCallBack( DataItemCallback, this ) ); )
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceCmdHandler::GenerateChannelDataItem() - return" ) ) );
+ return KErrNone;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencecmdhandler.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,147 @@
+// ssyreferencecmdhandler.h
+
+/*
+* Copyright (c) 2006-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:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef SSYREFERENCECMDHANDLER_H
+#define SSYREFERENCECMDHANDLER_H
+
+#include <e32base.h>
+#include "ssyreferenceconfig.h"
+
+// FORWARD DECLARATIONS
+class CSsyReferenceChannel;
+
+/**
+ * Command handler class for handling commands of one channel. Each opened
+ * channel has its own instance of this class
+ */
+class CSsyReferenceCmdHandler : public CActive
+ {
+
+public:
+
+ /**
+ * Two-phase constructor
+ *
+ * @param[in] aSsyChannel Reference to SSY Channel instance.
+ * @return Pointer to created CSsyReferenceCmdHandler object
+ */
+ static CSsyReferenceCmdHandler* NewL( CSsyReferenceChannel& aSsyChannel );
+
+ /**
+ * Virtual destructor
+ */
+ virtual ~CSsyReferenceCmdHandler();
+
+// from base class CSsyControl
+
+ /**
+ * Processes command specified in param aMessage.
+ *
+ * @param[in] aMessage Contains command information to process
+ * @return Symbian error code
+ */
+ TInt ProcessCommand( TSsyReferenceMsg aMessage );
+
+ /**
+ * From CActive
+ */
+ void RunL();
+
+ /**
+ * From CActive
+ */
+ void DoCancel();
+
+ /**
+ * From CActive
+ */
+ TInt RunError( TInt aError );
+
+ /**
+ * Callback function for DataItem generation
+ */
+ static TInt DataItemCallback( TAny* aThis );
+
+ /**
+ * Handles data item generation. Called from DataItemCallback
+ */
+ TInt GenerateChannelDataItem();
+
+private:
+
+ /**
+ * C++ constructor.
+ *
+ * @param[in] aSsyChannel Reference to SSY Channel instance.
+ */
+ CSsyReferenceCmdHandler( CSsyReferenceChannel& aSsyChannel );
+
+ /**
+ * Symbian 2nd phase constructor.
+ */
+ void ConstructL();
+
+ /**
+ * Makes synchronous calls asynchronous
+ */
+ void IssueRequest( TInt aError = KErrNone );
+
+ /**
+ * Sends response to channel
+ */
+ void SendResponse( TInt aError = KErrNone );
+
+private: // data
+
+ /**
+ * Reference to SSY Conrtol to send responses for commands
+ */
+ CSsyReferenceChannel& iSsyChannel;
+
+ /**
+ * Pointer to currently processing message
+ */
+ TSsyReferenceMsg* iMessage;
+
+ /**
+ * Data item array
+ */
+ TSsyRefDataItemArray iDataItemArray;
+
+ /**
+ * Pointer to next item to generate in iDataItemArray
+ */
+ TInt iDataItemPtr;
+
+ /**
+ * Periodic timer for generating channel data
+ */
+ CPeriodic* iTimer;
+ };
+
+#endif // SSYREFERENCECMDHANDLER_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferenceconfig.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,896 @@
+// ssyreferenceconfig.cpp
+
+// Copyright (c) 2006-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 <sensors/sensrvtypes.h>
+#include <f32file.h>
+#include <gmxmldocument.h>
+#include <gmxmlelement.h>
+#include <sensors/channels/ssyreferenceaccelerometer.h>
+#include <sensors/channels/ssyreferencemagnetometer.h>
+#include <sensors/channels/ssyreferenceorientation.h>
+#include <sensors/channels/ssyreferenceproximity.h>
+
+#include "ssyreferencecontrol.h"
+#include "ssyreferenceconfig.h"
+#include "ssyreferencetrace.h"
+
+
+// ======== CONSTANTS =======
+_LIT( KSsyReferenceCfgFileOrig, "z:\\refssy\\ssyreferenceconfig.xml" );
+_LIT( KSsyReferenceCfgFileExt, "c:\\refssy\\ssyreferenceconfig.xml" );
+
+// Config file definitions
+
+// Maximum attribute length
+const TInt KSsyRefMaxAttribLength = 20;
+
+// TAG DEFINITIONS
+_LIT( KSsyRefRootTag, "SsyReferenceConfig" ); // Ssy general information tag
+_LIT( KSsyRefGeneralInfoTag, "SsyGeneralInformation" ); // Ssy general information tag
+_LIT( KSsyRefChannelInfoGroupTag, "ChannelInformationGroup" ); // Channel information group tag
+_LIT( KSsyRefChannelItemTag, "ChannelItem" ); // Channel item tag
+_LIT( KSsyRefChannelDataTag, "ChannelData" ); // Channel data tag
+_LIT( KSsyRefChannelDataItemTag, "ChannelDataItem" ); // Channel data item tag
+
+_LIT( KSsyRefProperties, "Properties" ); // Properties tag
+_LIT( KSsyRefPropertyItem, "PropertyItem" ); // PropertyItem tag
+
+// Data item definitions
+_LIT( KSsyRefAxisDataItemTag, "SsyRefChannelDataAxis" ); // SsyRefChannelDataAxis data item tag
+_LIT( KSsyRefXAxis, "XAxis" ); // XAxis from SsyRefChannelDataAxis
+_LIT( KSsyRefYAxis, "YAxis" ); // YAxis from SsyRefChannelDataAxis
+_LIT( KSsyRefZAxis, "ZAxis" ); // ZAxis from SsyRefChannelDataAxis
+
+_LIT( KSsyRefTappingDataItemTag, "SsyRefChannelDataTapping" ); // SsyRefChannelDataTapping data item tag
+_LIT( KSsyRefDirection, "Direction" ); // Direction from SsyRefChannelDataTapping
+
+_LIT( KSsyRefProximityDataItemTag, "SsyRefChannelDataProximity" ); // SsyRefChannelDataProximity data item tag
+_LIT( KSsyRefProximityState, "ProximityState" ); // ProximityStatus from SsyRefChannelDataProximity
+
+// ATTRIBUTE DEFINITIONS
+_LIT( KSsyRefChannelCount, "ChannelCount" ); // Channel count from ChannelInformationGroup
+_LIT( KSsyRefChannelId, "ChannelId" ); // Channel ID from ChannelItem
+_LIT( KSsyRefContextType, "ContextType" ); // Context type from ChannelItem
+_LIT( KSsyRefQuantity, "Quantity" ); // Quantity from ChannelItem
+_LIT( KSsyRefChannelType, "ChannelType" ); // ChannelType from ChannelItem
+_LIT( KSsyRefLocation, "Location" ); // Location from ChannelItem
+_LIT( KSsyRefVendorId, "Vendor" ); // Vendor from ChannelItem
+
+
+// Channel data item specific attribute definitions
+_LIT( KSsyRefStartInterval, "StartIntervalMs" ); // StartInterval from ChannelData
+_LIT( KSsyRefDataItemCount, "count" ); // count from ChannelDataItem
+_LIT( KSsyRefDataTypeID, "DataTypeId" ); // DataTypeId from ChannelDataItem
+_LIT( KSsyRefInterval, "IntervalMs" ); // IntervalMs from ChannelDataItem
+
+// Property spesific attributes
+_LIT( KSsyRefPropertyId, "PropertyId" ); // PropertyId from PropertyItem
+_LIT( KSsyRefArrayIndex, "ArrayIndex" ); // ArrayIndex from PropertyItem
+_LIT( KSsyRefItemIndex, "ItemIndex" ); // ItemIndex from PropertyItem
+_LIT( KSsyRefPropertyValue, "PropertyValue" ); // PropertyValue from PorpertyItem
+_LIT( KSsyRefPropertyType, "PropertyType" ); // PropertyType from PropertyItem
+_LIT( KSsyRefMaxValue, "MaxValue" ); // MaxValue from PropertyItem
+_LIT( KSsyRefMinValue, "MinValue" ); // MinValue from PorpertyItem
+_LIT( KSsyRefReadOnly, "ReadOnly" ); // ReadOnly from PropertyItem
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig C++ constructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceConfig::CSsyReferenceConfig() :
+ CActive( EPriorityMuchLess )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::CSsyReferenceConfig()" ) ) );
+ CActiveScheduler::Add( this );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::CSsyReferenceConfig() - return" ) ) );
+ }
+
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::ConstructL()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ConstructL()" ) ) );
+ // Create config file parser
+ iConfigParser = CMDXMLParser::NewL( this );
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ConstructL() - return" ) ) );
+ }
+
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::NewL
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceConfig* CSsyReferenceConfig::NewL()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::NewL()" ) ) );
+ CSsyReferenceConfig* self = new ( ELeave ) CSsyReferenceConfig();
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::NewL() - return" ) ) );
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceConfig::~CSsyReferenceConfig()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::~CSsyReferenceConfig()" ) ) );
+
+ if ( iConfigParser )
+ {
+ delete iConfigParser;
+ iConfigParser = NULL;
+ }
+
+ if ( iGenralInfoElement )
+ {
+ delete iGenralInfoElement;
+ iGenralInfoElement = NULL;
+ }
+
+ if ( iChannelGroupElement )
+ {
+ delete iChannelGroupElement;
+ iChannelGroupElement = NULL;
+ }
+
+ if ( iSsyReferenceConfig )
+ {
+ delete iSsyReferenceConfig;
+ iSsyReferenceConfig = NULL;
+ }
+
+ if ( iConfigFile )
+ {
+ delete iConfigFile;
+ iConfigFile = NULL;
+ }
+
+ iChannelPairArray.Reset();
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::~CSsyReferenceConfig() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::InitConfig
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::InitConfigL()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::InitConfig()" ) ) );
+
+ // Open config file
+ RFs fileSession;
+ User::LeaveIfError( fileSession.Connect() );
+
+ // Locate extrenal file...
+ RFile file;
+ TInt err( file.Open( fileSession, KSsyReferenceCfgFileExt, EFileRead ) );
+ file.Close();
+
+ // Check is external file found
+ if ( KErrNone == err )
+ {
+ // Use SSY with external configuration
+ User::LeaveIfError( iConfigParser->ParseFile( fileSession, KSsyReferenceCfgFileExt ) );
+ }
+ else
+ {
+ // Use SSY with original configuration
+
+ // Start parsing file and wait notification to ParseFileCompleteL
+ // XML Parser takes ownership of the RFs and closes it when file is parsed
+ User::LeaveIfError( iConfigParser->ParseFile( fileSession, KSsyReferenceCfgFileOrig ) );
+ }
+
+ iConfigFileParsed = EFalse;
+
+ // This active object has very low priority since XML parser uses Active objects also,
+ // so it is mandatory to let XML parser to complete sooner than this active object
+ IssueRequest();
+ iSchedulerWait.Start(); // Blocks until file is parsed
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::InitConfig() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::IssueRequest
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::IssueRequest( TInt aError )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::IssueRequest()" ) ) );
+ // Provides synchronous function calls to be handled as asynchronous
+ if ( !IsActive() )
+ {
+ SetActive();
+ TRequestStatus *s = &iStatus;
+ User::RequestComplete( s, aError );
+ }
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::IssueRequest() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::RunL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::RunL()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::RunL() - %i" ), iStatus.Int() ) );
+
+ if ( iConfigFileParsed )
+ {
+ // Stop blocking
+ iSchedulerWait.AsyncStop();
+ }
+ else
+ {
+ // Continue RunL loop
+ IssueRequest();
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::RunL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::DoCancel()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::DoCancel()" ) ) );
+
+ // Stop blocking
+ iSchedulerWait.AsyncStop();
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::DoCancel() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceConfig::RunError( TInt /*aError*/ )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::RunError()" ) ) );
+
+ // Handle possible errors here and return KErrNone to prevent SSY from panic
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::RunError() - return" ) ) );
+ return KErrNone;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::ParseFileCompleteL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::ParseFileCompleteL()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ParseFileCompleteL()" ) ) );
+ // First get document
+ iConfigFile = iConfigParser->DetachXMLDoc();
+ // Then get document element
+ CMDXMLElement* documentElement = iConfigFile->DocumentElement();
+ // Get root element, 'SsyReferenceConfig'
+ iSsyReferenceConfig = documentElement->FirstChildOfType( KSsyRefRootTag );
+ // Get gereral information element
+ iGenralInfoElement = iSsyReferenceConfig->FirstChildOfType( KSsyRefGeneralInfoTag );
+ // Get channel information group element
+ iChannelGroupElement = iSsyReferenceConfig->FirstChildOfType( KSsyRefChannelInfoGroupTag );
+ // Get channel count
+ iChannelCount = GetAttributeIntValue( *iChannelGroupElement, KSsyRefChannelCount );
+
+ // No need to delete documentElement, it is owned by iConfigFile.
+ documentElement = NULL;
+ iConfigFileParsed = ETrue;
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ParseFileCompleteL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetAttributeIntValue
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceConfig::GetAttributeIntValue( CMDXMLElement& aElement, const TDesC& aAttrib )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeIntValue()" ) ) );
+ COMPONENT_TRACE( ( _L( " Element: %s", aElement.NodeName() ) ) );
+ COMPONENT_TRACE( ( _L( " Attribute: %s", aAttrib ) ) );
+
+ TInt intValue( 0 );
+
+ // Check availability
+ if ( aElement.IsAttributeSpecified( aAttrib ) )
+ {
+ // Buffer to where to read value
+ TBufC<KSsyRefMaxAttribLength> buffer( KNullDesC );
+ TPtrC ptr( buffer );
+
+ // Read attribute value
+ aElement.GetAttribute( aAttrib, ptr );
+
+ // Cast literal value into TInt
+ TLex lexValue( ptr );
+ lexValue.Val( intValue );
+ }
+
+ COMPONENT_TRACE( ( _L( " IntValue: %i", intValue ) ) );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeIntValue() - return" ) ) );
+ return intValue;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetAttributeStrValue
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::GetAttributeStrValue( CMDXMLElement& aElement, const TDesC& aAttrib, TDes8& aTarget )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeStrValue()" ) ) );
+ COMPONENT_TRACE( ( _L( " Element: %s", aElement.NodeName() ) ) );
+ COMPONENT_TRACE( ( _L( " Attribute: %s", aAttrib ) ) );
+
+ // Check availability
+ if ( aElement.IsAttributeSpecified( aAttrib ) )
+ {
+ // Buffer to where to read value
+ TBufC<KSsyRefMaxAttribLength> buffer( KNullDesC );
+ TPtrC ptr( buffer );
+
+ // Read attribute value
+ aElement.GetAttribute( aAttrib, ptr );
+
+ // Copy string from 16-bit descriptor to 8-bit descriptor
+ aTarget.Copy( ptr );
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeStrValue() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetAttributeHexValue
+// ---------------------------------------------------------------------------
+//
+TUint CSsyReferenceConfig::GetAttributeHexValue( CMDXMLElement& aElement, const TDesC& aAttrib )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeHexValue()" ) ) );
+ COMPONENT_TRACE( ( _L( " Element: %s", aElement.NodeName() ) ) );
+ COMPONENT_TRACE( ( _L( " Attribute: %s", aAttrib ) ) );
+
+ TUint32 hexValue( 0 );
+
+ // Check availability
+ if ( aElement.IsAttributeSpecified( aAttrib ) )
+ {
+ // Buffer to where to read value
+ TBufC<KSsyRefMaxAttribLength> buffer( KNullDesC );
+ TPtrC ptr( buffer );
+
+ // Read attribute value
+ aElement.GetAttribute( aAttrib, ptr );
+
+ // Get bounded value and cast it into TUint32 (hex)
+ TRadix radix( EHex );
+ TUint limit( 0xFFFFFFFF );
+
+ // Append string into Lex and skip first two characters, 0x
+ TLex lexValue( ptr );
+ lexValue.Inc( 2 );
+
+ // Read value
+ lexValue.BoundedVal( hexValue, radix, limit );
+ }
+
+ COMPONENT_TRACE( ( _L( " HexValue: %x", hexValue ) ) );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeHexValue() - return" ) ) );
+ return hexValue;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetAttributeRealValue
+// ---------------------------------------------------------------------------
+//
+TReal CSsyReferenceConfig::GetAttributeRealValue( CMDXMLElement& aElement, const TDesC& aAttrib )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeRealValue()" ) ) );
+ COMPONENT_TRACE( ( _L( " Element: %s", aElement.NodeName() ) ) );
+ COMPONENT_TRACE( ( _L( " Attribute: %s", aAttrib ) ) );
+
+ TReal realValue( 0 );
+
+ // Check availability
+ if ( aElement.IsAttributeSpecified( aAttrib ) )
+ {
+
+ // Buffer to where to read value
+ TBufC<KSsyRefMaxAttribLength> buffer( KNullDesC );
+ TPtrC ptr( buffer );
+
+ // Read attribute value
+ aElement.GetAttribute( aAttrib, ptr );
+
+ // Cast literal value into TReal
+ TLex lexValue( ptr );
+ TInt error = lexValue.Val( realValue );
+ if( error!=KErrNone )
+ {
+ realValue = error;
+ }
+ }
+
+ COMPONENT_TRACE( ( _L( " IntValue: %i", realValue ) ) );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetAttributeRealValue() - return" ) ) );
+ return realValue;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::ChannelCount
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceConfig::ChannelCount()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ChannelCount() - %i" ), iChannelCount ) );
+ return iChannelCount;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GenerateChannels
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::GenerateChannels( RSensrvChannelInfoList& aChannelList )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GenerateChannels()" ) ) );
+
+ // Initialize channel pair array
+ TSsyRefChannelIdArray tempArray( iChannelCount );
+ iChannelPairArray = tempArray;
+
+ // Go through Channel group element and get all information
+ TSensrvChannelInfo channelInfo;
+ CMDXMLElement* channelElement = iChannelGroupElement->FirstChildOfType( KSsyRefChannelItemTag );
+
+ while( channelElement )
+ {
+ // check is element correct type of node
+ if ( channelElement->NodeType() == CMDXMLNode::EElementNode )
+ {
+ // read channel identifier
+ iChannelPairArray.Append( TSsyRefChannelIdPair( GetAttributeIntValue( *channelElement, KSsyRefChannelId ) ) );
+
+ // Read attributes
+ channelInfo.iContextType = ( TSensrvContextType ) GetAttributeIntValue( *channelElement, KSsyRefContextType );
+ channelInfo.iQuantity = ( TSensrvQuantity ) GetAttributeIntValue( *channelElement, KSsyRefQuantity );
+ channelInfo.iChannelType = ( TSensrvChannelTypeId ) GetAttributeHexValue( *channelElement, KSsyRefChannelType );
+ GetAttributeStrValue( *channelElement, KSsyRefLocation, channelInfo.iLocation );
+ GetAttributeStrValue( *channelElement, KSsyRefVendorId, channelInfo.iVendorId );
+ channelInfo.iChannelDataTypeId = ( TSensrvChannelDataTypeId ) GetAttributeHexValue( *channelElement, KSsyRefDataTypeID );
+
+ // Calculate data item size based on channel type
+ switch ( channelInfo.iChannelType )
+ {
+ case KSensrvChannelTypeIdAccelerometerXYZAxisData:
+ {
+ channelInfo.iDataItemSize = KSsyRefAxisDataItemSize;
+ break;
+ }
+ case KSensrvChannelTypeIdProximityMonitor:
+ {
+ channelInfo.iDataItemSize = KSsyRefProximityDataItemSize;
+ break;
+ }
+ case KSensrvChannelTypeIdAccelerometerWakeupData:
+ case KSensrvChannelTypeIdAccelerometerDoubleTappingData:
+ {
+ channelInfo.iDataItemSize = KSsyRefTappingDataItemSize;
+ break;
+ }
+ default:
+ {
+ channelInfo.iDataItemSize = 0;
+ break;
+ }
+ }
+
+ // Append channel info to list
+ aChannelList.Append( channelInfo );
+ }
+ channelElement = static_cast<CMDXMLElement*>( channelElement->NextSibling() );
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GenerateChannels() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetChannelDataInformation
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::GetChannelDataInformationL(
+ const TInt aSrvChannelId,
+ TSsyRefDataItemArray& aDataItemList,
+ TInt& aStartInterval )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetChannelDataInformation()" ) ) );
+
+ // First, get correct config channel element corresponding to aSrvChannelId
+ CMDXMLElement* channelElement = ChannelElement( aSrvChannelId );
+
+ if ( channelElement )
+ {
+ // Channel element found, get channel data group element
+ CMDXMLElement* groupElement = channelElement->FirstChildOfType( KSsyRefChannelDataTag );
+
+ if ( groupElement )
+ {
+ // Get start interval
+ aStartInterval = GetAttributeIntValue( *groupElement, KSsyRefStartInterval );
+
+ // First, loop channel data items to get total count
+ CMDXMLElement* dataItemElement = groupElement->FirstChildOfType( KSsyRefChannelDataItemTag );
+
+ // Take channel data item type at this point. One channel can produce only one type of
+ // channel data item
+ TUint channelType( GetAttributeHexValue( *dataItemElement, KSsyRefDataTypeID ) );
+
+ TInt channelItemCount( 0 ); // Total number of data items
+ TInt definitionCount( 0 ); // Total number of different definitions
+
+ // Go through elements and get counters
+ while ( dataItemElement )
+ {
+ definitionCount++;
+ channelItemCount = channelItemCount + GetAttributeIntValue( *dataItemElement, KSsyRefDataItemCount );
+ // This will return NULL if no next sibling found
+ dataItemElement = static_cast<CMDXMLElement*>( dataItemElement->NextSibling() );
+ }
+
+ // Now, start all over to get item information
+ dataItemElement = groupElement->FirstChildOfType( KSsyRefChannelDataItemTag );
+
+ // Create temp array now that we know the data item count
+ TSsyRefDataItemArray tempArray( channelItemCount );
+
+ for ( TInt i = 0; i < definitionCount; i++ )
+ {
+ // Check element type
+ if ( dataItemElement->NodeType() == CMDXMLNode::EElementNode )
+ {
+ // First we get interval and count from channel item
+ TInt interval( GetAttributeIntValue( *dataItemElement, KSsyRefInterval ) );
+ TInt countOfType( GetAttributeIntValue( *dataItemElement, KSsyRefDataItemCount ) );
+
+ // Read next child values to corresponding data type class
+ switch ( channelType )
+ {
+ case TSensrvAccelerometerAxisData::KDataTypeId:
+ {
+ CMDXMLElement* axisDataElement = dataItemElement->FirstChildOfType( KSsyRefAxisDataItemTag );
+ TInt axisX( GetAttributeIntValue( *axisDataElement, KSsyRefXAxis ) );
+ TInt axisY( GetAttributeIntValue( *axisDataElement, KSsyRefYAxis ) );
+ TInt axisZ( GetAttributeIntValue( *axisDataElement, KSsyRefZAxis ) );
+
+ // Create channel data type item
+ TSsyRefChannelDataAxis channelData( axisX, axisY, axisZ, interval );
+ // add items into array
+ for ( TInt k = 0; k < countOfType; k++ )
+ {
+ tempArray.Append( channelData );
+ }
+ break;
+ }
+ case TSensrvTappingData::KDataTypeId:
+ {
+ CMDXMLElement* tappingDataElement = dataItemElement->FirstChildOfType( KSsyRefTappingDataItemTag );
+ TInt direction( GetAttributeHexValue( *tappingDataElement, KSsyRefDirection ) );
+
+ // Create channel data type item
+ TSsyRefChannelDataTapping channelData( direction, interval );
+ // add items into array
+ for ( TInt k = 0; k < countOfType; k++ )
+ {
+ tempArray.Append( channelData );
+ }
+ break;
+ }
+ case TSensrvProximityData::KDataTypeId:
+ {
+ CMDXMLElement* proximityDataElement = dataItemElement->FirstChildOfType( KSsyRefProximityDataItemTag );
+ TInt state( GetAttributeIntValue( *proximityDataElement, KSsyRefProximityState ) );
+
+ // Create channel data type item
+ TSsyRefChannelDataProximity channelData( state, interval );
+ // add items into array
+ for ( TInt k = 0; k < countOfType; k++ )
+ {
+ tempArray.Append( channelData );
+ }
+ break;
+ }
+ default:
+ {
+ // Other data items are not supported
+ User::Leave( KErrGeneral );
+ }
+ }
+ }
+
+ // Get next channel data item element
+ dataItemElement = static_cast<CMDXMLElement*>( dataItemElement->NextSibling() );
+ }
+
+ // Compress temp array in case there were comments
+ tempArray.Compress();
+
+ // copy information to param array
+ aDataItemList = tempArray;
+ }
+ else
+ {
+ User::Leave( KErrNotFound );
+ }
+ }
+ else
+ {
+ User::Leave( KErrNotFound );
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetChannelDataInformation() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetElementPropertiesL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::GetElementPropertiesL(
+ CMDXMLElement& aElement,
+ RSensrvPropertyList& aPropertyList )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetElementPropertiesL()" ) ) );
+
+ // First we need 'Properties' element
+ CMDXMLElement* properties = aElement.FirstChildOfType( KSsyRefProperties );
+
+ if ( !properties )
+ {
+ // Wrong element... or properties are not defined
+ User::Leave( KErrNotFound );
+ }
+
+ // Get first property get started
+ CMDXMLElement* propertyItem = properties->FirstChildOfType( KSsyRefPropertyItem );
+ TInt propertyCount( 0 );
+
+ // Loop properties to get count of properties
+ while ( propertyItem )
+ {
+ propertyCount++;
+ propertyItem = static_cast<CMDXMLElement*>( propertyItem->NextSibling() ); // returns NULL if next not found
+ }
+
+ if ( !propertyCount )
+ {
+ // Check that there are properties
+ User::Leave( KErrNotFound );
+ }
+
+ // Temporary property list now that we know the property count
+ RSensrvPropertyList tempList( propertyCount );
+
+ // Start loop again from the start and read each property
+ propertyItem = properties->FirstChildOfType( KSsyRefPropertyItem );
+ for ( TInt i = 0; i < propertyCount; i++ )
+ {
+ // Check element type
+ if ( propertyItem->NodeType() == CMDXMLNode::EElementNode )
+ {
+ // Read property values
+ const TSensrvPropertyId propertyId( ( TSensrvPropertyId )GetAttributeHexValue( *propertyItem, KSsyRefPropertyId ) );
+ const TInt itemIndex( GetAttributeIntValue( *propertyItem, KSsyRefItemIndex ) );
+ const TBool readOnly( ( TBool )GetAttributeIntValue( *propertyItem, KSsyRefReadOnly ) );
+ const TSensrvPropertyType propertyType( ( TSensrvPropertyType ) GetAttributeIntValue( *propertyItem, KSsyRefPropertyType ) );
+
+ // Array index must be handled in different way as it is not mandatory and it may not exist in XML file
+ TInt arrayIndex( ESensrvSingleProperty );
+
+ // Extra check is needed, otherwise this value is always '0' when it should be 'ESensrvSingleProperty' by default
+ if ( propertyItem->IsAttributeSpecified( KSsyRefArrayIndex ) )
+ {
+ // Attribute exists, now we can read the value
+ arrayIndex = GetAttributeIntValue( *propertyItem, KSsyRefArrayIndex );
+ }
+
+ // Resolve type, get correct type value and append property into list
+ switch ( propertyType )
+ {
+ case ESensrvIntProperty:
+ {
+ const TInt intValue( GetAttributeIntValue( *propertyItem, KSsyRefPropertyValue ) );
+ const TInt maxValue( GetAttributeIntValue( *propertyItem, KSsyRefMaxValue ) );
+ const TInt minValue( GetAttributeIntValue( *propertyItem, KSsyRefMinValue ) );
+ TSensrvProperty property( propertyId, itemIndex, intValue, maxValue, minValue, readOnly, propertyType );
+ property.SetArrayIndex( arrayIndex );
+ tempList.Append( property );
+ break;
+ }
+ case ESensrvRealProperty:
+ {
+ const TReal intValue( GetAttributeRealValue( *propertyItem, KSsyRefPropertyValue ) );
+ const TReal maxValue( GetAttributeRealValue( *propertyItem, KSsyRefMaxValue ) );
+ const TReal minValue( GetAttributeRealValue( *propertyItem, KSsyRefMinValue ) );
+ TSensrvProperty property( propertyId, itemIndex, intValue, maxValue, minValue, readOnly, propertyType );
+ property.SetArrayIndex( arrayIndex );
+ tempList.Append( property );
+ break;
+ }
+ case ESensrvBufferProperty:
+ {
+ TBuf8<KSensrvPropertyTextBufferSize> desValue;
+ GetAttributeStrValue( *propertyItem, KSsyRefPropertyValue, desValue );
+ TSensrvProperty property( propertyId, itemIndex, desValue, readOnly, propertyType );
+ property.SetArrayIndex( arrayIndex );
+ tempList.Append( property );
+ break;
+ }
+ default:
+ {
+ // Unknown property type -> leave
+ User::Leave( KErrArgument );
+ }
+ }
+ }
+
+ // Next property
+ propertyItem = static_cast<CMDXMLElement*>( propertyItem->NextSibling() ); // returns NULL if next not found
+ }
+
+ // Compress temp list in case there were comment nodes
+ tempList.Compress();
+
+ // copy temp list to parameter list
+ aPropertyList = tempList;
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetElementPropertiesL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::ChannelElement
+// ---------------------------------------------------------------------------
+//
+CMDXMLElement* CSsyReferenceConfig::ChannelElement( const TInt aSrvChannelId )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ChannelElement()" ) ) );
+
+ const TInt configId( ConfigChannelId( aSrvChannelId ) );
+ TBool channelFound( EFalse );
+
+ // Loop channel group and match configId for the channel ID in element
+ CMDXMLElement* channelItemElement = iChannelGroupElement->FirstChildOfType( KSsyRefChannelItemTag );
+
+ for ( TInt i = 0; i < iChannelCount && !channelFound; i++ )
+ {
+ TInt channelId( GetAttributeIntValue( *channelItemElement, KSsyRefChannelId ) );
+ if ( configId == channelId )
+ {
+ // Channel found, no need to loop
+ channelFound = ETrue;
+ }
+ else
+ {
+ // Take next channel
+ channelItemElement = static_cast<CMDXMLElement*>( channelItemElement->NextSibling() );
+ }
+ }
+
+ // If not found, return NULL
+ if ( !channelFound )
+ {
+ channelItemElement = NULL;
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ChannelElement() - return" ) ) );
+ return channelItemElement;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::UpdateChannelIds
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::UpdateChannelIds( RSensrvChannelInfoList aChannelList )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::UpdateChannelIds()" ) ) );
+
+
+ if ( ChannelCount() == aChannelList.Count() )
+ {
+ for ( TInt i = 0; i < aChannelList.Count(); i++ )
+ {
+ iChannelPairArray[i].SetServerId( aChannelList[i].iChannelId );
+ }
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::UpdateChannelIds() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::ConfigChannelId
+// ---------------------------------------------------------------------------
+//
+TInt CSsyReferenceConfig::ConfigChannelId( const TInt aSrvChannelId ) const
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ConfigChannelId()" ) ) );
+ TInt returnValue( 0 );
+
+ for ( TInt i = 0; i < iChannelPairArray.Count(); i++ )
+ {
+ if ( iChannelPairArray[i].ServerId() == aSrvChannelId )
+ {
+ returnValue = iChannelPairArray[i].ConfigId();
+ }
+ }
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::ConfigChannelId() - return" ) ) );
+ return returnValue;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetSensorPropertiesL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::GetSensorPropertiesL( RSensrvPropertyList& aPropertyList )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetSensorPropertiesL()" ) ) );
+
+ // We already have SsyGeneralInformation element, read properties from that
+ GetElementPropertiesL( *iGenralInfoElement, aPropertyList );
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetSensorPropertiesL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceConfig::GetChannelPropertiesL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceConfig::GetChannelPropertiesL(
+ const TInt aSrvChannelId,
+ RSensrvPropertyList& aPropertyList )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetChannelPropertiesL()" ) ) );
+
+ // Get channel element first
+ CMDXMLElement* channelElement = ChannelElement( aSrvChannelId );
+
+ if ( !channelElement )
+ {
+ // Leave, channel element is not found
+ User::Leave( KErrNotFound );
+ }
+
+ // Get properties of this channel element
+ GetElementPropertiesL( *channelElement, aPropertyList );
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceConfig::GetChannelPropertiesL() - return" ) ) );
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferenceconfig.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,522 @@
+// ssyreferenceconfig.h
+
+/*
+* Copyright (c) 2006-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:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+
+#ifndef SSYREFERENCECONFIG_H
+#define SSYREFERENCECONFIG_H
+
+// INCLUDES
+#include <e32base.h>
+#include <sensors/sensrvtypes.h>
+#include <sensors/sensrvchannelinfo.h>
+#include <gmxmlparser.h>
+#include <sensors/channels/ssyreferenceaccelerometer.h>
+#include <sensors/channels/ssyreferencemagnetometer.h>
+#include <sensors/channels/ssyreferenceorientation.h>
+#include <sensors/channels/ssyreferenceproximity.h>
+
+// CONSTANTS
+// Data item sizes
+const TInt KSsyRefAxisDataItemSize = sizeof( TSensrvAccelerometerAxisData );
+const TInt KSsyRefTappingDataItemSize = sizeof( TSensrvTappingData );
+const TInt KSsyRefProximityDataItemSize = sizeof( TSensrvProximityData );
+
+// ENUMS
+enum TSsyReferenceFunctions
+ {
+ ESsyReferenceOpenChannel,
+ ESsyReferenceOpenChannelResp,
+ ESsyReferenceDataItemReceived,
+ ESsyReferenceCloseChannel,
+ ESsyReferenceCloseChannelResp,
+ ESsyReferenceStartChannelData,
+ ESsyReferenceStopChannelData
+ };
+
+/**
+ * Base class for Channel data types. Contains iChannelDataType which is set
+ * by derived classes on construction.
+ */
+class TSsyRefChannelDataBase
+ {
+ public:
+ /**
+ * Enumeration for possible channel data types
+ */
+ enum TSsyRefChannelDataType
+ {
+ ESsyRefChannelTypeTapping = 5000,
+ ESsyRefChannelTypeAxis,
+ ESsyRefChannelTypeProximity,
+ ESsyRefChannelTypeAmbientLight
+ };
+
+ TInt ChannelDataType() const { return iChannelDataType; }
+ TInt Interval() const { return iInterval; }
+
+ void SetTimestamp( const TTime aTimestamp ) { iTimestamp = aTimestamp; }
+ TTime Timestamp() const { return iTimestamp; }
+
+ TInt Size() const { return iSize; }
+
+ protected:
+
+ /**
+ * Protected constructor as this class is not supposed to be instantiate
+ * directly.
+ */
+ TSsyRefChannelDataBase() {}
+
+ protected: // data
+
+ /**
+ * Identifies the type of data type class derived from this base class
+ */
+ TInt iChannelDataType;
+
+ /**
+ * Interval. Indicates time in ms from previous item until next item is produced
+ */
+ TInt iInterval;
+
+ /**
+ * Timestamp. Time when this data item is generated.
+ */
+ TTime iTimestamp;
+
+ /**
+ * Size of one data item. This is filled by derived class
+ */
+ TInt iSize;
+
+ /**
+ * Axis data item values.
+ * Accessible only from TSsyRefChannelDataAxis class
+ */
+ TInt iXAxis;
+ TInt iYAxis;
+ TInt iZAxis;
+
+
+ /**
+ * Proximity data item values.
+ * Accessible only from TSsyRefChannelProximity class
+ */
+ TInt iProximityState;
+
+ /**
+ * AmbientLight data item values.
+ * Accessible only from TSsyRefChannelAmbientLight class
+ */
+ TInt iAmbientLightState;
+
+ /**
+ * Tapping data item values. Difrection of the tapping.
+ * Accessible only from TSsyRefChannelDataTapping class
+ */
+ TInt iDirection;
+ };
+
+// Type definition array for Data item base class
+typedef RArray<TSsyRefChannelDataBase> TSsyRefDataItemArray;
+
+/**
+ * Message item for SSY <--> Sensor communications
+ * Contains Channel ID for which the message belongs to,
+ * Function ID that identifies the command and
+ * error for error cases.
+ */
+class TSsyReferenceMsg
+ {
+ public:
+
+ /**
+ * Constructor of the TSsyReferenceMsg
+ *
+ * @param[in] aChannelId Channel identifier
+ * @param[in] aFunction See TSsyReferenceFunctions
+ */
+ TSsyReferenceMsg( TInt aChannelId, TInt aFunction ) :
+ iChannelId( aChannelId ),
+ iFunction( aFunction ),
+ iError( KErrNone )
+ {}
+
+ /**
+ * Copy constructor of the TSsyReferenceMsg
+ *
+ * @param[in] aMsg Object to be copied to constructed object
+ */
+ TSsyReferenceMsg( const TSsyReferenceMsg& aMsg ) :
+ iChannelId( aMsg.iChannelId ),
+ iFunction( aMsg.iFunction ),
+ iError( aMsg.iError )
+ {}
+
+ TInt ChannelId() { return iChannelId; }
+
+ void SetFunction( TInt aFunction ) { iFunction = aFunction; }
+ TInt Function() { return iFunction; }
+
+ void SetError( TInt aError ) { iError = aError; }
+ TInt Error() { return iError; }
+
+ void SetDataItem( TSsyRefChannelDataBase* aDataItem ) { iDataItem = aDataItem; }
+ TSsyRefChannelDataBase* DataItem() const { return iDataItem; }
+
+ private: // data
+
+ TInt iChannelId; // Identifies the channel
+ TInt iFunction; // Identifies the command
+ TInt iError; // Error is passed to response handler
+
+ // Data item for received data. This is casted to correct data item
+ // class implementation according to ChannelDataType
+ TSsyRefChannelDataBase* iDataItem;
+ };
+
+/**
+ * Tapping data type class implementation.
+ */
+class TSsyRefChannelDataTapping : public TSsyRefChannelDataBase
+ {
+ public:
+
+ TSsyRefChannelDataTapping( TInt aDirection, TInt aInterval )
+ {
+ iChannelDataType = ESsyRefChannelTypeTapping;
+ iSize = KSsyRefTappingDataItemSize;
+ iInterval = aInterval;
+ iDirection = aDirection;
+ }
+
+ TInt Direction() const { return iDirection; }
+ };
+
+/**
+ * XYZ Axis data type class implementation.
+ */
+class TSsyRefChannelDataAxis : public TSsyRefChannelDataBase
+ {
+ public:
+
+ TSsyRefChannelDataAxis( TInt aXAxis, TInt aYAxis, TInt aZAxis,
+ TInt aInterval )
+ {
+ iChannelDataType = ESsyRefChannelTypeAxis;
+ iSize = KSsyRefAxisDataItemSize;
+ iInterval = aInterval;
+ iXAxis = aXAxis;
+ iYAxis = aYAxis;
+ iZAxis = aZAxis;
+ }
+
+ TInt XAxis() const { return iXAxis; }
+ TInt YAxis() const { return iYAxis; }
+ TInt ZAxis() const { return iZAxis; }
+ };
+
+
+/**
+ * Proximity data type class implementation.
+ */
+class TSsyRefChannelDataProximity : public TSsyRefChannelDataBase
+ {
+ public:
+
+ TSsyRefChannelDataProximity( TInt aProximityState, TInt aInterval )
+ {
+ iChannelDataType = ESsyRefChannelTypeProximity;
+ iSize = KSsyRefProximityDataItemSize;
+ iInterval = aInterval;
+ iProximityState = aProximityState;
+ }
+
+ TInt ProximityState() const { return iProximityState; }
+ };
+
+/**
+ * Channel ID pair class for pairing config file channel id and
+ * Sensor Server generated channel ID.
+ */
+class TSsyRefChannelIdPair
+ {
+ public:
+ /**
+ * Constructor of the TSsyRefChannelIdPair
+ *
+ * @param[in] aConfigChannelId Channel identifier from config file
+ */
+ TSsyRefChannelIdPair( TInt aConfigChannelId ) :
+ iConfigChannelId( aConfigChannelId )
+ {}
+
+ TInt ConfigId() const { return iConfigChannelId; }
+ TInt ServerId() const { return iSrvChannelId; }
+
+ void SetServerId( const TInt aSrvId ) { iSrvChannelId = aSrvId; }
+
+ private: // data
+
+ TInt iConfigChannelId; // Config file ID of the channel
+ TInt iSrvChannelId; // Sensor server assigned ID of the channel
+ };
+
+typedef RArray<TSsyRefChannelIdPair> TSsyRefChannelIdArray;
+
+
+// CONSTANTS
+
+/**
+ * Configuration class for SSY reference plugin. Generates configured SSY channel information.
+ * This keeps reference SSY implementation independent from 'sensor' it uses. This class is fully
+ * modifiable regarding to the needs of this SSY. It may be for example accelerometer sensor
+ * without any changes in the SSY reference implementation. Only this class is modified.
+ */
+class CSsyReferenceConfig : public CActive, public MMDXMLParserObserver
+ {
+
+public:
+
+ /**
+ * Two-phase constructor
+ *
+ * @return Pointer to created CSsyReferenceControl object
+ */
+ static CSsyReferenceConfig* NewL();
+
+ /**
+ * Virtual destructor
+ */
+ virtual ~CSsyReferenceConfig();
+
+ /**
+ * From CActive
+ */
+ void RunL();
+
+ /**
+ * From CActive
+ */
+ void DoCancel();
+
+ /**
+ * From CActive
+ */
+ TInt RunError( TInt aError );
+
+ /**
+ * From MMDXMLParserObserver
+ *
+ * Call back function used to inform a client of the Parser when a parsing operation completes.
+ */
+ void ParseFileCompleteL();
+
+ /**
+ * Starts parsing config file. This function blocks until file is parsed
+ */
+ void InitConfigL();
+
+ /**
+ * Total number of channels this SSY provides
+ *
+ * @return Count of channels this SSY is configured to provide
+ */
+ TInt ChannelCount();
+
+ /**
+ * Generates channels this SSY is configured to provide
+ *
+ * @param[in,out] aChannnelList Filled with generated channels by this configurator
+ */
+ void GenerateChannels( RSensrvChannelInfoList& aChannelList );
+
+ /**
+ * Updates Sensor server's generated channel Ids
+ *
+ * @param[in] aChannnelList Same list as GenerateChannels produces but
+ * this contains channel identifiers
+ */
+ void UpdateChannelIds( RSensrvChannelInfoList aChannelList );
+
+ /**
+ * Reads all channel data information from config file and fills
+ * parameters with information
+ *
+ * @param[in] aSrvChannelId Sensor server generated channel id of the target channel
+ * @param[in,out] aDataItemList Contains data item objects defined in config file. Each
+ * Data item is presented as Data Item class derived from TSsyRefChannelDataBase.
+ * List can contain only one type of derived channel data items
+ * @param[in,out] aStartInterval Contains start interval to start producing data items
+ */
+ void GetChannelDataInformationL( const TInt aSrvChannelId,
+ TSsyRefDataItemArray& aDataItemList,
+ TInt& aStartInterval );
+
+ /**
+ * Reads sensor properties from config file and adds them to list
+ *
+ * @param[out] aPropertyList List where to append properties
+ */
+ void GetSensorPropertiesL( RSensrvPropertyList& aPropertyList );
+
+ /**
+ * Reads channel properties from config file and adds them to list
+ *
+ * @param[in] aSenSrvChannelId Sensor server generated channel id
+ * @param[out] aPropertyList List where to append properties
+ */
+ void GetChannelPropertiesL( const TInt aSrvChannelId,
+ RSensrvPropertyList& aPropertyList );
+
+private:
+
+ /**
+ * C++ constructor.
+ */
+ CSsyReferenceConfig();
+
+ /**
+ * Symbian 2nd phase constructor.
+ */
+ void ConstructL();
+
+ /**
+ * Makes synchronous calls asynchronous
+ */
+ void IssueRequest( TInt aError = KErrNone );
+
+ /**
+ * Reads attribute value from element and casts it into TInt value
+ *
+ * @param[in] aElement Element from where to read attribute
+ * @param[in] aAttrib Attribute name which to read
+ * @return Integer value of read value
+ */
+ TInt GetAttributeIntValue( CMDXMLElement& aElement, const TDesC& aAttrib );
+
+ /**
+ * Reads attribute value from element and casts it into literal value
+ *
+ * @param[in] aElement Element from where to read attribute
+ * @param[in] aAttrib Attribute name which to read
+ * @param[in/out] aTarget Target descriptor where to copy read literal
+ */
+ void GetAttributeStrValue( CMDXMLElement& aElement, const TDesC& aAttrib, TDes8& aTarget );
+
+ /**
+ * Reads attribute value from element and casts it into TReal value
+ *
+ * @param[in] aElement Element from where to read attribute
+ * @param[in] aAttrib Attribute name which to read
+ * @return value of the attribute
+ */
+ TReal GetAttributeRealValue( CMDXMLElement& aElement, const TDesC& aAttrib );
+
+ /**
+ * Reads Hexadesimal attribute value from element and casts it into Integer value
+ *
+ * @param[in] aElement Element from where to read attribute
+ * @param[in] aAttrib Attribute name which to read
+ * @return Unsigned integer value of read Hexadesimal value
+ */
+ TUint GetAttributeHexValue( CMDXMLElement& aElement, const TDesC& aAttrib );
+
+ /**
+ * Compares Sensor server generated channel IDs and return corresponding
+ * ConfigFile channel id
+ *
+ * @param[in] aSrvChannelId SenServer generated channel ID for which pair is needed
+ * @return ConfigFile channel ID that is paired with aSrvChannelId
+ */
+ TInt ConfigChannelId( const TInt aSrvChannelId ) const;
+
+ /**
+ * Searches channel element for given SensorServer generated channel ID
+ *
+ * @param[in] aSrvChannelId SenServer generated channel ID identifying wanted channel element
+ * @return Pointer to found channel element or NULL if not found
+ */
+ CMDXMLElement* ChannelElement( const TInt aSrvChannelId );
+
+ /**
+ * Reads properties from given element and adds them to list.
+ * Element can be either 'SsyGenealInformation' or 'ChannelItem'
+ *
+ * @param[in] aElement Element from where to read properties
+ * @param[out] aPropertyList List where to append properties
+ */
+ void GetElementPropertiesL( CMDXMLElement& aElement, RSensrvPropertyList& aPropertyList );
+
+
+private: // data
+
+ /**
+ * Pointer of the config xml-file parser
+ */
+ CMDXMLParser* iConfigParser;
+
+ /**
+ * Contains Ssy general information element and all of its childs
+ */
+ CMDXMLElement* iGenralInfoElement;
+
+ /**
+ * Contains Ssy Channel information group element and all of its childs
+ * including each channel information and channel data for testing purpose
+ */
+ CMDXMLElement* iChannelGroupElement;
+
+ /**
+ * Number of channels defined in config file
+ */
+ TInt iChannelCount;
+
+ /**
+ * Active scheduler wait for blocking construction until config file is parsed
+ */
+ CActiveSchedulerWait iSchedulerWait;
+
+ /**
+ * Indicates is config file parsed
+ */
+ TBool iConfigFileParsed;
+
+ /**
+ * Channel ID pair array
+ */
+ TSsyRefChannelIdArray iChannelPairArray;
+
+ /**
+ * Elements of the config file. These needs to be stored
+ */
+ CMDXMLDocument* iConfigFile;
+ CMDXMLElement* iSsyReferenceConfig; // Root of the config
+ };
+
+#endif //SSYREFERENCECONFIG_H
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencecontrol.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,281 @@
+// ssyreferencecontrol.cpp
+
+// Copyright (c) 2006-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 <sensors/spi/ssycallback.h> // MSsyCallback
+#include "ssyreferencecontrol.h"
+#include "ssyreferencetrace.h"
+#include "ssyreferencechannel.h"
+#include "ssyreferencecmdhandler.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl C++ constructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceControl::CSsyReferenceControl( MSsyCallback& aSsyCallback ) :
+ iSsyCallback( aSsyCallback )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::CSsyReferenceControl()" ) ) );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::CSsyReferenceControl() - return" ) ) );
+ }
+
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceControl::ConstructL()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::ConstructL()" ) ) );
+
+ // Create configurator and start config file parsing
+ iConfigFile = CSsyReferenceConfig::NewL();
+ TRAPD( err, iConfigFile->InitConfigL() ); // This will block until config is ready
+
+ if ( KErrNone != err )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::ConstructL() - Init config failed: %i" ), err ) );
+ }
+
+ // ---------------------------------------------------------------
+
+ // Store channel count for later use
+ const TInt channelCount( iConfigFile->ChannelCount() );
+
+ // Instantiate channel info list
+ RSensrvChannelInfoList channelInfoList( channelCount );
+ CleanupClosePushL( channelInfoList );
+
+ // Fills channel info list with generated channel info objects
+ iConfigFile->GenerateChannels( channelInfoList );
+
+ // Register channels. Sensor Server generates unique ID for each channel
+ iSsyCallback.RegisterChannelsL( channelInfoList );
+
+ // Update channel IDs to ConfigFile
+ iConfigFile->UpdateChannelIds( channelInfoList );
+
+ // Create channels
+ iChannelArray = new ( ELeave ) CArrayPtrFlat<CSsyReferenceChannel>( channelCount );
+ for ( TInt i = 0; i < channelCount; i++ )
+ {
+ CSsyReferenceChannel* channel = CSsyReferenceChannel::NewL( *this, channelInfoList[i] );
+ iChannelArray->AppendL( channel );
+ }
+
+ // Clean up
+ CleanupStack::PopAndDestroy( &channelInfoList );
+
+ // Get properties of this SSY. Leaves with KErrNotFound if not found. These properties are
+ // not mandatory, so we can ignore that leave
+ TRAP_IGNORE( iConfigFile->GetSensorPropertiesL( iProperties ) );
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::ConstructL() - return" ) ) );
+ }
+
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::NewL
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceControl* CSsyReferenceControl::NewL( MSsyCallback& aSsyCallback )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::NewL()" ) ) );
+ CSsyReferenceControl* self = new ( ELeave ) CSsyReferenceControl( aSsyCallback );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::NewL() - return" ) ) );
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceControl::~CSsyReferenceControl()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::~CSsyReferenceControl()" ) ) );
+
+ if ( iChannelArray )
+ {
+ if ( iChannelArray->Count() )
+ {
+ iChannelArray->ResetAndDestroy();
+ }
+
+ delete iChannelArray;
+ }
+
+ if ( iConfigFile )
+ {
+ delete iConfigFile;
+ iConfigFile = NULL;
+ }
+
+ iProperties.Reset();
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::~CSsyReferenceControl() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::SsyCallback
+// ---------------------------------------------------------------------------
+//
+MSsyCallback& CSsyReferenceControl::SsyCallback() const
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::SsyCallback()" ) ) );
+ return iSsyCallback;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::SsyConfig
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceConfig& CSsyReferenceControl::SsyConfig() const
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::SsyConfig()" ) ) );
+ return *iConfigFile;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::FindPropertyL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceControl::FindPropertyL(
+ const TSensrvPropertyId aPropertyId,
+ const TInt aArrayIndex,
+ TSensrvProperty& aProperty )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::FindPropertyL()" ) ) );
+ TSensrvProperty* property = NULL;
+ TBool propertyFound( EFalse );
+
+ // Search property
+ for ( TInt i = 0; i < iProperties.Count() && !propertyFound; i++ )
+ {
+ property = static_cast<TSensrvProperty*>( &iProperties[i] );
+
+ // Compare property IDs
+ if ( property->GetPropertyId() == aPropertyId )
+ {
+ // Correct property ID is found, now check is it array type of property.
+ // Either array indexes must match or propertys array index has to be array info
+ if ( ( property->GetArrayIndex() == aArrayIndex ) ||
+ ( ( property->GetArrayIndex() == ESensrvArrayPropertyInfo ) &&
+ ( ESensrvSingleProperty == aArrayIndex ) ) )
+ {
+ // Correct array index found
+ propertyFound = ETrue;
+ }
+ }
+ }
+
+ // Leave if not found
+ if ( !propertyFound )
+ {
+ User::Leave( KErrNotFound );
+ }
+
+ aProperty = *property;
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::FindPropertyL() - return" ) ) );
+ }
+
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::FindChannel
+// ---------------------------------------------------------------------------
+//
+CSsyReferenceChannel* CSsyReferenceControl::FindChannelL( TSensrvChannelId aChannelID )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::FindChannel()" ) ) );
+
+ if ( !iChannelArray )
+ {
+ User::Leave( KErrNotFound );
+ }
+
+ const TInt channelCount( iChannelArray->Count() );
+ CSsyReferenceChannel* channel = NULL;
+
+ // Check that there are channels
+ if ( channelCount )
+ {
+ // Loop channels until correct channel is found
+ for ( TInt i = 0; i < channelCount; i++ )
+ {
+ channel = iChannelArray->At( i );
+
+ // Compare channel id
+ if ( channel->ChannelId() == aChannelID )
+ {
+ // Channel found, no need to loop rest
+ i = channelCount;
+ }
+ }
+ }
+
+ // Leave if channel is not found
+ if ( !channel )
+ {
+ User::Leave( KErrNotFound );
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::FindChannel() - return" ) ) );
+ return channel;
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::OpenChannelL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceControl::OpenChannelL( TSensrvChannelId aChannelID )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::OpenChannelL()" ) ) );
+ // Find and open channel
+ User::LeaveIfError( FindChannelL( aChannelID )->OpenChannel() );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::OpenChannelL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::CloseChannelL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceControl::CloseChannelL( TSensrvChannelId aChannelID )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::CloseChannelL()" ) ) );
+ // Find and close channel
+ User::LeaveIfError( FindChannelL( aChannelID )->CloseChannel() );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::CloseChannelL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferenceControl::ProcessResponse
+// ---------------------------------------------------------------------------
+//
+void CSsyReferenceControl::ProcessResponse( TSsyReferenceMsg* /*aMessage*/ )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::ProcessResponse()" ) ) );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferenceControl::ProcessResponse() - return" ) ) );
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencecontrol.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,156 @@
+// ssyreferencecontrol.h
+
+/*
+* Copyright (c) 2006-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:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+#ifndef SSYREFERENCECONTROL_H
+#define SSYREFERENCECONTROL_H
+
+#include <sensors/spi/ssycontrol.h>
+#include "ssyreferenceconfig.h"
+
+// FORWARD DECLARATIONS
+class CSsyReferenceChannel;
+
+/**
+ * Main control class for SSY. Controls sensor basic functionality and provides mandatory
+ * ECOM interface specific things.
+ */
+class CSsyReferenceControl : public CSsyControl
+ {
+
+public:
+
+ /**
+ * Two-phase constructor
+ *
+ * @param[in] aSsyCallback Reference to SSY callback instance.
+ * @return Pointer to created CSsyReferenceControl object
+ */
+ static CSsyReferenceControl* NewL( MSsyCallback& aSsyCallback );
+
+ /**
+ * Virtual destructor
+ */
+ virtual ~CSsyReferenceControl();
+
+// from base class CSsyControl
+
+ /**
+ * From CSsyControl
+ * Request for SSY to open a sensor channel asynchronously.
+ * Response to the request is delivered through MSsyCallback::ChannelOpened().
+ * Initilizes SSY (and the sensor) to be ready for other control commands via
+ * data and property providers. Multiple OpenChannel()-requests can be
+ * active for different channels at the same time.
+ *
+ * @param[in] aChannelID Channel that is requested to be opened
+ * @return Symbian error code
+ */
+ void OpenChannelL( TSensrvChannelId aChannelID );
+
+ /**
+ * From CSsyControl
+ * Request to close a sensor channel asynchronously.
+ * Response to the request is delivered through MSsyCallback::ChannelClosed().
+ * Multiple CloseChannel()-requests can be active for different channels
+ * at the same time.
+ *
+ * @param[in] aChannelID Channel that is reqeusted to be closed
+ * @leave Any One of the system wide error codes
+ */
+ void CloseChannelL( TSensrvChannelId aChannelID );
+
+ /**
+ * Reference to SSY Callback instance
+ */
+ MSsyCallback& SsyCallback() const;
+
+ /**
+ * Reference to SSY Config file
+ */
+ CSsyReferenceConfig& SsyConfig() const;
+ /**
+ * Handles response to CSsyReferenceCmdHandler::ProcessCommand
+ *
+ * @param[in] aMessage Contains information of the response
+ */
+ void ProcessResponse( TSsyReferenceMsg* aMessage );
+
+ /**
+ * Search property of given property id from the channel properties and
+ * returns reference to that. Leaves with KErrNotFound if property is not found
+ *
+ * @param[in] aPropertyId Property ID to locate
+ * @param[in] aArrayIndex Propertys array index
+ * @param[out] aProperty Contains found property
+ */
+ void FindPropertyL( const TSensrvPropertyId aPropertyId,
+ const TInt aArrayIndex,
+ TSensrvProperty& aProperty );
+
+private:
+
+ /**
+ * C++ constructor.
+ *
+ * @param[in] aSsyCallback Reference to SSY callback instance.
+ */
+ CSsyReferenceControl( MSsyCallback& aSsyCallback );
+
+ /**
+ * Symbian 2nd phase constructor.
+ */
+ void ConstructL();
+
+ /**
+ * Finds and returns pointer to channel
+ */
+ CSsyReferenceChannel* FindChannelL( TSensrvChannelId aChannelID );
+
+private: // data
+
+ /**
+ * Reference to SSY CallBack to send responses to Sensor Server
+ */
+ MSsyCallback& iSsyCallback;
+
+ /**
+ * Pointer array of all channels provided by this SSY
+ */
+ CArrayPtrFlat<CSsyReferenceChannel>* iChannelArray;
+
+ /**
+ * Pointer to config file parser
+ */
+ CSsyReferenceConfig* iConfigFile;
+
+ /**
+ * Property list of general properties of this SSY
+ */
+ RSensrvPropertyList iProperties;
+ };
+
+#endif // SSYREFERENCECONTROL_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencepropertyprovider.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,164 @@
+// ssyreferencepropertyprovider.cpp
+
+// Copyright (c) 2006-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 "ssyreferencepropertyprovider.h"
+#include "ssyreferencetrace.h"
+#include "ssyreferencechannel.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSsyReferencePropertyProvider C++ constructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferencePropertyProvider::CSsyReferencePropertyProvider( CSsyReferenceChannel& aChannel ) :
+ iChannel( aChannel )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::CSsyReferencePropertyProvider()" ) ) );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::CSsyReferencePropertyProvider() - return" ) ) );
+ }
+
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void CSsyReferencePropertyProvider::ConstructL()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::ConstructL()" ) ) );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::ConstructL() - return" ) ) );
+ }
+
+
+// ---------------------------------------------------------------------------
+// CSsyReferencePropertyProvider::NewL
+// ---------------------------------------------------------------------------
+//
+CSsyReferencePropertyProvider* CSsyReferencePropertyProvider::NewL( CSsyReferenceChannel& aChannel )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::NewL()" ) ) );
+ CSsyReferencePropertyProvider* self = new ( ELeave ) CSsyReferencePropertyProvider( aChannel );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::NewL() - return" ) ) );
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CSsyReferencePropertyProvider::~CSsyReferencePropertyProvider()
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::~CSsyReferencePropertyProvider()" ) ) );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::~CSsyReferencePropertyProvider() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferencePropertyProvider::CheckPropertyDependenciesL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferencePropertyProvider::CheckPropertyDependenciesL(
+ const TSensrvChannelId /*aChannelId*/,
+ const TSensrvProperty& /*aProperty*/,
+ RSensrvChannelList& /*aAffectedChannels*/ )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::CheckPropertyDependenciesL()" ) ) );
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::CheckPropertyDependenciesL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferencePropertyProvider::SetPropertyL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferencePropertyProvider::SetPropertyL(
+ const TSensrvChannelId aChannelId,
+ const TSensrvProperty& aProperty )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::SetPropertyL()" ) ) );
+
+ if ( iChannel.ChannelId() != aChannelId )
+ {
+ User::Leave( KErrArgument );
+ }
+
+ // Search property. Leaves with KErrNotFound if property is not found.
+ // Leaves with KErrAccessDenied if found property is Read only
+ iChannel.FindAndUpdatePropertyL( aProperty );
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::SetPropertyL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferencePropertyProvider::GetPropertyL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferencePropertyProvider::GetPropertyL(
+ const TSensrvChannelId aChannelId,
+ TSensrvProperty& aProperty )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::GetPropertyL()" ) ) );
+
+ if ( iChannel.ChannelId() != aChannelId && aChannelId != 0 )
+ {
+ User::Leave( KErrArgument );
+ }
+ else
+ {
+ // Search property. Leaves with KErrNotFound if property is not found
+ aProperty = iChannel.FindPropertyL(
+ aProperty.GetPropertyId(),
+ aProperty.PropertyItemIndex(),
+ aProperty.GetArrayIndex() );
+ }
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::GetPropertyL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferencePropertyProvider::GetAllPropertiesL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferencePropertyProvider::GetAllPropertiesL(
+ const TSensrvChannelId aChannelId,
+ RSensrvPropertyList& aChannelPropertyList )
+ {
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::GetAllPropertiesL()" ) ) );
+
+ if ( iChannel.ChannelId() != aChannelId )
+ {
+ User::Leave( KErrArgument );
+ }
+
+ iChannel.GetProperties( aChannelPropertyList );
+
+ COMPONENT_TRACE( ( _L( "SSY Reference Plugin - CSsyReferencePropertyProvider::GetAllPropertiesL() - return" ) ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CSsyReferencePropertyProvider::GetPropertyProviderInterfaceL
+// ---------------------------------------------------------------------------
+//
+void CSsyReferencePropertyProvider::GetPropertyProviderInterfaceL( TUid /*aInterfaceUid*/,
+ TAny*& aInterface )
+ {
+ aInterface = NULL;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencepropertyprovider.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,139 @@
+// ssyreferencepropertyprovider.h
+
+/*
+* Copyright (c) 2006-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:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+
+
+#ifndef SSYREFERENCEPROPERTYPROVIDER_H
+#define SSYREFERENCEPROPERTYPROVIDER_H
+
+#include <sensors/spi/ssypropertyprovider.h>
+
+
+class CSsyReferenceChannel;
+
+/**
+ * Channel property provider implementation.
+ */
+class CSsyReferencePropertyProvider : public CBase, public MSsyPropertyProvider
+ {
+
+public:
+
+ /**
+ * Two-phase constructor
+ *
+ * @param[in] aChannel Reference to channel this provider belongs to
+ * @return Pointer to created CSsyReferenceControl object
+ */
+ static CSsyReferencePropertyProvider* NewL( CSsyReferenceChannel& aChannel );
+
+ /**
+ * Virtual destructor
+ */
+ virtual ~CSsyReferencePropertyProvider();
+
+// from base class MSsyPropertyProvider
+
+ /**
+ * From MSsyPropertyProvider
+ * Check if property value affects other sensor channels already open.
+ * If the new property value is legal but affects somehow other channels' properties,
+ * SSY must return list of the affected channels so that the sensor server can
+ * check if the client allowed to set this property. If the SSY value
+ * is not legal SSY must leave with KErrArgument-value.
+ *
+ * @param[in] aProperty Property to be checked.
+ * @param[out] aAffectedChannels Return list of the channel which will be affected if the property
+ * value will be set.
+ * @leave KErrArgument If the property value is illegal.
+ */
+ void CheckPropertyDependenciesL( const TSensrvChannelId aChannelId,
+ const TSensrvProperty& aProperty,
+ RSensrvChannelList& aAffectedChannels );
+
+ /**
+ * From MSsyPropertyProvider
+ * Set property for the channel. Before the sensor server sets the property value,
+ * it is checked with CheckPropertyDependenciesL()-function.
+ * This means a property value should always be valid for the SSY.
+ *
+ * @param[in] aProperty Rereference to a property object to be set
+ */
+ void SetPropertyL( const TSensrvChannelId aChannelId,
+ const TSensrvProperty& aProperty );
+
+ /**
+ * From MSsyPropertyProvider
+ * Get channel property value. The property parameter contains channel id and
+ * item index. SSY fills values and attributes to the property object.
+ *
+ * @param[in, out] aProperty Reference to a property object to be filled
+ * with property values and attributes.
+ */
+ void GetPropertyL( const TSensrvChannelId aChannelId,
+ TSensrvProperty& aProperty );
+
+ /**
+ * From MSsyPropertyProvider
+ * Get all channel properties. Returns all properties which are related to this channel.
+ *
+ * @param[out] aChannelPropertyList List of the all properties of the channel.
+ */
+ void GetAllPropertiesL( const TSensrvChannelId aChannelId,
+ RSensrvPropertyList& aChannelPropertyList );
+
+ /**
+ * Returns a pointer to a specified interface - to allow future extension
+ * of this class without breaking binary compatibility
+ *
+ * @param aInterfaceUid Identifier of the interface to be retrieved
+ * @param aInterface A reference to a pointer that retrieves the specified interface.
+ */
+ void GetPropertyProviderInterfaceL( TUid aInterfaceUid,
+ TAny*& aInterface );
+
+private:
+
+ /**
+ * C++ constructor.
+ * @param[in] aChannel Reference to channel this provider belongs to
+ */
+ CSsyReferencePropertyProvider( CSsyReferenceChannel& aChannel );
+
+ /**
+ * Symbian 2nd phase constructor.
+ */
+ void ConstructL();
+
+private: // data
+
+ /**
+ * Reference to channel for which this provider belongs to
+ */
+ CSsyReferenceChannel& iChannel;
+ };
+
+#endif // SSYREFERENCEPROPERTYPROVIDER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sensorsupport/testsensor/src/ssyreferencetrace.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,117 @@
+// ssyreferencetrace.h
+
+/*
+* Copyright (c) 2006-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:
+*
+*/
+
+
+
+
+/**
+ @file
+ @internalComponent
+*/
+#ifndef SSYREFERENCETRACE_H
+#define SSYREFERENCETRACE_H
+
+
+// INCLUDES
+#include <e32svr.h>
+
+
+// PC-LINT OPTIONS
+// Removes null statement not in line by itself warnings from
+// COMPONENT_TRACE macros
+//lint -esym(960,54)
+
+// Removes "area too small" pointer cast warnings.
+//lint -e826
+
+
+
+// CONSTANTS
+// MACROS
+#ifdef _DEBUG
+
+ #ifdef THREAD_TRACE_FLAG
+
+ #define THREAD_TRACE RDebug::Print(RThread().Name());
+
+ #else
+
+ #define THREAD_TRACE
+
+ #endif // #ifdef THREAD_TRACE_FLAG
+
+ #ifdef BUFFER_TRACE_FLAG
+
+ #define BUFFER_TRACE_DEBUG
+ #define DEBUG_PRINT_BUFFER DebugPrintBuffer();
+ #define BUFFER_TRACE( a ) RDebug::Print a
+
+ #else
+
+ #define DEBUG_PRINT_BUFFER
+ #define BUFFER_TRACE( a )
+
+ #endif // #ifdef THREAD_TRACE_FLAG
+
+ #ifdef COMPONENT_TRACE_FLAG
+
+ #define COMPONENT_TRACE( a ) THREAD_TRACE;RDebug::Print a
+ #define COMPONENT_TRACE_DEBUG
+
+ #else // #ifdef COMPONENT_TRACE_FLAG
+
+ #define COMPONENT_TRACE( a )
+
+ #endif //#ifdef COMPONENT_TRACE_FLAG
+
+ #ifdef API_TRACE_FLAG
+
+ #define API_TRACE( a ) THREAD_TRACE;RDebug::Print a
+ #define API_TRACE_DEBUG
+
+ #else //#ifdef API_TRACE_FLAG
+
+ #define API_TRACE( a )
+
+ #endif //#ifdef API_TRACE_FLAG
+
+ #ifdef ERROR_TRACE_FLAG
+
+ #define ERROR_TRACE( a ) THREAD_TRACE;RDebug::Print a
+ #define ERROR_TRACE_DEBUG
+
+ #else //#ifdef ERROR_TRACE_FLAG
+
+ #define ERROR_TRACE( a )
+
+ #endif //#ifdef ERROR_TRACE_FLAG
+
+#else // #ifdef _DEBUG
+
+ #define COMPONENT_TRACE( a )
+ #define API_TRACE( a )
+ #define ERROR_TRACE( a )
+ #define BUFFER_TRACE( a )
+ #define THREAD_TRACE
+ #define DEBUG_PRINT_BUFFER
+
+#endif //#ifdef _DEBUG
+
+#endif // SSYREFERENCETRACE_H
+
--- a/startupservices/SplashScreen/src/SplashScreen.cpp Fri May 14 16:01:13 2010 +0300
+++ b/startupservices/SplashScreen/src/SplashScreen.cpp Thu May 27 13:01:09 2010 +0300
@@ -24,7 +24,7 @@
#include <startupdomainpskeys.h>
#include <SVGEngineInterfaceImpl.h>
#include <gdi.h>
-#include <COEMAIN.H>
+#include <coemain.h>
// USER INCLUDES
#include "SplashScreen.h"
--- a/startupservices/Startup/inc/StartupAppUi.h Fri May 14 16:01:13 2010 +0300
+++ b/startupservices/Startup/inc/StartupAppUi.h Thu May 27 13:01:09 2010 +0300
@@ -27,7 +27,7 @@
#ifndef STARTUPAPPUI_H
#define STARTUPAPPUI_H
-#include <secondarydisplay/secondarydisplaystartupapi.h>
+#include <SecondaryDisplay/SecondaryDisplayStartupAPI.h>
// USER INCLUDES
--- a/startupservices/Startup/pubsub/startupappprivatepskeys.h Fri May 14 16:01:13 2010 +0300
+++ b/startupservices/Startup/pubsub/startupappprivatepskeys.h Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-2010 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"
@@ -38,4 +38,6 @@
// and finished showing country & time queries.
};
+const TUint32 KPSStartupAppStarted = 0x00000002;
+
#endif // STARTUPAPPPRIVATEPSKEYS_H
--- a/startupservices/Startup/src/StartupApplication.cpp Fri May 14 16:01:13 2010 +0300
+++ b/startupservices/Startup/src/StartupApplication.cpp Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 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"
@@ -21,6 +21,12 @@
// INCLUDE FILES
#include "StartupApplication.h"
#include "StartupDocument.h"
+#include "startupappprivatepskeys.h"
+#include <e32property.h>
+
+//Security policies
+_LIT_SECURITY_POLICY_C1(KReadDeviceDataPolicy, ECapabilityReadDeviceData);
+_LIT_SECURITY_POLICY_C1(KWriteDeviceDataPolicy, ECapabilityWriteDeviceData);
// ========================= MEMBER FUNCTIONS ================================
@@ -53,6 +59,12 @@
GLDEF_C TInt E32Main()
{
+ //Make sure startup app is only started once
+ TInt ret = RProperty::Define(KPSUidStartupApp, KPSStartupAppStarted, RProperty::EInt, KReadDeviceDataPolicy, KWriteDeviceDataPolicy);
+ if(ret!=KErrNone)
+ {
+ return KErrNone;
+ }
return EikStart::RunApplication(NewApplication);
}
--- a/startupservices/Startup/syserrcmd/src/syserrcmd.cpp Fri May 14 16:01:13 2010 +0300
+++ b/startupservices/Startup/syserrcmd/src/syserrcmd.cpp Thu May 27 13:01:09 2010 +0300
@@ -22,7 +22,7 @@
#include <data_caging_path_literals.hrh>
#include <featmgr.h>
-#include <secondarydisplay/secondarydisplaystartupapi.h>
+#include <SecondaryDisplay/SecondaryDisplayStartupAPI.h>
#include <StringLoader.h>
#include <startup.rsg>
#include <stringresourcereader.h>
--- a/startupservices/startupanimation/sanimctrl/src/sanimstartupctrl.cpp Fri May 14 16:01:13 2010 +0300
+++ b/startupservices/startupanimation/sanimctrl/src/sanimstartupctrl.cpp Thu May 27 13:01:09 2010 +0300
@@ -25,7 +25,7 @@
#include <Profile.hrh>
#include <ProfileEngineSDKCRKeys.h>
#include "sanimengine.h"
-#include <secondarydisplay/secondarydisplaystartupapi.h>
+#include <SecondaryDisplay/SecondaryDisplayStartupAPI.h>
#include "sanimstartupctrl.h"
#include "trace.h"
--- a/sysresmonitoring/oommonitor/bwins/oommonitorU.DEF Fri May 14 16:01:13 2010 +0300
+++ b/sysresmonitoring/oommonitor/bwins/oommonitorU.DEF Thu May 27 13:01:09 2010 +0300
@@ -13,4 +13,8 @@
?SetMemoryMonitorTls@@YAXPAVCMemoryMonitor@@@Z @ 12 NONAME ; void SetMemoryMonitorTls(class CMemoryMonitor *)
?ThisAppIsNotExiting@ROomMonitorSession@@QAEXH@Z @ 13 NONAME ; void ROomMonitorSession::ThisAppIsNotExiting(int)
?WsSession@COomMonitorPlugin@@QAEAAVRWsSession@@XZ @ 14 NONAME ; class RWsSession & COomMonitorPlugin::WsSession(void)
+ ?FreeRam@COomMonitorPluginV2@@UAEXXZ @ 15 NONAME ; void COomMonitorPluginV2::FreeRam(void)
+ ?RequestOptionalRam@ROomMonitorSession@@QAEHHHHAAH@Z @ 16 NONAME ; int ROomMonitorSession::RequestOptionalRam(int, int, int, int &)
+ ?RequestOptionalRam@ROomMonitorSession@@QAEXHHHAAVTRequestStatus@@@Z @ 17 NONAME ; void ROomMonitorSession::RequestOptionalRam(int, int, int, class TRequestStatus &)
+ ?SetOomPriority@ROomMonitorSession@@QAEXW4TOomPriority@1@@Z @ 18 NONAME ; void ROomMonitorSession::SetOomPriority(enum ROomMonitorSession::TOomPriority)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/data/oomconfig.xml Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,181 @@
+<!--
+ Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+ All rights reserved.
+ This component and the accompanying materials are made available
+ under the terms of the License "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:
+
+-->
+
+
+<!-- This is the configuration file for the new OOM Monitor. This configuration file
+defines an OOM policy where RAM is released in the following order.
+
+1. Empty server caches (skin server cache, icon server cache, MDS cache, TFX server cache)
+2. Close applications that have not been used for more than 12 hours (including Browser and high priority applications)
+3. If Browser is in the background, empty Browser cache and close unused windows
+4. Close always-on applications in the following order: Clock, Calendar, Messaging, Contacts, Logs, Camera
+5. Close applications that have not been used for more than 15 minutes (including Browser but excluding high priority applications)
+6. Close Matrix UI if it has not been used for more than 15 seconds and continue closing WRT widgets immediately.
+7. Close WRT widgets
+8. Close other background applications that have been used within 15 minutes except Browser and high priority applications
+9. Close high priority applications
+10. If Browser is in the foreground, empty Browser cache and close unused windows
+11. Close Browser in the background when it has been used within 15 minutes
+-->
+<oom_config>
+
+<!-- Low RAM and good RAM thresholds are defined here in kilobytes.
+ The max_app_close_batch indicates how many applications can be closed in parallel.
+ The value 1 means that applications are not closed in parallel.
+ default_wait_after_plugin defines how long is waited (in milliseconds) after
+ an OOM plugin is called and before the free RAM is checked to determine if more
+ actions are needed. This value is meaningful only when "check" or "estimate" sync mode is
+ used with plugins.
+-->
+ <global_settings low_ram_threshold="3637" good_ram_threshold="4900" swap_usage_monitored="true" low_swap_threshold="15000" good_swap_threshold="25000" max_app_close_batch="3" default_wait_after_plugin="10" max_app_exit_time="2000">
+ </global_settings>
+
+<!-- Application specific low RAM and good RAM thresholds are defined here. The higher values of
+the low and good thresholds are defined to avoid OOM errors with these applications when the default
+threshold values are used.
+-->
+ <app_specific_thresholds>
+ <app uid="10008d39" low_ram_threshold="8637" good_ram_threshold="9900"></app> <!-- Browser -->
+ <app uid="20001f63" low_ram_threshold="4637" good_ram_threshold="5900"></app> <!-- Maps -->
+ <app uid="101f857a" low_ram_threshold="5637" good_ram_threshold="6900"></app> <!-- camera -->
+ <app uid="10282822" low_ram_threshold="5637" good_ram_threshold="6900"></app> <!-- Widget UI -->
+ <app uid="200009ee" low_ram_threshold="8637" good_ram_threshold="9900"></app> <!-- Photos -->
+ <app uid="20007b39" low_ram_threshold="10637" good_ram_threshold="11900"></app> <!-- NGage -->
+ </app_specific_thresholds>
+
+<!-- The priority of closing each application is defined here.
+-->
+ <app_close_settings>
+
+<!-- The uid DEFAULT_APP refers to all applications, which priority is not specifically
+ defined in the conf file.
+-->
+ <close_app uid="DEFAULT_APP" priority="80" sync_mode="check">
+ <app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+ <app_close_idle_priority idle_time="43200" priority="20"></app_close_idle_priority>
+ </close_app>
+<!-- The uid BUSY_APP refers to applications, which have set the OOM priority BUSY
+ by using the OOM Monitor API SetOomPriority(). The priority NEVER_CLOSE
+ means that the application is not closed at all.
+-->
+ <close_app uid="BUSY_APP" priority="NEVER_CLOSE" sync_mode="check"></close_app>
+
+<!-- The uid HIGH_PRIORITY_APP refers to applications, which have set the OOM priority HIGH
+ by using the OOM Monitor API SetOomPriority().
+-->
+ <close_app uid="HIGH_PRIORITY_APP" priority="90" sync_mode="check">
+ <app_close_idle_priority idle_time="43200" priority="20"></app_close_idle_priority>
+ </close_app>
+ <close_app uid="10005903" priority="80" sync_mode="check"> <!-- Clock -->
+ <app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+ <app_close_idle_priority idle_time="43200" priority="40"></app_close_idle_priority>
+ </close_app>
+ <close_app uid="10005901" priority="80" sync_mode="check"> <!-- Calendar -->
+ <app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+ <app_close_idle_priority idle_time="43200" priority="41"></app_close_idle_priority>
+ </close_app>
+ <close_app uid="100058c5" priority="80" sync_mode="check"> <!-- Messaging -->
+ <app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+ <app_close_idle_priority idle_time="43200" priority="42"></app_close_idle_priority>
+ </close_app>
+ <close_app uid="101f4cce" priority="80" sync_mode="check"> <!-- Contacts -->
+ <app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+ <app_close_idle_priority idle_time="43200" priority="43"></app_close_idle_priority>
+ </close_app>
+ <close_app uid="101f4cd5" priority="80" sync_mode="check"> <!-- Logs -->
+ <app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+ <app_close_idle_priority idle_time="43200" priority="44"></app_close_idle_priority>
+ </close_app>
+ <close_app uid="101f857a" priority="80" sync_mode="check"> <!-- Camcorder -->
+ <app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+ <app_close_idle_priority idle_time="43200" priority="45"></app_close_idle_priority>
+ </close_app>
+ <close_app uid="10008d39" priority="110" sync_mode="check"> <!-- Browser -->
+ <app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+ <app_close_idle_priority idle_time="43200" priority="20"></app_close_idle_priority>
+ </close_app>
+
+ <!--CWRTWidget.exe -->
+ <close_app uid="200267C0" priority="100" sync_mode="check"> <!-- Ovi Widget UI -->
+ <app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+ <app_close_idle_priority idle_time="43200" priority="30"></app_close_idle_priority>
+ </close_app>
+ <!--CWRTWidget.exe End -->
+ <!--CWRTWidget2.exe -->
+ <close_app uid="200267D6" priority="80" sync_mode="check">
+ <app_close_idle_priority idle_time="900" priority="50"></app_close_idle_priority>
+ <app_close_idle_priority idle_time="43200" priority="30"></app_close_idle_priority>
+ </close_app>
+ <!--CWRTWidget2.exe End -->
+<!-- Widget UI plugin handles the closing of widgets. Widget UI application is not closed.
+-->
+ <close_app uid="10282822" priority="NEVER_CLOSE" sync_mode="check"> </close_app> <!-- Widget UI -->
+ <close_app uid="101f4cd2" priority="NEVER_CLOSE" sync_mode="continue">
+ <app_close_idle_priority idle_time="15" priority="60"></app_close_idle_priority>
+ <foreground_app_priority if_foreground_app_id="10207218" priority="NEVER_CLOSE"></foreground_app_priority> <!-- Fast swap -->
+ </close_app> <!-- Matrix UI -->
+ <close_app uid="10207a89" priority="NEVER_CLOSE" sync_mode="check">
+ <app_close_idle_priority idle_time="43200" priority="20"></app_close_idle_priority>
+ </close_app> <!-- Radio -->
+ </app_close_settings>
+<!-- The priority of executing each system plugin is defined here.
+ System plugin is a plugin, which priority is not related to any application.
+-->
+ <system_plugin_settings>
+<!-- The uid DEFAULT_PLUGIN refers to all plugins, which priority is not specificly
+ defined in the conf file.
+-->
+ <system_plugin uid="DEFAULT_PLUGIN" priority="10" sync_mode="continue"></system_plugin>
+ <system_plugin uid="10207140" priority="10" sync_mode="continue"></system_plugin> <!-- AKNSKINSOOMPLUGIN -->
+ <system_plugin uid="10281fe6" priority="10" sync_mode="continue"></system_plugin> <!-- AKNICONOOMPLUGIN -->
+ <system_plugin uid="10282e4f" priority="10" sync_mode="continue"></system_plugin> <!-- TFXSRVOOMPLUGIN -->
+ <system_plugin uid="2001b2c6" priority="10" sync_mode="continue"></system_plugin> <!-- MDSOOMPLUGIN -->
+ </system_plugin_settings>
+<!-- The priority of executing each application plugin is defined here.
+ Application plugin is a plugin, which priority depends on the target application.
+ The target application must be defined for each application plugin.
+ By default all plugins are system plugins unless specifically defined as application
+ plugin in this section.
+-->
+ <app_plugin_settings>
+ <app_plugin uid="10281f93" target_app_id="10008d39" priority="30" wait="100" sync_mode="check"> <!-- WEBENGINEMEMORYPLUGIN, target app Browser -->
+ <plugin_foreground_app_priority target_app_id="10008d39" priority="100"></plugin_foreground_app_priority>
+ </app_plugin>
+
+<!-- Widget memory plugin has very long plugin wait time because we don't want to unnecessarily
+ close any other applications after closing it. We call Widget memory plugin only if
+ Widget UI application is running in the background.
+-->
+ <app_plugin uid="10282855" target_app_id="10282822" priority="70" wait="3500" sync_mode="check" call_if_target_app_not_running="false"> <!-- WIDGETMEMORYPLUGIN, target app Widget UI -->
+ <plugin_foreground_app_priority target_app_id="10282822" priority="NEVER_CLOSE"></plugin_foreground_app_priority> <!-- target app Widget UI -->
+ </app_plugin>
+ <!--CWRTWidget.exe - Plugin -->
+
+ <app_plugin uid="200267D3" target_app_id="200267C0" priority="70" wait="3500" sync_mode="check" call_if_target_app_not_running="false">
+ <plugin_foreground_app_priority target_app_id="200267C0" priority="NEVER_CLOSE"></plugin_foreground_app_priority>
+ </app_plugin>
+
+ <!--CWRTWidget.exe - Plugin End-->
+ <!--CWRTWidget2.exe - Plugin -->
+
+ <app_plugin uid="200267DB" target_app_id="200267D6" priority="50" wait="3500" sync_mode="check" call_if_target_app_not_running="false">
+ <plugin_foreground_app_priority target_app_id="200267D6" priority="NEVER_CLOSE"></plugin_foreground_app_priority>
+ </app_plugin>
+
+ <!--CWRTWidget2.exe - Plugin End-->
+ </app_plugin_settings>
+</oom_config>
--- a/sysresmonitoring/oommonitor/eabi/oommonitorU.DEF Fri May 14 16:01:13 2010 +0300
+++ b/sysresmonitoring/oommonitor/eabi/oommonitorU.DEF Thu May 27 13:01:09 2010 +0300
@@ -17,4 +17,10 @@
_ZN20CAppOomMonitorPlugin4NewLE4TUid @ 16 NONAME
_ZTI17COomMonitorPlugin @ 17 NONAME ; #<TI>#
_ZTV17COomMonitorPlugin @ 18 NONAME ; #<VT>#
+ _ZN18ROomMonitorSession18RequestOptionalRamEiiiRi @ 19 NONAME
+ _ZN19COomMonitorPluginV27FreeRamEv @ 20 NONAME
+ _ZTI19COomMonitorPluginV2 @ 21 NONAME ; #<TI>#
+ _ZTV19COomMonitorPluginV2 @ 22 NONAME ; #<VT>#
+ _ZN18ROomMonitorSession18RequestOptionalRamEiiiR14TRequestStatus @ 23 NONAME
+ _ZN18ROomMonitorSession14SetOomPriorityENS_12TOomPriorityE @ 24 NONAME
--- a/sysresmonitoring/oommonitor/group/bld.inf Fri May 14 16:01:13 2010 +0300
+++ b/sysresmonitoring/oommonitor/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 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"
@@ -18,16 +18,15 @@
#include <platform_paths.hrh>
+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
--- a/sysresmonitoring/oommonitor/group/oommonitor.mmp Fri May 14 16:01:13 2010 +0300
+++ b/sysresmonitoring/oommonitor/group/oommonitor.mmp Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 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"
@@ -18,10 +18,22 @@
#include <platform_paths.hrh>
+//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,5 +87,8 @@
LIBRARY ecom.lib
LIBRARY hal.lib
LIBRARY efsrv.lib
-
-SMPSAFE
+LIBRARY xmlframework.lib
+LIBRARY cone.lib
+#ifdef _DEBUG
+LIBRARY flogger.lib
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/group/oommonitorlib.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/OomTraces.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,487 @@
+/*
+* Copyright (c) 2006-2010 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 <flogger.h> // RFileLogger
+#else
+#include <e32debug.h> // 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 <e32base.h> // 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 <e32debug.h> // 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomaction.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+
+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, TBool aIsDataPaged) = 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomactionconfig.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2006-2010 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 <e32cmn.h>
+#include <e32std.h>
+#include <w32std.h>
+
+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<MOomRuleConfig> iRules;
+ };
+
+#include "oomactionconfig.inl"
+
+#endif /*OOMACTIONCONFIG_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomactionconfig.inl Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2006-2010 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomactionlist.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,240 @@
+/*
+* Copyright (c) 2006-2010 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 <e32def.h>
+#include <e32base.h>
+
+#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 <class T>
+/**
+ * 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<TPlugin> 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 <class T>
+ void BuildPluginActionsL(COomPluginList<T>& 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 aCurrentRamTarget the desired amount of free unpaged memory
+ * @param aCurrentSwapTarget the desired amount of free paged memory
+ */
+ inline void SetCurrentTargets(TUint aCurrentRamTarget, TUint aCurrentSwapTarget);
+
+ /**
+ * 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<COomCloseApp> iCloseAppActions;
+ RPointerArray<COomRunPlugin> iRunPluginActions;
+ RArray<TActionRef> iActionRefs;
+
+ TInt iCurrentActionIndex;
+
+ TUint iCurrentRamTarget;
+ TBool iSwapUsageMonitored;
+ TUint iCurrentSwapTarget;
+
+ /*
+ * Flag specifying that a OomMonitor event is in progress.
+ */
+ TBool iFreeingMemory;
+
+ CMemoryMonitor& iMonitor;
+
+ /**
+ * The list of V1 plugins
+ * Own
+ */
+ COomPluginList<COomMonitorPlugin>* iPluginList;
+
+ /**
+ * The list of V2 plugins
+ * Own
+ */
+ COomPluginList<COomMonitorPluginV2>* iPluginListV2;
+
+ /**
+ * The maximum priority of actions that should be run by an OomMonitor Event
+ */
+ TInt iMaxPriority;
+
+ CMemoryMonitorServer& iServer;
+
+ };
+
+#include "oomactionlist.inl"
+
+#endif /*OOMACTIONLIST_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomactionlist.inl Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2006-2010 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 <class T>
+inline TInt COomPluginList<T>::Count()
+ {
+ return iPlugins.Count();
+ }
+
+template <class T>
+inline T& COomPluginList<T>::Implementation(TInt aIndex)
+ {
+ return *(iPlugins[aIndex].iImpl);
+ }
+
+template <class T>
+inline TInt32 COomPluginList<T>::Uid(TInt aIndex)
+ {
+ return iPlugins[aIndex].iUid;
+ }
+
+inline void COomActionList::SetCurrentTargets(TUint aCurrentRamTarget, TUint aCurrentSwapTarget)
+ {
+ iCurrentRamTarget = aCurrentRamTarget;
+ iCurrentSwapTarget = aCurrentSwapTarget;
+ }
+
+
+#endif /*OOMACTIONLISTINL_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomactionref.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+#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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomappclosetimer.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+
+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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomappclosewatcher.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+
+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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomapplicationconfig.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+
+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;
+ TUint iGoodSwapThreshold;
+ TUint iLowSwapThreshold;
+
+private:
+
+ void ConstructL();
+
+ COomApplicationConfig(TUint aApplicationId);
+
+ COomCloseAppConfig* iCloseAppConfig;
+
+ TInt iIndex;
+
+ TUint iApplicationId;
+ };
+
+#include "oomapplicationconfig.inl"
+
+#endif /*OOMAPPLICATIONCONFIG_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomapplicationconfig.inl Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2006-2010 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomclientrequestqueue.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,134 @@
+/*
+* Copyright (c) 2006-2010 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 <e32std.h>
+#include <e32base.h>
+#include <e32property.h>
+
+#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<TClientRequest> iQueue;
+
+ TBool iClientRequestActive;
+
+ CMemoryMonitor& iMonitor;
+
+ COomClientRequestTimer* iClientRequestTimer;
+
+ TTime iLastClientCompletedTime;
+ };
+
+#endif // COOMCLIENTREQUESTQUEUE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomcloseapp.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,100 @@
+/*
+* Copyright (c) 2006-2010 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 <apgtask.h>
+
+#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, TBool aIsDataPaged);
+
+ ~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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomcloseapp.inl Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006-2010 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomcloseappconfig.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2006-2010 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomcloseappconfig.inl Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2006-2010 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomconfig.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+
+#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 SetSwapUsageMonitored(TBool aMonitored);
+ inline void SetDefaultLowSwapThreshold(TInt aLowSwapThreshold);
+ inline void SetDefaultGoodSwapThreshold(TInt aGoodSwapThreshold);
+ inline void SetMaxCloseAppBatch(TUint MaxCloseAppBatch);
+ inline void SetDefaultWaitAfterPlugin(TInt aMilliseconds);
+ inline void SetMaxAppExitTime(TInt aMilliseconds);
+
+private:
+ void ConstructL();
+
+ RHashMap<TInt32, COomApplicationConfig*> iApplicationToConfigMapping; // A hash-map of application configs, keyed on the application ID
+
+ RHashMap<TInt32, COomRunPluginConfig*> iPluginToConfigMapping; // A hash-map of plug-in configs, keyed on the plugin ID
+
+ COomGlobalConfig iGlobalConfig;
+ };
+
+#include "oomconfig.inl"
+
+#endif /*OOMCONFIG_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomconfig.inl Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2006-2010 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::SetSwapUsageMonitored(TBool aMonitored)
+ {
+ iGlobalConfig.iSwapUsageMonitored = aMonitored;
+ }
+
+void COomConfig::SetDefaultLowSwapThreshold(TInt aLowSwapThreshold)
+ {
+ iGlobalConfig.iLowSwapThreshold = aLowSwapThreshold;
+ }
+
+void COomConfig::SetDefaultGoodSwapThreshold(TInt aGoodSwapThreshold)
+ {
+ iGlobalConfig.iGoodSwapThreshold = aGoodSwapThreshold;
+ }
+
+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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomconfigparser.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2006-2010 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 <xml/contenthandler.h>
+
+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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomconstants.hrh Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2006-2010 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomforegroundrule.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+#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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomforegroundrule.inl Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2006-2010 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomglobalconfig.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+#include <e32hashtab.h>
+
+/**
+ * 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;
+ TBool iSwapUsageMonitored;
+ TInt iLowSwapThreshold;
+ TInt iGoodSwapThreshold;
+ TUint iMaxCloseAppBatch;
+ TInt iDefaultWaitAfterPlugin;
+ TInt iMaxAppExitTime;
+
+ RHashSet<TUint> iForceCheckPriorities;
+ };
+
+#include "oomglobalconfig.inl"
+
+#endif /*OOMGLOBALCONFIG_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomglobalconfig.inl Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2006-2010 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomidletimerule.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+
+#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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomidletimerule.inl Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2006-2010 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomlog.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2006-2010 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 <apgwgnam.h>
+
+#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<RWsSession::TWindowGroupChainInfo> 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oommemorymonitor.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,205 @@
+/*
+* Copyright (c) 2006-2010 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 <e32property.h>
+#include <f32file.h>
+#include <w32std.h>
+#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 aFreeRamTarget, TInt aFreeSwapSpaceTarget);
+ void StartFreeSomeRamL(TInt aFreeRamTarget, TInt aFreeSwapSpaceTarget, TInt aMaxPriority);
+ void FreeOptionalRamL(TInt aBytesRequested, TInt aPluginId, TBool aDataPaged); // 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);
+ void GetFreeSwapSpace(TInt& aCurrentFreeSwapSpace);
+ TActionTriggerType ActionTrigger() const;
+#ifdef CLIENT_REQUEST_QUEUE
+ void ActionsCompleted(TInt aBytesFree, TBool aMemoryGood);
+ TInt GoodRamThreshold() const;
+ TInt LowRamThreshold() const;
+#endif
+ void RequestFreeMemoryL(TInt aBytesRequested, TBool aDataPaged);
+ 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;
+
+ TBool iDataPaged;
+
+private: //data
+
+ // parameters for OOM watcher.
+ TInt iLowRamThreshold;
+ TInt iGoodRamThreshold;
+ TInt iLowSwapThreshold;
+ TInt iGoodSwapThreshold;
+ TInt iCurrentRamTarget;
+ TInt iCurrentSwapTarget;
+
+
+
+#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*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oommemorymonitorserver.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+
+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*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oommemorymonitorsession.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+
+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);
+ TBool IsDataPaged(const RMessage2& aMessage);
+private:
+ RMessagePtr2 iRequestFreeRam;
+#ifndef CLIENT_REQUEST_QUEUE
+ TInt iFunction;
+#endif
+ TInt iMinimumMemoryRequested;
+ };
+
+#endif /*OOMMEMORYMONITORSESSION_H*/
--- a/sysresmonitoring/oommonitor/inc/oommonitorclientserver.h Fri May 14 16:01:13 2010 +0300
+++ b/sysresmonitoring/oommonitor/inc/oommonitorclientserver.h Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 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"
@@ -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 <e32std.h>
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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomoutofmemorywatcher.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+
+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& aMonitor, TInt aLowRamThreshold, TInt aGoodRamThreshold,
+ TBool aSwapUsageMonitored, TInt aLowSwapThreshold, TInt aGoodSwapThreshold);
+ ~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 aLowRamThreshold, TInt aGoodRamThreshold, TInt aLowSwapThreshold, TInt aGoodSwapThreshold);
+private:
+ COutOfMemoryWatcher(CMemoryMonitor& aMonitor, TBool aSwapUsageMonitored);
+ void ConstructL(TInt aLowRamThreshold, TInt aGoodRamThreshold, TInt aLowSwapThreshold, TInt aGoodSwapThreshold);
+private: // from CActive
+ void DoCancel();
+ void RunL();
+private: // data
+ RChangeNotifier iChangeNotifier;
+ CMemoryMonitor& iMemoryMonitor;
+ TBool iSwapUsageMonitored;
+ };
+
+#endif /*OOMOUTOFMEMORYWATCHER_H*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oompanic.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2006-2010 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 <e32def.h>
+
+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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oompluginwaiter.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+
+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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomruleconfig.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2006-2010 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 <e32std.h>
+
+class COomWindowGroupList;
+
+NONSHARABLE_CLASS(MOomRuleConfig)
+ {
+public:
+ virtual TBool RuleIsApplicable(const COomWindowGroupList& aWindowGroupList, TInt aAppIndexInWindowGroup) const = 0;
+ virtual TUint Priority() const = 0;
+ };
+
+#endif /*OOMRULECONFIG_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomrunplugin.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2006-2010 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, TBool aIsDataPaged);
+
+ // 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomrunplugin.inl Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2006-2010 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomrunpluginconfig.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2006-2010 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomrunpluginconfig.inl Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 2006-2010 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomsubscribehelper.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+
+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*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomwindowgrouplist.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,119 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+#include <e32hashtab.h>
+#include <w32std.h>
+
+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<RWsSession::TWindowGroupChainInfo> iWgIds;
+ RArray<RWsSession::TWindowGroupChainInfo> iUncollapsedWgIds;
+
+ enum TOomPriority
+ {
+ EOomPriorityNormal,
+ EOomPriorityHigh,
+ EOomPriorityBusy
+ };
+
+ class TOomWindowGroupProperties
+ {
+ public:
+ TOomWindowGroupProperties();
+ TUint32 iIdleTickTime;
+ TOomPriority iDynamicPriority;
+ };
+
+ RHashMap<TInt, TOomWindowGroupProperties> iWgToPropertiesMapping; // A mapping between window group IDs and the properties such as idle time and the high-priority flag
+ RHashSet<TInt> 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomwindowgrouplist.inl Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2006-2010 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_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/oomwserveventreceiver.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2006-2010 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 <w32std.h>
+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*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/traceconfiguration.hrh Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/inc/tracedefs.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2006-2010 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
--- a/sysresmonitoring/oommonitor/rom/oommonitor.iby Fri May 14 16:01:13 2010 +0300
+++ b/sysresmonitoring/oommonitor/rom/oommonitor.iby Thu May 27 13:01:09 2010 +0300
@@ -22,6 +22,7 @@
#include <data_caging_paths_for_iby.hrh>
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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomIdletimerule.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2006-2010 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;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomaction.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2006-2010 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;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomactionconfig.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2006-2010 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;
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomactionlist.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,712 @@
+/*
+* Copyright (c) 2006-2010 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 <hal.h>
+#include <u32hal.h>
+#include <apgwgnam.h>
+
+#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 <class T>
+COomPluginList<T>::COomPluginList()
+ {
+ FUNC_LOG;
+ }
+
+template <class T>
+COomPluginList<T>::~COomPluginList()
+ {
+ FUNC_LOG;
+
+ TInt count = iPlugins.Count();
+ for (TInt ii=0; ii<count; ii++)
+ {
+ TPlugin& plugin = iPlugins[ii];
+ if (plugin.iImpl) // only if successfully added
+ REComSession::DestroyedImplementation(plugin.iDtorUid);
+ }
+ iPlugins.Close();
+ }
+
+template <class T>
+void COomPluginList<T>::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; ii<count; ii++)
+ {
+ iPlugins.AppendL(TPlugin());
+ TPlugin& plugin = iPlugins[ii];
+ TUid uid(implArray[ii]->ImplementationUid());
+ plugin.iImpl = static_cast<T*>(REComSession::CreateImplementationL(uid, plugin.iDtorUid, NULL));
+ plugin.iUid = uid.iUid;
+ }
+
+ CleanupStack::PopAndDestroy(&implArray);
+ }
+
+template <class T>
+COomPluginList<T>::TPlugin::TPlugin()
+: iImpl(0)
+ {
+ FUNC_LOG;
+ }
+
+template <class T>
+COomPluginList<T>* COomPluginList<T>::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 <class T>
+void COomActionList::BuildPluginActionsL(COomPluginList<T>& 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 freeRamEstimate = 0; // The amount of free memory we expect to be free after the currently initiated operations
+ HAL::Get(HALData::EMemoryRAMFree, freeRamEstimate);
+ TUint64 freeSwapEstimate = 0;
+ if (iSwapUsageMonitored)
+ {
+ SVMSwapInfo swapInfo;
+ UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo, 0);
+ freeSwapEstimate = swapInfo.iSwapFree;
+ }
+
+ 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<COomCloseApp*>(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);
+
+ // At the moment the actions don't make any difference between freeing
+ // RAM and freeing swap. So we try to free the biggest of the two.
+ // Until the plugins are updated to make a distinction between swap and RAM this is the best
+ // we can do. For application close actions the amount to try to free is ignored anyway.
+ TUint amountToTryToFree = 0;
+ if (iCurrentRamTarget > freeRamEstimate)
+ {
+ amountToTryToFree = iCurrentRamTarget - freeRamEstimate;
+ }
+ if (iSwapUsageMonitored && (iCurrentSwapTarget > freeSwapEstimate) && ((iCurrentSwapTarget - freeSwapEstimate) > amountToTryToFree))
+ {
+ amountToTryToFree = iCurrentSwapTarget - freeSwapEstimate;
+ }
+ action->FreeMemory(amountToTryToFree, iMonitor.iDataPaged);
+ 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
+ freeRamEstimate += 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)
+ && (freeRamEstimate >= iCurrentRamTarget))
+ {
+ 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 = 0;
+ iMonitor.GetFreeMemory(freeMemory);
+ TInt freeSwap = 0;
+ if (iSwapUsageMonitored)
+ {
+ iMonitor.GetFreeSwapSpace(freeSwap);
+ }
+ if ((freeMemory >= iCurrentRamTarget) &&
+ ((!iSwapUsageMonitored) || (freeSwap >= iCurrentSwapTarget)))
+ {
+ 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 = 0;
+ iMonitor.GetFreeMemory(freeMemory);
+ TInt freeSwap = 0;
+ if (iSwapUsageMonitored)
+ {
+ iMonitor.GetFreeSwapSpace(freeSwap);
+ }
+ if ((freeMemory < iCurrentRamTarget) ||
+ (iSwapUsageMonitored && (freeSwap < iCurrentSwapTarget)))
+ // 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 >= iCurrentRamTarget) &&
+ ((!iSwapUsageMonitored) || (freeSwap >= iCurrentSwapTarget)))
+ {
+ 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;
+ iSwapUsageMonitored = aConfig.GlobalConfig().iSwapUsageMonitored;
+ iFreeingMemory = EFalse;
+
+ // Get the list of V1 and V2 plugins available to the system
+ iPluginList = COomPluginList<COomMonitorPlugin>::NewL(KOomPluginInterfaceUidValue);
+ iPluginListV2 = COomPluginList<COomMonitorPluginV2>::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);
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomactionref.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2006-2010 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;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomappclosetimer.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2006-2010 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();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomappclosewatcher.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2006-2010 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();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomapplicationconfig.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2006-2010 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;
+ iGoodSwapThreshold = KOomThresholdUnset;
+ iLowSwapThreshold = KOomThresholdUnset;
+ }
+
+COomApplicationConfig::COomApplicationConfig(TUint aApplicationId) : iApplicationId(aApplicationId)
+ {
+ FUNC_LOG;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomclientrequestqueue.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,359 @@
+/*
+* Copyright (c) 2006-2010 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 <UikonInternalPSKeys.h>
+
+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<TClientRequest> 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<COomClientRequestQueue*>(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();
+
+ RThread clientThread;
+ TInt err = (request->iRequestFreeRamMessage).Client(clientThread);
+ TBool dataPaged = EFalse;
+ if(err == KErrNone)
+ {
+ RProcess processName;
+ err = clientThread.Process(processName);
+ dataPaged = processName.DefaultDataPaged();
+ }
+ else
+ {
+ OomMonitorPanic(KInvalidClientRequestType);
+ }
+
+
+ switch (request->iClientRequestType)
+ {
+ case EClientServerRequestOptionalRam:
+ {
+ TInt pluginId = request->iRequestFreeRamMessage.Int2();
+ iMonitor.FreeOptionalRamL(request->iBytesRequested, pluginId, dataPaged);
+ break;
+ }
+ case EClientServerRequestFreeMemory:
+ iMonitor.RequestFreeMemoryL(request->iBytesRequested, dataPaged);
+ 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<TClientRequest> 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.GoodRamThreshold();
+ 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();
+ }
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomcloseapp.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,123 @@
+/*
+* Copyright (c) 2006-2010 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 <apgtask.h>
+
+#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, TBool aIsDataPaged)
+ {
+ 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);
+
+ RThread thread;
+ TInt err=thread.Open(iCurrentTask.ThreadId());
+ if (!err)
+ {
+ RProcess process;
+ thread.Process(process);
+ TBool isDataPaged = process.DefaultDataPaged();
+ if((aIsDataPaged && isDataPaged) || (!aIsDataPaged && !isDataPaged ))
+ {
+ 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;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomcloseappconfig.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2006-2010 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;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomconfig.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,195 @@
+/*
+* Copyright (c) 2006-2010 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 <e32hashtab.h>
+
+#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<TInt32, COomApplicationConfig*>::TIter iterator(iApplicationToConfigMapping);
+ while (iterator.NextValue())
+ delete iterator.CurrentValue();
+
+ // Iterate through the plugiun hash map deleting all of the items
+ RHashMap<TInt32, COomRunPluginConfig*>::TIter pluginIterator(iPluginToConfigMapping);
+ while (pluginIterator.NextValue())
+ delete pluginIterator.CurrentValue();
+
+ iApplicationToConfigMapping.Close();
+ }
+
+void COomConfig::ConstructL()
+ {
+ FUNC_LOG;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomconfigparser.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,1149 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+#include <xml/parser.h>
+
+#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,
+KOomErrSwapUsageMonitoredErrorInGlobalSettings,
+KOomErrLowSwapErrorInGlobalSettings,
+KOomErrGoodSwapErrorInGlobalSettings,
+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(KOomAttributeSwapUsageMonitored, "swap_usage_monitored");
+_LIT8(KOomAttributeLowSwapThreshold, "low_swap_threshold");
+_LIT8(KOomAttributeGoodSwapThreshold, "good_swap_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<KOomXmlFileBufferSize> 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 swapUsageMonitored;
+ TInt err = GetValueFromBooleanAttributeList(aAttributes, KOomAttributeSwapUsageMonitored, swapUsageMonitored);
+
+ if (err == KErrNone)
+ iConfig.SetSwapUsageMonitored(swapUsageMonitored);
+ else
+ ConfigError(KOomErrSwapUsageMonitoredErrorInGlobalSettings);
+ }
+
+ if (err == KErrNone)
+ {
+ TInt defaultLowSwapThreshold;
+ TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeLowSwapThreshold, defaultLowSwapThreshold);
+
+ if (err == KErrNone)
+ iConfig.SetDefaultLowSwapThreshold(defaultLowSwapThreshold * KBytesInMegabyte);
+ else
+ ConfigError(KOomErrLowSwapErrorInGlobalSettings);
+ }
+
+ if (err == KErrNone)
+ {
+ TInt defaultGoodSwapThreshold;
+ TInt err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeGoodSwapThreshold, defaultGoodSwapThreshold);
+
+ if (err == KErrNone)
+ iConfig.SetDefaultGoodSwapThreshold(defaultGoodSwapThreshold * KBytesInMegabyte);
+ else
+ ConfigError(KOomErrGoodSwapErrorInGlobalSettings);
+ }
+
+ 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);
+ }
+
+ // Set the app specific swap thresholds (if they exist)
+ // Get the app specific low swap threshold
+ if (err == KErrNone)
+ {
+ TUint lowThreshold;
+ err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeLowSwapThreshold, lowThreshold);
+ if (err == KErrNone)
+ {
+ appConfig->iLowSwapThreshold = lowThreshold * KBytesInMegabyte;
+ }
+ else if (err == KErrNotFound)
+ err = KErrNone;
+
+ if (err != KErrNone)
+ ConfigError(KOomErrBadLowThresholdValueForAppConfig);
+ }
+
+ // Get the app specific good swapthreshold
+ if (err == KErrNone)
+ {
+ TUint goodThreshold;
+ err = GetValueFromDecimalAttributeList(aAttributes, KOomAttributeGoodSwapThreshold, goodThreshold);
+ if (err == KErrNone)
+ {
+ appConfig->iGoodSwapThreshold = 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;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomforegroundrule.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2006-2010 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;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomglobalconfig.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2006-2010 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();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomlog.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,306 @@
+/*
+* Copyright (c) 2006-2010 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 <hal.h>
+#include <w32std.h>
+#include <e32std.h>
+#include <apgwgnam.h>
+#include <flogger.h>
+
+#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<KMaxTimeStampSize> timeStamp;
+ iStartTime.FormatL(timeStamp, KTimeStampFormat);
+ TBuf8<KMaxTimeStampSize> 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<KMaxUidBufferSize> 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<iWgIds.Count();)
+ {
+ RWsSession::TWindowGroupChainInfo& info = iWgIds[ii];
+ if (info.iParentId > 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<count; jj++)
+ {
+ if (iWgIds[jj].iId == info.iParentId)
+ {
+ parentPos = jj;
+ break;
+ }
+ }
+
+ if (parentPos > 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oommemorymonitor.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,523 @@
+/*
+* Copyright (c) 2006-2010 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 <hal.h>
+#include <u32hal.h>
+
+#include <UikonInternalPSKeys.h>
+
+#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, iLowRamThreshold, iGoodRamThreshold, iConfig->GlobalConfig().iSwapUsageMonitored, iLowSwapThreshold, iGoodSwapThreshold);
+ iOOMWatcher->Start();
+
+ iWservEventReceiver = new(ELeave) CWservEventReceiver(*this, iWs);
+ iWservEventReceiver->ConstructL();
+ }
+
+const COomGlobalConfig& CMemoryMonitor::GlobalConfig()
+ {
+ CMemoryMonitor* globalMemoryMonitor = static_cast<CMemoryMonitor*>(Dll::Tls());
+ return globalMemoryMonitor->iConfig->GlobalConfig();
+ }
+
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void CMemoryMonitor::FreeMemThresholdCrossedL()
+ {
+ FUNC_LOG;
+
+ iActionTrigger = ERamRotation;
+ StartFreeSomeRamL(iGoodRamThreshold, iGoodSwapThreshold);
+ }
+
+void CMemoryMonitor::HandleFocusedWgChangeL()
+ {
+ FUNC_LOG;
+
+ TInt oldGoodRamThreshold = iGoodRamThreshold;
+ TInt oldLowRamThreshold = iLowRamThreshold;
+ TInt oldGoodSwapThreshold = iGoodSwapThreshold;
+ TInt oldLowSwapThreshold = iLowSwapThreshold;
+
+ // Refresh the low and good memory thresholds as they may have changed due to the new foreground application
+ RefreshThresholds();
+
+ if ((oldGoodRamThreshold != iGoodRamThreshold)
+ || (oldLowRamThreshold != iLowRamThreshold)
+ || (oldGoodSwapThreshold != iGoodSwapThreshold)
+ || (oldLowSwapThreshold != iLowSwapThreshold))
+ // If the thresholds have changed then update the memory watched
+ {
+ iOOMWatcher->UpdateThresholds(iLowRamThreshold, iGoodRamThreshold, iLowSwapThreshold, iGoodSwapThreshold);
+ }
+
+ // If the available memory is less than the low memory threshold then free some RAM
+ User::CompressAllHeaps();
+ TInt currentFreeRam = 0;
+ HAL::Get( HALData::EMemoryRAMFree, currentFreeRam );
+ TInt currentFreeSwap = 0;
+ if (iConfig->GlobalConfig().iSwapUsageMonitored)
+ {
+ SVMSwapInfo swapInfo;
+ UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo, 0);
+ currentFreeSwap = swapInfo.iSwapFree;
+ }
+
+ if ((currentFreeRam < iLowRamThreshold) ||
+ (iConfig->GlobalConfig().iSwapUsageMonitored && (currentFreeSwap < iLowSwapThreshold)))
+ {
+ iActionTrigger = ERamRotation;
+ StartFreeSomeRamL(iGoodRamThreshold, iGoodSwapThreshold);
+ }
+ }
+
+void CMemoryMonitor::StartFreeSomeRamL(TInt aFreeRamTarget, TInt aFreeSwapTarget)
+ {
+ StartFreeSomeRamL(aFreeRamTarget, aFreeSwapTarget, KOomPriorityInfinate - 1);
+ }
+
+void CMemoryMonitor::StartFreeSomeRamL(TInt aFreeRamTarget, TInt aFreeSwapTarget, TInt aMaxPriority) // The maximum priority of action to run
+ {
+ FUNC_LOG;
+
+ TRACES4("MemoryMonitor::StartFreeSomeRamL: aFreeRamTarget = %d, iCurrentRamTarget = %d, aFreeSwapSpaceTarget = %d, iCurrentSwapTarget = %d", aFreeRamTarget, iCurrentRamTarget, aFreeSwapTarget, iCurrentSwapTarget);
+
+ // 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 (aFreeRamTarget > iCurrentRamTarget)
+ {
+ iCurrentRamTarget = aFreeRamTarget;
+ }
+
+ if (aFreeSwapTarget > iCurrentSwapTarget)
+ {
+ iCurrentSwapTarget = aFreeSwapTarget;
+ }
+
+ // check if there is enough free memory already.
+ TInt freeMemory = 0;
+ GetFreeMemory(freeMemory);
+ TInt freeSwap = 0;
+ if (iConfig->GlobalConfig().iSwapUsageMonitored)
+ {
+ GetFreeSwapSpace(freeSwap);
+ }
+
+ TRACES2("MemoryMonitor::StartFreeSomeRamL, freeMemory = %d, freeSwap = %d", freeMemory, freeSwap);
+
+ if ((freeMemory >= iCurrentRamTarget) &&
+ ((!iConfig->GlobalConfig().iSwapUsageMonitored) || (freeSwap >= iCurrentSwapTarget)))
+ {
+ 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->SetCurrentTargets(iCurrentRamTarget, iCurrentSwapTarget);
+
+ // Run the memory freeing actions
+ iOomActionList->FreeMemory(aMaxPriority);
+ }
+
+void CMemoryMonitor::RequestFreeMemoryPandSL(TInt aBytesRequested)
+ {
+ FUNC_LOG;
+
+ iActionTrigger = EPublishAndSubscribe;
+ StartFreeSomeRamL(aBytesRequested + iLowRamThreshold, iLowSwapThreshold);
+ }
+
+void CMemoryMonitor::RequestFreeMemoryL(TInt aBytesRequested, TBool aDataPaged)
+ {
+ FUNC_LOG;
+
+ iActionTrigger = EClientServerRequestFreeMemory;
+ iDataPaged = aDataPaged;
+ StartFreeSomeRamL(iLowRamThreshold, aBytesRequested + iLowSwapThreshold);
+ }
+
+void CMemoryMonitor::FreeOptionalRamL(TInt aBytesRequested, TInt aPluginId, TBool aDataPaged) // The ID of the plugin that will clear up the allocation, used to determine the priority of the allocation
+ {
+ FUNC_LOG;
+
+ iActionTrigger = EClientServerRequestOptionalRam;
+
+ iDataPaged = aDataPaged;
+
+ // 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 + iGoodRamThreshold, iLowSwapThreshold, 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);
+ }
+
+void CMemoryMonitor::GetFreeSwapSpace(TInt& aCurrentFreeSwapSpace)
+ {
+ FUNC_LOG;
+
+ SVMSwapInfo swapInfo;
+ UserSvr::HalFunction(EHalGroupVM, EVMHalGetSwapInfo, &swapInfo, 0);
+ aCurrentFreeSwapSpace = swapInfo.iSwapFree;
+
+ TRACES1("CMemoryMonitor::GetFreeSwapSpace: Free swap space now %d", aCurrentFreeSwapSpace);
+ }
+
+#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...
+ iGoodRamThreshold = CMemoryMonitor::GlobalConfig().iGoodRamThreshold;
+ iLowRamThreshold = CMemoryMonitor::GlobalConfig().iLowRamThreshold;
+ iGoodSwapThreshold = CMemoryMonitor::GlobalConfig().iGoodSwapThreshold;
+ iLowSwapThreshold = CMemoryMonitor::GlobalConfig().iLowSwapThreshold;
+ TRACES4("CMemoryMonitor::RefreshThresholds: Global Good Ram Threshold = %d, Global Low Ram Threshold = %d, Global Good Swap Threshold = %d, Global Low Swap Threshold = %d", iGoodRamThreshold, iLowRamThreshold, iGoodSwapThreshold, iLowSwapThreshold);
+
+#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)
+ {
+ iGoodRamThreshold = iConfig->GetApplicationConfig(foregroundAppId).iGoodRamThreshold;
+ TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Good Ram Threshold = %d", foregroundAppId, iGoodRamThreshold);
+ }
+ // If this application configuration overrides the low_ram_threshold then set it
+ if (iConfig->GetApplicationConfig(foregroundAppId).iLowRamThreshold != KOomThresholdUnset)
+ {
+ iLowRamThreshold = iConfig->GetApplicationConfig(foregroundAppId).iLowRamThreshold;
+ TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Low Ram Threshold = %d", foregroundAppId, iLowRamThreshold);
+ }
+
+ if (iConfig->GetApplicationConfig(foregroundAppId).iGoodSwapThreshold != KOomThresholdUnset)
+ {
+ iGoodSwapThreshold = iConfig->GetApplicationConfig(foregroundAppId).iGoodSwapThreshold;
+ TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Good Swap Threshold = %d", foregroundAppId, iGoodSwapThreshold);
+ }
+ // If this application configuration overrides the low_swap_threshold then set it
+ if (iConfig->GetApplicationConfig(foregroundAppId).iLowSwapThreshold != KOomThresholdUnset)
+ {
+ iLowSwapThreshold = iConfig->GetApplicationConfig(foregroundAppId).iLowSwapThreshold;
+ TRACES2("CMemoryMonitor::RefreshThresholds: For foreground app %x, Low Swap Threshold = %d", foregroundAppId, iLowSwapThreshold);
+ }
+ }
+ }
+
+// 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
+ iCurrentRamTarget = iGoodRamThreshold;
+ iCurrentSwapTarget = iGoodSwapThreshold;
+ iOomActionList->SetCurrentTargets(iCurrentRamTarget, iCurrentSwapTarget);
+ }
+
+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::GoodRamThreshold() const
+ {
+ return iGoodRamThreshold;
+ }
+
+TInt CMemoryMonitor::LowRamThreshold() const
+ {
+ return iLowRamThreshold;
+ }
+
+void CMemoryMonitor::ActionsCompleted(TInt aBytesFree, TBool aMemoryGood)
+ {
+ iQueue->ActionsCompleted(aBytesFree, aMemoryGood);
+ }
+#endif //CLIENT_REQUEST_QUEUE
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oommemorymonitorserver.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,114 @@
+/*
+* Copyright (c) 2006-2010 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<CMemoryMonitorSession*>(s)->CloseAppsFinished(aBytesFree, aMemoryGood);
+ }
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oommemorymonitorsession.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,183 @@
+/*
+* Copyright (c) 2006-2010 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<CMemoryMonitorServer*>(const_cast<CServer2*>(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
+ }
+
+TBool CMemoryMonitorSession::IsDataPaged(const RMessage2& aMessage)
+ {
+ RThread clientThread;
+ TInt err = aMessage.Client(clientThread);
+ TBool dataPaged = EFalse;
+ if(err == KErrNone)
+ {
+ RProcess processName;
+ err = clientThread.Process(processName);
+ if(err == KErrNone)
+ {
+ dataPaged = processName.DefaultDataPaged();
+ }
+ else
+ {
+ PanicClient(aMessage, EPanicIllegalFunction);
+ }
+ }
+ else
+ {
+ PanicClient(aMessage, EPanicIllegalFunction);
+ }
+ return dataPaged;
+ }
+
+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(), IsDataPaged(aMessage));
+#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(), IsDataPaged(aMessage));
+#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
--- a/sysresmonitoring/oommonitor/src/oommonitor.cpp Fri May 14 16:01:13 2010 +0300
+++ b/sysresmonitoring/oommonitor/src/oommonitor.cpp Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 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"
@@ -16,41 +16,20 @@
*/
-#include <hal.h>
-#include <s32file.h>
-#include <w32std.h>
-#include <akneiksrvc.h>
-#include <LafMemoryWatcher.rsg>
-#include <bautils.h>
-#include <apgwgnam.h>
-#include <apgtask.h>
-#include <barsc.h>
-#include <barsread2.h>
-#include <e32property.h>
-#include <UikonInternalPSKeys.h>
-#include <UiklafInternalCRKeys.h>
-
-#include <data_caging_path_literals.hrh>
#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<count; ii++)
- {
- ASSERT(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<iWgIds.Count();)
- {
- RWsSession::TWindowGroupChainInfo& info = iWgIds[ii];
- if (info.iParentId > 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<count; jj++)
- {
- if (iWgIds[jj].iId == info.iParentId)
- {
- parentPos = jj;
- break;
- }
- }
-
- if (parentPos > 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; ii<count; ii++)
- {
- TPlugin& plugin = iPlugins[ii];
- if (plugin.iImpl) // only if successfully added
- REComSession::DestroyedImplementation(plugin.iDtorUid);
- }
- iPlugins.Close();
- }
-
-void COomPlugins::ConstructL()
- {
- RImplInfoPtrArray implArray;
- CleanupClosePushL(implArray);
- REComSession::ListImplementationsL(KOomPluginInterfaceUid, implArray);
-
- TInt count = implArray.Count();
- iPlugins.ReserveL(count);
-
- for (TInt ii=0; ii<count; ii++)
- {
- iPlugins.AppendL(TPlugin());
- TPlugin& plugin = iPlugins[ii];
- TUid uid(implArray[ii]->ImplementationUid());
- plugin.iImpl = static_cast<COomMonitorPlugin*>(REComSession::CreateImplementationL(uid, plugin.iDtorUid, NULL));
- }
-
- CleanupStack::PopAndDestroy(&implArray);
- }
-
-void COomPlugins::FreeRam()
- {
- TInt count = iPlugins.Count();
- for (TInt ii=0; ii<count; ii++)
- {
- TPlugin& plugin = iPlugins[ii];
- plugin.iImpl->FreeRam();
- }
- }
-
-void COomPlugins::MemoryGood()
- {
- TInt count = iPlugins.Count();
- for (TInt ii=0; ii<count; ii++)
- {
- TPlugin& plugin = iPlugins[ii];
- plugin.iImpl->MemoryGood();
- }
- }
-
-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<CMemoryMonitorSession*>(s)->CloseAppsFinished(aMemoryGood);
- }
-
-
-CMemoryMonitorSession::CMemoryMonitorSession()
- {
- }
-
-void CMemoryMonitorSession::CreateL()
- {
- }
-
-CMemoryMonitorSession::~CMemoryMonitorSession()
- {
- }
-
-CMemoryMonitorServer& CMemoryMonitorSession::Server()
- {
- return *static_cast<CMemoryMonitorServer*>(const_cast<CServer2*>(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);
}
--- a/sysresmonitoring/oommonitor/src/oommonitorplugin.cpp Fri May 14 16:01:13 2010 +0300
+++ b/sysresmonitoring/oommonitor/src/oommonitorplugin.cpp Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 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"
@@ -16,26 +16,33 @@
*/
+#include <apgwgnam.h>
#include "oommonitorplugin.h"
-#include "oommonitor.h"
-#include <apgwgnam.h>
+#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<CMemoryMonitor*>(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);
}
--- a/sysresmonitoring/oommonitor/src/oommonitorsession.cpp Fri May 14 16:01:13 2010 +0300
+++ b/sysresmonitoring/oommonitor/src/oommonitorsession.cpp Thu May 27 13:01:09 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2010 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"
@@ -16,33 +16,104 @@
*/
-#include "oommonitorsession.h"
+#include <coemain.h>
+#include <oommonitorsession.h>
#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;
+ }
+ }
+ }
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomoutofmemorywatcher.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,152 @@
+/*
+* Copyright (c) 2006-2010 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"
+#include <u32hal.h>
+
+// ======================================================================
+// class COutOfMemoryWatcher
+// - notifies when free memory crosses preset thresholds
+// ======================================================================
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+COutOfMemoryWatcher* COutOfMemoryWatcher::NewL(CMemoryMonitor& aMonitor, TInt aLowRamThreshold, TInt aGoodRamThreshold, TBool aSwapUsageMonitored, TInt aLowSwapThreshold, TInt aGoodSwapThreshold)
+ {
+ FUNC_LOG;
+
+ COutOfMemoryWatcher* self = new (ELeave) COutOfMemoryWatcher(aMonitor, aSwapUsageMonitored);
+ CleanupStack::PushL(self);
+ self->ConstructL(aLowRamThreshold, aGoodRamThreshold, aLowSwapThreshold, aGoodSwapThreshold);
+ CleanupStack::Pop(self);
+ return self;
+ }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+COutOfMemoryWatcher::~COutOfMemoryWatcher()
+ {
+ FUNC_LOG;
+
+ Cancel();
+ }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+COutOfMemoryWatcher::COutOfMemoryWatcher(CMemoryMonitor& aMonitor, TBool aSwapUsageMonitored)
+: CActive(CActive::EPriorityStandard),
+ iMemoryMonitor(aMonitor),
+ iSwapUsageMonitored(aSwapUsageMonitored)
+ {
+ FUNC_LOG;
+
+ CActiveScheduler::Add(this);
+ }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void COutOfMemoryWatcher::ConstructL(TInt aLowRamThreshold, TInt aGoodRamThreshold, TInt aLowSwapThreshold, TInt aGoodSwapThreshold)
+ {
+ FUNC_LOG;
+
+ UserSvr::SetMemoryThresholds(aLowRamThreshold,aGoodRamThreshold);
+ if (iSwapUsageMonitored)
+ {
+ SVMSwapThresholds thresholds;
+ thresholds.iLowThreshold = aLowSwapThreshold;
+ thresholds.iGoodThreshold = aGoodSwapThreshold;
+ UserSvr::HalFunction(EHalGroupVM, EVMHalSetSwapThresholds, &thresholds, 0);
+ }
+ User::LeaveIfError(iChangeNotifier.Create());
+ }
+
+void COutOfMemoryWatcher::UpdateThresholds(TInt aLowRamThreshold, TInt aGoodRamThreshold, TInt aLowSwapThreshold, TInt aGoodSwapThreshold)
+ {
+ FUNC_LOG;
+
+ UserSvr::SetMemoryThresholds(aLowRamThreshold,aGoodRamThreshold);
+ if (iSwapUsageMonitored)
+ {
+ SVMSwapThresholds thresholds;
+ thresholds.iLowThreshold = aLowSwapThreshold;
+ thresholds.iGoodThreshold = aGoodSwapThreshold;
+ UserSvr::HalFunction(EHalGroupVM, EVMHalSetSwapThresholds, &thresholds, 0);
+ }
+ }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+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)
+ {
+ iMemoryMonitor.FreeMemThresholdCrossedL();
+ }
+
+ // We are not active until FreeMemThresholdCrossedL returns.
+ Start();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oompanic.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006-2010 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 <e32std.h>
+
+void OomMonitorPanic(TOomMonitorPanic aReason)
+ {
+ _LIT(KCat, "OomMonitor");
+ User::Panic(KCat, aReason);
+ }
+
+void OomConfigParserPanic(TInt aReason)
+ {
+ _LIT(KParserCat, "OomParser");
+ User::Panic(KParserCat, aReason);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oompluginwaiter.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2006-2010 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();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomrunplugin.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2006-2010 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, TBool)
+ {
+ 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);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomrunpluginconfig.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2006-2010 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;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomsubscribehelper.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2006-2010 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 <e32property.h>
+#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();
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomwindowgrouplist.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,480 @@
+/*
+* Copyright (c) 2006-2010 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 <w32std.h>
+#include <e32std.h>
+#include <apgtask.h>
+#include <apgwgnam.h>
+
+#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<TInt>::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<TInt, TOomWindowGroupProperties>::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<iWgIds.Count();)
+ {
+ RWsSession::TWindowGroupChainInfo& info = iWgIds[ii];
+ if (info.iParentId > 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<count; jj++)
+ {
+ if (iWgIds[jj].iId == info.iParentId)
+ {
+ parentPos = jj;
+ break;
+ }
+ }
+
+ if (parentPos > 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<numGroups; i++)
+ {
+ //find the index for the required aWgId
+ __ASSERT_DEBUG(i < iUncollapsedWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));
+ if (iUncollapsedWgIds[i].iId == aWgId)
+ {
+ parentPos = i;
+ break;
+ }
+ }
+
+ if (parentPos >=0 )
+ {
+ __ASSERT_DEBUG(parentPos < iUncollapsedWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));
+ while (iUncollapsedWgIds[parentPos].iParentId > 0)
+ {
+ // find the index for the parent
+ for (TInt j=0; j<numGroups; j++)
+ {
+ __ASSERT_DEBUG(j < iUncollapsedWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));
+ if (iUncollapsedWgIds[j].iId == iUncollapsedWgIds[parentPos].iParentId)
+ {
+ parentPos = j;
+ __ASSERT_DEBUG(parentPos < iUncollapsedWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));
+ break; // break out of inner loop
+ }
+ }
+ }
+ __ASSERT_DEBUG(parentPos < iUncollapsedWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));
+ return iUncollapsedWgIds[parentPos].iId;
+ }
+ else
+ {
+ return KErrNotFound;
+ }
+ }
+
+
+TBool COomWindowGroupList::IsBusy(TInt aWgIndex)
+ {
+ TBool isBusy = EFalse;
+ __ASSERT_DEBUG(aWgIndex < iWgIds.Count(), OomMonitorPanic(KWindowGroupArrayIndexOutOfBounds));
+ TOomWindowGroupProperties* wgProperties = iWgToPropertiesMapping.Find(iWgIds[aWgIndex].iId);
+ if (wgProperties)
+ {
+ isBusy = (wgProperties->iDynamicPriority == 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;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/src/oomwserveventreceiver.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2006-2010 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 <akneiksrvc.h>
+#include <apgwgnam.h>
+#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();
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/conf/oomtest.cfg Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,3 @@
+[StifSettings]
+CheckHeapBalance= on
+[EndStifSettings]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/data/oomconfig.xml Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,89 @@
+<!--
+ Copyright (c) 2004-20010 Nokia Corporation and/or its subsidiary(-ies).
+ All rights reserved.
+ This component and the accompanying materials are made available
+ under the terms of the License "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:
+
+-->
+
+
+
+
+<oom_config>
+
+ <global_settings low_ram_threshold="4096" good_ram_threshold="5000" max_app_close_batch="4" default_wait_after_plugin="10" max_app_exit_time="5000">
+ <force_check priority="8"></force_check>
+ </global_settings>
+
+ <app_specific_thresholds>
+ <app uid="E6CFBA08" low_ram_threshold="8192" good_ram_threshold="10000"></app>
+ </app_specific_thresholds>
+
+ <app_close_settings>
+ <close_app uid="DEFAULT_APP" priority="9" sync_mode="check">
+ <app_close_idle_priority idle_time="30" priority="9"></app_close_idle_priority>
+ </close_app>
+
+ <close_app uid="BUSY_APP" priority="NEVER_CLOSE" sync_mode="check"></close_app>
+ <close_app uid="HIGH_PRIORITY_APP" priority="10" sync_mode="check"></close_app>
+
+ <close_app uid="E6CFBA03" priority="7" sync_mode="check">
+ <foreground_app_priority if_foreground_app_id="E6CFBA02" priority="9"></foreground_app_priority>
+ </close_app>
+
+ <close_app uid="E6CFBA02" priority="8" sync_mode="check"></close_app>
+
+ <close_app uid="E6CFBA01" priority="9" sync_mode="check">
+ <app_close_idle_priority idle_time="30" priority="2"></app_close_idle_priority>
+ </close_app>
+
+ <close_app uid="E6CFBA09" priority="7" sync_mode="continue"></close_app>
+ <close_app uid="E6CFBA04" priority="7" sync_mode="check"></close_app>
+ <close_app uid="E6CFBA05" priority="7" sync_mode="check"></close_app>
+
+ <close_app uid="E6CFBA07" priority="NEVER_CLOSE" sync_mode="check"></close_app>
+ <close_app uid="E6CFBA06" priority="NEVER_CLOSE" sync_mode="check"></close_app>
+ <close_app uid="E6CFBA0A" priority="NEVER_CLOSE" sync_mode="check"></close_app>
+ <close_app uid="101f4cd5" priority="NEVER_CLOSE" sync_mode="check"></close_app><!-- log -->
+ <close_app uid="1028311d" priority="NEVER_CLOSE" sync_mode="check"></close_app><!-- test app 39 for uishellservices_menucontentservice. related to content harvester panic -->
+ <close_app uid="101f4cd2" priority="NEVER_CLOSE" sync_mode="check"></close_app><!-- application shell menu -->
+ </app_close_settings>
+
+
+ <system_plugin_settings>
+ <system_plugin uid="DEFAULT_PLUGIN" priority="10"></system_plugin>
+ <system_plugin uid="10286A34" priority="5"></system_plugin>
+
+ <system_plugin uid="10286A35" priority="6">
+ <plugin_foreground_app_priority target_app_id="E6CFBA07" priority="9"></plugin_foreground_app_priority>
+ </system_plugin>
+
+ <system_plugin uid="10286A36" priority="7"></system_plugin>
+ <system_plugin uid="10286A37" priority="8" wait="1000" sync_mode="check"></system_plugin>
+ <system_plugin uid="10286A3C" priority="4"></system_plugin>
+ <system_plugin uid="10286A3D" priority="9"></system_plugin>
+ </system_plugin_settings>
+
+ <app_plugin_settings>
+ <app_plugin uid="10286A3A" target_app_id="E6CFBA02" priority="4" sync_mode="check" call_if_target_app_not_running="false"></app_plugin>
+ <app_plugin uid="10286A3B" target_app_id="E6CFBA03" priority="3" call_if_target_app_not_running="true"></app_plugin>
+ <app_plugin uid="10286A38" target_app_id="E6CFBA03" priority="9" call_if_target_app_not_running="false">
+ <plugin_idle_priority idle_time="30" priority="1"></plugin_idle_priority>
+ </app_plugin>
+
+ <app_plugin uid="10286A39" target_app_id="E6CFBA01" priority="10">
+ <plugin_foreground_app_priority target_app_id="TARGET_APP" priority="1"></plugin_foreground_app_priority>
+ </app_plugin>
+
+ </app_plugin_settings>
+
+</oom_config>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2006-2010 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
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest.pkg Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,83 @@
+;
+; 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:
+;
+;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"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest_manualtestrun.pkg Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,83 @@
+;
+; 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:
+;
+;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"
Binary file sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest_manualtestrun.sis has changed
Binary file sysresmonitoring/oommonitor/tsrc/oomtest/group/oomtest_manualtestrun.sisx has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/group/readme.txt Thu May 27 13:01:09 2010 +0300
@@ -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"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/init/oomtest.ini Thu May 27 13:01:09 2010 +0300
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/stub/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/bwins/t_oomclientu.def Thu May 27 13:01:09 2010 +0300
@@ -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)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/clisrc/client.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2006-2010 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));
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/eabi/t_oomclientu.def Thu May 27 13:01:09 2010 +0300
@@ -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
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/group/t_oomallocclient.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2006-2010 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 <platform_paths.hrh>
+
+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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/group/t_oomallocserver.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2006-2010 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 <platform_paths.hrh>
+
+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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/CAllocManager.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,131 @@
+/*
+* Copyright (c) 2006-2010 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 <e32std.h>
+#include <e32base.h>
+
+// 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<CAllocSimulation> iSimulations;
+ };
+
+#endif // CALLOCMANAGER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/clientserver.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+
+
+// 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
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/server.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+#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;
+ };
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/inc/t_oomclient.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2006-2010 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 <e32std.h>
+
+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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/srvsrc/CAllocManager.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,203 @@
+/*
+* Copyright (c) 2006-2010 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 <e32property.h>
+#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<TUint>(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;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomallocserver/srvsrc/server.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,277 @@
+/*
+* Copyright (c) 2006-2010 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 <e32property.h>
+#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<CMyServer*>(const_cast<CServer2*>(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 (iReceiveLen<aMessage.Length())
+ m.Set(m.Left(iReceiveLen));
+ TInt r=iReceiveMsg.Write(0,m);
+ if (r==KErrNone)
+ iReceiveMsg.Complete(KErrNone);
+ else
+ PanicClient(iReceiveMsg,EPanicBadDescriptor);
+ }
+ }
+
+void CMySession::ServiceL(const RMessage2& aMessage)
+//
+// Handle a client request.
+// Leaving is handled by CMyServer::ServiceError() which reports
+// the error code to the client
+//
+ {
+ switch (aMessage.Function())
+ {
+ case EAllocServReset:
+ aMessage.Complete(Server().AllocManager().Reset());
+ break;
+ case EAllocServConfig:
+ Server().AllocManager().ConfigureL(aMessage.Int0(),
+ aMessage.Int1(), aMessage.Int2(), aMessage.Int3());
+ aMessage.Complete(KErrNone);
+ break;
+ case EAllocServStart:
+ aMessage.Complete(Server().AllocManager().StartAllocating());
+ break;
+ case EAllocServStop:
+ aMessage.Complete(Server().AllocManager().StopAllocating());
+ break;
+ case EAllocServMemoryLow:
+ aMessage.Complete(Server().AllocManager().MemoryLow(aMessage.Int0()));
+ break;
+ case EAllocServMemoryGood:
+ aMessage.Complete(Server().AllocManager().MemoryGood(aMessage.Int0()));
+ break;
+ default:
+ PanicClient(aMessage, EPanicIllegalFunction);
+ break;
+ }
+ }
+
+void CMySession::ServiceError(const RMessage2& aMessage,TInt aError)
+//
+// Handle an error from CMySession::ServiceL()
+// A bad descriptor error implies a badly programmed client, so panic it;
+// otherwise use the default handling (report the error to the client)
+//
+ {
+ if (aError==KErrBadDescriptor)
+ PanicClient(aMessage,EPanicBadDescriptor);
+ CSession2::ServiceError(aMessage,aError);
+ }
+
+void CShutdown::RunL()
+//
+// Initiate server exit when the timer expires
+//
+ {
+ CActiveScheduler::Stop();
+ }
+
+CServer2* CMyServer::NewLC()
+ {
+ CMyServer* self=new(ELeave) CMyServer;
+ CleanupStack::PushL(self);
+ self->ConstructL();
+ 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<CMySession*>(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;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/data/t_oomdummyapp.rls Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/data/t_oomdummyapp.rss Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,188 @@
+/*
+* Copyright (c) 2006-2010 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 <eikon.rh>
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <appinfo.rh>
+#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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/data/t_oomdummyapp_reg.rss Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2006-2010 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 <appinfo.rh>
+#include <t_oomdummyapp_0xE6CFBA00.rsg>
+
+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;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/gfx/qgn_menu_t_oomdummyapp.svg Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 88 87.999">
+<g>
+<g>
+<g>
+<g>
+<rect fill="none" width="88" height="87.999"/>
+</g>
+</g>
+<g>
+<linearGradient id="XMLID_7_" gradientUnits="userSpaceOnUse" x1="12.3042" y1="18.3799" x2="63.4113" y2="79.287">
+<stop offset="0" style="stop-color:#B3DDFF"/>
+<stop offset="0.8146" style="stop-color:#084296"/>
+<stop offset="1" style="stop-color:#084296"/>
+</linearGradient>
+<path fill="url(#XMLID_7_)" d="M32.135,7.415L14.363,17.432v23.167c0,0,8.926,15.351,10.468,18.001 c-2.386,1.704-15.44,11.03-15.44,11.03l21.613,12.652c0,0,12.907-9.85,14.71-11.226c1.979,1.109,16.231,9.101,16.231,9.101 l16.664-15.132c0,0-14.066-6.929-16.888-8.318c1.467-3.01,10.531-21.604,10.531-21.604l-22.298-9.59 c0,0-1.486,3.173-2.093,4.467c-2.046-0.88-6.573-2.826-6.573-2.826s-3.713,2.463-5.696,3.778 c-0.327-0.744-0.542-1.233-0.657-1.495c0.007-0.824,0.213-23.72,0.213-23.72L32.135,7.415z"/>
+<linearGradient id="XMLID_8_" gradientUnits="userSpaceOnUse" x1="40.8276" y1="52.1914" x2="16.1997" y2="21.1353">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_8_)" points="59.051,57.621 69.536,36.111 50.944,28.115 48.852,32.581 41.493,29.418 34.719,33.911 32.932,29.849 33.117,9.157 16.363,18.601 16.363,40.06 27.476,59.169 13.064,69.463 30.856,79.879 45.546,68.669 61.667,77.708 75.089,65.521 "/>
+<linearGradient id="XMLID_9_" gradientUnits="userSpaceOnUse" x1="60.585" y1="31.876" x2="53.8582" y2="45.1125">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_9_)" points="41.26,48.783 50.944,28.115 69.536,36.111 59.051,57.621 "/>
+<polygon fill="#0046B7" points="16.363,40.06 27.476,59.169 41.26,48.783 32.932,29.849 "/>
+<polygon fill="#3366CC" points="16.363,40.06 16.363,18.601 33.117,9.157 32.932,29.849 "/>
+<polygon fill="#CFECFF" points="26.696,39.23 41.493,29.418 59.523,37.168 45.546,47.954 "/>
+<path fill="#5AA7E0" d="M41.954,55.286"/>
+<polygon fill="#3366CC" points="26.696,39.23 27.476,59.169 45.546,68.669 45.546,47.954 "/>
+<polygon fill="#5AA7E0" points="13.064,69.463 27.476,59.169 45.546,68.669 30.856,79.879 "/>
+<linearGradient id="XMLID_10_" gradientUnits="userSpaceOnUse" x1="29.2085" y1="63.6836" x2="48.7102" y2="56.1976">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="0.0056" style="stop-color:#5AA7E0"/>
+<stop offset="0.85" style="stop-color:#3366CC"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_10_)" points="43.423,46.971 27.476,59.169 45.546,68.669 45.546,47.954 "/>
+<polygon fill="#0046B7" points="45.546,47.954 45.546,68.669 59.051,57.621 59.523,37.168 "/>
+<linearGradient id="XMLID_11_" gradientUnits="userSpaceOnUse" x1="45.3936" y1="59.5186" x2="59.0508" y2="59.5186">
+<stop offset="0" style="stop-color:#0046B7"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_11_)" points="45.394,50.368 45.546,68.669 59.051,57.621 "/>
+<linearGradient id="XMLID_12_" gradientUnits="userSpaceOnUse" x1="60.8945" y1="68.6807" x2="57.2953" y2="58.792">
+<stop offset="0" style="stop-color:#5AA7E0"/>
+<stop offset="0.4101" style="stop-color:#5AA7E0"/>
+<stop offset="1" style="stop-color:#3366CC"/>
+</linearGradient>
+<polygon fill="url(#XMLID_12_)" points="61.667,77.708 45.546,68.669 59.051,57.621 75.089,65.521 "/>
+</g>
+</g>
+</g>
+</svg>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/group/Icons_scalable_dc.mk Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,69 @@
+#
+# 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: This is file for creating .mif file (scalable icon)
+#
+# ============================================================================
+# 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 <http://forum.nokia.com/document/Forum_Nokia_Technical_Library_v1_35/contents/FNTL/Build_process_fails_at_mif_file_creation_in_S60_3rd_Ed_FP1_SDK.htm>
+# ----------------------------------------------------------------------------
+
+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
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2006-2010 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
+
+t_oomdummyapp.mmp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/group/t_oomdummyapp.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2006-2010 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 <platform_paths.hrh>
+
+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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/Custom.xml Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!DOCTYPE cshcust SYSTEM "/cshlpcmp/dtd/CSHcust.dtd">
+<?xml:stylesheet href="/cshlpcmp/xsl/cshcust.xsl" title="CS-Help customization" type="text/xsl"?>
+<cshcust>
+<parastyle name="body" font="sansserif" size="10"/>
+<parastyle name="tip" font="sansserif" size="10" left="20"></parastyle>
+<parastyle name="note" font="sansserif" size="10" left="20"></parastyle>
+<parastyle name="important" font="sansserif" size="10" left="20"></parastyle>
+<body style="body"/>
+<titlestyle fontstyle="sansserif" size="10"/>
+<listbullet1style bulletchar="8226"/>
+<listbullet2style bulletchar="8226"/>
+<lists leftindent="20"/>
+</cshcust>
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/build_help.mk Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,60 @@
+#
+# 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: This make file will build the application help file (.hlp)
+#
+# ============================================================================
+# 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/t_oomdummyapp.cshlp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<!DOCTYPE cshproj SYSTEM "/epoc32/tools/cshlpcmp/dtd/cshproj.dtd">
+<?xml:stylesheet href="/epoc32/tools/cshlpcmp/xsl/CSHproj.xsl" title="CS-Help project" type="text/xsl"?>
+<cshproj>
+<helpfileUID>0xE6CFBA00</helpfileUID>
+<directories>
+ <input></input>
+ <output></output>
+ <graphics></graphics>
+ <working>temp\</working>
+</directories>
+<files>
+ <source>
+ <xmlfile>t_oomdummyapp.xml</xmlfile>
+ </source>
+ <destination>t_oomdummyapp_0xE6CFBA00.hlp</destination>
+ <customization>custom.xml</customization>
+ </files>
+</cshproj>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/help/t_oomdummyapp.xml Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!DOCTYPE asptml SYSTEM "/epoc32/tools/cshlpcmp/dtd/asptml.dtd">
+<?xml:stylesheet href="/epoc32/tools/cshlpcmp/xsl/asptml.xsl" title="asptml" type="text/xsl"?>
+<asptml>
+<uid value="0xE6CFBA00"/>
+<topic><category>t_oomdummyapp</category><topictitle>General Information</topictitle>
+<synonyms>General Information</synonyms>
+<context contextUID="General_Information"/>
+<index>General Information</index>
+<p>Insert your help here.</p>
+<p></p>
+</topic>
+</asptml>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/CMsgHandler.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h> // For CActive, link against: euser.lib
+#include <e32msgqueue.h>
+#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<TInt> iMsgQueue; // messages from the harness
+ Ct_oomdummyappAppUi& iOwner;
+
+ };
+
+#endif // CMSGHANDLER_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyapp.hrh Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2006-2010 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__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyapp.pan Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2006-2010 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__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappAppUi.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2006-2010 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 <aknappui.h>
+
+// 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<TCoeHelpContext>* HelpContextL() const;
+
+private:
+ // Data
+
+ /**
+ * The application view
+ * Owned by Ct_oomdummyappAppUi
+ */
+ Ct_oomdummyappAppView* iAppView;
+ CMsgHandler* iMsgHandler;
+
+ };
+
+#endif // __T_OOMDUMMYAPPAPPUI_h__
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappAppView.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2006-2010 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 <coecntrl.h>
+
+// 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappApplication.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2006-2010 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 <aknapp.h>
+#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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappDocument.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2006-2010 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 <akndoc.h>
+
+// 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/inc/t_oomdummyappmsgs.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* 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:
+*
+*/
+
+#ifndef T_OOMDUMMAPPMSGS_H_
+#define T_OOMDUMMAPPMSGS_H_
+
+const TInt KOomDummyAppSetBusy = 5;
+const TInt KOomDummyAppSetNormalPriority = 6;
+const TInt KOomDummyAppSetHighPriority = 7;
+
+#endif /*T_OOMDUMMAPPMSGS_H_*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/sis/backup_registration.xml Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,5 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+ <system_backup/>
+ <restore requires_reboot = "no"/>
+</backup_registration>
--- /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 Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,52 @@
+;
+; 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:
+;
+; 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
+;<source> <destination>
+"$(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"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/CMsgHandler.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2006-2010 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;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyapp.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2006-2010 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 <eikstart.h>
+#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);
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappAppUi.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,271 @@
+/*
+* Copyright (c) 2006-2010 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 <avkon.hrh>
+#include <aknmessagequerydialog.h>
+#include <aknnotewrappers.h>
+#include <stringloader.h>
+#include <f32file.h>
+#include <s32file.h>
+#include <hlplch.h>
+
+#include <t_oomdummyapp_0xE6CFBA00.rsg>
+#include <oommonitorsession.h>
+
+//#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<TCoeHelpContext>* 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<TCoeHelpContext>* 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<TCoeHelpContext>* array = new (ELeave) CArrayFixFlat<
+ TCoeHelpContext> (1);
+ CleanupStack::PushL(array);
+ //array->AppendL(TCoeHelpContext(KUidt_oomdummyappApp, KGeneral_Information));
+ CleanupStack::Pop(array);
+ return array;
+ }
+
+// End of File
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappAppView.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2006-2010 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 <coemain.h>
+#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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappApplication.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyapp/src/t_oomdummyappDocument.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/data/t_oomdummyplugin.rss Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2006-2010 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 <ecom\registryinfo.rh>
+#include <oommonitorplugin.hrh>
+
+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 = "";
+ }
+ };
+ }
+ };
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/group/t_oomdummyplugin.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2006-2010 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 <platform_paths.hrh>
+
+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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/inc/debug.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2006-2010 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 <e32debug.h>
+
+#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_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/inc/dummyplugin.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2006-2010 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 <oommonitorplugin.h>
+#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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/inc/t_oomdummyplugin_properties.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2006-2010 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_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/src/dummyplugin.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2006-2010 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 <e32property.h>
+#include <e32cmn.h>
+#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));
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin/src/ecom_entry.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2006-2010 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 <ecom\implementationproxy.h>
+#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;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/data/t_oomdummyplugin2.rss Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2006-2010 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 <ecom\registryinfo.rh>
+#include <oommonitorplugin.hrh>
+
+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 = "";
+ }
+ };
+ }
+ };
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/group/t_oomdummyplugin2.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2006-2010 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 <platform_paths.hrh>
+
+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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/inc/debug.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2006-2010 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 <e32debug.h>
+
+#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_ */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/inc/dummyplugin2.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2006-2010 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 <oommonitorplugin.h>
+#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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/inc/t_oomdummyplugin_properties2.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,21 @@
+/*
+* Copyright (c) 2006-2010 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:
+*
+*/
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/src/dummyplugin2.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2006-2010 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 <e32property.h>
+#include <e32cmn.h>
+#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));
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomdummyplugin2/src/ecom_entry2.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2006-2010 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 <ecom\implementationproxy.h>
+#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;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/group/t_oomharness.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2006-2010 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 <platform_paths.hrh>
+
+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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/CDummyApplicationHandle.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,91 @@
+/*
+* Copyright (c) 2006-2010 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 <e32std.h>
+#include <e32base.h>
+#include <e32msgqueue.h>
+
+// 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<TInt> iMsgQueue;
+ TUid iUid;
+ };
+
+#endif // CDUMMYAPPLICATIONHANDLE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/cleanuputils.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2006-2010 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 T>
+class CleanupResetAndDestroy
+ {
+public:
+ inline static void PushL(T& aRef);
+private:
+ static void ResetAndDestroy(TAny *aPtr);
+ };
+
+template <class T>
+inline void CleanupResetAndDestroyPushL(T& aRef);
+
+
+#include "cleanuputils.inl"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/cleanuputils.inl Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2006-2010 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 T>
+inline void CleanupResetAndDestroy<T>::PushL(T& aRef)
+ {
+ CleanupStack::PushL(TCleanupItem(&ResetAndDestroy,&aRef));
+ }
+
+template <class T>
+void CleanupResetAndDestroy<T>::ResetAndDestroy(TAny *aPtr)
+ {
+ static_cast<T*>(aPtr)->ResetAndDestroy();
+ }
+
+template <class T>
+inline void CleanupResetAndDestroyPushL(T& aRef)
+ {
+ CleanupResetAndDestroy<T>::PushL(aRef);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/inc/t_oomharness.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,308 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+#include <e32hashtab.h>
+#include <e32cmn.h>
+
+#include "CDummyApplicationHandle.h"
+#include "t_oomclient.h"
+#include <oommonitorsession.h>
+
+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<TInt32, TPluginCallCount> iPluginCallCounts;
+
+ RPointerArray<CCDummyApplicationHandle> 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);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/sis/t_oomharness_EKA2.pkg Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,39 @@
+;
+; 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:
+;
+; 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"
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/src/CDummyApplicationHandle.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2006-2010 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 <w32std.h>
+#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);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness/src/t_oomharness.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,1715 @@
+/*
+* Copyright (c) 2006-2010 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 <e32base.h>
+#include <e32std.h>
+#include <e32cons.h> // Console
+#include <e32hal.h>
+#include <e32property.h>
+#include <e32cmn.h>
+#include <hal.h>
+#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>(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>(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>(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>(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>(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<CCDummyApplicationHandle> 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;i<apps.Count();i++)
+ {
+ if(apps[i]->Process().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<TUid>(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;i<apps.Count();i++)
+ {
+ if(apps[i]->Process().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;id<KOOMDummyPluginImplementationCount;id++)
+ {
+ User::LeaveIfError(RProperty::Get(KUidOomPropertyCategory, id + KUidOOMDummyPluginFirstImplementation + KOOMDummyPluginLowMemoryCount, tmp));
+ initialLowCount[id] = tmp;
+ User::LeaveIfError(RProperty::Get(KUidOomPropertyCategory, id + KUidOOMDummyPluginFirstImplementation + KOOMDummyPluginGoodMemoryCount, tmp));
+ initialGoodCount[id] = tmp;
+ line.Format(_L("%x %d %d\n"), KUidOOMDummyPluginFirstImplementation + id, initialLowCount[id], initialGoodCount[id]);
+ console->Write(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;id<KOOMDummyPluginImplementationCount;id++)
+ {
+ User::LeaveIfError(RProperty::Get(KUidOomPropertyCategory, id + KUidOOMDummyPluginFirstImplementation + KOOMDummyPluginLowMemoryCount, tmp));
+ finalLowCount[id] = tmp;
+ User::LeaveIfError(RProperty::Get(KUidOomPropertyCategory, id + KUidOOMDummyPluginFirstImplementation + KOOMDummyPluginGoodMemoryCount, tmp));
+ finalGoodCount[id] = tmp;
+ line.Format(_L("%x %d %d\n"), KUidOOMDummyPluginFirstImplementation + id, finalLowCount[id], finalGoodCount[id]);
+ console->Write(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;id<KOOMDummyPluginImplementationCount;id++)
+ {
+ User::LeaveIfError(RProperty::Get(KUidOomPropertyCategory, id + KUidOOMDummyPluginFirstImplementation + KOOMDummyPluginLowMemoryCount, tmp));
+ finalLowCount[id] = tmp;
+ User::LeaveIfError(RProperty::Get(KUidOomPropertyCategory, id + KUidOOMDummyPluginFirstImplementation + KOOMDummyPluginGoodMemoryCount, tmp));
+ finalGoodCount[id] = tmp;
+ line.Format(_L("%x %d %d\n"), KUidOOMDummyPluginFirstImplementation + id, finalLowCount[id], finalGoodCount[id]);
+ console->Write(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;
+ }
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/BWINS/t_oomharness_stifu.def Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+ ?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * LibEntryL(void)
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/EABI/t_oomharness_stifu.def Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+ _Z9LibEntryLv @ 1 NONAME
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/group/t_oomharness_stif.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2006-2010 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 <platform_paths.hrh>
+
+//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
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/inc/CDummyApplicationHandle.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2006-2010 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 <e32std.h>
+#include <e32base.h>
+#include <e32msgqueue.h>
+
+// 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<TInt> iMsgQueue;
+ TUid iUid;
+ };
+
+#endif // CDUMMYAPPLICATIONHANDLE_H
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/inc/t_oomharness.h Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,681 @@
+/*
+* Copyright (c) 2006-2010 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 <StifLogger.h>
+#include <e32hashtab.h>
+#include <e32cmn.h>
+#include "CDummyApplicationHandle.h"
+#include "t_oomclient.h"
+#include <oommonitorsession.h>
+#include <e32property.h>
+
+// 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::<NameOfFunction> ( 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<TTestCaseInfo>& 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<TInt32, TPluginCallCount> iPluginCallCounts;
+
+ RPointerArray<CCDummyApplicationHandle> 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/src/CDummyApplicationHandle.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2006-2010 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 <w32std.h>
+#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);
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/src/t_oomharness.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,584 @@
+/*
+* Copyright (c) 2006-2010 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 <Stiftestinterface.h>
+#include "t_oomharness.h"
+#include <e32math.h>
+#include "SettingServerClient.h"
+#include <e32property.h>
+
+// 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<TTestCaseInfo>& 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<TTestCaseInfo>& 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomharness_stif/src/t_oomharnesscases.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,3332 @@
+/*
+* Copyright (c) 2006-2010 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 <e32hal.h> //User::HAL
+#include <e32property.h> //RProperty
+#include "t_oomharness.h"
+#include "CDummyApplicationHandle.h"
+#include "../../t_oomdummyapp/inc/t_oomdummyappmsgs.h"
+#include "t_oomdummyplugin_properties.h"
+#include <hal.h>
+
+// 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>(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>(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>(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>(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>(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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/data/t_oomtestapp.rss Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,171 @@
+/*
+* Copyright (c) 2006-2010 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 <eikon.rh>
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <appinfo.rh>
+#include <commondialogs.hrh>
+#include <commondialogs.rh>
+#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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/data/t_oomtestapp_reg.rss Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,30 @@
+/*
+* Copyright (c) 2006-2010 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 <appinfo.rh>
+#include "t_oomtestapp.hrh"
+
+UID2 KUidAppRegistrationResourceFile
+UID3 T_OOM_TESTAPP_UID
+
+RESOURCE APP_REGISTRATION_INFO
+ {
+ app_file = T_OOM_TESTAPP_NAME_STRING;
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/oomtestapps.pkg Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,65 @@
+;
+; 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:
+;
+;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"
Binary file sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/oomtestapps.sisx has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp.mmh Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2006-2010 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 <platform_paths.hrh>
+
+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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp10.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp2.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp3.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp4.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp5.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp6.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp7.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp8.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/group/t_oomtestapp9.mmp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs/t_oomtestapp.hrh Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs10/t_oomtestapp.hrh Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs2/t_oomtestapp.hrh Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs3/t_oomtestapp.hrh Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs4/t_oomtestapp.hrh Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs5/t_oomtestapp.hrh Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs6/t_oomtestapp.hrh Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs7/t_oomtestapp.hrh Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs8/t_oomtestapp.hrh Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/appdefs9/t_oomtestapp.hrh Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006-2010 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappapplication.h Thu May 27 13:01:09 2010 +0300
@@ -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 <aknapp.h>
+
+// 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappappui.h Thu May 27 13:01:09 2010 +0300
@@ -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 <aknappui.h>
+#include <oommonitorsession.h>
+
+// 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappappview.h Thu May 27 13:01:09 2010 +0300
@@ -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 <coecntrl.h>
+
+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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappcmd.hrh Thu May 27 13:01:09 2010 +0300
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/inc/t_oomtestappdocument.h Thu May 27 13:01:09 2010 +0300
@@ -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 <akndoc.h>
+
+// 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappapplication.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2006-2010 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 <eikstart.h>
+#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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappappui.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,260 @@
+/*
+* Copyright (c) 2006-2010 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 <avkon.hrh>
+#include <aknquerydialog.h>
+#include <commondialogs.hrh>
+#include <akncommondialogsdynmem.h>
+#include <f32file.h>
+#include <t_oomtestapp.rsg>
+#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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappappview.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,134 @@
+/*
+* Copyright (c) 2006-2010 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 <coemain.h>
+#include <eikenv.h>
+#include <aknutils.h>
+#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<KTextBufferSize> 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sysresmonitoring/oommonitor/tsrc/oomtest/t_oomtestapp/src/t_oomtestappdocument.cpp Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2006-2010 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
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/BWINS/MT_OomMonitorU.DEF Fri May 14 16:01:13 2010 +0300
+++ /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)
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/EABI/MT_OomMonitorU.DEF Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-EXPORTS
- _Z16CreateTestSuiteLv @ 1 NONAME
-
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_COomMonitorPlugin.cpp Fri May 14 16:01:13 2010 +0300
+++ /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 <EUnitMacros.h>
-#include <EUnitDecorators.h>
-#include <oommonitorplugin.h>
-#include <oommonitor.h>
-
-
-
-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
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_COomMonitorPlugin.h Fri May 14 16:01:13 2010 +0300
+++ /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 <CEUnitTestSuiteClass.h>
-#include <EUnitDecorators.h>
-#include <oommonitorplugin.h>
-
-// 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
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor.cpp Fri May 14 16:01:13 2010 +0300
+++ /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 <EUnitMacros.h>
-#include <EUnitDecorators.h>
-#include <oommonitorsession.h>
-
-// 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
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor.h Fri May 14 16:01:13 2010 +0300
+++ /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 <CEUnitTestSuiteClass.h>
-#include <EUnitDecorators.h>
-#include <oommonitorsession.h>
-
-// 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
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/MT_OomMonitor_DllMain.cpp Fri May 14 16:01:13 2010 +0300
+++ /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 <CEUnitTestSuite.h>
-
-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
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/MT_OomMonitor/stub_MemoryMonitor.cpp Fri May 14 16:01:13 2010 +0300
+++ /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 <oommonitor.h>
-#include <oommonitorplugin.h>
-
-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()
- {
- }
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/group/MT_OomMonitor.mmp Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +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 <platform_paths.hrh>
-
-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
-
-
-SMPSAFE
-// End of file
-
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/group/bld.inf Fri May 14 16:01:13 2010 +0300
+++ /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
--- a/sysresmonitoring/oommonitor/tsrc/public/basic/test.xml Fri May 14 16:01:13 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<test>
- <name>oommonitor Automated Tests</name>
- <target>
- <device rank="none" alias="DEFAULT">
- <property name="HARNESS" value="EUNIT" />
- <property name="TYPE" value="Ariane" />
- </device>
- </target>
- <plan name="oommonitor Automated Test Plan" harness="EUNIT" enabled="true" passrate="100">
- <session name="session" harness="EUNIT" enabled="true" passrate="100">
- <set name="set" harness="EUNIT" enabled="true" passrate="100">
- <target>
- <device rank="master" alias="DEFAULT"/>
- </target>
- <case name="Test Case 1" harness="EUNIT" enabled="true" passrate="100">
- <flash target-alias="DEFAULT" images="ATS3Drop/images/sydo_oommonitor_ats3_image.fpsx" />
- <flash target-alias="DEFAULT" images="ATS3Drop/images/sydo_oommonitor_ats3_image_udaerase.fpsx" />
-
- <!-- Create CTC coverage result folder -->
- <step name="Create CTC log dir" harness="EUNIT" enabled="true" passrate="100" significant="false">
- <command>makedir</command>
- <params>
- <param dir="c:\data\ctc\"/>
- </params>
- </step>
-
-
- <!-- Install testmodule MT_OomMonitor -->
- <step name="Install testmodule MT_OomMonitor DLL" harness="EUNIT" enabled="true" passrate="100" significant="false">
- <command>install</command>
- <params>
- <param component-path="ATS3Drop"/>
- <param type="binary"/>
- <param src="MT_OomMonitor.dll"/>
- <param dst="c:\sys\bin\MT_OomMonitor.dll"/>
- </params>
- </step>
-
- <!-- Start CTC manager -->
- <step name="CTC start" harness="EUNIT" enabled="true" passrate="100" significant="false">
- <command>execute</command>
- <params>
- <param file="z:\sys\bin\ctcman.exe"/>
- </params>
- </step>
-
- <!-- Create EUnit log dir -->
- <step name="Create EUnit log dir" harness="EUNIT" enabled="true" passrate="100" significant="false">
- <command>makedir</command>
- <params>
- <param dir="c:\shared\eunit\logs\"/>
- </params>
- </step>
-
- <!-- Execute tests -->
- <step name="Execute tests" harness="EUNIT" enabled="true" passrate="100" significant="true">
- <command>execute</command>
- <params>
- <param parameters="/l xml MT_OomMonitor"/>
- <param timeout="360"/>
- <param result-file="c:\shared\eunit\logs\EUnit_log.xml"/>
- <param file="z:\sys\bin\EUNITEXERUNNER.EXE"/>
- </params>
- </step>
-
- <!-- Save CTC coverage data -->
- <step name="Save CTC data" harness="EUNIT" enabled="true" passrate="100" significant="false">
- <command>execute</command>
- <params>
- <param parameters="writefile"/>
- <param file="z:\sys\bin\ctcman.exe"/>
- </params>
- </step>
-
- <!-- Fetch and clean CTC data -->
- <step name="Fetch and clean CTC data" harness="EUNIT" enabled="true" passrate="100" significant="false">
- <command>fetch-log</command>
- <params>
- <param delete="true"/>
- <param path="c:\data\ctc\ctcdata.txt"/>
- </params>
- </step>
- </case>
- </set>
- </session>
- </plan>
- <files>
- <file>ATS3Drop/images/sydo_oommonitor_ats3_image.fpsx</file>
- <file>ATS3Drop/images/sydo_oommonitor_ats3_image_udaerase.fpsx</file>
-
- <file>ATS3Drop/armv5_urel/MT_OomMonitor.dll</file>
- </files>
-
- <postAction>
- <type>SendEmailAction</type>
- <params>
- <param name="type" value="ATS3_REPORT"/>
- <param name="to" value="ext-yang.1.lu@nokia.com"/>
- <param name="subject" value="ATS3 report for §RUN_NAME§ §RUN_START_DATE§ §RUN_START_TIME§"/>
- <param name="send-files" value="true"/>
- </params>
- </postAction>
-
- <postAction>
- <type>FileStoreAction</type>
- <params>
- <param name="to-folder" value="\\ousrv058\data$\ATS3Reports\S60_5_0\SyDo\appexts\oommonitor\"/>
- </params>
- </postAction>
-</test>
--- a/systemsettings/GSAccessoryPlugin/group/bld.inf Fri May 14 16:01:13 2010 +0300
+++ b/systemsettings/GSAccessoryPlugin/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -35,7 +35,7 @@
../conf/GSAccessoriesPlugin_10207194.crml MW_LAYER_CRML(gsaccessoriesplugin_10207194.crml)
PRJ_MMPFILES
-GSAccessoryPlugin.mmp
+// GSAccessoryPlugin.mmp
PRJ_EXTENSIONS
START EXTENSION s60/mifconv
--- a/systemsettings/gssensorplugin/group/bld.inf Fri May 14 16:01:13 2010 +0300
+++ b/systemsettings/gssensorplugin/group/bld.inf Thu May 27 13:01:09 2010 +0300
@@ -32,7 +32,7 @@
../rom/gssenpluginresources.iby LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(gssenpluginresources.iby)
PRJ_MMPFILES
-gssensorplugin.mmp
+// gssensorplugin.mmp
PRJ_EXTENSIONS
--- a/tzservices/tzloc/src/TzLocalizationDbAccessor.cpp Fri May 14 16:01:13 2010 +0300
+++ b/tzservices/tzloc/src/TzLocalizationDbAccessor.cpp Thu May 27 13:01:09 2010 +0300
@@ -99,7 +99,28 @@
User::LeaveIfError(iDbsSession.Connect());
//Attempt to open the database
TInt error = iLocalizedTimeZoneDb.Open(iDbsSession,KTzLocalizationDbName,KTzLocalizationDbSecurityPolicy);
+ if (error == KErrNotFound)
+ {
+ //Database file doesn't exist. Attempt to create a new one.
+ error = iLocalizedTimeZoneDb.Create(iDbsSession,KTzLocalizationDbName,KTzLocalizationDbSecurityPolicy);
+ if (error == KErrNone)
+ {
+ User::LeaveIfError(CreateFrequentlyUsedZoneTableL());
+ User::LeaveIfError(CreateUserCityTableL());
+ }
+ }
User::LeaveIfError(error);
+ // Check if both tables are created.
+ TRAP(error, iLocalizedTimeZoneDb.ColSetL(KCZTableName));
+ if (error)
+ {
+ User::LeaveIfError(CreateFrequentlyUsedZoneTableL());
+ }
+ TRAP(error, iLocalizedTimeZoneDb.ColSetL(KUCTableName));
+ if (error)
+ {
+ User::LeaveIfError(CreateUserCityTableL());
+ }
}
/**
--- a/tzservices/tzserver/Client/Source/timezoneuserdata.cpp Fri May 14 16:01:13 2010 +0300
+++ b/tzservices/tzserver/Client/Source/timezoneuserdata.cpp Thu May 27 13:01:09 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2008-2010 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"
@@ -523,7 +523,6 @@
iTzServer.DeleteUserTimeZoneL(aTzId);
}
-
/**
Returns the time zone identifiers for all existing user-defined time zones.
@@ -533,5 +532,19 @@
*/
EXPORT_C void CTzUserData::GetTzIdsL(RPointerArray<CTzId>& aTzIds) const
{
+ CleanupStack::PushL( TCleanupItem(CleanupPointerArray, &aTzIds) );
iTzServer.GetUserTimeZoneIdsL(aTzIds);
+ CleanupStack::Pop();
}
+
+void CTzUserData::CleanupPointerArray(TAny* aArray)
+ {
+ RPointerArray<CTzId>* array = static_cast<RPointerArray<CTzId>* >(aArray);
+ if (array)
+ {
+ array->ResetAndDestroy();
+ array->Close();
+ }
+ }
+
+
--- a/tzservices/tzserver/Include/tzuserdefineddata.h Fri May 14 16:01:13 2010 +0300
+++ b/tzservices/tzserver/Include/tzuserdefineddata.h Thu May 27 13:01:09 2010 +0300
@@ -1,4 +1,4 @@
-// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 1997-2010 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"
@@ -53,7 +53,8 @@
private:
CTzUserData(RTz& aTzServer);
-
+ static void CleanupPointerArray(TAny* aArray);
+
private:
RTz& iTzServer;
};
--- a/tzservices/tzserver/group/BLD.INF Fri May 14 16:01:13 2010 +0300
+++ b/tzservices/tzserver/group/BLD.INF Thu May 27 13:01:09 2010 +0300
@@ -57,6 +57,7 @@
// ROM
TimeZoneServer.iby /epoc32/rom/include/timezoneserver.iby
+Timezoneserver.iby /epoc32/rom/include/core/mw/timezoneserver.iby
PRJ_MMPFILES
TimeZoneClient.mmp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tzservices/tzserver/group/timezonetests.pkg Thu May 27 13:01:09 2010 +0300
@@ -0,0 +1,41 @@
+;
+; 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:
+;
+
+;Languages
+&EN
+
+
+;Localised Vendor name
+%{"timezonetests.pkg EN"}
+
+; Vendor name
+: "timezonetests"
+
+"\epoc32\data\c\dstscripts\LocationTest.script"-"c:\Dstscripts\LocationTest.script"
+"\epoc32\data\c\dstscripts\ConversionTest.script"-"c:\Dstscripts\ConversionTest.script"
+"\epoc32\data\c\dstscripts\VCalTest.script"-"c:\Dstscripts\VCalTest.script"
+"\epoc32\data\c\dstscripts\PerformanceTest.script"-"c:\Dstscripts\PerformanceTest.script"
+"\epoc32\data\c\dstscripts\autoupdatetest.script"-"c:\Dstscripts\autoupdatetest.script"
+"\epoc32\data\c\dstscripts\utcoffsettest.script"-"c:\Dstscripts\utcoffsettest.script"
+"\epoc32\data\c\dstscripts\autoupdatenotificationtest.script"-"c:\Dstscripts\autoupdatenotificationtest.script"
+"\epoc32\data\c\dstscripts\utcalarmtest.script"-"c:\Dstscripts\utcalarmtest.script"
+"\epoc32\data\c\dstscripts\isdaylightsavingontest.script"-"c:\Dstscripts\isdaylightsavingontest.script"
+"\epoc32\data\c\dstscripts\ServerMsgSender.script"-"c:\Dstscripts\ServerMsgSender.script"
+"\epoc32\data\c\dstscripts\BackupRestore.script"-"c:\Dstscripts\BackupRestore.script"
+"\epoc32\data\c\dstscripts\TimeZoneOffsetCheck.script"-"c:\Dstscripts\TimeZoneOffsetCheck.script"
+"\epoc32\data\c\Dstscripts\unittest.script"-"c:\Dstscripts\unittest.script"
+"\epoc32\data\c\dstscripts\NextDSTChange.script"-"c:\Dstscripts\NextDSTChange.script"
+"\epoc32\data\c\dstscripts\UnknownZoneTime.script"-"c:\Dstscripts\UnknownZoneTime.script"
\ No newline at end of file