Watch for V4L2 node removal to stop service

There are cases where the gadget driver may not send a
UVC_EVENT_DISCONNECT before cleaning up and removing the V4L2
node. In those cases, the DeviceAsWebcam service had no way to
know when the V4L2 node was removed and would refer to a stale
FD. Under some circumstaces, it would lead to a ramdump when
the FD was evenutally closed.

UVC Gadget driver waits for one second after removal of V4L2 nodes
to clean up resource, with the expectation that DeviceAsWebcam
service will close the fd in that time. To that goal, this CL adds
an inotify watch mechanism to UVCDevice that allows it to listen
to unlinking of the V4L2 node. This ensures that DeviceAsWebcam
service cleans up the node references before UVC gadget cleans up
the underlying kernel resources.

Bug: 296256109
Test: Manually disabled UVC_EVENT_DISCONNECT handling to see
      ensure that the function behaves properly even if
      UVC_EVENT_DISCONNECT doesn't come through.

Merged-In: I4b70456904363b9e28f19da19433b0bee15bfb1d
Change-Id: I4b70456904363b9e28f19da19433b0bee15bfb1d
(cherry picked from commit 87ccad41c89a6620d737f8c6789e3de73b13060c)
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
2 files changed