Read from socket earlier in boot

We see large batched reads close to boot. In addition to heavy logging,
statsd previously would not start reading events from the socket until
StatsService::startup() had completed. This includes waiting up to 5
seconds for StatsCompanionService (sayHiToStatsCompanion) and reading and
initializing all configs (StatsService::StartUp). If system server is up
by this time, it could also lead to many atoms being pulled, although
this is unlikely.

The change is to begin reading events from the socket immediately and
add them to the internal queue. However, we delay processing events from
the queue until the initialization has occurred. This gives us a higher
capacity for events during the initialization while still not parsing
events until the configs are set up, so no atoms will be missed.

Test: manual testing of boot codepaths. I was able to trigger the case
when statsd starts before system server. However, in the past we have
seen cases where system server has started first. I was unable to
trigger that case. It is possible that ag/11975342 made this case
impossible or substantially less likely
Test: atest statsd_test
Bug: 344975220
Ignore-AOSP-First: will CP
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:986f004f92d3eb7a93b47997aaf03ff6cbe1f780)
Merged-In: I73eaf9dba0972dd79c74a210a27c054a53039fab
Change-Id: I73eaf9dba0972dd79c74a210a27c054a53039fab
5 files changed