Update sequence and method of the mock object to prevent flaky

Use doReturn family of methods as suggestion in the Mockito doc
to prevent certain rare occasions. Also mock the tcp polling
interval before creating NetworkMonitor to prevent interacting
mock while NetworkMonitor's handler may not be idle.

Bug: 161426331
Test: atest NetworkStackNextTests:NetworkMonitorTest \
      --rerun-until-failure 100
Change-Id: I420bb197f4f62513b48828181a9907852cdfdc5f
1 file changed