PowerManagerService

简介: 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;   浅睡眠
目录
相关文章
|
8月前
|
前端开发
【Web 前端】对于数组去重都有哪些方法?
【4月更文挑战第22天】【Web 前端】对于数组去重都有哪些方法?
|
8月前
|
前端开发 Java API
Java并发基础:CompletableFuture全面解析
CompletableFuture类使得并发任务的处理变得简单而高效,通过简洁的API,开发者能轻松创建、组合和链式调用异步操作,无需关心底层线程管理,这不仅提升了程序的响应速度,还优化了资源利用率,让复杂的并发逻辑变得易于掌控。
200 1
Java并发基础:CompletableFuture全面解析
|
8月前
|
开发工具 Android开发
rk平台Android12屏幕永不休眠
rk平台Android12屏幕永不休眠
131 1
|
8月前
|
存储 Dragonfly NoSQL
Tair 对 Redis 引擎架构之争的看法
本文详细讲解了阿里云自研数据库Tair的发展以及介绍。
73670 1
|
8月前
|
监控 测试技术 API
Python Web应用程序构建
【4月更文挑战第11天】Python Web开发涉及多种框架,如Django、Flask和FastAPI,选择合适框架是成功的关键。示例展示了使用Flask创建简单Web应用,以及如何使用ORM(如SQLAlchemy)管理数据库。
59333 7
|
8月前
|
Android开发
Android 状态栏WiFi图标的显示逻辑
Android 状态栏WiFi图标的显示逻辑
197 0
|
8月前
使用EventBus 3.0 报 Subscriber class com.example.test.MainActivity and its super classes have no public methods with the @Subscribe annotation
使用EventBus 3.0 报 Subscriber class com.example.test.MainActivity and its super classes have no public methods with the @Subscribe annotation
141 5
|
8月前
|
Web App开发 存储 Android开发
update_engine简介
update_engine简介
103 5
|
8月前
|
XML API Android开发
获取正在前台运行的apk 包名
获取正在前台运行的apk 包名
218 5
|
8月前
|
安全 Linux API
SELinux权限
SELinux权限
104 5