ilabs-flir 2.3.4 → 2.3.5

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.
@@ -463,20 +463,34 @@ object FlirManager {
463
463
  Log.d(TAG, "Updated Var.cool to $shaderIdx via reflection (raw=$rawIdx)")
464
464
 
465
465
  // If we are in FLIR mode, also notify the SDK palette using the official SDK palette list
466
- val sdkPalettes = PaletteManager.getDefaultPalettes()
467
- val paletteNames = sdkPalettes.map { it.name }
468
- Log.d(TAG, "True FLIR Palettes: $paletteNames")
469
-
470
- val maxEff = sdkPalettes.size
471
- val paletteIdx = rawIdx % maxEff
472
- val safeIdx = if (paletteIdx < 0) paletteIdx + maxEff else paletteIdx
473
-
474
- val targetPaletteName = paletteNames[safeIdx]
475
- Log.d(TAG, "Applying true FLIR palette: $targetPaletteName (index: $safeIdx, max: $maxEff)")
476
-
477
- sdkManager?.setPalette(targetPaletteName)
466
+ var sdkPalettes: List<Palette>? = null
467
+ try {
468
+ sdkPalettes = PaletteManager.getDefaultPalettes()
469
+ } catch (t: Throwable) {
470
+ try {
471
+ val altClazz = Class.forName("com.flir.thermalsdk.image.palettes.PaletteManager")
472
+ val method = altClazz.getMethod("getDefaultPalettes")
473
+ sdkPalettes = method.invoke(null) as? List<Palette>
474
+ } catch (t2: Throwable) {
475
+ Log.w(TAG, "Palette discovery failed in updateAcol", t2)
476
+ }
477
+ }
478
+
479
+ if (sdkPalettes != null) {
480
+ val paletteNames = sdkPalettes.map { it.name }
481
+ Log.d(TAG, "True FLIR Palettes: $paletteNames")
482
+
483
+ val maxEff = sdkPalettes.size
484
+ val paletteIdx = rawIdx % maxEff
485
+ val safeIdx = if (paletteIdx < 0) paletteIdx + maxEff else paletteIdx
486
+
487
+ val targetPaletteName = paletteNames[safeIdx]
488
+ Log.d(TAG, "Applying true FLIR palette: $targetPaletteName (index: $safeIdx, max: $maxEff)")
489
+
490
+ sdkManager?.setPalette(targetPaletteName)
491
+ }
478
492
 
479
- } catch (e: Exception) {
493
+ } catch (e: Throwable) {
480
494
  Log.w(TAG, "Could not update Var.cool via reflection: ${e.message}")
481
495
  }
482
496
  }
@@ -487,7 +501,25 @@ object FlirManager {
487
501
  fun generatePaletteIcons(context: Context): List<Map<String, String>> {
488
502
  val results = mutableListOf<Map<String, String>>()
489
503
  try {
490
- val rawPalettes = PaletteManager.getDefaultPalettes()
504
+ var rawPalettes: List<Palette>? = null
505
+ try {
506
+ rawPalettes = PaletteManager.getDefaultPalettes()
507
+ } catch (t: Throwable) {
508
+ Log.e(TAG, "PaletteManager.getDefaultPalettes() failed in icon generation", t)
509
+ try {
510
+ val altClazz = Class.forName("com.flir.thermalsdk.image.palettes.PaletteManager")
511
+ val method = altClazz.getMethod("getDefaultPalettes")
512
+ rawPalettes = method.invoke(null) as? List<Palette>
513
+ } catch (t2: Throwable) {
514
+ Log.e(TAG, "Alternative package search also failed in icon generation", t2)
515
+ }
516
+ }
517
+
518
+ if (rawPalettes == null) {
519
+ Log.e(TAG, "Failed to retrieve any palettes from SDK")
520
+ return emptyList()
521
+ }
522
+
491
523
  val palettes = rawPalettes.toMutableList()
492
524
 
493
525
  // Reorder: Move WhiteHot/Gray to the front
@@ -144,7 +144,7 @@ class FlirModule(private val reactContext: ReactApplicationContext) : ReactConte
144
144
  val result = com.facebook.react.bridge.Arguments.createArray()
145
145
  palettes.forEach { result.pushString(it) }
146
146
  promise?.resolve(result)
147
- } catch (e: Exception) {
147
+ } catch (e: Throwable) {
148
148
  promise?.reject("ERR_FLIR_PALETTES", e)
149
149
  }
150
150
  }
@@ -162,7 +162,7 @@ class FlirModule(private val reactContext: ReactApplicationContext) : ReactConte
162
162
  result.pushMap(map)
163
163
  }
164
164
  promise?.resolve(result)
165
- } catch (e: Exception) {
165
+ } catch (e: Throwable) {
166
166
  promise?.reject("ERR_FLIR_PALETTE_ICONS", e)
167
167
  }
168
168
  }
@@ -306,7 +306,7 @@ class FlirModule(private val reactContext: ReactApplicationContext) : ReactConte
306
306
  try {
307
307
  FlirManager.updateAcol(value)
308
308
  promise?.resolve(true)
309
- } catch (e: Exception) {
309
+ } catch (e: Throwable) {
310
310
  promise?.reject("ERR_FLIR_ACOL", e)
311
311
  }
312
312
  }
@@ -318,7 +318,7 @@ class FlirModule(private val reactContext: ReactApplicationContext) : ReactConte
318
318
  FlirManager.setPalette(name)
319
319
  }
320
320
  promise?.resolve(true)
321
- } catch (e: Exception) {
321
+ } catch (e: Throwable) {
322
322
  promise?.reject("ERR_FLIR_PALETTE", e)
323
323
  }
324
324
  }
@@ -101,8 +101,25 @@ public class FlirSdkManager {
101
101
  if (isInitialized)
102
102
  return;
103
103
  try {
104
+ try {
105
+ // Explicitly load the native library to ensure JNI methods are linked
106
+ try {
107
+ System.loadLibrary("atlas_native");
108
+ Log.i(TAG, "Successfully loaded atlas_native library manually");
109
+ } catch (UnsatisfiedLinkError e) {
110
+ Log.w(TAG, "System.loadLibrary(atlas_native) failed (might be loaded by SDK): " + e.getMessage());
111
+ }
112
+
104
113
  ThermalSdkAndroid.init(context);
114
+
115
+ // Small delay to ensure JNI linkage is stable
116
+ try { Thread.sleep(100); } catch (InterruptedException ignored) {}
117
+
105
118
  isInitialized = true;
119
+ Log.i(TAG, "FLIR SDK initialized successfully. Arch: " + System.getProperty("os.arch"));
120
+ } catch (Throwable e) {
121
+ Log.e(TAG, "Critical failure during FLIR SDK initialization", e);
122
+ }
106
123
  Log.d(TAG, "SDK initialized");
107
124
  } catch (Exception e) {
108
125
  Log.e(TAG, "SDK init failed", e);
@@ -358,13 +375,29 @@ public class FlirSdkManager {
358
375
  if (paletteToApply != null) {
359
376
  try {
360
377
  Palette palette = null;
361
- // Try modern way if available (via image's palette manager)
362
- // Otherwise fallback to static PaletteManager
363
- List<Palette> sdkPalettes = PaletteManager.getDefaultPalettes();
364
- for (Palette p : sdkPalettes) {
365
- if (p.name.equalsIgnoreCase(paletteToApply)) {
366
- palette = p;
367
- break;
378
+ // 1. Try to get default palettes list safely
379
+ List<Palette> sdkPalettes = null;
380
+ try {
381
+ sdkPalettes = PaletteManager.getDefaultPalettes();
382
+ } catch (Throwable t) {
383
+ Log.e(TAG, "PaletteManager.getDefaultPalettes() failed (Linkage Error?)", t);
384
+ // Fallback: Try to use reflection for alternative package if suggested
385
+ try {
386
+ Class<?> altClazz = Class.forName("com.flir.thermalsdk.image.palettes.PaletteManager");
387
+ java.lang.reflect.Method method = altClazz.getMethod("getDefaultPalettes");
388
+ sdkPalettes = (List<Palette>) method.invoke(null);
389
+ Log.i(TAG, "Successfully retrieved palettes using alternative package");
390
+ } catch (Throwable t2) {
391
+ Log.e(TAG, "Alternative PaletteManager search also failed", t2);
392
+ }
393
+ }
394
+
395
+ if (sdkPalettes != null) {
396
+ for (Palette p : sdkPalettes) {
397
+ if (p.name.equalsIgnoreCase(paletteToApply)) {
398
+ palette = p;
399
+ break;
400
+ }
368
401
  }
369
402
  }
370
403
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ilabs-flir",
3
- "version": "2.3.4",
3
+ "version": "2.3.5",
4
4
  "description": "FLIR Thermal SDK for React Native - iOS & Android (bundled at compile time via postinstall)",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",