Skip to content

Commit

Permalink
Add reset api for android app server (#28398)
Browse files Browse the repository at this point in the history
Signed-off-by: Jaehoon You <jaehoon.you@samsung.com>
Signed-off-by: Charles Kim <chulspro.kim@samsung.com>
Co-authored-by: Jaehoon You <jaehoon.you@samsung.com>
  • Loading branch information
2 people authored and pull[bot] committed Feb 15, 2024
1 parent 3fceeae commit 4639954
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ class MatterApp @Inject constructor() {
fun stop() {
chipAppServer?.stopApp()
}

fun reset() {
chipAppServer?.resetApp()
}
}
5 changes: 5 additions & 0 deletions src/app/server/java/AndroidAppServerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,8 @@ void ChipAndroidAppShutdown(void)
chip::Server::GetInstance().Shutdown();
chip::Platform::MemoryShutdown();
}

void ChipAndroidAppReset(void)
{
chip::Server::GetInstance().ScheduleFactoryReset();
}
2 changes: 2 additions & 0 deletions src/app/server/java/AndroidAppServerWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ CHIP_ERROR ChipAndroidAppInit(AppDelegate * appDelegate = nullptr);

void ChipAndroidAppShutdown(void);

void ChipAndroidAppReset(void);

jint AndroidAppServerJNI_OnLoad(JavaVM * jvm, void * reserved);

void AndroidAppServerJNI_OnUnload(JavaVM * jvm, void * reserved);
8 changes: 8 additions & 0 deletions src/app/server/java/CHIPAppServer-JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ JNI_METHOD(jboolean, stopApp)(JNIEnv * env, jobject self)
return JNI_TRUE;
}

JNI_METHOD(jboolean, resetApp)(JNIEnv * env, jobject self)
{
chip::DeviceLayer::StackLock lock;
ChipAndroidAppReset();

return JNI_TRUE;
}

void * IOThreadAppMain(void * arg)
{
JNIEnv * env;
Expand Down
2 changes: 2 additions & 0 deletions src/app/server/java/src/chip/appserver/ChipAppServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ public ChipFabricProvider getFabricProvider() {
public native boolean startAppWithDelegate(ChipAppServerDelegate appDelegate);

public native boolean stopApp();

public native boolean resetApp();
}

0 comments on commit 4639954

Please sign in to comment.