storage device design pattern jeff meissner; ken hardy windows program management
TRANSCRIPT
Storage Device Design Pattern
JEFF MEISSNER; KEN HARDY
Windows Program Management
2 6/29/2011MICROSOFT CONFIDENTIAL
Agenda• Storage Pattern Overview• Examples• Windows.Storage Namespace• AutoPlay• Device Configuration• Summary• Resources
3 6/29/2011MICROSOFT CONFIDENTIAL
A Design Pattern represents the programming model a Metro style app can use to communicate with a Specialized Connected Device.
Choose the best Design Pattern for your device based upon the underlying protocol you use to communicate with it.
Design Pattern Connectivity Description API
Networked Connected over a Wi-Fi network. Sends and receives data over TCP-IP. Windows.Networking
Removable Storage
Externally connected over USB. Can send and receive files from a device.
Windows.Storage
Portable Device Externally connected over USB.
Connected over a Wi-Fi or Bluetooth network.
Intelligent device that transfers objects with properties and methods.
Windows Portable Device
WDF Custom Driver Access
Externally connected over USB. Or connected over a Bluetooth network.
Transfers commands and data using device IO control.
Device AccessIDeviceIoContrlol
Design Pattern Connectivity Description API
Removable Storage
Externally connected over USB. Can send and receive files from a device.
Windows.Storage
Specialized Device Design Patterns
4 6/29/2011MICROSOFT CONFIDENTIAL
Removable Storage Pattern
• Functionality represented as files in a file system• Information transferred to/from Windows with simple file access
Protocols: USB Mass Storage Class; Media Transfer Protocol (MTP)Transport: USBAPI: Windows.Storage
Advantages Disadvantages
Low cost, standard hardware No control over which apps access the device
Uses class driver
Supported on ‘Windows RT’
Support for AutoPlay
5 6/29/2011MICROSOFT CONFIDENTIAL
Removable Storage Pattern
Digital camera stores videos as files in its flash memory. When device is connected to Windows 8, the companion app launches and allows users to import and edit the content, apply filters & effects, and/or post directly to their favorite social media outlet.
• Acquisition Scenarios: Automatic Acquisition, Windows Store Download• Device Discovery: Devices.Enumeration; AutoPlay• Device Access: Windows.Storage
EXAMPLE
DeviceDevice
metadataMetro style
app
+ metaapp+
6 6/29/2011MICROSOFT CONFIDENTIAL
Windows.Storage Namespace
• Used to manage files, folders, and app settings• Standard way to access storage devices and volumes in the Windows
Runtime
7 6/29/2011MICROSOFT CONFIDENTIAL
Windows.Storage NamespaceSUPPORTED INTERFACES
Interface Description
IStorageFile Represents a file. Provides information about the file and its contents, and ways to manipulate them.
IStorageFolder Manipulates folders and their contents, and provides information about them.
IStorageItem Manipulates storage items (files and folders) and their contents, and provides information about them.
IStorageItemProperties Provides access to common and content properties on items (like files and folders).
IStreamedFileDataRequest Represents a sequential-access output stream that indicates a request for the data stream of a StorageFile that was created by calling CreateStreamedFileAsync or ReplaceWithStreamedFileAsync.
8 6/29/2011MICROSOFT CONFIDENTIAL
App Manifest
• Support the Removable Storage Capability• File Type Associations• Register as an AutoPlay handler
MANIFEST DECLARATIONS TO SUPPORT THESE SCENARIOS
9 6/29/2011MICROSOFT CONFIDENTIAL
AutoPlay in Windows 8
• Opt out completely• Standard behavior
• General storage• Content-type
• Recommend an app • Custom events
• Using AutoRun.INF
10 6/29/2011MICROSOFT CONFIDENTIAL
Opting out of AutoPlay Behavior
• New for Windows 8• Useful on devices with multiple volumes• Behavior specified in AUTORUN.INF
[autorun]UseAutoPlay=0
• Windows will ignore this volume for AutoPlay• Also disables any AutoRun behavior specified in AUTORUN.INF
TO OPT OUT OF AUTOPLAY AUTORUN.INF IS REQUIRED
11 6/29/2011MICROSOFT CONFIDENTIAL
Standard AutoPlay BehaviorDEVICE WITHOUT METADATA OR AUTORUN.INF BEHAVIOR DEFINED
• Initial device connection receives an AutoPlay toast
• Lists all handlers for these types of devices in the fly out
• User can ignore new choices
• When new handlers are installed the user is prompted again
12 6/29/2011MICROSOFT CONFIDENTIAL
Recommended App BehaviorDEVICE COMPANION APP IS INSTALLED
• Behavior is defined in the Metadata
• Displays recommended app name and icon if available
• Displays progress until app has completed downloading
13 6/29/2011MICROSOFT CONFIDENTIAL
Custom Event Behavior
• Define custom event in AutoRun.INF on the device
[autorun]CustomEvent = eventname
• Support the custom event in manifest of the companion app• Does not guarantee uniqueness• If this is defined, no other handlers are offered
DEVICE AND APP USE CUSTOM EVENTS
14 6/29/2011MICROSOFT CONFIDENTIAL
Configuring a Device
• Device metadata configures behavior• Define a device companion app• Define a recommended AutoPlay action• Define a recommended AutoPlay appNote that the default behavior where no Metadata is provided is to launch AutoPlay
• Registering a device for AutoPlay• Device registration is the same as Windows 7• Desktop application registrations are the same as Windows 7
WINDOWS 8 BEHAVIOR UPON DEVICE ARRIVAL
15 6/29/2011MICROSOFT CONFIDENTIAL
Supporting Multiple Platforms
• Device Stage experiences will continue to work in Windows 8• Same Metadata package can be used for both Windows 7 and Windows 8
• Metadata allows both a device app recommendation AND a Device Stage experience• When both are defined, Windows 8 will choose the device app recommendation
WINDOWS 8 BEHAVIOR UPON DEVICE ARRIVAL
16 6/29/2011MICROSOFT CONFIDENTIAL
Summary• Supporting this pattern is straight forward
• Mass storage devices• Class drivers• Simple API for device access through the Windows Runtime
• Create a vastly improved end-user experience by providing:• Device Metadata• Companion app • Include support for AutoPlay
17 6/29/2011MICROSOFT CONFIDENTIAL
Resources
• App Capability Declarations• http://msdn.microsoft.com/en-us/library/windows/apps/hh464936.aspx
• App Contracts and Extensions• http://msdn.microsoft.com/en-us/library/windows/apps/hh464906.aspx
• Registering an app for AutoPlay• http://msdn.microsoft.com/en-us/library/windows/apps/hh452728.aspx
• Device Metadata portal• http://msdn.microsoft.com/en-us/library/windows/hardware/hh833794.aspx
• Windows.Storage namespace• http://msdn.microsoft.com/en-us/library/windows/apps/br227346.aspx
18 6/29/2011MICROSOFT CONFIDENTIAL
Resources – Continued
• Hands-On Lab – Mass Storage Device App• Removable Storage Sample
• http://code.msdn.microsoft.com/windowsapps/Removable-Storage-52cc49f0• Device Enumeration & Activation
• http://code.msdn.microsoft.com/windowsapps/Device-Enumeration-Sample-a6e45169
Thank you.
© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to
be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.