Skip to content

Commit

Permalink
Loading ChipDeviceController JNI
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadb-amazon committed Apr 2, 2024
1 parent fadc263 commit 8ede2b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.content.Context;
import android.util.Log;
import chip.appserver.ChipAppServer;
import chip.devicecontroller.ChipDeviceController;
import chip.platform.AndroidBleManager;
import chip.platform.AndroidChipPlatform;
import chip.platform.ChipMdnsCallbackImpl;
Expand Down Expand Up @@ -97,6 +98,16 @@ public MatterError initialize(AppParameters appParameters) {
return MatterError.CHIP_ERROR_INVALID_ARGUMENT;
}

Log.d(TAG, "Calling ChipDeviceController loadJni");
ChipDeviceController.loadJni();
/* ControllerParams params = ControllerParams.newBuilder()
.setControllerVendorId(0xFFF1)
.setUdpListenPort(0)
.setEnableServerInteractions(false)
.build();
ChipDeviceController chipDeviceController = new ChipDeviceController(params);*/
Log.d(TAG, "Done loadingJni on ChipDeviceController");

MatterError err = finishInitialization(appParameters);

if (err.hasNoError()) {
Expand Down Expand Up @@ -172,6 +183,5 @@ public MatterError stop() {

static {
System.loadLibrary("TvCastingApp");
System.loadLibrary("CHIPController");
}
}
7 changes: 5 additions & 2 deletions src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,15 @@ jint JNI_OnLoad(JavaVM * jvm, void * reserved)

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

chip::Platform::MemoryInit();
// temporarily commenting out...
//chip::Platform::MemoryInit();

// Save a reference to the JVM. Will need this to call back into Java.
JniReferences::GetInstance().SetJavaVm(jvm, "chip/devicecontroller/ChipDeviceController");
sJVM = jvm;

// temporarily commenting out...
/*
// Get a JNI environment object.
env = JniReferences::GetInstance().GetEnvForCurrentThread();
VerifyOrExit(env != nullptr, err = CHIP_JNI_ERROR_NO_ENV);
Expand Down Expand Up @@ -142,7 +145,7 @@ jint JNI_OnLoad(JavaVM * jvm, void * reserved)
chip::DeviceLayer::StackUnlock unlock;
JNI_OnUnload(jvm, reserved);
}

*/
return (err == CHIP_NO_ERROR) ? JNI_VERSION_1_6 : JNI_ERR;
}

Expand Down

0 comments on commit 8ede2b7

Please sign in to comment.