Fix network logging cts test.

There is a lag between sending enough network events and
receiving a broadcast, during that time server socket is
closed, which causes busy loop spewing exceptions to the
log. Checking if the socket is closed is more reliable.

+ sprinkled some finals.

Change-Id: I02802af768c58f4af898c20f893a3590f60e4ec0
Fixes: 78517818
Test: atest CtsDevicePolicyManagerTestCases:com.android.cts.devicepolicy.DeviceOwnerTest#testNetworkLogging_multipleBatches
1 file changed