Fix and improve TrustManagerServiceTest

- Make these unit tests have fewer dependencies on the system.  For
  example, don't use the system's real UserManagerService and
  LockSettingsService.  Use userId 50 instead of userId 0 to help avoid
  unwanted dependencies.

- Set up more things in setUp() so that individual tests don't need to.

- Run the TrustManagerService handler on a separate thread so that code
  that flushes the message queue does not cause a deadlock.  The
  existing tests are fine without this, but this is needed for a later
  CL that adds tests that call reportKeyguardShowingChanged().

This fixes failures in firstBootCompleted_defaultTrustAgentEnabled,
newSystemTrustAgent_notEnabledWhenDefaultAgentIsSet, and
serviceBooted_knownAgentsNotSet_enabledAgentsNotUpdated.

Bug: 296464083
Test: atest TrustManagerServiceTest
Change-Id: I6d1baacd38275b3cc9ba583b98ed1b139123ea9b
2 files changed