Support NetworkStatsEventLogger

The performPoll method in the NetworkStatsService can be called
for many reasons, such as RAT changed events, LinkProperties
changed events, open session method calls, forceUpdate method
calls, etc.
However, the current logging is not sufficient to trace down
the caller of performPoll. This makes it difficult to debug
frequent poll issues or performance problems.

Adding debug log to logcat is not an option, given that
performPoll might run several times per second by system server
callers.

This change adds a reason code to the performPoll method and
a helper class to log performPoll events. This will allow us
to track down the caller of performPoll and better understand
why it is being called frequently or causing performance
problems.

This change also introduces a PollEvent object, which can be
used to put related information in subsequent changes when
logging.

Sample output:
Poll counts per reason:
  DUMPSYS: 0
  FORCE_UPDATE: 6
  GLOBAL_ALERT: 0
  NETWORK_STATUS_CHANGED: 3
  OPEN_SESSION: 0
  PERIODIC: 1
  RAT_CHANGED: 1
  REG_CALLBACK: 3
  REMOVE_UIDS: 0
  UPSTREAM_CHANGED: 1

Recent poll events:
  2023-10-04T02:47:12.937370 - Poll(flags=3, PollEvent{reason=REG_CALLBACK})
  2023-10-04T02:47:13.178559 - Poll(flags=3, PollEvent{reason=FORCE_UPDATE})

Test: manual
Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsEventLoggerTest
Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
Bug: 301141955
Change-Id: Ic6d0543ccdef12493385f45200199854b841a26b
4 files changed