Skip to content

Commit 883b69a

Browse files
[Amazon] StopConnect for UDC in Android tv-casting-app
Updated JNI and Android tv-casting-app to use CharToStringUTF util function to create jstring and handle NULL JNIEnv interface Changes * JNI to use CharToStringUTF util function to create jstring for all ConnectionState and not just errors Test 1. Manually verified UDC attempt is successful both Android iOS for following 1. Attempt UDC attempt (both commissionee & commissioner generated passcode) 2. Navigate back to discovery page 3. Start new UDC attempt (both commissionee & commissioner generated passcode) 2. Manually verified UDC attempt is successful both Android iOS for following. UDC will finish in the background. 1. Attempt UDC attempt (both commissionee & commissioner generated passcode) 2. Confirm passcode on TV app or casting app depending on who generated passcode 3. Navigate back before commission fnishes. 3. Manual regression test following * UDC attempt happy path (no navigate back) for both commissinee & commissioner generated passcode
1 parent d179e92 commit 883b69a

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

examples/tv-casting-app/android/App/app/src/main/jni/cpp/core/MatterCastingPlayer-JNI.cpp

+15-13
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,14 @@ JNI_METHOD(void, disconnect)
168168
JNI_METHOD(jstring, getConnectionStateNative)
169169
(JNIEnv * env, jobject thiz)
170170
{
171+
char error_str[50];
172+
jobject jstr_obj = nullptr;
173+
171174
if (NULL == env)
172175
{
173-
jobject err_jstr = nullptr;
174176
LogErrorOnFailure(
175-
chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString("JNIEnv interface is NULL"), err_jstr));
176-
return static_cast<jstring>(err_jstr);
177+
chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString("JNIEnv interface is NULL"), jstr_obj));
178+
return static_cast<jstring>(jstr_obj);
177179
}
178180

179181
chip::DeviceLayer::StackLock lock;
@@ -186,20 +188,20 @@ JNI_METHOD(jstring, getConnectionStateNative)
186188
switch (state)
187189
{
188190
case matter::casting::core::ConnectionState::CASTING_PLAYER_NOT_CONNECTED:
189-
return env->NewStringUTF("NOT_CONNECTED");
191+
LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString("NOT_CONNECTED"), jstr_obj));
192+
break;
190193
case matter::casting::core::ConnectionState::CASTING_PLAYER_CONNECTING:
191-
return env->NewStringUTF("CONNECTING");
194+
LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString("CONNECTING"), jstr_obj));
195+
break;
192196
case matter::casting::core::ConnectionState::CASTING_PLAYER_CONNECTED:
193-
return env->NewStringUTF("CONNECTED");
194-
default: {
195-
char error_str[50];
197+
LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString("CONNECTED"), jstr_obj));
198+
break;
199+
default:
196200
snprintf(error_str, sizeof(error_str), "Unsupported Connection State: %d", state);
197-
198-
jobject err_jstr = nullptr;
199-
LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString(error_str), err_jstr));
200-
return static_cast<jstring>(err_jstr);
201-
}
201+
LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(CharSpan::fromCharString(error_str), jstr_obj));
202+
break;
202203
}
204+
return static_cast<jstring>(jstr_obj);
203205
}
204206

205207
JNI_METHOD(jobject, getEndpoints)

0 commit comments

Comments
 (0)