Hold a strong reference to the callback in TextClassifierService

Issue:
TextClassifierService failed to invoke the callback to send the result back
to client occasionally because  the callback object may be GCed.
And thus smart selection failed occasionally, as the client doesn't get
a response back when it hits this issue. It won't fallback to local
textclassifier due to the timeout specified in TextView.

Cause:
We thought that ITextClassifierCallback is a "cross process" reference, and
so we only store a weak reference of it to avoid leak.
And it turns out that it is wrong. As soon as the weak ref gets GCed in
the service, that counts as dropping the callback. The service doesn't
know about any strong references the client has.

Bug: 138865849

Test: Try smart selection over 30 times, make sure smart action is shown
for every single time.

Change-Id: Ia9218cf67e8d67697a0fdff22c7918a55efc39ca
2 files changed