PowerManagerService

1.唤醒盒子   使盒子进入假待机

PowerManager powerManager = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
        if (mode.equals("0")) {
            powerManager.goToSleep(SystemClock.uptimeMillis());  进入假待机
        } else if (mode.equals("1")) {
            powerManager.wakeUp(SystemClock.uptimeMillis());     唤醒盒子
        }

2.判断盒子是否处于假待机

PowerManager powerManager = (PowerManager) getContext().getSystemService(Context.POWER_SERVICE);
powerManager.isInteractive();

3.几种状态

frameworks\base\core\java\android\os\PowerManagerInternal.java

/**
* Wakefulness: The device is asleep. It can only be awoken by a call to wakeUp().
* The screen should be off or in the process of being turned off by the display controller.
* The device typically passes through the dozing state first.
*/
public static final int WAKEFULNESS_ASLEEP = 0;  深度睡眠

/**
* Wakefulness: The device is fully awake. It can be put to sleep by a call to goToSleep().
* When the user activity timeout expires, the device may start dreaming or go to sleep.
*/ 
public static final int WAKEFULNESS_AWAKE = 1;   唤醒状态

/**
* Wakefulness: The device is dreaming. It can be awoken by a call to wakeUp(),
* which ends the dream. The device goes to sleep when goToSleep() is called, when
* the dream ends or when unplugged.
* User activity may brighten the screen but does not end the dream.
*/
public static final int WAKEFULNESS_DREAMING = 2;   屏保   

/**
* Wakefulness: The device is dozing. It is almost asleep but is allowing a special
* low-power "doze" dream to run which keeps the display on but lets the application
* processor be suspended. It can be awoken by a call to wakeUp() which ends the dream.
* The device fully goes to sleep if the dream cannot be started or ends on its own.
*/
public static final int WAKEFULNESS_DOZING = 3;   浅睡眠

 

posted @ 2023-04-10 11:30  xiaowang_lj  阅读(83)  评论(0编辑  收藏  举报