Check if the weak reference of java object is alive before using it

This CL get the global strong reference from the weak reference before
calling methods on a weak java object reference in Tuner JNI.

The method call would use the strong ref instead of the weak ref after
making sure it's non-null because weak ref is not garanteed non-null
even after the null check

see https://docs.oracle.com/javase/8/docs/technotes/guides/jni/spec/functions.html#weak_global_references
for more details

Test: atest android.media.tv.tuner.cts
Bug: 176190716
Change-Id: I81215c18cda413c5ddee0e46480ce3783dfe4be9
2 files changed