Developer’s Guide to the ARM Emulator

4/7/2010

Jeff Hopper, JW Hedgehog, Inc. with contributions by Jim Wilson, JW Hedgehog, Inc.

July 2007

Summary

This article provides a comprehensive guide of how to take advantage of the many features provided by the Device Emulator including the newly available features of Device Emulator 2.0. Topics discussed include emulator configuration, managing emulator state, customizing the emulator bootstrap process, creating custom emulator skins, command line usage, and much more. You’ll also learn advanced techniques for using the Microsoft ARM Device Emulator in your mobile application development. (33 printed pages)

Download Developer's Guide to the ARM Emulator Samples.zip from the Microsoft Download Center.

Applies To

Microsoft® Visual Studio® 2005

Microsoft Device Emulator 2.0

Microsoft Device Emulator 1.0

Microsoft ActiveSync® 4.5

Introduction

The Basics

Managing Emulator State

Creating a New Emulator Configuration

Bootstrapping and XML Provisioning

Changing the Emulator Skin

Device Emulator 2.0

Power State Emulation

Phone Profile Emulation

Cellular Emulator

Conclusion

Introduction

With the ever-increasing array of mobile devices becoming available today, the Microsoft Device Emulator 1.0, an Advanced RISC Machine (ARM) device emulator, is one of the most useful tools available to mobile application developers. The emulator provides a way to test your mobile application on a variety of devices and platforms even if you do not own a physical device. While using one or more real devices can be a valuable aspect of a testing plan, by using the emulator, you can verify your application’s behavior across a much wider variety of virtual devices and configurations than would normally be practical using physical devices. Testing an application on the emulator is faster, easier, and more convenient than with physical devices because you can easily reproduce consistent testing scenarios.

This article begins by describing the basic concepts of the emulator and related tools, and some common emulator operations. The article then explores more advanced concepts that can be useful when testing applications on the emulator. By learning and using these concepts, you will find that you can improve the overall quality of your mobile applications while reducing the time spent configuring and managing the emulator.

The Basics

To help ensure a solid foundation in the basic concepts of using the device emulator, this section introduces the emulator-related tools and their common operations.

Tools

To effectively use the emulator for mobile application development, you need to be aware of the various emulator-related tools available to you, including the emulator itself, the Device Emulator Manager, Microsoft ActiveSync 4.5 or higher, the Visual Studio 2005 IDE and various remote tools that are available with Visual Studio 2005.

Device Emulator

The Microsoft Device Emulator is a true ARM emulator, and because it has the same instruction set, memory layout, and drivers as a real ARM device, you can be confident that the emulator behavior is consistent with that of a real device. Whether you are writing native or managed code, the same compiled application assemblies that you generate for an actual device are also used on the emulator when debugging applications in Visual Studio 2005. While the emulator is normally installed with Visual Studio 2005, if you need to demonstrate or test mobile applications on non-developer machines, it is also available as a stand-alone release.

As you can see in Figure 1, which shows the emulator emulating two different devices, the emulator very accurately emulates real devices, right down to the appearance and display characteristics. Visual Studio 2005 comes with four Pocket PC 2003 emulators, including standard-resolution, VGA, and square devices, and two Smartphone 2003 emulators. By downloading and installing the free Windows Mobile® 5.0 SDK for Pocket PC, Windows Mobile 5.0 SDK for Smartphone, Windows Mobile 6 Professional SDK, and Windows Mobile 6 Standard SDK, you get nearly 20 additional device emulator definitions. As you will see later in this article, you can also create your own device emulator definitions, customizing the devices’ appearance, configuration, and memory content.

Bb630224.ccbaa5c6-5775-4b3e-bf07-ffc690a098e2(en-us,MSDN.10).gif

Figure 1. The Pocket PC 2003 SE Emulator (left) and the Windows Mobile 5.0 Smartphone Emulator (right)

Device Emulator Manager

The Device Emulator Manager provides a consolidated view and control of all available device emulators as you can see in Figure 2. You can launch the Device Emulator Manager by choosing Tools | Device Emulator Manager on the Visual Studio 2005 menu, or by executing C:\Program Files\Microsoft Device Emulator\1.0\Dvcemumanager.exe.

Bb630224.9436f76a-99a8-4062-902b-c9e3be6ad02b(en-us,MSDN.10).gif

Figure 2. The Device Emulator Manager

The Device Emulator Manager can serve as your central control for all emulators. With it, you can see which device emulators are currently running, start and stop emulators, simulate a warm device boot, clear saved emulator states, and connect with the host network using Microsoft ActiveSync 4.5 or higher.

ActiveSync

Using Microsoft ActiveSync version 4.5 or higher, you can simulate a physical cradling with the host machine, enabling the device emulator to access the local network and the Internet, to synchronize Microsoft Outlook® and file data with the host machine, and enabling the host machine to browse files on the emulated device, just like a real cradled device. You can download the latest version of Microsoft ActiveSync (4.5 at the time of this article’s publication) from https://www.microsoft.com/windowsmobile/activesync/activesync45.mspx.

Note

The default ActiveSync configuration allows emulator cradling, but if you have any difficulties in cradling an emulator, you should make sure ActiveSync is configured to allow direct memory access (DMA) connections. In ActiveSync, click File | Connection Settings to display the dialog box shown in Figure 3. Make sure Allow connections to one of the following is checked and that DMA is selected in the drop-down list.

Bb630224.b928f112-4843-40c7-8d73-6aa071b4a5ec(en-us,MSDN.10).gif

Figure 3. The ActiveSync Connection Settings dialog box

When you cradle a device emulator (by selecting the Cradle menu item in the Device Emulator Manager), the standard ActiveSync Synchronization Setup Wizard appears upon device detection. You can use the wizard to set up synchronization with the emulator if you need to, but if you are just using ActiveSync to connect the device to the network, you can simply cancel the wizard; a guest partnership is created in which nothing is automatically synchronized, but you can use all the connectivity features of ActiveSync.

Visual Studio 2005 and Visual Studio 2005 Remote Tools

You can control most of the emulator-related functionality directly from Visual Studio 2005. Using the Device toolbar, as shown in Figure 4, you can select the target of the project’s deployment. You can deploy to a physical device or to any of the installed emulators for the project’s selected platform.

Bb630224.793553e7-c463-442a-8069-41f9fea7c769(en-us,MSDN.10).gif

Figure 4. The Visual Studio 2005 Device toolbar

Note

Visual Studio 2005 can be installed with Pocket PC 2003 SE and Smartphone 2003 SE emulator definitions, and you can install the Windows Mobile 5.0 SDKs and Windows Mobile 6 SDKs mentioned previously for additional platforms.

You can launch the emulator that is selected in the Device toolbar’s drop-down list by clicking the first button on the toolbar, Connect to Device. The second button, Device Options, provides a shortcut to the Visual Studio Device Options dialog box. This article will discuss these device options further in a later section.

The most common feature of integration between Visual Studio and the device emulator is probably the ability of Visual Studio to automatically launch your application on the emulator when you start a project (with or without debugging). While the Device toolbar’s controls can come in handy, you usually do not need to use them to explicitly start an emulator if your purpose is simply to run and test your application on the emulator.

Visual Studio 2005 also includes several remote tools, including the Remote Registry Editor, shown in Figure 5, which are able to connect to emulators just like physical devices. When installed, they are available at Start | All Programs | Microsoft Visual Studio 2005 | Visual Studio Remote Tools. When you connect a remote tool to the selected emulator, the emulator is started if it is not already running.

Bb630224.1a77bbad-584d-4ee6-90df-e83cd72d73df(en-us,MSDN.10).gif

Figure 5. The Remote Registry Editor

Table 1 shows a list of the remote tools and a brief description of each one. Keep in mind that these tools can be used on both emulators and real devices.

Table 1. Visual Studio 2005 Remote Tools

Remote Tool Description

Remote Registry Editor

Allows viewing and editing of the device’s registry.

Remote Process Viewer

Displays the details of the processes running on the emulator as well as each process’ threads and modules; besides viewing the details of each process, you can also use this tool to terminate processes, which can be useful for processes that may have become unresponsive or are running in the background on the device.

Remote Heap Walker

Allows detailed analysis of the memory that is used by the device’s running applications.

Remote Spy

Displays the windows instantiated by the device’s applications and the messages received by them; provides search-by-name feature.

Remote File Viewer

Allows browsing and manipulation of files on the device, including copying files to and from the device.

Remote Zoom-In

Allows capturing of screen images from the device.

Common Operations

In addition to emulating the features of a real device, the device emulator also includes features that allow you to customize the emulator’s behavior, interact with the desktop computer file system, and map desktop serial ports to the emulator. This section covers these features and the commonly performed operations that take advantage of them.

Start the Emulator from the Command Prompt

You have already seen several ways to launch a device emulator from Visual Studio and the Device Emulator Manager, but you can also start an emulator from the command line C:\Program Files\Microsoft Device Emulator\1.0\DeviceEmulator.exe. While this command-line method of starting the emulator can be useful and flexible when used interactively, its value is really seen when applied to a scripted testing scenario. When used in conjunction with ROM image files and emulator saved-state files, command-line emulator launching can help ensure consistent loading of an emulator and its configuration for testing purposes.

To familiarize yourself with the various possible command-line options, you can run the DeviceEmulator.exe application without any command-line options, and the Command Line Option Help information is displayed, as shown in Figure 6.

Bb630224.ee31df85-1db9-47b1-a0b3-41643417daff(en-us,MSDN.10).gif

Figure 6. The Device Emulator Command Line Option Help

The first parameter, binfile, is the name of a binary (commonly, .bin or .nb0) file with the kernel image the emulator is to use for ROM. If you would like to load the saved state of an emulator from a saved-state (commonly, .dess) file, use the /s filename option, but do not specify a binfile (in this case, the saved-state file would contain the necessary pointers to the device’s ROM, among other configuration and state settings). If you specify only a binfile, the device cold boots from the specified ROM image and the device’s state is not saved upon closing the emulator. Specifying both binfile and the /s option cold boots the device from the specified binary ROM file, but enables saving of the device state upon closing the emulator. You must specify at least one of these two options in order to load an emulator from the command line.

As an example, take the following command line:

"C:\Program Files\Microsoft Device Emulator\1.0\DeviceEmulator.exe" "C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Deviceemulation\0409\PPC_USA.bin" /memsize 256 /hostkey Left-Alt /video 640x360x32

The path used for the binfile parameter in this example causes the emulator to cold boot the standard Windows Mobile 5.0 Pocket PC OS. The /memsize parameter causes the emulator to have 256 MB of RAM. Normally, all keystrokes are consumed by the guest emulator, but by specifying a /hostkey parameter and value, you can use your host machine keyboard’s shortcuts by holding the specified key while pressing the key or keys you want your host machine to process. This example command line specifies the host machine’s left ALT key as the host key. This can be useful, for example, to switch between the emulator and other windows running on your machine with the standard ALT+TAB key combination that would normally be processed by the emulator, not your actual machine, as you would normally expect. Note that whether or not the keyboard shortcut normally uses the ALT key, you need to hold down the key specified by the /hostkey parameter, in this case the left ALT key, for your host machine to receive the keystrokes. Finally, the /video parameter in this example command line causes the emulator’s screen size to be 640 pixels by 360 pixels with 32-bit color depth, which may be useful to emulate a theoretical Windows Mobile device suitable for playing full wide-screen video. As you can see in Figure 7, the device’s physical properties, like its body and any physical buttons, are not emulated when using the /video switch—only the device’s screen is displayed. As you will see later in this article, you can emulate a device’s physical layout with custom skins, which is the method that the standard Pocket PC and Smartphone emulators use.

Bb630224.00c96ede-315f-42fc-ad74-01b70b7f9b89(en-us,MSDN.10).gif

Figure 7. A custom device emulator launched from the command line

The next few sections will present some additional useful emulator features that can be controlled both on the command line and with the emulator’s or Visual Studio user interfaces.

Access Files on the Host Computer As a Virtual Storage Card

Whether you need the ability to transfer files between the device and your physical computer, or to test the device with a virtual storage card, you can use the /sharedfolder parameter to cause the emulator to mount a specified folder on your computer, including folders on network drives, as a virtual storage card. By adding the following parameter and value to the example command line above, you can cause the host machine’s D:\Emulator\EmuStorage folder to be accessible as a storage card on the device emulator.

/sharedfolder "D:\Emulator\EmuStorage"

As is the case with many of the command-line parameters, you can also use the emulator’s File | Configure menu item or the Visual Studio Device Emulator Properties dialog box to specify shared folders. Figure 8 shows the value being set on a running emulator. Notice that some values can be configured only when an emulator is not running, as indicated by the disabled controls in the dialog box.

Bb630224.1b99ad42-89d3-4137-a687-17253da863db(en-us,MSDN.10).gif

Figure 8. Specifying a shared folder from the emulator’s File | Configure menu item

Connect Peripherals

If you need to test physical serial peripheral devices that can be connected to your host machine, you can use the /u0, /u1, and /u2 parameters to map the device’s serial ports to your machines’. For example, add the following parameter and value to specify that the peripheral device physically connected to your machine’s COM3 serial port be available as the device’s first serial port peripheral device.

/u0 COM3

Figure 9 shows the same mapping in the Visual Studio Emulator Properties dialog box. By selecting the Create text console window for serial port 1 check box (or specifying the /c parameter from the command line), you can create a console window to show all input and output of the port selected for serial port 1. If you are using managed code, you should note that all output from OutputDebugString also goes to this console.

Bb630224.bbd38d9e-c2af-4ce0-b02b-b812653e6b52(en-us,MSDN.10).gif

Figure 9. Mapping serial ports in the Emulator Properties dialog box

Managing Emulator State

When you open a preset or user-defined emulator from Visual Studio or Device Emulator Manager, a Device Emulator Saved State (.dess) file for that device type is created, using a unique Virtual Machine Identifier (VMID) as the base file name. When you subsequently close the emulator, you are prompted to save any state changes, or you can use the emulator’s File | Save State and Exit menu item to save the current state of the emulator and close it. If you do save the emulator’s state, the next time you launch that emulator, its saved state will be restored, much like a physical device is powered off and then retains and restores its state when powered back on.

Note

If you launch the emulator from the command line but do not specify a saved-state file with the /s parameter, as in the previous example, you will not be prompted to save changes when you close the emulator. You may think that using the File | Save State and Exit menu item in this situation would first save the device’s state, but it does not, because there is no known saved-state file. When using the command line, if you also want the ability to save a device’s state, you must use the /s parameter.

Using saved state files from the command line can help provide a consistent configuration for testing scenarios. To illustrate this point, consider the following procedure to create a saved emulator state and use it from the command line.

You will start by letting the emulator create a saved-state file based on the standard Windows Mobile 5.0 Pocket PC Emulator and copying that file to a new location for further modification.

Create a saved-state file

You may already have a saved-state file for the Windows Mobile 5.0 Smartphone on your machine, but to make sure you do, follow these steps:

  1. Launch (connect to) the Windows Mobile 5.0 Pocket PC Emulator from the Device Emulator Manager.
  2. After the device has started up, click File | Reset | Soft to warm boot the device in case it already had a saved state.
  3. Click File | Save State and Exit to save the device’s state in the default location.

Copy and modify the saved-state file for testing purposes

  1. Use Windows Explorer to browse to the default user saved-state file location, C:\Documents and Settings\<username>\Application Data\Microsoft\Device Emulator, inserting your user name where appropriate.
  2. Using the files’ dates and times, locate the most recently modified .dess file. This is the saved-state file that you just created or modified by launching the emulator and saving its state.
  3. Copy the file to a new location, for example, D:\Emulator, and rename it Windows Mobile 5.0 Pocket PC Emulator Test Device.dess.
  4. Launch the saved device by double-clicking on the .dess file.
    At this point, you can set up the device to be in whatever state is useful for your testing purposes. You may want to copy standard test data, create Pocket Outlook contacts, set up the device for network connectivity, install other programs, or any number of other things. For demonstration purposes in this article, you will add a contact and create a file to be used by a theoretical application.
  5. On the device emulator, click Start | Contacts, click New, enter a name and phone number for the contact, and then click OK.
  6. On your computer, use ActiveSync or Remote File Viewer to copy files to the emulator, for example, copy D:\Emulator\CustomAppData.txt to \MyDocuments on the emulator.
  7. Close the emulator, saving state changes when you are prompted.

Launch the saved emulator state from the command line

At this point, assuming you have set up the device as is necessary to test your application, you can launch it from the command line for use in testing.

  1. Use the following command line to launch the emulator: "C:\Program Files\Microsoft Device Emulator\1.0\DeviceEmulator.exe" /s "D:\Emulator\Windows Mobile 5.0 Pocket PC Emulator Test Device.dess"
    Note   The final two steps are for verification purposes only. In an actual testing situation, you might save the preceding command line in a batch file, use it to launch the device in the desired state, and then proceed with testing.
  2. Notice that the emulator is in the same state in which you saved it. If the device’s contacts are not already visible, click Start | Contacts. You should see the contact that you created previously.
  3. To verify that the file you copied is on the device, click Start | Programs, click File Explorer, and if the My Documents folder is not already visible, browse to it. You should see the CustomAppData.txt file that you copied previously.

Note that when you close the emulator this time, your practice should be to not save the device’s state because your next test run would need to use the same beginning saved device state that you created for testing purposes. Any testing you have done will have changed the state of the device, which would be undesirable for consistent testing.

Creating a New Emulator Configuration

You may want to create a custom device emulator configuration that you can launch from Visual Studio or the Device Emulator Manager. You can perform this action in the Visual Studio Device tools options screen as shown in Figure 10.

Bb630224.b49ec5fa-9334-4e99-ba9f-44d7a55353e9(en-us,MSDN.10).gif

Figure 10. Visual Studio Device tools options

The easiest way to start creating a new device emulator configuration is to select an existing emulator that is closest in configuration to the one you want to create. For example, to create an emulator based on the Windows Mobile 5.0 Pocket PC Emulator, follow these steps:

  1. In the Devices list, select Windows Mobile 5.0 Pocket PC Emulator, and then click the Save As button.

  2. Name the emulator Widescreen Windows Mobile 5.0 Pocket PC Emulator, and click OK.

  3. With your new Widescreen Windows Mobile 5.0 Pocket PC Emulator selected, click the Properties button to display the properties window shown in Figure 11.
    Bb630224.5c89f77d-e175-4a22-ba85-5a10d39bd1ce(en-us,MSDN.10).gif

    Figure 11. The Widescreen Windows Mobile 5.0 Pocket PC Emulator Properties window
    Notice that this screen applies properties to both emulators and actual devices. Here, you can configure the default output location to which Visual Studio deploys your application, the network transport, a bootstrapper, and device disconnection detection. If you are configuring an emulator, the Emulator Options button is enabled so you can further configure the emulator.

  4. Click the Emulator Options button now to display the Emulator Properties window shown in Figure 12.
    Bb630224.88f8a508-3478-44ce-80b5-da80fcd206b3(en-us,MSDN.10).gif

    Figure 12. The Emulator Properties window General tab
    You first saw this dialog box in the Common Operations section of this article when configuring an emulator’s shared folder and peripherals at run-time. The same dialog box is used when configuring an emulator at design-time, but at design-time, all of the options are available for modification because the emulator is not running. You have also seen that you can modify most of these parameters from the command line.

  5. For this custom device emulator that you are creating, check Specify RAM size, enter 256 as the RAM size, change the Host key to Left Alt, and add D:\Emulator\EmuStorage as the Shared folder, making the same configuration choices as you did from the command line previously. You could also specify a custom binary file for the operating system, a ROM address in that binary image, and a file that emulates flash memory on this tab.

  6. Click the Display tab to display the configuration screen shown in Figure 13.
    Bb630224.67974d97-bc81-4e06-b0a9-8fe4bacc949b(en-us,MSDN.10).gif

    Figure 13. The Emulator Properties window Display tab

  7. Again, to configure the emulator as you did previously from the command line, select Video, and enter 640 as the Screen width, 360 as the Screen height, and 32 as the Color depth.

  8. Click OK to close the dialog, click OK again to save your configuration changes, and then click OK once more to close the Visual Studio options screen.

  9. To launch your custom device emulator, return to the Device Emulator Manager, and click the Refresh button to add your newly created emulator to the list.

  10. Locate and select Widescreen Windows Mobile 5.0 Pocket PC Emulator from the list, and use the Connect action to launch the emulator. It should appear similar to the one you launched from the command line previously.

Notice that if you close your custom emulator and save its state, a new .dess file will be created in the standard folder for your custom emulator just like the preset emulators.

Bootstrapping and XML Provisioning

Just like a real device, certain aspects of an emulator’s initial configuration, including but not limited to browser favorites, locale, clock, home screen, network connections and registry settings, can be controlled with XML provisioning. For a complete list of settings that can be provisioned, see Configuration Service Provider Reference for Windows Mobile-Based Devices. When Visual Studio deploys and runs an application on an emulator, or when the Device Emulator Manager is used to launch an emulator, you can optionally specify an XML provisioning file that is used to “bootstrap” the emulator’s configuration. This XML provisioning file must conform to the Open Mobile Alliance (OMA) Client Provisioning format; see OMA Client Provisioning Files in the Windows Mobile Version 5.0 SDK for complete details. You can see example files of each type of configuration setting at OMA Client Provisioning XML File Examples in the Windows Mobile Version 5.0 SDK.

You specify the XML provisioning file for a given emulator, whether standard or custom, in the Visual Studio Device Options Properties dialog, which you saw earlier in this article, by clicking the Configure button next to Bootstrapper and then typing the name of or browsing for an XML file, as shown in Figure 14.

Bb630224.673cea82-5bf2-4e63-aaba-f03f89cc3fbe(en-us,MSDN.10).gif

Figure 14. Specifying an XML provisioning file for the custom Widescreen emulator

The following XML provisioning file will add a URL to the emulator’s Microsoft Internet Explorer® Mobile favorites list.

<wap-provisioningdoc>
   <characteristic type="BrowserFavorite">
      <characteristic type="Video Store">
         <parm name="URL" value="https://www.southridgevideo.com/"/>
         <parm name="Order" value="0"/>
      </characteristic>
   </characteristic>
</wap-provisioningdoc>

Changing the Emulator Skin

If you need to emulate the physical appearance of custom device hardware, you can easily create a custom skin with a text editor and an image editor. A custom skin consists of an XML skin definition file and an image (.bmp or .png) file that shows the appearance of the device. Optionally, you can create two additional image files, one that shows the appearance of the device’s buttons when they are pressed, and one that maps a unique color to each button. All of these files must be in the same folder. The following XML excerpt partially defines a custom skin that will accommodate the widescreen video device demonstrated earlier in this article. The complete skin definition file and three image files are available as part of the accompanying download.

<?xml version="1.0" encoding="UTF-8" ?>
<skin>
   <view
      titleBar ="Windows Mobile 5.0 Widescreen"
      displayPosX="23"
      displayPosY="21"
      displayWidth="640"
      displayHeight="360"
      displayDepth="32"
      mappingImage="Widescreen_Map.png"
      normalImage="Widescreen_Up.png"
      downImage="Widescreen_Down.png">
       <button
          toolTip="Power"
          onPressAndHold="0x75"
          mappingColor="0x00FF00"
       />
       ...
        <button
          toolTip="Soft Key 1"
          onClick="0x3B"
          mappingColor="0x330033"
       />
       ...
       <button
         toolTip="Up"
         onPressAndHold="0x48"
         mappingColor="0x00FFCC"
         KeyEvent="Up"
       />
       <button
          toolTip="Down"
          onPressAndHold="0x50"
          mappingColor="0x0000FF"
          KeyEvent="Down"
       />
       ...
   </view>
</skin>

You can see that the <view/> element contains attributes and <button/> child elements that define the skin. Table 2 shows a list of the <view/> element’s attributes that are used to define a custom skin.

Table 2. Custom skin <view/> attributes

Attribute Description

titleBar

Title bar of running emulator window.

displayPosX

Horizontal position, in pixels, of emulator’s screen display, relative to emulated device’s physical image.

displayPosY

Vertical position, in pixels, of emulator’s screen display, relative to emulated device’s physical image.

displayWidth

Width, in pixels, of emulator’s screen display.

displayHeight

Height, in pixels, of emulator’s screen display.

displayDepth

Color bit-depth (8, 16, or 32) of emulator’s screen display.

normalImage

File name of image containing the emulator’s normal appearance (buttons not pressed).

downImage

File name of image containing the emulator’s appearance with all buttons pressed.

mappingImage

File name of image containing areas mapped with a unique color for each button.

Table 3 shows a list of the <button/> element’s attributes that are used to define a single emulated button.

Table 3. Custom skin <button/> attributes

Attribute Description

mappingColor

Hexadecimal value representing the RGB color for the button. All pixels with this color in the mapping image file can be clicked on the emulator skin, and the corresponding pixels in the normal image are replaced with those in the down image file.

tooltip

The tool tip text that appears when the pointer hovers over the button.

onClick

Keyboard key codes (hexadecimal or integer) to be passed to the emulator when the button is pressed.

onPressAndHold

Keyboard key codes (hexadecimal or integer) to be repeated while the button is pressed and held.

Figure 15 shows the normal image used for the custom widescreen emulator. All buttons are in the up position.

Bb630224.5efbf5c4-bcb0-4a15-94cb-a820aeab09a4(en-us,MSDN.10).gif

Figure 15. The Widescreen emulator’s normal image

Figure 16 shows the down image used for the custom widescreen emulator. All buttons are in the down position. Notice that you do not need to supply the entire image of the device as you do in the normal image, just enough of the area surrounding each button as the mapping image determines, which you will see next.

Note

The outlining dashed border is not part of the actual image, as you can see from the downloadable sample file, but is included here for visibility purposes.

Bb630224.d1b34c81-9ac7-4a09-afcc-a3fcea2a930b(en-us,MSDN.10).gif

Figure 16. The Widescreen emulator’s down image

Figure 17 shows the mapping image used for the custom widescreen emulator. Each button’s location is mapped with a unique color, whose RGB value is defined in the XML skin definition file.

Note

The outlining dashed border is not part of the actual image, as you can see from the downloadable sample file, but is included here for visibility purposes.

Bb630224.d1616408-3cb9-4d21-bbaa-8e55bee42d5b(en-us,MSDN.10).gif

Figure 17. The Widescreen emulator’s mapping image

To specify the custom skin that should be used for an emulator, you can use the emulator’s property pages as shown in Figure 18, or you can include the /skin parameter followed by the name of the XML skin definition file on the command line, as shown in the following command line excerpt.

/skin "D:\Emulator\EmuSkin\Widescreen_Skin.xml"

Bb630224.056b182e-a214-424a-afff-3e403b2a348c(en-us,MSDN.10).gif

Figure 18. Specifying a custom skin file for the Widescreen emulator

Figure 19 shows the emulator running in the custom skin defined above.

Bb630224.36e50de6-1922-4898-84ed-08055d509e99(en-us,MSDN.10).gif

Figure 19. The Widescreen emulator running in its custom skin

Device Emulator 2.0

Up until now, all of the features discussed in this article are available to developers using both Microsoft Device Emulator 1.0 and Device Emulator 2.0. The Device Emulator 2.0 available as part of the Windows Mobile 6 SDK or as a stand-alone release, builds on these features to provide developers with an even more enhanced and productive development experience. One of the most significant changes to the Device Emulator 2.0 is the re-architecture of the just-in-time execution capabilities to improve performance of Device Emulator. Although it is difficult to quantify the precise performance gains experienced by any given application, a performance increase of up to 40 percent is not uncommon.

Note

In this case, the just-in-time execution does not refer to the .NET Compact Framework but rather refers to the Device Emulator execution of ARM instructions.

Your desktop computer can have only one version of the Desktop Emulator installed. By installing the Device Emulator 2.0, you automatically replace the Device Emulator 1.0. To replace the Device Emulator 1.0, the Device Emulator 2.0 overwrites the 1.0 version, which results in a somewhat misleading path to the Device Emulator 2.0 executable: %ProgramFiles%\Microsoft Device Emulator\1.0\DeviceEmulator.exe.

The enhancements to Device Emulator 2.0 also include several new features aimed at providing a more complete and true-to-life testing environment. Once the Device Emulator 2.0 is installed, it is used for all of the Windows Mobile emulator images. This means that even older emulator images such as Pocket PC 2003SE take full advantage of the new features of Device Emulator 2.0. The remainder of this article discusses the new Device Emulator 2.0 features.

Power State Emulation

By their nature, mobile devices spend a great deal of time on battery power. When the charge level of the device's battery becomes very low, your application may need to take specific actions to avoid data loss in the event that the entire battery charge expires. So that you can now test the effects of power state changes on your application, the Device Emulator 2.0 introduces power state emulation.

Bb630224.b9bfee58-bcba-4870-9967-c85faccf8361(en-us,MSDN.10).gif

Figure 20. The Device Emulator 2.0 power state configuration control

As shown in Figure 20, the emulator configuration dialog allows you to switch the emulator state between battery power and AC power by selecting or clearing the Battery: check box. When on battery power, you can also set the battery charge level percentage. The emulator responds to these changes in the power state and charge level just as a device does. The emulator displays the appropriate icons and messages, and raises the appropriate State and Notifications Broker events.

Phone Profile Emulation

The Device Emulator 2.0 provides support for three new phone profiles: headset, speakerphone, and car kit. As shown in Figure 21 you can enable each of these profiles by selecting the appropriate check box in the emulator configuration dialog box. When you select the profile check boxes, the emulator behaves just as if you have plugged in a headset, enabled the speakerphone, or connected a car kit. As part of the phone profile emulation, the Device Emulator 2.0 raises all of the appropriate State and Notifications Broker events.

Bb630224.740db390-c882-44db-9212-115acd5639de(en-us,MSDN.10).gif

Figure 21. The Device Emulator 2.0 phone profile configuration controls

Cellular Emulator

One of the most significant enhancements to the Device Emulator 2.0 is not actually part of the Device Emulator 2.0. It is instead a separate emulator, the Cellular Emulator, which cooperates with the Device Emulator 2.0 to provide cellular-based features to the Device Emulator 2.0. The Cellular Emulator, shown in Figure 22, emulates a cellular radio and provides the Device Emulator 2.0 with the ability to send and receive calls, send and receive Short Message System (SMS) messages, and establish a General Packet Radio Service (GPRS) connection to the network. As part of the GPRS connection features, the Cellular Emulator can emulate switching between 2G and 3G networks, and can emulate dropping the GPRS connection.

Bb630224.4cc35737-d82f-4665-aa0d-ee06ddc103c6(en-us,MSDN.10).gif

Figure 22. The Cellular Emulator

To use the features provided by the Cellular Emulator you must create an association between the Device Emulator 2.0 and the Cellular Emulator. To create this association, follow these steps.

  1. Take note of the COM port number displayed in the lower-left corner of the Cellular Emulator; COM4 in Figure 22.
  2. Open the Emulator Properties dialog box. To open the Emulator Properties dialog box, select File on the Device Emulator menu, and then click Configure…
  3. In the Emulator Properties dialog box, click the Peripherals tab.
  4. Enter the COM port number from the Cellular Emulator into Serial Port 0 as shown in Figure 23. If you do not see the COM port number in the drop-down list, you can enter it yourself.
  5. Close the Emulator Properties dialog box. To close the Emulator Properties dialog box, click OK.
  6. Perform a soft reset of the Device Emulator 2.0. To perform a soft reset, on the File menu, click Reset, and then click Soft.

Bb630224.5522e3c3-0be3-4a5d-a04b-3de68655e6a4(en-us,MSDN.10).gif

Figure 23. Entering the Cellular Emulator COM port number to enable cellular service emulation for the Device Emulator

With the Device Emulator 2.0 and the Cellular Emulator connected, you can now make and receive phone calls. To make a phone call, you simply dial the phone on the Device Emulator 2.0. The other phone emulator features are available on the Cellular Emulator Call Manager tab shown in Figure 22. Table 4 describes each of these features.

Table 4. Cellular Emulator Call Manager tab features

Feature Description

Active Calls

Shows the list of calls being made from or to the Device Emulator 2.0.

Drop Call

Clicking the Drop Call button immediately terminates the selected call in the Active Calls list.

Call Device

Initiates a call to the Device Emulator 2.0. The value entered in the Phone Number field will appear to the Device Emulator 2.0 as the phone number of the caller. Clicking the Dial button initiates the call.

Preset Number

A reference list of special phone numbers. Calling the numbers in the Preset Number list from the Device Emulator 2.0 will initiate a call that behaves as described for that number.

The Cellular Emulator Network tab, shown in Figure 24, allows you to control certain behaviors of the Device Emulator 2.0 GPRS connection. Table 5 describes each of these features.

Bb630224.166574a2-63a1-4609-b46d-e306f32ba3ac(en-us,MSDN.10).gif

Figure 24. The Cellular Emulator Network tab

Table 5. Cellular Emulator Network tab features

Feature Description

Network Selection

Clicking the Switch to 2G button sends an event to the cellular radio indicating that the radio is registered to a GSM network that supports GPRS. Clicking the Switch to 3G button sends an event to the cellular radio indicating that the radio is registered to a Universal Mobile Telecommunications System (UMTS) cell.

GPRS Control

Clicking the Disconnect GPRS button immediately disconnects the active GPRS connection if one exists.

Data Channel

Shows the details of information exchanged over the active connection. The Active Time is displayed in seconds.

With the Cellular Emulator connected, the Device Emulator 2.0 can send SMS messages. The SMS tab, shown in Figure 25, allows you to see the messages that the Device Emulator 2.0 sends; the SMS tab also provides a facility to send SMS messages to the Device Emulator 2.0. Table 6 describes the SMS tab.

Bb630224.afda3a04-79ad-40a0-a621-34481563a5ed(en-us,MSDN.10).gif

Figure 25. The Cellular Emulator SMS tab

Table 6. Cellular Emulator SMS tab features

Feature Description

Send To Device

Entering text in the text field and clicking the Send button sends the SMS message to the Device Emulator 2.0. Selecting the Repeatly check box sends the message to the Device Emulator the number of times specified in the Max count field. The Cellular Emulator will pause between sending each message for the number of milliseconds specified in the Interval(ms) field.

Receive From Device

Displays SMS messages sent by the Device Emulator 2.0. Each message shows the destination phone number and the time the message was sent.

Note

At the time of this writing, the SMS tab misspells the Repeatedly check box. The Network tab currently displays the check box label as Repeatly.

The Cellular Emulator Injection tab, shown in Figure 26, allows you to modify the state of the Cellular Emulator. This tab exposes features intended for developers who need to emulate modifying the state of a cellular radio; most application developers do not need to use the features provided by this tab. For those developers who do need to modify the state of the Cellular Emulator, you can enter your own AT commands on this tab. For the most part, the AT commands conform to the 3GPP standards. Table 7 describes the Injection tab.

Bb630224.d541a3bc-7ec3-4744-8c26-74f67bc111d3(en-us,MSDN.10).gif

Figure 26. The Cellular Emulator Injection tab

Table 7. Cellular Emulator Injection tab features

Feature Description

Execute AT Commands

Entering a command in the AT Input field and clicking the Execute button modifies the state of the Cellular Emulator and shows the command result in the Result field. The Cellular Emulator does not send the responses or events to applications running on the Device Emulator 2.0.

Send Event to Device

Selecting one of the predefined events in the Predefined Event field and clicking the Send button modifies the Cellular Emulator state. To send a custom event, select Customer Event in the Predefined Events field, type the command in the Event field, and click the Send button. The command modifies the Cellular Emulator state. Whether you enter a predefined or custom event, the Cellular Emulator sends the corresponding events to applications running on the Device Emulator 2.0.

Note

At the time of this writing, the Injection tab’s Predefined Events field misspells the Custom Event value. The field currently displays the value as Customer Event.

The Configuration tab, shown in Figure 27, allows you to modify the SIM/USIM configuration of the Cellular Emulator. The features provided by this tab are intended for developers familiar with SIM/USIM file systems; most application developers do not need to use the features provided by this tab. Table 8 describes the Configuration tab.

Bb630224.1dac8554-a6b1-4a03-9927-98cddaad722d(en-us,MSDN.10).gif

Figure 27. The Cellular Emulator Configuration tab

Table 8. Cellular Emulator Network tab features

Feature Description

SIM File

Shows the path of the current configuration file. Clicking the Import button allows you to select a different configuration file. For more information on the SIM configuration file, see Cellular Emulator Configuration in the Windows Mobile 6 SDK documentation.

Connection

Clicking the Reset button reinitializes the Cellular Emulator using the information contained in the configuration file.

The AT log tab, shown in Figure 28, displays a history of the AT commands sent between the applications running on the Device Emulator 2.0 and the Cellular Emulator. All commands that begin with >> are commands sent from the Device Emulator 2.0 to the Cellular Emulator. All commands that begin with << are commands sent from the Cellular Emulator to the Device Emulator 2.0.

Bb630224.bc02457f-a235-4f4a-8f6a-0646fdedf64c(en-us,MSDN.10).gif

Figure 28. The Cellular Emulator AT Log tab

Conclusion

In this article, you have seen that by effectively using the Microsoft Device Emulator, you can greatly improve your mobile application’s testing coverage, while avoiding the cost of multiple physical devices. You have seen that you can customize the behavior and appearance of the emulator to fit your needs and automate your testing procedures, thus improving your overall testing reliability. Finally, you have seen that the Device Emulator 2.0 provides a number of improvements over the Device Emulator 1.0 that allows you to more thoroughly test your applications.