When looper calls a callback that triggered for a poll on a file descriptor it provides the reason for the wakeup, because users are allowed to register multiple. Hence it is important for the user to know the trigger reason to enact on the result appropriately. E.g. a HANGUP typically requires the callback to be deregistered by returning false, as the other end (for a pipe() or socket()) has been closed and this file descriptor should no longer trigger any other event.
Note that various events are received by this callback regardless of whether the user registered it with that flag in events. This is all reflected by updating the documentation comments for FdEvent based on upstream Android documentation.
Keep in mind that FdEvent is a bitflag, and Android uses that to batch up multiple events. E.g. writing to a pipe() and closing the write fd - while the read fd is registered in a callback - causes the callback (from a subsequent looper.poll*()) to be called with INPUT | HANGUP, indicating that there is data to read but that the file descriptor will be dormant after that.
When
looper
calls a callback that triggered for a poll on a file descriptor it provides the reason for the wakeup, because users are allowed to register multiple. Hence it is important for the user to know the trigger reason to enact on the result appropriately. E.g. aHANGUP
typically requires the callback to be deregistered by returningfalse
, as the other end (for apipe()
orsocket()
) has been closed and this file descriptor should no longer trigger any other event.Note that various events are received by this callback regardless of whether the user registered it with that flag in
events
. This is all reflected by updating the documentation comments forFdEvent
based on upstream Android documentation.Keep in mind that
FdEvent
is abitflag
, and Android uses that to batch up multiple events. E.g. writing to apipe()
and closing the writefd
- while the readfd
is registered in a callback - causes the callback (from a subsequentlooper.poll*()
) to be called withINPUT | HANGUP
, indicating that there is data to read but that the file descriptor will be dormant after that.