ContextHubService: Update caches on nanoapp unload

When we unloaded a nanoapp, we weren't updating the cache of
nanoapp information at the ContextHubServer java layer.  Also,
we were leaking the handle.

We fix both of these by invoking the shared delete_app_instance()
function which properly handles all of this.

Furthermore, we allow delete_app_instance() to accept a nullptr
for the JNIEnv, and fix invalidateNanoApps() so that it won't
crash if it's unable to connect to the JVM.

Note that our Java communication in general here should be
cleaned up, but we're too late in the release cycle for
that, and leave that for b/30961119.

Bug: 30951974, 30968860
Change-Id: Ibb07666a8d54618bddaa3eaf36f9578926eb2b0f
1 file changed