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] Move InitChipStack() to AndroidChipPlatform #11647

Merged
merged 2 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions src/app/server/java/AppMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ CHIP_ERROR ChipAndroidAppInit(void)
err = chip::Platform::MemoryInit();
SuccessOrExit(err);

err = chip::DeviceLayer::PlatformMgr().InitChipStack();
SuccessOrExit(err);

ConfigurationMgr().LogDeviceConfig();

// Init ZCL Data Model and CHIP App Server
Expand Down
4 changes: 0 additions & 4 deletions src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self)

ChipLogProgress(Controller, "newDeviceController() called");

// sSystemLayer and sInetLayer are in platform/android to share with app server
err = DeviceLayer::PlatformMgr().InitChipStack();
SuccessOrExit(err);

wrapper = AndroidDeviceControllerWrapper::AllocateNew(sJVM, self, kLocalDeviceId, &DeviceLayer::SystemLayer(),
&DeviceLayer::InetLayer(), &err);
SuccessOrExit(err);
Expand Down
6 changes: 6 additions & 0 deletions src/platform/android/AndroidChipPlatform-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ void AndroidChipPlatformJNI_OnUnload(JavaVM * jvm, void * reserved)
chip::Platform::MemoryShutdown();
}

JNI_METHOD(void, initChipStack)(JNIEnv * env, jobject self)
{
CHIP_ERROR err = chip::DeviceLayer::PlatformMgr().InitChipStack();
VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(DeviceLayer, "Error initializing CHIP stack: %s", ErrorStr(err)));
}

// for BLEManager
JNI_METHOD(void, nativeSetBLEManager)(JNIEnv *, jobject, jobject manager)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public AndroidChipPlatform(
ConfigurationManager cfg,
ServiceResolver resolver,
ChipMdnsCallback chipMdnsCallback) {
// Order is important here: initChipStack() initializes the BLEManagerImpl, which depends on the
// BLEManager being set. setConfigurationManager() depends on the CHIP stack being initialized.
setBLEManager(ble);
initChipStack();
setKeyValueStoreManager(kvm);
setConfigurationManager(cfg);
setServiceResolver(resolver, chipMdnsCallback);
Expand Down Expand Up @@ -72,6 +75,9 @@ public native void handleUnsubscribeComplete(
// for ConfigurationManager
private native void setConfigurationManager(ConfigurationManager manager);

/** Initialize the CHIP stack. */
private native void initChipStack();

// for ServiceResolver
private void setServiceResolver(ServiceResolver resolver, ChipMdnsCallback chipMdnsCallback) {
if (resolver != null) {
Expand Down