ilabs-flir 2.4.3 → 2.4.4
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.
|
@@ -340,7 +340,8 @@ class FlirModule(private val reactContext: ReactApplicationContext) : ReactConte
|
|
|
340
340
|
@ReactMethod
|
|
341
341
|
fun resumeFlirAfterPreview(promise: Promise?) {
|
|
342
342
|
try {
|
|
343
|
-
|
|
343
|
+
// Respect the gate - do not open it blindly on resume
|
|
344
|
+
FlirManager.startDiscovery()
|
|
344
345
|
promise?.resolve(true)
|
|
345
346
|
} catch (e: Exception) {
|
|
346
347
|
promise?.reject("ERR_RESUME_FLIR", e)
|
|
@@ -48,7 +48,7 @@ public class FlirSdkManager {
|
|
|
48
48
|
private final Executor executor = Executors.newSingleThreadExecutor();
|
|
49
49
|
|
|
50
50
|
// State
|
|
51
|
-
private
|
|
51
|
+
private final AtomicBoolean isInitialized = new AtomicBoolean(false);
|
|
52
52
|
private boolean isScanning = false;
|
|
53
53
|
private Camera camera;
|
|
54
54
|
private ThermalStreamer streamer;
|
|
@@ -103,32 +103,34 @@ public class FlirSdkManager {
|
|
|
103
103
|
// ==================== INITIALIZE ====================
|
|
104
104
|
|
|
105
105
|
public void initialize() {
|
|
106
|
-
if (isInitialized)
|
|
107
|
-
|
|
108
|
-
try {
|
|
109
|
-
ThermalSdkAndroid.init(context);
|
|
106
|
+
if (isInitialized.compareAndSet(false, true)) {
|
|
107
|
+
Log.d(TAG, "Initializing FLIR SDK (async)...");
|
|
110
108
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
109
|
+
executor.execute(() -> {
|
|
110
|
+
try {
|
|
111
|
+
ThermalSdkAndroid.init(context);
|
|
112
|
+
|
|
113
|
+
// Small delay to ensure JNI linkage is stable
|
|
114
|
+
try { Thread.sleep(100); } catch (InterruptedException ignored) {}
|
|
115
|
+
|
|
116
|
+
Log.d(TAG, "FLIR SDK initialized successfully on background thread. Arch: " + System.getProperty("os.arch"));
|
|
117
|
+
} catch (Throwable t) {
|
|
118
|
+
Log.e(TAG, "Failed to initialize FLIR SDK", t);
|
|
119
|
+
isInitialized.set(false);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
|
|
123
125
|
public boolean isInitialized() {
|
|
124
|
-
return isInitialized;
|
|
126
|
+
return isInitialized.get();
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
// ==================== DISCOVERY ====================
|
|
128
130
|
|
|
129
131
|
public void scan() {
|
|
130
132
|
executor.execute(() -> {
|
|
131
|
-
if (!isInitialized) {
|
|
133
|
+
if (!isInitialized.get()) {
|
|
132
134
|
notifyError("SDK not initialized");
|
|
133
135
|
return;
|
|
134
136
|
}
|