diff --git a/examples/virtual-device-app/android/App/core/matter/src/main/java/com/matter/virtual/device/app/core/matter/MatterApp.kt b/examples/virtual-device-app/android/App/core/matter/src/main/java/com/matter/virtual/device/app/core/matter/MatterApp.kt index 19d73cced0f04b..3b38261bf85496 100644 --- a/examples/virtual-device-app/android/App/core/matter/src/main/java/com/matter/virtual/device/app/core/matter/MatterApp.kt +++ b/examples/virtual-device-app/android/App/core/matter/src/main/java/com/matter/virtual/device/app/core/matter/MatterApp.kt @@ -45,4 +45,8 @@ class MatterApp @Inject constructor() { fun stop() { chipAppServer?.stopApp() } + + fun reset() { + chipAppServer?.resetApp() + } } diff --git a/src/app/server/java/AndroidAppServerWrapper.cpp b/src/app/server/java/AndroidAppServerWrapper.cpp index ab88729d6f1d9b..69436b17641d55 100644 --- a/src/app/server/java/AndroidAppServerWrapper.cpp +++ b/src/app/server/java/AndroidAppServerWrapper.cpp @@ -80,3 +80,8 @@ void ChipAndroidAppShutdown(void) chip::Server::GetInstance().Shutdown(); chip::Platform::MemoryShutdown(); } + +void ChipAndroidAppReset(void) +{ + chip::Server::GetInstance().ScheduleFactoryReset(); +} diff --git a/src/app/server/java/AndroidAppServerWrapper.h b/src/app/server/java/AndroidAppServerWrapper.h index 19088b9913ada1..8b09579185a773 100644 --- a/src/app/server/java/AndroidAppServerWrapper.h +++ b/src/app/server/java/AndroidAppServerWrapper.h @@ -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); diff --git a/src/app/server/java/CHIPAppServer-JNI.cpp b/src/app/server/java/CHIPAppServer-JNI.cpp index 1b486f1bd3ac82..2fd6aa8dbb516c 100644 --- a/src/app/server/java/CHIPAppServer-JNI.cpp +++ b/src/app/server/java/CHIPAppServer-JNI.cpp @@ -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; diff --git a/src/app/server/java/src/chip/appserver/ChipAppServer.java b/src/app/server/java/src/chip/appserver/ChipAppServer.java index e501329085522f..3d947081df4cfb 100644 --- a/src/app/server/java/src/chip/appserver/ChipAppServer.java +++ b/src/app/server/java/src/chip/appserver/ChipAppServer.java @@ -39,4 +39,6 @@ public ChipFabricProvider getFabricProvider() { public native boolean startAppWithDelegate(ChipAppServerDelegate appDelegate); public native boolean stopApp(); + + public native boolean resetApp(); }