Mock local services in a more reliable way

This is a preparation before making

  InputMethodManagerService#mImeDrawsImeNavBarRes

multi-user ready.

As discussed in https://github.com/mockito/mockito/issues/2142, mocked
static methods are available only in the calling thread. For testing
purposes just calling

  LocalServices.addService()

to inject mocked local services then removing them with

  LocalServices.removeAllServicesForTest()

would be much more simpler and easier to understand.

Bug: 345519864
Test: atest FrameworksInputMethodSystemServerTests
Flag: TEST_ONLY
Change-Id: If2d5e8ae6e002de9698c6a8eda489a6824f244e7
2 files changed