Nokia N97 SDK Example Applications Guide |
HWRMTestApp Example
1. About this Example
2. Prerequisites
3. Design and Implemention
HWRMTestApp is an example application that demonstrates HW Resource Manager API functionality. HW Resource Manager provides
client APIs for controlling lights and vibra of the device. It also has additional responsibillty of publishing certain power
state related Publish & Subscribe properties.
HWRMTestApp is a simple Symbian S60 based UI application. The core functionality is implemented in CHWRMTestAppAppUi class, which instantiates the HW Resource Manager API objects that used for controlling light and vibra settings. User input
is received from menus that are configured in application's resource file, and eventually HandleCommandL method of CHWRMTestAppAppUi class receives commands entered by user and directs the service requests to the right method that handles them. CHWRMTestAppContainer instantiates the editor control that is used for displaying information to the user.
The following sections explain the capabilities of the application, the current state of scalableUI support, the module dependencies
and finally, steps required to build and use the application..
The program capabilities are defined in HWRMTestApp.mmp file: CAPABILITY ReadDeviceData.
The program takes screen parameters in the start of the application. The program does not support changing the screen layout
while the program is running.
At build time there exists following module dependencies:
- HWRMTestApp requires HWRMLightClient.lib and HWRMVibraClient.lib.
In addition, several UI related libraries provided by SDK are required: euser, apparc, cone, eikcore, eikcoctl, avkon, efsrv,
bafl, eikdlg.
Application can be built in directory hwrmtestapp\group by running the following commands:
bldmake bldfiles
abld build winscw udeb
In addition it is possible to create project from CodeWarrior IDE by running the following command:
After succesful build, application can be found and started from
- Applications > Installed > HWRMTestApp.
In the following is described a typical use case scenario for the HWRMTestApp application. The scenario is as follows:
- User starts the application
- User changes vibra settings
- User changes light settings
- User receives information about power state changes
- User exits from the application
The rest of the sub sections describe how individual scenario steps are performed.
When the GUI is being constructed following instances of classes are being constructed:
In order to receive vibra and light status change information the CHWRTestAppAppUi class inherits interfaces MHWRMVibraObserver
and MHWRMLightObserver.
CHWRMVibra instance is used for:
- reserving and releasing vibra
- setting vibra on and off
- querying vibra state i.e. is vibra on or off
Depending on the function used, the following parameters may be queried from the user:
- duration: time in milliseconds vibra will be active
- intensity: percentage of full vibra rotation speed. Sign digit dictates the vibra motor rotation direction.
- restore: if ETrue is selected, the vibration state on last release will be restored upon successful reservation.
- NoCCoeEnv: if EFalse is selected vibra will be automatically released when the application goes to background and reserved
when the application is restored to foreground.
Information on usage of a function, its parameters and the result data is passed to the CHWRMTestAppContainer instance which presents the data to the user.
CHWRMLight instance is used for:
- reserving and releasing a light target
- setting light target on and off
- setting light target blinking
- querying light target status i.e. is light target on, off or blinking
Depending on the function used, the following parameters may be queried from the user:
- target: the light device that should be controlled (display, keyboard, hardware specific custom target)
- duration: time in milliseconds light target will be active
- intensity: percentage of full light intensity
- restore: if ETrue is selected, the light state on last release will be restored upon successful reservation.
- fade: if ETrue is selected, the light target will be turned on/off gradually (fade-in/fade-out)
Information on usage of a function, its parameters and the result data is passed to the CHWRMTestAppContainer instance which presents the data to the user.
CHWRMTestAppAppUi class contains three instances of class CHWRMTestAppPropertyObserver, which is a generic class for receiving notifications on changes on a specified Publish&Subscribe key. All the instances
are registered to listen to the category KPSUIDHWRMPowerState which contains keys for battery status changes (KHWRMBatteryStatus),
battery level changes (KHWRMBatteryLevel) and charging status changes (KHWRMChargingStatus). Whenever a power state parameter
that is monitored by HW Resource Manager changes, e.g. battery level drops, it is written to the specific Publis&Subscribe
key. Each CHWRMTestAppPropertyObserver instance reports change in key it is listening to by adding a message to CHWRMTestAppContainer instance, which presents the information to the user.
Exiting the application releases all the dynamic data of the application. Deleting CHWRMVibra and CHWRLight instances closes
connections to the HW Resource Manager. Deleting CHWRMTestAppPropertyObserver instances cancels subscriptions on power state Publish&Subscribe keys.
|
© Nokia 2009
|

|