Windows Phone Capability Detection

,Windows Phone Store Test Kit

Windows Phone Store Test Kit, Fair Use

When a Windows Phone project is created, the manifest file (WMAppManifest.xml) is automatically created. This "automatically created" manifest file contains a default set of capabilities for your application. Before submitting your application to the Windows Phone Store, the manifest needs to be updated to correctly specify only the exact capabilities your application requires. If you don't specify an application's capabilities accurately in the manifest, the application might not run as expected. It may also fail the validation test when you submit it to the Windows Phone Store, or it may be unnecessarily rejected by a user for privacy or security concerns. For example, a project I created for WP 7.1 listed the following capabilities in the manifest file:

<Capabilities>
   <Capability Name="ID_CAP_GAMERSERVICES"/>
   <Capability Name="ID_CAP_IDENTITY_DEVICE"/>
   <Capability Name="ID_CAP_IDENTITY_USER"/>
   <Capability Name="ID_CAP_LOCATION"/>
   <Capability Name="ID_CAP_MEDIALIB"/>
   <Capability Name="ID_CAP_MICROPHONE"/>
   <Capability Name="ID_CAP_NETWORKING"/>
   <Capability Name="ID_CAP_PHONEDIALER"/>
   <Capability Name="ID_CAP_PUSH_NOTIFICATION"/>
   <Capability Name="ID_CAP_SENSORS"/>
   <Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>
   <Capability Name="ID_CAP_ISV_CAMERA"/>
   <Capability Name="ID_CAP_CONTACTS"/>
   <Capability Name="ID_CAP_APPOINTMENTS"/>
</Capabilities>

However, the automated tests in the "Windows Phone Store Test Kit" determined the only needed capability was:

<Capabilities>
   <Capability Name="ID_CAP_NETWORKING"/>
</Capabilities>

Windows Phone works under a security model based on its capabilities. When the user installs an application they will be asked to "opt in" to letting the application use certain capabilities. This allows the user to determine if he wants to allow the application to perform capabilities that may be of privacy or security concerns. In the above example, the application only obtains data feeds for reporting the weather forecast for specified locations. If I did not remove the unused capability-entries from the manifest file, the user would get the impression the application was using the following capabilities: camera, microphone, gelocation, access to appointment data, access to contacts data, and access to device-specific information. A wise user would reject the application because it has no legitimate reason to have all those capabilities. A full list of all the application capabilities is available from the following Windows Phone Development Center article: App capabilities and hardware requirements for Windows Phone.

Note 1:
The Windows Phone "Store Test Kit" was formerly named "Marketplace Test Kit" in SDK 7.x.

Note 2:
The Marketplace Test Kit installed with Windows Phone SDK 7.1 is obsolete. Use the Store Test Kit installed with Windows Phone SDK 8.0 (which only runs on the Window 8 operating system) to test apps that target Windows Phone OS 7.1.

Note 3:
Using Windows Phone SDK 7.1 required the use of either the "Zune" software or the "Windows Phone Connect Tool" to test with a physical device. This is no longer needed in SDK 8.0 as the connection capability was added to Visual Studio 2012. See what else is New in Windows Phone SDK 8.0


Manifest Designer and Windows Phone Store Test Kit

The Windows Phone Store Test Kit determines which capabilities an application requires, in addition to many other tests used in the process of submitting an application to the Windows Phone Store. These capabilities need to be listed in the application's manifest. Edit WMAppManifest.xml to contain only the capabilities returned by the tests. See Microsoft's instructions for Modifying the App Manifest File. Introduced in Windows Phone SDK 8.0 is a Manifest Designer that is integrated with Visual Studio. Manifest Designer makes it easy to update the manifest file without editing the raw XML of the file. Below is a screen capture of the Manifest Designer.

,Manifest Designer Introduced in SDK 8.0


Hardware Requirement Specifications (New in SDK 8.0)

Also introduced in Windows Phone 8 were new optional-entries in the manifest file for specifying hardware requirements. The Microsoft article on App capabilities and hardware requirements for Windows Phone explains the differences between the Capability and Hardware elements as:

Capability elements are entries in the manifest file that notify the user while installing the app of special software capabilities that your app receives. When you test your app on Windows Phone Emulator during the development process, if your app uses APIs associated with items such as location services or device ID, your app is automatically granted the corresponding capability. However, to function correctly on a phone, you must modify the WMAppManifest.xml file to include the correct list of capabilities that your app requires. For this reason, you must mark the manifest file appropriately before you submit the app to the Store. The capabilities listed in the app manifest are disclosed to a user when they view an app for purchase in Windows Phone Store. Some capabilities, such as location services, are prominently displayed so the user is fully aware that an app will be accessing their location information.

A requirement element is an optional entry in the app manifest file that is used to specify hardware requirements and limit the exposure of an app to users that have a phone with the necessary hardware to run the app. If your app requires certain hardware to function correctly, you should add the requirement to the app manifest before you submit it to the Store. This means that your app will only be displayed and available for purchase, and then download and installation by users with a phone that has the required hardware. Failure to mark hardware requirements correctly could result in poor ratings for your app because it could be purchased by a user and not function correctly on their phone.

Running the Windows Phone Store Tests

It is recommended the tests be run against a release build that is targeting a "Windows Phone Device". To start the tests connect the Windows Phone device to your computer and verify that it has been detected by the operating system. Then In Visual Studio 2012 right-click on the project in the Solution Explorer window and select "Open Store Test Kit".

There are three tabs inside the Store Test Kit for applications that target Windows Phone OS 7.1:
Note: The "Requirements Page" of the Manifest Designer is additionally displayed on applications that target Windows Phone OS 8.0.

1. Application Details - On this page you specify the image resources. See screen capture below.

,Store Test Kit - Application Details Screen


2. Automated Tests - On this page there are two sets of tests. The first "Run Tests" validates the XAP package, reports the capabilities used by the device (to be put the manifest file), and validates the images specified on the first tab. See screen capture below:

,Store Test Kit - Automated Tests Screen (1st Test Group)


The second set of tests "Start Windows Phone Application Analysis" analyzes the application's performance. See screen capture below:

,Start Windows Phone Application Analysis


3. Manual Tests - On this page is a list of tests to be performed manually against your application. See screen print below:

,Store Test Kit - Manual Tests