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月前
|
Java Android开发
|
8月前
|
前端开发
【Web 前端】对于数组去重都有哪些方法?
【4月更文挑战第22天】【Web 前端】对于数组去重都有哪些方法?
|
8月前
|
前端开发 Java API
Java并发基础:CompletableFuture全面解析
CompletableFuture类使得并发任务的处理变得简单而高效,通过简洁的API,开发者能轻松创建、组合和链式调用异步操作,无需关心底层线程管理,这不仅提升了程序的响应速度,还优化了资源利用率,让复杂的并发逻辑变得易于掌控。
206 1
Java并发基础:CompletableFuture全面解析
|
8月前
|
数据库 Android开发
Android 通过升级SettingsProvider数据强制覆盖用户的设置项
Android 通过升级SettingsProvider数据强制覆盖用户的设置项 【5月更文挑战第7天】
230 5
|
8月前
|
存储 Dragonfly NoSQL
Tair 对 Redis 引擎架构之争的看法
本文详细讲解了阿里云自研数据库Tair的发展以及介绍。
73689 1
|
8月前
|
监控 测试技术 API
Python Web应用程序构建
【4月更文挑战第11天】Python Web开发涉及多种框架,如Django、Flask和FastAPI,选择合适框架是成功的关键。示例展示了使用Flask创建简单Web应用,以及如何使用ORM(如SQLAlchemy)管理数据库。
59339 7
|
6月前
|
Android开发
Android kernel 操作gpio
Android kernel 操作gpio
83 0
|
8月前
好文推荐
好文推荐
187 2
|
7月前
|
Java Android开发
android 长按power键的触发时间
android 长按power键的触发时间
160 0
|
8月前
|
Android开发 C++
so兼容32位和64位
在Android开发中遇到32位`xxx.so`动态库在64位设备上运行失败的问题,导致应用崩溃。错误提示因缺少64位版本的库。尝试创建`arm64-v8a`目录并复制库文件后,依然崩溃,因为库本身是32位。解决方案是在`build.gradle`中添加配置,指定支持的ABI滤镜,并在`gradle.properties`中设置`android.useDeprecatedNdk=true`,以解决兼容性问题。
198 7

热门文章

最新文章