Basically, this is a problem with my phone. Other users report that this also happens with their phones, from different brands, but with the same version of Android. Other people have no problems - this convincingly indicates that this is not a problem with the version of Android, but with the implementation of each company for their hardware drivers.
I need constant accelerometer data, and I cannot measure this data for me - I have an Arduino with Bluetooth and an accelerometer, so I could implement this solution. Therefore, I decided that a workaround for my mobile phone was to allow the screen (darkened) and ignore the battery consumption. Later I will conduct battery tests using another Android phone that works with the screen off.
Additional error information
I researched a few more and found reports from other Android users, and I think maybe I understand what is going on. The libsensors.so library, which has drivers for telephone sensors, was not developed by Google, but by every mobile phone manufacturer - of course, because each cell phone has its own specific equipment. Google provides only the C header file so that developers know what they need to implement. In some implementations of these drivers, developers simply turn off the accelerometer when the screen turns off, thereby preventing the receiver of sensor events from receiving new events.
I also tested this with CyanogenMod RC7.2, but it did not work either, because the accelerometer drivers are original from LG.
Emails exchanged with HR LG
I sent an email to the LG P990 developers and finally got some specific answers! This can be of great help to some people like me who are experiencing these problems with Android. I wrote the following question
Hello! I am developing a dissertation in computer science, and currently I am receiving data from accelerometer equipment. At the moment, I found out that accelerometers do not send events when the screen is off, so even when I grab wakelock from one of my programs, I can make sure that my program is still working (via the LOGcat output), but there is no accelerometer happening. I have to fade my screen (which I cannot afford, the battery drains too fast) to start receiving accelerometers. I also tried to access it through my own C code, registering on the events of the accelerometer, but the result was the same, the accelerometer did not give out any values, although I was turning my device. So I was wondering if I could have direct access to hardware, with my own code, without having to register with a listener. Is it possible? If so, could you give some advice? I would really appreciate any help! Martin
For which I received this answer:
Dear Martin, We have received a response from Dev. Team. They said that you cannot get the accelerometer when the phone screen is off. Because the HAL layer did not implement the sysFS path for receiving an H / W event, such as an accelerometer, and there is no open API for receiving an event. Thank. Best Regards. (Sean Kim)
Then I sent the email back, saying, among other things, that I considered this a mistake, since you should have access to all the hardware when purchasing a tracking lock:
[...] I asked this question because I have friends who are also Android phones with the same version of gingerbread, but from other brands of mobile phones, and some of them reported that they receive events from accelerometers when the screen is off. I read about some forums that this error - I consider this a mistake, because when I purchase Wakelock, I would expect the processing to continue - it depends on the sensor drivers that manufacturers implement for their mobile phones. Is it likely that these drivers can be updated or will this error be fixed at some point? It would help me a lot with my current job [...]
And then I got this answer:
In my knowledge from Dev. Team, this is not a mistake. This phone is limitless due to the H / W architecture. We need to reverse engineer the HAL architecture and device driver to support your request. But, as you know, this is too complicated due to lack of resources. We are trying to help you with all our efforts, but we cannot support your request, as I mentioned. (Sean Kim)
Thus, they obviously know about it, but they don’t try to fix it because either they don’t think that this is a mistake - I still believe that this is a logical flaw - or they don’t have the time / resources to fix it.
Bottom line If you have a mobile phone that does not send accelerometer events with the screen off, try updating the firmware. If this does not solve, and you really want to make a serious hack, repeat your hardware level - tell me: maybe this is something related to libsensors.so.