6

We recently got a Nexus 5 to use as a test device. It's running Android 4.4.2. The problem is that it continually spews the following exception as a warning every 2 to 4 seconds:

01-02 22:33:33.482      751-894/? W/Binder﹕ Caught a RuntimeException from the binder stub implementation.
java.lang.IllegalArgumentException: Wake lock not active
        at com.android.server.power.PowerManagerService.updateWakeLockWorkSourceInternal(PowerManagerService.java:794)
        at com.android.server.power.PowerManagerService.updateWakeLockWorkSource(PowerManagerService.java:780)
        at com.android.server.power.PowerManagerService.updateWakeLockUids(PowerManagerService.java:761)
        at android.os.IPowerManager$Stub.onTransact(IPowerManager.java:103)
        at android.os.Binder.execTransact(Binder.java:404)
        at dalvik.system.NativeStart.run(Native Method)

No other phones, that we've tested display the same warning (including a Nexus 4 running 4.4.2)

We are using the WAKE_LOCK permission

<uses-permission android:name="android.permission.WAKE_LOCK" />

for Google Cloud Messenger

I've also made sure that this is happening in our app. The warning stay after filtering logcat by package name. It also stops as soon as you exit the app.

The main problem this causes is that Android Studio lags after a while so I need to clear logcat. Also runtime exception aren't something I want to just let lie either. Any ideas why this is happening?

[Edit]
Here's the place where It's being used in our code. It's just the GcmBroadcastReceiver from Google

public class GcmBroadcastReceiver extends WakefulBroadcastReceiver
{
    public void onReceive(Context context, Intent intent)
    {
        // Explicitly specify that GcmIntentService will handle the intent.
        ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName());

        // Start the service, keeping the device awake while it is launching.
        startWakefulService(context, (intent.setComponent(comp)));
        setResultCode(Activity.RESULT_OK);
    }
}
Bjorninn
  • 4,027
  • 4
  • 27
  • 39
  • Do you have some sample code of how you are acquiring/using the lock? – Selecsosi Jan 02 '14 at 22:56
  • Are you properly clearing the lock via `WakefulBroadcastReceiver` at the end of your service's work (e.g., `onHandleIntent()`)? – CommonsWare Jan 02 '14 at 23:20
  • We're using an almost copy-paste version of GcmIntentService from here: http://developer.android.com/google/gcm/client.html and like the onHandleIntent(Intent intent) method there we call completeWakefulIntent(intent) at the end. – Bjorninn Jan 02 '14 at 23:39
  • I'm not using a wake-lock on my app and see this constantly. I don't think it's your app, I think it's a bug in 4.4 – edthethird Jan 13 '14 at 15:23

2 Answers2

0

This might be the same problem that I have with the MediaPlayer. When I ask the MediaPlayer to handle the wake locks for me in my separate thread service I get Wake lock not active every five seconds or so..

I found this coming from the code that I just copied from the example code. If I throw the UnsupportedOperationException from public IBinder onBind(Intent intent) as in the example I get the above mentioned exception Wake lock not active every five seconds or so.

The simple solution is to return null instead of throwing the exception.

Hope this helps you.

bengtb
  • 61
  • 1
0

I had this exact same error, but from calling MediaPlayer.setVolume too often.

Ivan Neeson
  • 2,823
  • 2
  • 16
  • 11