Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Add exception return in JNI #25423

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,12 +734,14 @@ JNI_METHOD(void, updateCommissioningNetworkCredentials)
{
ChipLogError(Controller, "ApplyNetworkCredentials failed. Err = %" CHIP_ERROR_FORMAT, err.Format());
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, err);
return;
}
err = wrapper->UpdateCommissioningParameters(commissioningParams);
if (err != CHIP_NO_ERROR)
{
ChipLogError(Controller, "UpdateCommissioningParameters failed. Err = %" CHIP_ERROR_FORMAT, err.Format());
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, err);
return;
}

// Only invoke NetworkCredentialsReady when called in response to NetworkScan result
Expand Down Expand Up @@ -919,6 +921,7 @@ JNI_METHOD(jstring, getIpAddress)(JNIEnv * env, jobject self, jlong handle, jlon
{
ChipLogError(Controller, "Failed to get device address.");
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, err);
return nullptr;
}

addr.ToString(addrStr);
Expand Down Expand Up @@ -962,6 +965,7 @@ JNI_METHOD(jobject, getNetworkLocation)(JNIEnv * env, jobject self, jlong handle
{
ChipLogError(Controller, "Failed to get device address.");
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, err);
return nullptr;
}

addr.GetIPAddress().ToString(addrStr);
Expand Down Expand Up @@ -1176,6 +1180,7 @@ JNI_METHOD(jbyteArray, getAttestationChallenge)
{
ChipLogProgress(Controller, "Could not cast device pointer to Device object");
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, CHIP_ERROR_INCORRECT_STATE);
return nullptr;
}

err = chipDevice->GetAttestationChallenge(attestationChallenge);
Expand Down Expand Up @@ -1260,6 +1265,7 @@ JNI_METHOD(void, subscribe)
{
ChipLogError(Controller, "No device found");
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, CHIP_ERROR_INCORRECT_STATE);
return;
}

std::vector<app::AttributePathParams> attributePathParamsList;
Expand Down Expand Up @@ -1311,6 +1317,7 @@ JNI_METHOD(void, read)
{
ChipLogError(Controller, "No device found");
JniReferences::GetInstance().ThrowError(env, sChipDeviceControllerExceptionCls, CHIP_ERROR_INCORRECT_STATE);
return;
}

std::vector<app::AttributePathParams> attributePathParamsList;
Expand Down