Give enough time before enabling TestIme for CtsWidgetTestCases

This is a follow up CL [1] to our previous attempt to avoid
preinstalled IMEs from unexpectedly interfering CtsWidgetTestCases.

There has been a race condition when

   ime enable com.android.cts.testime/.TestIme

specified in AndroidTest.xml silently fails if it is executed too
early after installing TestIme.apk, because InputMethodManagerService
internally relies on broadcast Intents such as
Intent.ACTION_PACKAGE_ADDED to update its internal IME list.

To reduce the chance of such a race condition, this CL does

 * try to install TestIme.apk before other APKs used for
   CtsWidgetTestCases,
 * call "am wait-for-broadcast-idle" to make sure all the broadcasts
   are issued, and
 * add 1 sec sleep, which can be increased upon partners' requests

Other than above tweaks, there should be no semantic changes in
CtsWidgetTestCases itself.

 [1]: I20ca55f1f7cde5451ce2a49926d019cced39b6a4
      1d0026ff911338557bc8c6292fa2eacb21121bd8

Bug: 186526091
Fix: 188105339
Test: atest CtsWidgetTestCases
Change-Id: I213cbc533df05eddd03f8a01c5577f24bc221095
1 file changed