我怀疑一些应用程序是不恰当的获取 qualire_causes_wakeup wakelock 。有没有办法获得Wakelock活动的日志或使用其他方式调试此方法？
Sometimes when my Nexus One is plugged in with the screen switched off, the screen turns itself on (showing the lock screen) seemingly randomly, and I have the "Stay awake" Development option turned on, so it stays switched on until I manually switch it off again.
I suspect that some app is inappropriately obtaining an ACQUIRE_CAUSES_WAKEUP WakeLock. Is there a way to get a log of WakeLock activity or some other way of debugging this?
The same happens occasionally on my Galaxy S, usually about 5-10 minutes after plugging in. If you can handle the dev tools, you could try charging the phone from an USB port while running
logcat and checking what goes on around the time the phone activates, or if the screen turns on only when charging from a wall socket you could run
aLogcat on the phone while charging and then try to see the reason, but it can be a bit tricky on the phone.
I had this problem when I had SipDroid installed -- every time its connection dropped and came back up, it would turn on the screen. You could use an app like Titanium Backup (requires root) to "freeze" an app, and see if the problem stops. If it does you know what app is the problem. Then uninstall it, or turn off background sync for it or something if that might be the problem. TB can uninstall system apps, but be careful which ones.
I eventually tracked this down using the app "Task Identifier". It's a bit awkward to use and has an odd interface, but it also has the useful feature of showing an alert if apps activate when the phone is sleeping.
It turned out that the problem was the sync service from the doubleTwist app, and it appears that it was indeed caused by an inappropriately-used ACQUIRE_CAUSES_WAKEUP WakeLock. I've e-mailed them a bug report.