Fix inline suggestion ref counting to not over-count

* Imagine this event sequence:
  1) the IME tries to re-attach an inline suggestion view to the
  window (e.g. because IME layout changes), it calls into the system
  server which causes recreating the backing view because it was
  destroyed earlier due to 0 ref-count (this happens under the hood
  without IME knowing it happens, so the view is still attached to
  the window).
  2) the IME receives a new inline suggestion pointing to the same
  backing view (perhaps due to filtering kicks in).
  3) the recreation from step 1 finishes, but now it will callback
  to the new inline suggestion, therefore the old view doesn't receive
  the new SurfacePackage. See RemoteInlineSuggestionUi for why.
  4) the view in step 1 is detached from window, since it never
  receives a SurfacePackage from the remote view, its detach shouldn't
  cause a reference count down on the remote view.

Test: atest android.autofillservice.cts.inline (sanity test)
Bug: 154683107

Change-Id: I2e6814ef3889de603f6e170efcb795b69ec9febe
1 file changed