Skip to content

Commit b24efd9

Browse files
authored
Extended Discovery has no timeout on android (#16285)
* added app init before running Matter main loop and added SetExtendedDiscoveryTimeoutSecs * fix restyled-io and ci errors * remove weak ApplicationInit() in app server as PR request * fix restyled-io and ci errors * move ApplicationInit to TvApp-JNI, we do not need it call in main loop
1 parent 545d9bf commit b24efd9

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

examples/tv-app/android/App/app/src/main/java/com/tcl/chip/chiptvserver/service/MatterServant.java

+7
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public static MatterServant get() {
5353
}
5454

5555
public void init(@NonNull Context context) {
56+
// The order is important, must
57+
// first new TvApp to load dynamic library
58+
// then chipPlatform to prepare platform
59+
// then TvApp.postInit to init app which needs platform
60+
// then start ChipAppServer
5661
TvApp tvApp =
5762
new TvApp(
5863
(app, clusterId, endpoint) -> {
@@ -92,6 +97,8 @@ public void init(@NonNull Context context) {
9297
new ChipMdnsCallbackImpl(),
9398
new DiagnosticDataProviderImpl(applicationContext));
9499

100+
tvApp.postInit();
101+
95102
chipAppServer = new ChipAppServer();
96103
chipAppServer.startApp();
97104
}

examples/tv-app/android/java/TVApp-JNI.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,20 @@
2626
#include "MediaPlaybackManager.h"
2727
#include "WakeOnLanManager.h"
2828
#include "credentials/DeviceAttestationCredsProvider.h"
29+
#include <app/server/Dnssd.h>
2930
#include <app/server/java/AndroidAppServerWrapper.h>
31+
#include <credentials/DeviceAttestationCredsProvider.h>
32+
#include <credentials/examples/DeviceAttestationCredsExample.h>
3033
#include <jni.h>
3134
#include <lib/core/CHIPError.h>
3235
#include <lib/support/CHIPJNIError.h>
3336
#include <lib/support/JniReferences.h>
3437

3538
using namespace chip;
39+
using namespace chip::app;
40+
using namespace chip::Credentials;
41+
42+
#define EXTENDED_DISCOVERY_TIMEOUT_SEC 20
3643

3744
#define JNI_METHOD(RETURN, METHOD_NAME) extern "C" JNIEXPORT RETURN JNICALL Java_com_tcl_chip_tvapp_TvApp_##METHOD_NAME
3845

@@ -130,3 +137,10 @@ JNI_METHOD(void, setDACProvider)(JNIEnv *, jobject, jobject provider)
130137
chip::Credentials::SetDeviceAttestationCredentialsProvider(p);
131138
}
132139
}
140+
141+
JNI_METHOD(void, postInit)(JNIEnv *, jobject app)
142+
{
143+
#if CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY
144+
DnssdServer::Instance().SetExtendedDiscoveryTimeoutSecs(EXTENDED_DISCOVERY_TIMEOUT_SEC);
145+
#endif
146+
}

examples/tv-app/android/java/src/com/tcl/chip/tvapp/TvApp.java

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ private void postClusterInit(int clusterId, int endpoint) {
3737

3838
public native void nativeInit();
3939

40+
// post native init after platform is inited
41+
public native void postInit();
42+
4043
public native void setKeypadInputManager(int endpoint, KeypadInputManager manager);
4144

4245
public native void setWakeOnLanManager(int endpoint, WakeOnLanManager manager);

0 commit comments

Comments
 (0)