Share via


Step 4: Provide OAL Support for Device Stage (Compact 7)

3/12/2014

When a computer issues an MTP GetDeviceInfo request to your device, MTP Responder gets information about the device from the SystemParametersInfo function.

To set that information, issue OEM adaptation layer (OAL) I/O control codes (IOCTLs) to inform the kernel of information about your device by calling the OEMIoControl function on device startup. You use the IOCTLs described in this topic to set the manufacturer name and the device ID and to add support for the battery level and free storage displays.

Manufacturer Name

To set the manufacturer name, use the following function call, where lpOutBuf is a pointer to a buffer that contains the string that represents your manufacturer name, and lpBytesReturned is the number of bytes that you wrote to lpOutBuf.

OEMIoControl(

IOCTL_HAL_GET_DEVICE_INFO,

SPI_GETUUID,

4,

lpOutBuf,

lpBytesReturned)

Device ID

To set the device ID, use the following function call, where lpOutBuf is a pointer to a buffer that contains the string that represents the device ID, and lpBytesReturned is the number of bytes that you wrote to lpOutBuf.

OEMIoControl(

IOCTL_HAL_GET_DEVICE_INFO,

SPI_GETPLATFORMMANUFACTURER,

4,

lpOutBuf,

lpBytesReturned)

Battery Level

To add support for displaying the battery level, implement the IOCTL_BATTERY_GETSYSTEMPOWERSTATUSEX2 control in your battery driver code. This control returns a SYSTEM_POWER_STATUS_EX2 structure that reports the battery level in the BatteryLifePercent field. The battery level is expressed as a percentage, with a value ranging from 0 to 100. The value that your battery driver code writes into BatteryLifePercent shows up as the battery level status for your device in the Devices and Printers folder on the computer. You must also enable SYSGEN_BATTERY to support the battery level status in your device.

Device Stage on the host computer issues an MTP GetDevicePropDesc request to MTP Responder to retrieve the battery level on your device. MTP Responder, in turn, calls the GetSystemPowerStatusEx2 function to determine the current battery level to send back to Device Stage.

You must implement support for displaying the battery level status even if the device has no battery. For example, if the device must be connected to wall current to operate, you still must support the IOCTL_BATTERY_GETSYSTEMPOWERSTATUSEX2 control in your OAL, return a SYSTEM_POWER_STATUS_EX2 structure, and report a power level of 100 percent.For more information, see IOCTL_BATTERY_GETSYSTEMPOWERSTATUSEX2. For more information about GetSystemPowerStatusEx2, see GetSystemPowerStatusEx2.

Free Storage Space

Add support for displaying free storage space status if you are implementing a device file system for use with MTP Responder. To add support for free storage space status, ensure that GetDiskFreeSpaceEx properly returns the total capacity and the amount of free storage on your device.

Device Stage on the desktop computer issues an MTP GetStorageInfo request to MTP Responder to retrieve information about physical storage on your device. In turn, MTP Responder calls the GetDiskFreeSpaceEx function to determine the total capacity and the amount of free space to send back to Device Stage. This function returns information about the amount of space on the local file system of the device. GetDiskFreeSpaceEx returns the total amount of space and the total amount of free space; these quantities appear next to the image for your device in Device Stage.

For more information, see GetDiskFreeSpaceEx .

File Time Stamps

To meet the minimum requirements for Windows logo certification, your device file system must support the ability to set the date and time that a file was created, last accessed, or last modified. For more information, see SetFileTime.

After you provide OAL support for Device Stage, go to Step 5: Handle Session Notifications (Optional).

See Also

Concepts

Implement Device Stage Support