Team,
I have been trying to mimic an accelerometer on Ubuntu 18.04 device which does not have any sensors. I have created a virtual device for Accelerometer based on hdaps.c using uinput and ioctl. But when I pass dummy events to the device the events are not sent to the Android Application running which is listening to the events using onSensorChanged.
This is the virtual device created using uinput and ioctl.
device 7: /dev/input/event5
name: "ST LIS3LV02DL Accelerometer"
events:
REL (0002): REL_HWHEEL REL_DIAL
ABS (0003): ABS_X : value 0, min 0, max 1024, fuzz 0, flat 0, resolution 0
ABS_Y : value 0, min 0, max 1024, fuzz 0, flat 0, resolution 0
ABS_Z : value 0, min 0, max 1024, fuzz 0, flat 0, resolution 0
ABS_WHEEL : value 0, min 0, max 64, fuzz 0, flat 0, resolution 0
input props:
<none>
Also I have made changes in init.sh to use 'ro.hardware.sensors' as 'hdaps'.
When the input device is sent the event using a utility , I could see those events being received by the virtual device using
#getevent -lt /dev/input/event5
But the Android Application does not receive those events. On checking the dumpsys generated by sensorservice I can see that the events are read by sensor service
Below is the snapshot of dumpsys
44 (ts=1578905209.329160929, wall=14:16:50.030) 1.03, 91.66, -1.42,
45 (ts=1578905209.382981062, wall=14:16:50.097) -0.12, 45.96, -0.64,
46 (ts=1578905209.382984877, wall=14:16:50.164) 1.04, 45.82, -0.59,
47 (ts=1578905209.382987976, wall=14:16:50.231) 1.04, 91.66, -1.42,
48 (ts=1578905209.387239933, wall=14:16:50.298) -0.11, 45.96, -0.64,
49 (ts=1578905209.387243986, wall=14:16:50.364) 1.04, 45.82, -0.59,
50 (ts=1578905209.387246132, wall=14:16:50.431) 1.04, 91.66, -1.42,
Active sensors:
HDAPS accelerometer (handle=0x00000000, connections=2)
Socket Buffer size = 39 events
WakeLock Status: not held
Mode : NORMAL
2 active connections
Connection Number: 0
Operating Mode: NORMAL
com.testinput.MainActivity | WakeLockRefCount 0 | uid 10079 | cache size 0 | max cache size 0
HDAPS accelerometer 0x00000000 | status: First flush pending | pending flush events 0
Connection Number: 1
Operating Mode: NORMAL
com.android.server.policy.WindowOrientationListener | WakeLockRefCount 0 | uid 1000 | cache size 0 | max cache size 0
HDAPS accelerometer 0x00000000 | status: active | pending flush events 0
Per my analysis the issue is because "com.testinput.MainActivity" which is the test app for accelerometer the status is " First flush pending", which I presume is due to SENSOR_TYPE_META_DATA not being sent when I send virtual accelerometer events.
I am not sure what this data is supposed to be in case of accelerometer. Can someone help me with this.
Thanks,
Tarun