Share via


Step 7: Handle Power Management Scenarios (Optional) (Compact 7)

3/12/2014

When you implement Device Stage support for Windows Embedded Compact 7 by adding MTP Responder to your OS design, you can optionally create a service to handle power management scenarios.

To avoid file system or database corruption in situations when power is partially or completely lost, you must notify the MTP transport service to halt so that it does not attempt to write any data. You are responsible for handling all power scenarios; MTP does not handle any power scenarios for you. These scenarios may include:

  • Bringing down the MTP stack in a low-power or power-loss situation to prevent data corruption during file synchronization.
  • Bringing the MTP stack back online after the device has been plugged into a power source to allow synchronization without a device restart.

To handle these situations, you must create a power notification handler service that will receive low-power, shutdown, and possibly reset notifications. When it receives a power notification, your service must stop the MTP transport so that no data is written. To do this, your service sends IOCTLs to the MTP transport service. For more information, see IOCTLs that are Sent by Applications.

The shutdown notification requires you to register your service with the power manager so that it can be notified about power changes.  On shutdown, your service will receive an IOCTL_POWER_SET call with the power state set to indicate shutdown. This is a blocking call, so your service can stop the MTP transport service and then return.  After your service returns, the shutdown sequence will continue.

After you handle power management scenarios, go to Step 8: Create a Presentation for Device Stage.

See Also

Concepts

Implement Device Stage Support