Added defensive code to prevent system crash

Bug: 26940611
Change-Id: I8226d1acb42ccc7d2cd910e30b47c7c63c9f490b
This commit is contained in:
Lifu Tang
2016-04-20 12:14:07 -07:00
parent 801d4161dd
commit 8b7ad976bf

View File

@@ -661,6 +661,16 @@ static void GeofenceMonitorStatusCallback(
TranslateToObject(lastLocation, locationObject);
}
// sCallbacksObject is created when FlpHardwareProvider on Java side is
// initialized. Sometimes the hardware may call this function before the Java
// side is ready. In order to prevent the system crash, check whether
// sCallbacksObj has been created. If not, simply ignore this event from
// hardware.
if (sCallbacksObj == NULL) {
ALOGE("FlpHardwareProvider hasn't been initialized.");
return;
}
sCallbackEnv->CallVoidMethod(
sCallbacksObj,
sOnGeofenceMonitorStatus,