5

I have a USB device that I am interfacing with an android app using USB host mode. The device sends some data approximately once every 10 seconds but in some cases (high priority data) the data can come anytime. On the android app side I have a service that reads the data using USB host mode API. My android app processes the data and writes data back to the usb device. Now all works fine till the android device goes to sleep. The service goes to pause and all communication stops. I understand that I can use partial wake lock to keep the CPU running and the communication going and that it will have a huge impact on the battery. I though have two questions:

  1. Since the USB device can send data anytime, I really need the android service to alive all the time especially since higher priority data can come anytime. This could potentially mean that I acquire the partial wake lock and never release it. Havent been able to find in documentation if this is allowed and if yes what are the ramifications besides draining the battery?

  2. Does the USB Host mode API or any other API provide a different and potentially better solution?

The app is a custom app with limited users and so battery drain is not a big issue. I just want to understand if there are other issues I need to be careful about or if there is a much better way to do it.

Pankaj
  • 599
  • 3
  • 10
  • http://stackoverflow.com/questions/6091270/how-can-i-keep-my-android-service-running-when-the-screen-is-turned-off check this out too - this might be more of what you want. http://stackoverflow.com/questions/8713361/keep-a-service-running-even-when-phone-is-asleep – Nate-Wilkins Sep 01 '12 at 13:16
  • Usb devices can wakeup a device afaik but that requires kernel level / hardware support and I don't think the host mode API has any way to influence that. If it is not working the only thing you can do is to keep the device awake which is allowed and besides draining battery drains the battery a lot. – zapl Sep 01 '12 at 14:57
  • Thanks for the response. Looks like partial wake lock is the only way to go. – Pankaj Sep 01 '12 at 16:52
  • Very good question. I need the same for my Car PC. I don't believe this is the only way to go. When I use usb keyboard, my phone wakes up immediately from any key. Probably the easiest way is to make a composite device with usb HID that will send some useless keypress signal just to woke up the device. – Dmitry Gusarov Sep 26 '15 at 09:19

0 Answers0