Handle Gnss Hal service death gracefully
Bug: 37460011
Fixes: 37460011
Test: adb shell
ps -A | grep 'gnss@1.0' | awk '{print $2}' | xargs kill
Change-Id: I6ff675fc198ab709d50637367f0b4648b55b021f
diff --git a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
index a3a7e1e..288f350 100644
--- a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
+++ b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
@@ -64,6 +64,7 @@
static jmethodID method_reportMeasurementData;
static jmethodID method_reportNavigationMessages;
static jmethodID method_reportLocationBatch;
+static jmethodID method_reportGnssServiceDied;
/*
* Save a pointer to JavaVm to attach/detach threads executing
@@ -120,10 +121,10 @@
{
// hidl_death_recipient interface
virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override {
- // TODO(b/37460011): implement a better death recovery mechanism without
- // crashing system server process as described in go//treble-gnss-death
- LOG_ALWAYS_FATAL("Abort due to IGNSS hidl service failure,"
- " restarting system server");
+ ALOGE("IGNSS hidl service failed, trying to recover...");
+
+ JNIEnv* env = android::AndroidRuntime::getJNIEnv();
+ env->CallVoidMethod(mCallbacksObj, method_reportGnssServiceDied);
}
};
@@ -1177,6 +1178,7 @@
clazz,
"reportLocationBatch",
"([Landroid/location/Location;)V");
+ method_reportGnssServiceDied = env->GetMethodID(clazz, "reportGnssServiceDied", "()V");
/*
* Save a pointer to JVM.