Merge "Prevent use of a null sCallbackObj by Hardware FLP" into nyc-dev
This commit is contained in:
@@ -78,7 +78,7 @@ static inline void ThrowOnError(
|
|||||||
env->ThrowNew(exceptionClass, methodName);
|
env->ThrowNew(exceptionClass, methodName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsValidCallbackThread() {
|
static bool IsValidCallbackThreadEnvOnly() {
|
||||||
JNIEnv* env = AndroidRuntime::getJNIEnv();
|
JNIEnv* env = AndroidRuntime::getJNIEnv();
|
||||||
|
|
||||||
if(sCallbackEnv == NULL || sCallbackEnv != env) {
|
if(sCallbackEnv == NULL || sCallbackEnv != env) {
|
||||||
@@ -89,6 +89,20 @@ static bool IsValidCallbackThread() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool IsValidCallbackThread() {
|
||||||
|
// sCallbacksObject is created when FlpHardwareProvider on Java side is
|
||||||
|
// initialized. Sometimes the hardware may call a function before the Java
|
||||||
|
// side is ready. In order to prevent a system crash, check whether
|
||||||
|
// sCallbacksObj has been created. If not, simply ignore this event from
|
||||||
|
// hardware.
|
||||||
|
if (sCallbacksObj == NULL) {
|
||||||
|
ALOGE("Attempt to use FlpHardwareProvider blocked, because it hasn't been initialized.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return IsValidCallbackThreadEnvOnly();
|
||||||
|
}
|
||||||
|
|
||||||
static void BatchingCapabilitiesCallback(int32_t capabilities) {
|
static void BatchingCapabilitiesCallback(int32_t capabilities) {
|
||||||
if(!IsValidCallbackThread()) {
|
if(!IsValidCallbackThread()) {
|
||||||
return;
|
return;
|
||||||
@@ -154,7 +168,7 @@ static int SetThreadEvent(ThreadEvent event) {
|
|||||||
}
|
}
|
||||||
case DISASSOCIATE_JVM:
|
case DISASSOCIATE_JVM:
|
||||||
{
|
{
|
||||||
if (!IsValidCallbackThread()) {
|
if (!IsValidCallbackThreadEnvOnly()) {
|
||||||
ALOGE(
|
ALOGE(
|
||||||
"Attempted to dissasociate an unnownk callback thread : '%s'.",
|
"Attempted to dissasociate an unnownk callback thread : '%s'.",
|
||||||
__FUNCTION__
|
__FUNCTION__
|
||||||
@@ -661,16 +675,6 @@ static void GeofenceMonitorStatusCallback(
|
|||||||
TranslateToObject(lastLocation, locationObject);
|
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(
|
sCallbackEnv->CallVoidMethod(
|
||||||
sCallbacksObj,
|
sCallbacksObj,
|
||||||
sOnGeofenceMonitorStatus,
|
sOnGeofenceMonitorStatus,
|
||||||
|
|||||||
Reference in New Issue
Block a user