2007年6月21日星期四

Stay in Unattended mode(written by Mike)

I believe the fastest way to get the screen to turn off is this. As soon as your app detects the phone ring, first call:

PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE);

Then call

PowerPolicyNotify(PPN_POWERBUTTONPRESSED, 0);

Now handle the call. You need to be calling SystemIdleTimerReset(); every 30 seconds to keep the system from falling asleep while you're processing the call.

When the call is over, do:

PowerPolicyNotify(PPN_UNATTENDEDMODE, FALSE);

The first PPN puts the system into a state where, if the power button is pressed, it will turn the screen off but not suspend.

The second PPN simulates the press of the power button. Assuming the screen was on at the time, this will tell the system to suspend, but will instead go to the Unattended (screen off) state because of the first call. (If the screen was off when you did the PowerButtonPressed, it would turn the screen on.)

When you're done with the call, the last PPN tells the system to suspend immediately (as long as there isn't another app in Unattended).

没有评论: