checkWakeLocks caught Exception [message #977910] |
Fri, 09 November 2012 17:32 |
Michael McDonald Messages: 1 Registered: November 2012 |
Junior Member |
|
|
I have an app that calls a class from the receiver below. It works fine when the phone is awake, but as soon as it is put to sleep, it returns the following error from logcat:
E/DeepSleepService(745): checkWakeLocks caught Exception java.io.FileNotFoundException: /sys/power/active_wake_lock: open failed: ENOENT (No such file or directory)
I can find nothing on the internet regarding that exception.
Here is the the receiver class:
//------------------------
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.util.Log;
public class OnAlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
AlarmAlertWakeLock.acquireCpuWakeLock(context);
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "wakelock");
wl.acquire();
context.startService(new Intent(context, Track.class));
wl.release();
}
}
//----------------------------------
Here is the AlarmAlertWakeLock class:
//----------------------------------
import android.content.Context;
import android.os.PowerManager;
import android.util.Log;
class AlarmAlertWakeLock {
private static PowerManager.WakeLock sCpuWakeLock;
static void acquireCpuWakeLock(Context context) {
if (sCpuWakeLock != null) {
return;
}
PowerManager pm =
(PowerManager) context.getSystemService(Context.POWER_SERVICE);
sCpuWakeLock = pm.newWakeLock(
PowerManager.PARTIAL_WAKE_LOCK, "AlarmAlertWakeLock");
sCpuWakeLock.acquire();
}
static void releaseCpuLock() {
if (sCpuWakeLock != null) {
sCpuWakeLock.release();
sCpuWakeLock = null;
}
}
}
//---------------------------------------
I have registered the receiver and added permission in my manifest:
<uses-permission android:name="android.permission.WAKE_LOCK" />
<receiver android:name="com.myApp.OnAlarmReceiver"
android:enabled="true"
android:exported="false"
android:label="OnAlarmReceiver">
</receiver>
Any idea what is causing this error when the phone is put to sleep, and how to fix?
[Updated on: Fri, 09 November 2012 21:48] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04349 seconds