@bits-innovate/react-native-vstarcam 1.0.30 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -59,6 +59,12 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
59
59
|
// Counter for unique internal client IDs
|
|
60
60
|
private static final java.util.concurrent.atomic.AtomicInteger nextClientPtr = new java.util.concurrent.atomic.AtomicInteger(1000);
|
|
61
61
|
|
|
62
|
+
// Static proxy references to prevent GC.
|
|
63
|
+
// If the native SDK holds these, Java must not collect them.
|
|
64
|
+
private static Object stateListenerProxy;
|
|
65
|
+
private static Object commandListenerProxy;
|
|
66
|
+
private static Object releaseListenerProxy;
|
|
67
|
+
|
|
62
68
|
// Helper for conditional debug logging
|
|
63
69
|
private static void logDebug(String message) {
|
|
64
70
|
if (DEBUG_LOGGING) {
|
|
@@ -270,14 +276,14 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
270
276
|
|
|
271
277
|
try {
|
|
272
278
|
// Create dynamic proxy for ClientStateListener
|
|
273
|
-
|
|
279
|
+
stateListenerProxy = Proxy.newProxyInstance(
|
|
274
280
|
stateListenerClass.getClassLoader(),
|
|
275
281
|
new Class<?>[] { stateListenerClass },
|
|
276
282
|
new InvocationHandler() {
|
|
277
283
|
@Override
|
|
278
284
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
|
279
285
|
try {
|
|
280
|
-
Log.d(TAG, "ClientStateListener." + method.getName() + " called
|
|
286
|
+
Log.d(TAG, "ClientStateListener." + method.getName() + " called");
|
|
281
287
|
if (method.getName().equals("stateListener")) {
|
|
282
288
|
// args: long clientPtr, int state
|
|
283
289
|
final long clientPtr = (Long) args[0];
|
|
@@ -297,28 +303,22 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
297
303
|
} catch (Exception e) {
|
|
298
304
|
Log.e(TAG, "Error in stateListener callback", e);
|
|
299
305
|
}
|
|
300
|
-
|
|
301
|
-
// Handle return type
|
|
302
|
-
Class<?> returnType = method.getReturnType();
|
|
303
|
-
if (returnType.equals(int.class) || returnType.equals(Integer.class)) {
|
|
304
|
-
return 0;
|
|
305
|
-
}
|
|
306
|
-
return null;
|
|
306
|
+
return null; // void stateListener
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
);
|
|
310
310
|
|
|
311
311
|
// Create dynamic proxy for ClientCommandListener
|
|
312
|
-
|
|
312
|
+
commandListenerProxy = Proxy.newProxyInstance(
|
|
313
313
|
commandListenerClass.getClassLoader(),
|
|
314
314
|
new Class<?>[] { commandListenerClass },
|
|
315
315
|
new InvocationHandler() {
|
|
316
316
|
@Override
|
|
317
317
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
|
318
318
|
try {
|
|
319
|
-
Log.d(TAG, "ClientCommandListener." + method.getName() + " called
|
|
319
|
+
Log.d(TAG, "ClientCommandListener." + method.getName() + " called");
|
|
320
320
|
if (method.getName().equals("commandListener")) {
|
|
321
|
-
// args: long clientPtr, byte[] data, int length
|
|
321
|
+
// args: long clientPtr, byte[] data, int length
|
|
322
322
|
final long clientPtr = (Long) args[0];
|
|
323
323
|
final byte[] data = (byte[]) args[1];
|
|
324
324
|
final int length = (Integer) args[2];
|
|
@@ -336,19 +336,13 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
336
336
|
} catch (Exception e) {
|
|
337
337
|
Log.e(TAG, "Error in commandListener callback", e);
|
|
338
338
|
}
|
|
339
|
-
|
|
340
|
-
// Handle return type
|
|
341
|
-
Class<?> returnType = method.getReturnType();
|
|
342
|
-
if (returnType.equals(int.class) || returnType.equals(Integer.class)) {
|
|
343
|
-
return 0;
|
|
344
|
-
}
|
|
345
|
-
return null;
|
|
339
|
+
return null; // void commandListener
|
|
346
340
|
}
|
|
347
341
|
}
|
|
348
342
|
);
|
|
349
343
|
|
|
350
344
|
// Create dynamic proxy for ClientReleaseListener
|
|
351
|
-
|
|
345
|
+
releaseListenerProxy = Proxy.newProxyInstance(
|
|
352
346
|
releaseListenerClass.getClassLoader(),
|
|
353
347
|
new Class<?>[] { releaseListenerClass },
|
|
354
348
|
new InvocationHandler() {
|
|
@@ -356,16 +350,14 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
356
350
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
|
357
351
|
try {
|
|
358
352
|
Log.d(TAG, "ClientReleaseListener." + method.getName() + " called");
|
|
353
|
+
if (method.getName().equals("releaseListener")) {
|
|
354
|
+
final long clientPtr = (Long) args[0];
|
|
355
|
+
Log.d(TAG, "Release callback: clientPtr=" + clientPtr);
|
|
356
|
+
}
|
|
359
357
|
} catch (Exception e) {
|
|
360
358
|
Log.e(TAG, "Error in releaseListener callback", e);
|
|
361
359
|
}
|
|
362
|
-
|
|
363
|
-
// Handle return type
|
|
364
|
-
Class<?> returnType = method.getReturnType();
|
|
365
|
-
if (returnType.equals(int.class) || returnType.equals(Integer.class)) {
|
|
366
|
-
return 0;
|
|
367
|
-
}
|
|
368
|
-
return null;
|
|
360
|
+
return null; // void releaseListener
|
|
369
361
|
}
|
|
370
362
|
}
|
|
371
363
|
);
|
|
@@ -373,7 +365,8 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
373
365
|
// Call JNIApi.init(stateListener, commandListener, releaseListener)
|
|
374
366
|
Method initMethod = jniApiClass.getMethod("init",
|
|
375
367
|
stateListenerClass, commandListenerClass, releaseListenerClass);
|
|
376
|
-
|
|
368
|
+
Log.d(TAG, "Calling JNIApi.init with proxies...");
|
|
369
|
+
initMethod.invoke(null, stateListenerProxy, commandListenerProxy, releaseListenerProxy);
|
|
377
370
|
|
|
378
371
|
isP2PInitialized = true;
|
|
379
372
|
Log.d(TAG, "P2P system initialized successfully!");
|
|
@@ -553,8 +546,8 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
553
546
|
Log.d(TAG, "Calling JNIApi.connect(" + clientInfo.sdkClientPtr + ", 15, " + param + ", " + actualConnectType + ")");
|
|
554
547
|
|
|
555
548
|
try {
|
|
556
|
-
connectMethod.invoke(null, clientInfo.sdkClientPtr, 15, param, actualConnectType);
|
|
557
|
-
Log.d(TAG, "JNIApi.connect
|
|
549
|
+
Object result = connectMethod.invoke(null, clientInfo.sdkClientPtr, 15, param, actualConnectType);
|
|
550
|
+
Log.d(TAG, "JNIApi.connect result: " + result);
|
|
558
551
|
} catch (java.lang.reflect.InvocationTargetException ite) {
|
|
559
552
|
Log.e(TAG, "JNIApi.connect threw exception: " + ite.getCause(), ite.getCause());
|
|
560
553
|
throw ite;
|
|
@@ -609,32 +602,35 @@ public class VStarCamModule extends ReactContextBaseJavaModule {
|
|
|
609
602
|
|
|
610
603
|
Log.d(TAG, "Calling JNIApi.login(" + clientInfo.sdkClientPtr + ", " + username + ", ***)");
|
|
611
604
|
|
|
612
|
-
boolean
|
|
605
|
+
boolean loginResult = false;
|
|
613
606
|
try {
|
|
614
|
-
loginMethod.invoke(null, clientInfo.sdkClientPtr, username, password);
|
|
615
|
-
Log.d(TAG, "JNIApi.login
|
|
616
|
-
|
|
607
|
+
Object result = loginMethod.invoke(null, clientInfo.sdkClientPtr, username, password);
|
|
608
|
+
Log.d(TAG, "JNIApi.login result: " + result);
|
|
609
|
+
// result is likely boolean based on signature log
|
|
610
|
+
if (result instanceof Boolean) {
|
|
611
|
+
loginResult = (Boolean) result;
|
|
612
|
+
} else if (result != null) {
|
|
613
|
+
loginResult = true; // Non-null result usually means success for some SDKs
|
|
614
|
+
}
|
|
617
615
|
} catch (java.lang.reflect.InvocationTargetException ite) {
|
|
618
616
|
Throwable cause = ite.getCause();
|
|
619
617
|
Log.e(TAG, "JNIApi.login threw exception: " + cause, cause);
|
|
620
|
-
// Don't rethrow - return false instead to prevent crash
|
|
621
618
|
promise.resolve(false);
|
|
622
619
|
return;
|
|
623
620
|
} catch (Throwable t) {
|
|
624
621
|
Log.e(TAG, "JNIApi.login crashed: " + t.getMessage(), t);
|
|
625
|
-
// Don't rethrow - return false instead to prevent crash
|
|
626
622
|
promise.resolve(false);
|
|
627
623
|
return;
|
|
628
624
|
}
|
|
629
625
|
|
|
630
|
-
if (
|
|
626
|
+
if (loginResult) {
|
|
631
627
|
clientInfo.isLoggedIn = true;
|
|
632
628
|
clientInfo.username = username;
|
|
633
629
|
clientInfo.password = password;
|
|
634
630
|
}
|
|
635
631
|
|
|
636
|
-
Log.d(TAG, "JNIApi.login completed with result: " +
|
|
637
|
-
promise.resolve(
|
|
632
|
+
Log.d(TAG, "JNIApi.login completed with result: " + loginResult);
|
|
633
|
+
promise.resolve(loginResult);
|
|
638
634
|
} catch (Exception e) {
|
|
639
635
|
Log.e(TAG, "clientLogin failed", e);
|
|
640
636
|
promise.reject("LOGIN_ERROR", e.getMessage());
|