|
@@ -442,7 +442,7 @@ void DeviceFound(const DeviceInfo *device)
|
|
/**
|
|
/**
|
|
* 发现成功回调
|
|
* 发现成功回调
|
|
*/
|
|
*/
|
|
- static void DiscoverySuccess(int subscribeId)
|
|
|
|
|
|
+ void DiscoverySuccess(int subscribeId)
|
|
{
|
|
{
|
|
// 获取JNIEnv环境
|
|
// 获取JNIEnv环境
|
|
JNIEnv *env;
|
|
JNIEnv *env;
|
|
@@ -462,7 +462,7 @@ void DeviceFound(const DeviceInfo *device)
|
|
/**
|
|
/**
|
|
* 发现失败回调
|
|
* 发现失败回调
|
|
*/
|
|
*/
|
|
- static void DiscoveryFailed(int subscribeId, DiscoveryFailReason reason)
|
|
|
|
|
|
+ void DiscoveryFailed(int subscribeId, DiscoveryFailReason reason)
|
|
{
|
|
{
|
|
// 获取JNIEnv环境
|
|
// 获取JNIEnv环境
|
|
JNIEnv *env;
|
|
JNIEnv *env;
|
|
@@ -513,6 +513,7 @@ JNIEXPORT jint JNICALL Java_com_jg_softbus_naservice_SubscribeService_discoveryS
|
|
|
|
|
|
JNIEXPORT jint JNICALL Java_com_jg_softbus_naservice_SubscribeService_stopDiscovery
|
|
JNIEXPORT jint JNICALL Java_com_jg_softbus_naservice_SubscribeService_stopDiscovery
|
|
(JNIEnv * env, jobject obj, jstring pkgName, jint subscribeId) {
|
|
(JNIEnv * env, jobject obj, jstring pkgName, jint subscribeId) {
|
|
|
|
+ (*env)->GetJavaVM(env, &jvm);
|
|
const char* pkgName_str = (*env)->GetStringUTFChars(env, pkgName, NULL);
|
|
const char* pkgName_str = (*env)->GetStringUTFChars(env, pkgName, NULL);
|
|
int ret = StopDiscovery(pkgName_str, subscribeId);
|
|
int ret = StopDiscovery(pkgName_str, subscribeId);
|
|
if (ret) {
|
|
if (ret) {
|
|
@@ -527,7 +528,7 @@ JNIEXPORT jint JNICALL Java_com_jg_softbus_naservice_SubscribeService_stopDiscov
|
|
}
|
|
}
|
|
printf("<stopDiscovery>stop discover pkgName=%s, subscribeId=%d\n", pkgName_str, subscribeId);
|
|
printf("<stopDiscovery>stop discover pkgName=%s, subscribeId=%d\n", pkgName_str, subscribeId);
|
|
(*env)->ReleaseStringUTFChars(env, pkgName, pkgName_str);
|
|
(*env)->ReleaseStringUTFChars(env, pkgName, pkgName_str);
|
|
- return 0;
|
|
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
static void discoverResult(int32_t refreshId, RefreshResult reason) {
|
|
static void discoverResult(int32_t refreshId, RefreshResult reason) {
|
|
// 获取JNIEnv环境
|
|
// 获取JNIEnv环境
|
|
@@ -578,6 +579,8 @@ JNIEXPORT jint JNICALL Java_com_jg_softbus_naservice_SubscribeService_refreshLNN
|
|
|
|
|
|
JNIEXPORT jint JNICALL Java_com_jg_softbus_naservice_SubscribeService_stopRefreshLNN
|
|
JNIEXPORT jint JNICALL Java_com_jg_softbus_naservice_SubscribeService_stopRefreshLNN
|
|
(JNIEnv * env, jobject obj, jstring pkgName, jint refreshId) {
|
|
(JNIEnv * env, jobject obj, jstring pkgName, jint refreshId) {
|
|
|
|
+ // 保存Java虚拟机的引用
|
|
|
|
+ (*env)->GetJavaVM(env, &jvm);
|
|
const char* pkgNameStr = (*env)->GetStringUTFChars(env, pkgName, NULL);
|
|
const char* pkgNameStr = (*env)->GetStringUTFChars(env, pkgName, NULL);
|
|
// 停止刷新LNN
|
|
// 停止刷新LNN
|
|
int ret = StopRefreshLNN(pkgNameStr, refreshId);
|
|
int ret = StopRefreshLNN(pkgNameStr, refreshId);
|
|
@@ -598,6 +601,8 @@ JNIEXPORT jint JNICALL Java_com_jg_softbus_naservice_SubscribeService_stopRefres
|
|
|
|
|
|
JNIEXPORT jobjectArray JNICALL Java_com_jg_softbus_naservice_SubscribeService_findDeviceNodes
|
|
JNIEXPORT jobjectArray JNICALL Java_com_jg_softbus_naservice_SubscribeService_findDeviceNodes
|
|
(JNIEnv *env, jobject obj, jstring pkgName) {
|
|
(JNIEnv *env, jobject obj, jstring pkgName) {
|
|
|
|
+ // 保存Java虚拟机的引用
|
|
|
|
+ (*env)->GetJavaVM(env, &jvm);
|
|
const char* pkgNameStr = (*env)->GetStringUTFChars(env, pkgName, NULL);
|
|
const char* pkgNameStr = (*env)->GetStringUTFChars(env, pkgName, NULL);
|
|
NodeBasicInfo **dev = NULL;
|
|
NodeBasicInfo **dev = NULL;
|
|
int ret, num;
|
|
int ret, num;
|
|
@@ -639,16 +644,20 @@ JNIEXPORT jint JNICALL Java_com_jg_softbus_naservice_SubscribeService_stopRefres
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_com_jg_softbus_naservice_SubscribeService_releaseDeviceNodes
|
|
JNIEXPORT void JNICALL Java_com_jg_softbus_naservice_SubscribeService_releaseDeviceNodes
|
|
(JNIEnv *env, jobject obj, jobjectArray nodes) {
|
|
(JNIEnv *env, jobject obj, jobjectArray nodes) {
|
|
|
|
+ // 保存Java虚拟机的引用
|
|
|
|
+ (*env)->GetJavaVM(env, &jvm);
|
|
// 释放创建的节点集合对象
|
|
// 释放创建的节点集合对象
|
|
(*env)->DeleteLocalRef(env, nodes);
|
|
(*env)->DeleteLocalRef(env, nodes);
|
|
}
|
|
}
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_com_jg_softbus_naservice_SubscribeService_destroy
|
|
JNIEXPORT void JNICALL Java_com_jg_softbus_naservice_SubscribeService_destroy
|
|
(JNIEnv *env, jobject obj) {
|
|
(JNIEnv *env, jobject obj) {
|
|
- printf("[subscribe]destory the subscribe data.");
|
|
|
|
|
|
+ printf("[subscribe]destory the subscribe data.\r\n");
|
|
// 删除全局引用
|
|
// 删除全局引用
|
|
(*env)->DeleteGlobalRef(env, globalRef);
|
|
(*env)->DeleteGlobalRef(env, globalRef);
|
|
- printf("[subscribe]globalRef have been destory.");
|
|
|
|
- free(jvm);
|
|
|
|
- printf("[subscribe]jvm have been destory.");
|
|
|
|
|
|
+ printf("[subscribe]globalRef have been destory.\r\n");
|
|
|
|
+ // if(jvm != NULL) {
|
|
|
|
+ // free(jvm);
|
|
|
|
+ // printf("[subscribe]jvm have been destory.\r\n");
|
|
|
|
+ // }
|
|
}
|
|
}
|