power management笔记
2010-06-13 13:03
344 查看
一、APP调用goToSleep,权限检查失败,虚拟机shut down是报错:
java.lang.SecurityException: Neither user nor current process has android.permission.DEVICE_POWER.
解决办法:
public void goToSleep(long time)
{
Log.d(TAG,"goToSleep/n");
//注释掉这句代码
//mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
synchronized (mLocks) {
goToSleepLocked(time);
}
}
二、唤醒之后直接回到睡眠前的状态,不要显示锁屏:
方法1(这种改法会影响所有的应用及其他用到唤醒的地方):
frameworks/policies/base/phone/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
中,把如下的函数直接返回false
public boolean isDeviceProvisioned() {
//return mDeviceProvisioned;
return false;
}
方法2(只针对当前应用):
SDK文档里面有这个接口:
KeyguardManager.KeyguardLock
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard();
java.lang.SecurityException: Neither user nor current process has android.permission.DEVICE_POWER.
解决办法:
public void goToSleep(long time)
{
Log.d(TAG,"goToSleep/n");
//注释掉这句代码
//mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
synchronized (mLocks) {
goToSleepLocked(time);
}
}
二、唤醒之后直接回到睡眠前的状态,不要显示锁屏:
方法1(这种改法会影响所有的应用及其他用到唤醒的地方):
frameworks/policies/base/phone/com/android/internal/policy/impl/KeyguardUpdateMonitor.java
中,把如下的函数直接返回false
public boolean isDeviceProvisioned() {
//return mDeviceProvisioned;
return false;
}
方法2(只针对当前应用):
SDK文档里面有这个接口:
KeyguardManager.KeyguardLock
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
lock.disableKeyguard();
相关文章推荐
- PCIe学习笔记(16)--- Power Management (1)
- PCIe学习笔记(17)--- Power Management (2)
- [笔记分享] [Power] MSM8x60 Power Management study report
- WM/WINCE代码研读系列之Power Management(6)
- Runtime Power Management Framework for I/O Devices
- linux内核学习初笔记(4)u-boot的board_init()函数clk_power与gpio妙用
- Linux电源管理(4)_Power Management Interface
- Dell PowerEdge™ R510 Servers 安装 Ubuntu Server 10.04 LTS 笔记
- Linux电源管理(4)_Power Management Interface
- ACPI---高级配置和电源管理接口(Advanced Configuration and Power Management Interface)
- Power Management of Online Data-Intensive Services
- Multi-Core Power-management
- Android Power Management
- PCIe学习笔记(18)--- Power Management (3)
- Android Power Management
- [20]iwl3945 no power management and solution of fan contorl
- win7+oracle10g+PLSQLDeveloper7.1.5+Navicat Premium9 For Oracl+PowerDesigner12.5安装笔记
- WM/WINCE代码研读系列之Power Management(6)
- [转]WM/WINCE代码研读系列之 Power Management(2)