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

Add memory init/shutdown in android libs #3397

Merged
merged 1 commit into from
Oct 22, 2020
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
10 changes: 9 additions & 1 deletion src/controller/java/CHIPDeviceController-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ struct StackUnlockGuard
StackUnlockGuard() { pthread_mutex_unlock(&sStackLock); }
~StackUnlockGuard() { pthread_mutex_lock(&sStackLock); }
};

} // namespace

// NOTE: Remote device ID is in sync with the echo server device id
Expand All @@ -138,6 +139,8 @@ jint JNI_OnLoad(JavaVM * jvm, void * reserved)

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

chip::Platform::MemoryInit();

// Save a reference to the JVM. Will need this to call back into Java.
sJVM = jvm;

Expand Down Expand Up @@ -220,6 +223,8 @@ void JNI_OnUnload(JavaVM * jvm, void * reserved)
sSystemLayer.Shutdown();
sInetLayer.Shutdown();
sJVM = NULL;

chip::Platform::MemoryShutdown();
}

JNI_METHOD(jlong, newDeviceController)(JNIEnv * env, jobject self)
Expand Down Expand Up @@ -533,7 +538,10 @@ JNI_METHOD(jboolean, disconnectDevice)(JNIEnv * env, jobject self, jlong deviceC

{
ScopedPthreadLock lock(&sStackLock);
err = deviceController->DisconnectDevice();
if (deviceController->IsConnected())
{
err = deviceController->DisconnectDevice();
}
}

if (err != CHIP_NO_ERROR)
Expand Down