Allow tests to set the NetworkAgent's callbacks when creating it.

ConnectivityServiceTest#testNetworkAgentCallbacks tests the
behaviour of the NetworkAgent callbacks onNetworkCreated,
onNetworkUnwanted, and onNetworkDestroyed. This uses a
NetworkAgentWrapper method that sets the callbacks after the
test agent is constructed.

This infrastructure not sufficient to test an upcoming change
which will make onNetworkCreated be fired as soon as the
registration onNetworkCreated is fired as soon as the agent is
registered. Fix the code so that the callbacks can be specified
at agent registration time. This is also a bit more realistic
since in real usage, the callbacks are methods on the
NetworkAgent subclass and are already set when the agent is
constructed.

Bug: 143158421
Test: test-only change
Change-Id: I53c58e7b6c6ae4abf08e0df5051694cc4568a510
2 files changed