Mark Punzalan f15a444d18 Remove active translation on Activity destroyed
When a translated Activity is destroyed or translation is finished
(e.g., finishTranslation() call), we also have to remove the entry in
the active translations we are keeping track in
TranslationManagerService. Prior to this change, we were not removing
the entry in the Activity destroyed case, and this caused problems when
a new callback is registered (e.g., Gboard) because it would incorrectly
get an onStarted() call for the now-inactive translation.

This can happen relatively frequently when the device has a work
profile, since switching to apps across profiles re-creates the IME, and
in the case of Gboard, it registers a callback every time.

Also added additional logging on Activity destroyed and when callbacks
are registered and triggered.

Bug: 245911471
Test: atest UiTranslationManagerTest
Change-Id: If1881fd4588725021d38e5b9336c3e69bca17039
Merged-In: If1881fd4588725021d38e5b9336c3e69bca17039
2022-10-06 18:23:30 +00:00
..