Respect UI Context for getDisplay

Before InputMethodService initializes, InputMethodService#getDisplay
will throw UnsupportedOperationException because it doesn't attach to
any display. However, it may make developers confuse about why
throwing exception for an UI context. This CL workarounds to also
check isUiContext flags to make the result of IMS#getDisplay consistent.
It should be considered to remove after IMS migrate to WindowContext
concept.

fixes: 161964893
Test: atest InputMethodServiceTest#testGetDisplayBeforeInitialization

Change-Id: Ie0bda707f0196b45a8851f645da7ecab6814bed6
1 file changed