ControllerInterface/Android: Add null check to AddDevice

The Google Play Console is showing some users getting a crash here,
and indeed, InputDevice.getDevice can return null.
This commit is contained in:
JosJuice 2023-08-15 13:31:18 +02:00
parent 54d3a226f3
commit 1d77bddc3b
1 changed files with 6 additions and 0 deletions

View File

@ -908,6 +908,12 @@ static void AddDevice(JNIEnv* env, int device_id)
jobject input_device = jobject input_device =
env->CallStaticObjectMethod(s_input_device_class, s_input_device_get_device, device_id); env->CallStaticObjectMethod(s_input_device_class, s_input_device_get_device, device_id);
if (!input_device)
{
ERROR_LOG_FMT(CONTROLLERINTERFACE, "Could not find device with ID {}", device_id);
return;
}
auto device = std::make_shared<AndroidDevice>(env, input_device); auto device = std::make_shared<AndroidDevice>(env, input_device);
env->DeleteLocalRef(input_device); env->DeleteLocalRef(input_device);