@mentra/bluetooth-sdk 3.2.0-dev.190 → 3.2.0-dev.193

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.
Files changed (61) hide show
  1. package/README.md +18 -0
  2. package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +1 -3
  3. package/android/src/main/java/com/mentra/bluetoothsdk/GeneratedReleaseMetadata.kt +5 -5
  4. package/android/src/main/java/com/mentra/bluetoothsdk/MentraLocalNetworkModule.kt +1 -1
  5. package/android/src/main/java/com/mentra/bluetoothsdk/debug/BleTraceLogger.kt +1 -1
  6. package/android/src/main/java/com/mentra/bluetoothsdk/otaserver/MentraOtaServerModule.kt +1 -1
  7. package/android/src/main/java/com/mentra/bluetoothsdk/photoreceiver/MentraPhotoReceiverModule.kt +1 -1
  8. package/android/src/main/java/com/mentra/bluetoothsdk/services/PhoneMic.kt +1 -1
  9. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Ar99.java +8 -8
  10. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/G1.kt +1 -1
  11. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Mach1.kt +2 -2
  12. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.kt +1 -1
  13. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLiveL2capChannel.kt +1 -1
  14. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraNex.kt +1 -1
  15. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/ar99/ota/Ar99OtaManager.java +2 -2
  16. package/android/src/main/java/com/mentra/bluetoothsdk/stt/STTTools.kt +2 -2
  17. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +1 -1
  18. package/android/src/main/java/com/mentra/bluetoothsdk/stt/VadGateSpeechPolicy.kt +1 -1
  19. package/android/src/main/java/com/mentra/bluetoothsdk/tts/TTSTools.kt +1 -1
  20. package/android/src/main/java/com/mentra/bluetoothsdk/utils/AES.java +7 -8
  21. package/android/src/main/java/com/mentra/bluetoothsdk/utils/BitmapJavaUtils.java +2 -2
  22. package/android/src/main/java/com/mentra/bluetoothsdk/utils/BlePhotoUploadService.java +34 -34
  23. package/android/src/main/java/com/mentra/bluetoothsdk/utils/G1Text.kt +1 -1
  24. package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleUploadService.java +4 -4
  25. package/android/src/main/java/com/mentra/bluetoothsdk/utils/K900ProtocolUtils.java +34 -34
  26. package/android/src/main/java/com/mentra/bluetoothsdk/utils/MessageChunkReassembler.java +10 -10
  27. package/android/src/main/java/com/mentra/bluetoothsdk/utils/MessageChunker.java +6 -6
  28. package/android/src/main/java/com/mentra/bluetoothsdk/utils/NativeLog.java +89 -0
  29. package/android/src/main/java/com/mentra/bluetoothsdk/utils/NexSGCUtils.kt +2 -2
  30. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/Ar99OpusPcmDecoder.java +10 -10
  31. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/ByteUtilAudioPlayer.java +7 -7
  32. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/Lc3Player.java +16 -16
  33. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PCMAudioPlayer.java +26 -26
  34. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PcmStreamPlayer.kt +1 -1
  35. package/android/src/test/java/com/mentra/bluetoothsdk/utils/NativeLogTest.kt +61 -0
  36. package/build/_private/BluetoothSdkModule.d.ts.map +1 -1
  37. package/build/_private/BluetoothSdkModule.js +3 -0
  38. package/build/_private/BluetoothSdkModule.js.map +1 -1
  39. package/build/_private/nativeLogConsole.d.ts +17 -0
  40. package/build/_private/nativeLogConsole.d.ts.map +1 -0
  41. package/build/_private/nativeLogConsole.js +16 -0
  42. package/build/_private/nativeLogConsole.js.map +1 -0
  43. package/build/generated/releaseMetadata.js +5 -5
  44. package/build/generated/releaseMetadata.js.map +1 -1
  45. package/ios/Source/BluetoothSdkDefaults.swift +1 -1
  46. package/ios/Source/Bridge.swift +3 -2
  47. package/ios/Source/GeneratedReleaseMetadata.swift +5 -5
  48. package/ios/Source/internal/BleTraceLogger.swift +3 -0
  49. package/ios/Source/sgcs/G1.swift +1 -1
  50. package/ios/Source/sgcs/MentraLive.swift +8 -8
  51. package/ios/Source/stt/STTTools.swift +1 -1
  52. package/ios/Source/utils/G1Text.swift +1 -1
  53. package/ios/Source/utils/JSCExperiment.swift +1 -2
  54. package/ios/Source/utils/MessageChunkReassembler.swift +6 -6
  55. package/ios/Source/utils/MessageChunker.swift +8 -8
  56. package/ios/Source/utils/Models.swift +1 -1
  57. package/ios/Tests/NativeLogTests.swift +34 -0
  58. package/package.json +1 -1
  59. package/src/_private/BluetoothSdkModule.ts +4 -0
  60. package/src/_private/nativeLogConsole.ts +24 -0
  61. package/src/generated/releaseMetadata.ts +5 -5
package/README.md CHANGED
@@ -14,6 +14,24 @@ The package includes:
14
14
 
15
15
  Use a development build or production native build. Expo Go cannot load this package because the SDK contains native code.
16
16
 
17
+ ## Diagnostics
18
+
19
+ After importing the SDK, native Android and iOS SDK diagnostics are forwarded
20
+ automatically to the JavaScript console, alongside your app's JS logs. Entries
21
+ are prefixed with `[native:android]` or `[native:ios]`. You do not need to add a
22
+ `log` listener just to print them; doing so would print them twice. The existing
23
+ `log` event remains available for custom consumers.
24
+
25
+ Credential-bearing messages are redacted before console output, and individual
26
+ messages are capped at 16,384 characters. The Mentra App's incident reports
27
+ capture this same combined console stream in the phone log attachment, subject
28
+ to its existing retention limits. Native diagnostics are also kept in the native
29
+ console. Forwarding covers SDK-owned diagnostics while the JS runtime is active,
30
+ not arbitrary OS or third-party native logs or logs from before subscription.
31
+
32
+ Rebuild the native app after updating the SDK to pick up both platforms' logging
33
+ changes. Adding this JS package alone cannot reroute logs in an older binary.
34
+
17
35
  ## Requirements
18
36
 
19
37
  - React Native `0.72+`.
@@ -114,9 +114,7 @@ public class Bridge private constructor() {
114
114
  /** Log a message and send it to JavaScript */
115
115
  @JvmStatic
116
116
  fun log(message: String) {
117
- val data = HashMap<String, Any>()
118
- data["message"] = message
119
- sendTypedMessage("log", data as Map<String, Any>)
117
+ com.mentra.bluetoothsdk.utils.NativeLog.i(TAG, message)
120
118
  }
121
119
 
122
120
  /** Report tar.bz2 extraction progress to JavaScript. */
@@ -3,9 +3,9 @@ package com.mentra.bluetoothsdk
3
3
  /** Generated by release CI. Do not edit in a release checkout. */
4
4
  internal object GeneratedReleaseMetadata {
5
5
  const val FAMILY_BASE_VERSION: String = "3.2.0"
6
- const val RELEASE_IDENTITY: String = "3.2.0-dev.190"
7
- const val RELEASE_SET_ID: String = "mentra-3.2.0-dev.190"
8
- const val SOURCE_COMMIT: String = "9cec54c1238d6d52a90e2edc84f0b99692b8a81a"
9
- const val OTA_MANIFEST_URL: String = "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-builds-v3.2.0/mentra-live-ota-3.2.0-dev.190.json"
10
- const val OTA_MANIFEST_SHA256: String = "00504171cce268dae2a22d9c4156cb7bac0b8a4397b35a3890ed561c619e5df0"
6
+ const val RELEASE_IDENTITY: String = "3.2.0-dev.193"
7
+ const val RELEASE_SET_ID: String = "mentra-3.2.0-dev.193"
8
+ const val SOURCE_COMMIT: String = "ca3b4bd4109d80253a3369cbf1ca8f9e86236fba"
9
+ const val OTA_MANIFEST_URL: String = "https://github.com/Mentra-Community/MentraOS/releases/download/mentra-builds-v3.2.0/mentra-live-ota-3.2.0-dev.193.json"
10
+ const val OTA_MANIFEST_SHA256: String = "b5201e1a9d926df220adfbf26cba934948d3f09ed81453c3600770a7618dd997"
11
11
  }
@@ -8,7 +8,7 @@ import android.net.wifi.WifiNetworkSpecifier
8
8
  import android.os.Handler
9
9
  import android.os.Looper
10
10
  import android.util.Base64
11
- import android.util.Log
11
+ import com.mentra.bluetoothsdk.utils.NativeLog as Log
12
12
  import expo.modules.kotlin.Promise
13
13
  import expo.modules.kotlin.modules.Module
14
14
  import expo.modules.kotlin.modules.ModuleDefinition
@@ -3,7 +3,7 @@ package com.mentra.bluetoothsdk.debug
3
3
  import android.content.Context
4
4
  import android.os.Build
5
5
  import android.os.Process
6
- import android.util.Log
6
+ import com.mentra.bluetoothsdk.utils.NativeLog as Log
7
7
  import org.json.JSONArray
8
8
  import org.json.JSONObject
9
9
 
@@ -1,6 +1,6 @@
1
1
  package com.mentra.bluetoothsdk.otaserver
2
2
 
3
- import android.util.Log
3
+ import com.mentra.bluetoothsdk.utils.NativeLog as Log
4
4
  import com.mentra.bluetoothsdk.net.LocalIpv4
5
5
  import expo.modules.kotlin.modules.Module
6
6
  import expo.modules.kotlin.modules.ModuleDefinition
@@ -2,7 +2,7 @@ package com.mentra.bluetoothsdk.photoreceiver
2
2
 
3
3
  import android.content.Context
4
4
  import android.net.Uri
5
- import android.util.Log
5
+ import com.mentra.bluetoothsdk.utils.NativeLog as Log
6
6
  import com.mentra.bluetoothsdk.debug.BleTraceLogger
7
7
  import com.mentra.bluetoothsdk.net.LocalIpv4
8
8
  import expo.modules.kotlin.exception.Exceptions
@@ -363,7 +363,7 @@ class PhoneMic private constructor(private val context: Context) {
363
363
  return success
364
364
  } catch (e: Exception) {
365
365
  Bridge.log("MIC: Phone internal recording failed: ${e.message}")
366
- e.printStackTrace()
366
+ com.mentra.bluetoothsdk.utils.NativeLog.e("PhoneMic", "Native exception", e)
367
367
  return false
368
368
  }
369
369
  }
@@ -17,7 +17,7 @@ import android.os.Build;
17
17
  import android.os.Handler;
18
18
  import android.os.Looper;
19
19
  import android.text.format.DateFormat;
20
- import android.util.Log;
20
+ import com.mentra.bluetoothsdk.utils.NativeLog;
21
21
  import com.google.protobuf.CodedInputStream;
22
22
  import com.google.protobuf.CodedOutputStream;
23
23
  import com.google.protobuf.WireFormat;
@@ -2144,19 +2144,19 @@ public class Ar99 extends SGCManager {
2144
2144
  return;
2145
2145
  }
2146
2146
  // Logcat: adb logcat -s Ar99Opus (DEBUG = per-chunk length; INFO = first chunk + hex)
2147
- Log.d(LOG_TAG_OPUS, "notify len=" + data.length);
2147
+ NativeLog.d(LOG_TAG_OPUS, "notify len=" + data.length);
2148
2148
  if (!opusLoggedFirstInSession) {
2149
2149
  opusLoggedFirstInSession = true;
2150
- Log.i(
2150
+ NativeLog.i(
2151
2151
  LOG_TAG_OPUS,
2152
2152
  "Opus BLE (first chunk) len=" + data.length + " head16=" + hexPrefixUpper(data, 16));
2153
2153
  }
2154
2154
  if (!getMicEnabled()) {
2155
- Log.w(LOG_TAG_OPUS, "received OPUS while glasses micEnabled=false; decoding anyway");
2155
+ NativeLog.w(LOG_TAG_OPUS, "received OPUS while glasses micEnabled=false; decoding anyway");
2156
2156
  }
2157
2157
  ensureOpusDecoder();
2158
2158
  if (opusPcmDecoder == null) {
2159
- Log.w(LOG_TAG_OPUS, "decoder unavailable; skipping PCM");
2159
+ NativeLog.w(LOG_TAG_OPUS, "decoder unavailable; skipping PCM");
2160
2160
  return;
2161
2161
  }
2162
2162
  opusPcmDecoder.submitBleNotify(data);
@@ -2187,11 +2187,11 @@ public class Ar99 extends SGCManager {
2187
2187
  }
2188
2188
 
2189
2189
  private void logSend(String message) {
2190
- Log.d(TAG, message);
2190
+ NativeLog.d(TAG, message);
2191
2191
  }
2192
2192
 
2193
2193
  private void logRecv(String message) {
2194
- Log.d(TAG, message);
2194
+ NativeLog.d(TAG, message);
2195
2195
  }
2196
2196
 
2197
2197
  private synchronized void ensureOpusDecoder() {
@@ -2211,7 +2211,7 @@ public class Ar99 extends SGCManager {
2211
2211
  @Override
2212
2212
  public void onNotifyProcessed(int rawLen, int pcmFrames, int pcmBytesOut) {
2213
2213
  if (pcmFrames > 0) {
2214
- Log.d(
2214
+ NativeLog.d(
2215
2215
  LOG_TAG_OPUS,
2216
2216
  "decoded PCM chunks="
2217
2217
  + pcmFrames
@@ -22,7 +22,7 @@ import android.graphics.Bitmap
22
22
  import android.graphics.BitmapFactory
23
23
  import android.os.Handler
24
24
  import android.os.Looper
25
- import android.util.Log
25
+ import com.mentra.bluetoothsdk.utils.NativeLog as Log
26
26
  import android.util.SparseArray
27
27
 
28
28
  import java.io.IOException
@@ -7,7 +7,7 @@ import android.graphics.BitmapFactory
7
7
  import android.graphics.drawable.Drawable
8
8
  import android.os.Handler
9
9
  import android.os.Looper
10
- import android.util.Log
10
+ import com.mentra.bluetoothsdk.utils.NativeLog as Log
11
11
 
12
12
  import androidx.lifecycle.LiveData
13
13
  import androidx.lifecycle.Observer
@@ -1128,7 +1128,7 @@ class Mach1 : SGCManager() {
1128
1128
  override fun onBitmapFailed(e: Exception?, errorDrawable: Drawable?) {
1129
1129
  // Handle the error
1130
1130
  Log.d(TAG, "Bitmap failed")
1131
- e!!.printStackTrace()
1131
+ com.mentra.bluetoothsdk.utils.NativeLog.e("Mach1", "Native exception", e!!)
1132
1132
  }
1133
1133
 
1134
1134
  override fun onPrepareLoad(placeHolderDrawable: Drawable?) {
@@ -29,7 +29,7 @@ import android.os.Handler
29
29
  import android.os.HandlerThread
30
30
  import android.os.Looper
31
31
  import android.os.SystemClock
32
- import android.util.Log
32
+ import com.mentra.bluetoothsdk.utils.NativeLog as Log
33
33
  import androidx.core.app.ActivityCompat
34
34
  import com.mentra.bluetoothsdk.BluetoothSdkDefaults
35
35
  import com.mentra.bluetoothsdk.Bridge
@@ -3,7 +3,7 @@ package com.mentra.bluetoothsdk.sgcs
3
3
  import android.bluetooth.BluetoothDevice
4
4
  import android.bluetooth.BluetoothSocket
5
5
  import android.os.Build
6
- import android.util.Log
6
+ import com.mentra.bluetoothsdk.utils.NativeLog as Log
7
7
  import androidx.annotation.RequiresApi
8
8
  import com.mentra.bluetoothsdk.Bridge
9
9
  import com.mentra.bluetoothsdk.utils.K900ProtocolUtils
@@ -27,7 +27,7 @@ import android.bluetooth.le.ScanSettings
27
27
  import android.os.Message
28
28
  import android.os.Handler
29
29
  import android.os.Looper
30
- import android.util.Log
30
+ import com.mentra.bluetoothsdk.utils.NativeLog as Log
31
31
  import android.content.Context
32
32
 
33
33
  import mentraos.ble.MentraosBle.GlassesToPhone
@@ -3,7 +3,7 @@ package com.mentra.bluetoothsdk.sgcs.ar99.ota;
3
3
  import android.bluetooth.BluetoothGatt;
4
4
  import android.os.Handler;
5
5
  import android.os.Looper;
6
- import android.util.Log;
6
+ import com.mentra.bluetoothsdk.utils.NativeLog;
7
7
  import java.io.ByteArrayOutputStream;
8
8
  import java.io.File;
9
9
  import java.io.FileInputStream;
@@ -85,7 +85,7 @@ public class Ar99OtaManager {
85
85
 
86
86
  public synchronized boolean startOTA(byte[] data) {
87
87
  if (isOTAInProgress()) {
88
- Log.w(TAG, "OTA is already in progress");
88
+ NativeLog.w(TAG, "OTA is already in progress");
89
89
  return false;
90
90
  }
91
91
  if (data == null || data.length == 0) {
@@ -280,7 +280,7 @@ object STTTools {
280
280
  Bridge.log(
281
281
  "ERROR extracting entry ${entry?.name}: ${e.javaClass.simpleName}: ${e.message}"
282
282
  )
283
- e.printStackTrace()
283
+ com.mentra.bluetoothsdk.utils.NativeLog.e("STTTools", "Native exception", e)
284
284
  throw e
285
285
  }
286
286
  }
@@ -348,7 +348,7 @@ object STTTools {
348
348
  return true
349
349
  } catch (e: Exception) {
350
350
  Bridge.log("EXTRACTION_ERROR: ${e.javaClass.simpleName}: ${e.message}")
351
- e.printStackTrace()
351
+ com.mentra.bluetoothsdk.utils.NativeLog.e("STTTools", "Native exception", e)
352
352
  return false
353
353
  }
354
354
  }
@@ -4,7 +4,7 @@ import android.content.Context
4
4
  import android.content.SharedPreferences
5
5
  import android.os.Handler
6
6
  import android.os.Looper
7
- import android.util.Log
7
+ import com.mentra.bluetoothsdk.utils.NativeLog as Log
8
8
  import com.k2fsa.sherpa.onnx.*
9
9
  import com.mentra.bluetoothsdk.Bridge
10
10
  import java.io.File
@@ -1,7 +1,7 @@
1
1
  package com.mentra.bluetoothsdk.stt
2
2
 
3
3
  import android.content.Context
4
- import android.util.Log
4
+ import com.mentra.bluetoothsdk.utils.NativeLog as Log
5
5
  import com.konovalov.vad.silero.Vad
6
6
  import com.konovalov.vad.silero.VadSilero
7
7
  import com.konovalov.vad.silero.config.FrameSize
@@ -164,7 +164,7 @@ object TTSTools {
164
164
  saved
165
165
  } catch (e: Exception) {
166
166
  Bridge.log("TTS_ERROR: ${e.javaClass.simpleName}: ${e.message}")
167
- e.printStackTrace()
167
+ com.mentra.bluetoothsdk.utils.NativeLog.e("TTSTools", "Native exception", e)
168
168
  false
169
169
  } finally {
170
170
  scheduleIdleTeardownLocked()
@@ -10,7 +10,7 @@ import java.util.Arrays;
10
10
  import javax.crypto.Cipher;
11
11
  import javax.crypto.spec.SecretKeySpec;
12
12
 
13
- import android.util.Log;
13
+ import com.mentra.bluetoothsdk.utils.NativeLog;
14
14
 
15
15
  public class AES {
16
16
  private static final String TAG = "WearableIntelligenceSystem_AES";
@@ -29,10 +29,10 @@ public class AES {
29
29
  secretKey = new SecretKeySpec(key, "AES");
30
30
  }
31
31
  catch (NoSuchAlgorithmException e) {
32
- e.printStackTrace();
32
+ com.mentra.bluetoothsdk.utils.NativeLog.e("AES", "Native exception", e);
33
33
  }
34
34
  catch (UnsupportedEncodingException e) {
35
- e.printStackTrace();
35
+ com.mentra.bluetoothsdk.utils.NativeLog.e("AES", "Native exception", e);
36
36
  }
37
37
  }
38
38
 
@@ -47,7 +47,7 @@ public class AES {
47
47
  }
48
48
  catch (Exception e)
49
49
  {
50
- Log.d(TAG, "Error while encrypting: " + e.toString());
50
+ NativeLog.d(TAG, "Error while encrypting: " + e.toString());
51
51
  }
52
52
  return null;
53
53
  }
@@ -64,7 +64,7 @@ public class AES {
64
64
  }
65
65
  catch (Exception e)
66
66
  {
67
- Log.d(TAG, "Error while encrypting: " + e.toString());
67
+ NativeLog.d(TAG, "Error while encrypting: " + e.toString());
68
68
  }
69
69
  return null;
70
70
  }
@@ -74,7 +74,6 @@ public class AES {
74
74
  {
75
75
  try
76
76
  {
77
- Log.d(TAG, "Secret key is: " + secret);
78
77
  setKey(secret);
79
78
  Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7PADDING");
80
79
  cipher.init(Cipher.DECRYPT_MODE, secretKey);
@@ -82,7 +81,7 @@ public class AES {
82
81
  }
83
82
  catch (Exception e)
84
83
  {
85
- Log.d(TAG, "Error while decrypting: " + e.toString());
84
+ NativeLog.d(TAG, "Error while decrypting: " + e.toString());
86
85
  }
87
86
  return null;
88
87
  }
@@ -99,7 +98,7 @@ public class AES {
99
98
  }
100
99
  catch (Exception e)
101
100
  {
102
- Log.d(TAG, "Error while decrypting: " + e.toString());
101
+ NativeLog.d(TAG, "Error while decrypting: " + e.toString());
103
102
  }
104
103
  return null;
105
104
  }
@@ -3,7 +3,7 @@ package com.mentra.bluetoothsdk.utils;
3
3
  import java.io.File;
4
4
  import android.graphics.Bitmap;
5
5
  import android.graphics.BitmapFactory;
6
- import android.util.Log;
6
+ import com.mentra.bluetoothsdk.utils.NativeLog;
7
7
  import android.graphics.Bitmap;
8
8
  import java.io.ByteArrayOutputStream;
9
9
  import java.io.IOException;
@@ -18,7 +18,7 @@ public class BitmapJavaUtils {
18
18
  Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
19
19
  return myBitmap;
20
20
  } else {
21
- Log.d(TAG, "Image doesn't exist");
21
+ NativeLog.d(TAG, "Image doesn't exist");
22
22
  return null;
23
23
  }
24
24
  }
@@ -3,7 +3,7 @@ package com.mentra.bluetoothsdk.utils;
3
3
  import android.graphics.Bitmap;
4
4
  import android.graphics.BitmapFactory;
5
5
  import android.os.Build;
6
- import android.util.Log;
6
+ import com.mentra.bluetoothsdk.utils.NativeLog;
7
7
 
8
8
  import androidx.annotation.Nullable;
9
9
  import androidx.annotation.VisibleForTesting;
@@ -60,20 +60,20 @@ public class BlePhotoUploadService {
60
60
  UploadCallback callback) {
61
61
  new Thread(() -> {
62
62
  try {
63
- Log.d(TAG, "Processing BLE photo for upload. Image size: " + imageData.length + " bytes");
63
+ NativeLog.d(TAG, "Processing BLE photo for upload. Image size: " + imageData.length + " bytes");
64
64
 
65
65
  byte[] jpegData = convertToJpegPreservingExif(imageData);
66
- Log.d(TAG, "Converted to JPEG for upload. Size: " + jpegData.length + " bytes");
66
+ NativeLog.d(TAG, "Converted to JPEG for upload. Size: " + jpegData.length + " bytes");
67
67
 
68
68
  // 3. Upload to webhook
69
69
  String responseBody =
70
70
  uploadToWebhook(jpegData, imageData.length, requestId, webhookUrl, authToken);
71
71
 
72
- Log.d(TAG, "Photo uploaded successfully for requestId: " + requestId);
72
+ NativeLog.d(TAG, "Photo uploaded successfully for requestId: " + requestId);
73
73
  callback.onSuccess(requestId, responseBody);
74
74
 
75
75
  } catch (Exception e) {
76
- Log.e(TAG, "Error processing BLE photo for requestId: " + requestId, e);
76
+ NativeLog.e(TAG, "Error processing BLE photo for requestId: " + requestId, e);
77
77
  callback.onError(requestId, e.getMessage());
78
78
  }
79
79
  }).start();
@@ -86,7 +86,7 @@ public class BlePhotoUploadService {
86
86
  static byte[] convertToJpegPreservingExif(byte[] imageData) throws Exception {
87
87
  long conversionStartMs = System.currentTimeMillis();
88
88
  if (isJpeg(imageData)) {
89
- Log.d(
89
+ NativeLog.d(
90
90
  TAG,
91
91
  "BLE relay pass-through: input already JPEG ("
92
92
  + imageData.length
@@ -114,7 +114,7 @@ public class BlePhotoUploadService {
114
114
  throw new Exception("Failed to decode image data");
115
115
  }
116
116
 
117
- Log.d(
117
+ NativeLog.d(
118
118
  TAG,
119
119
  "AVIF decode complete: "
120
120
  + bitmap.getWidth()
@@ -131,7 +131,7 @@ public class BlePhotoUploadService {
131
131
  bitmap.recycle();
132
132
  }
133
133
  long encodeDurationMs = System.currentTimeMillis() - encodeStartMs;
134
- Log.d(
134
+ NativeLog.d(
135
135
  TAG,
136
136
  "AVIF->JPEG encode complete: quality="
137
137
  + AVIF_TO_JPEG_QUALITY
@@ -146,13 +146,13 @@ public class BlePhotoUploadService {
146
146
  // already-decoded photo. Log and upload the plain JPEG instead.
147
147
  try {
148
148
  writeImuJsonToJpeg(outputFile.getAbsolutePath(), imuJson);
149
- Log.d(TAG, "Re-attached IMU EXIF UserComment on output JPEG (" + imuJson.length() + " chars)");
149
+ NativeLog.d(TAG, "Re-attached IMU EXIF UserComment on output JPEG (" + imuJson.length() + " chars)");
150
150
  } catch (Exception e) {
151
- Log.w(TAG, "Failed to attach IMU EXIF; uploading photo without it", e);
151
+ NativeLog.w(TAG, "Failed to attach IMU EXIF; uploading photo without it", e);
152
152
  }
153
153
  } else {
154
154
  boolean rawHasExif = containsExifMarkerInBytes(imageData);
155
- Log.w(
155
+ NativeLog.w(
156
156
  TAG,
157
157
  "No IMU from ExifInterface on "
158
158
  + inputFile.getName()
@@ -163,14 +163,14 @@ public class BlePhotoUploadService {
163
163
  + "). If rawHasExifMarker=true, EXIF may be present but unreadable via"
164
164
  + " ExifInterface on this container.");
165
165
  }
166
- Log.d(
166
+ NativeLog.d(
167
167
  TAG,
168
168
  "AVIF metadata handling complete in "
169
169
  + (System.currentTimeMillis() - metadataStartMs)
170
170
  + "ms");
171
171
 
172
172
  byte[] jpegData = java.nio.file.Files.readAllBytes(outputFile.toPath());
173
- Log.d(
173
+ NativeLog.d(
174
174
  TAG,
175
175
  "Phone image conversion complete: AVIF "
176
176
  + imageData.length
@@ -204,7 +204,7 @@ public class BlePhotoUploadService {
204
204
  if (containsExifMarkerInBytes(imageData)) {
205
205
  String fromTiff = HeifExifTagReader.readImuJson(imageData);
206
206
  if (fromTiff != null && !fromTiff.isEmpty()) {
207
- Log.d(
207
+ NativeLog.d(
208
208
  TAG,
209
209
  "Read IMU UserComment via TIFF scan ("
210
210
  + fromTiff.length()
@@ -223,7 +223,7 @@ public class BlePhotoUploadService {
223
223
  ExifInterface exif = new ExifInterface(imagePath);
224
224
  String userComment = exif.getAttribute(ExifInterface.TAG_USER_COMMENT);
225
225
  String imageDescription = exif.getAttribute(ExifInterface.TAG_IMAGE_DESCRIPTION);
226
- Log.d(
226
+ NativeLog.d(
227
227
  TAG,
228
228
  "ExifInterface on "
229
229
  + imagePath
@@ -236,13 +236,13 @@ public class BlePhotoUploadService {
236
236
  }
237
237
  return imageDescription;
238
238
  } catch (IOException e) {
239
- Log.w(TAG, "Could not read EXIF from BLE image: " + imagePath, e);
239
+ NativeLog.w(TAG, "Could not read EXIF from BLE image: " + imagePath, e);
240
240
  return null;
241
241
  }
242
242
  }
243
243
 
244
244
  private static void logIncomingImageDiagnostics(byte[] imageData, String tempPath) {
245
- Log.d(
245
+ NativeLog.d(
246
246
  TAG,
247
247
  "BLE image diagnostics: size="
248
248
  + imageData.length
@@ -336,12 +336,12 @@ public class BlePhotoUploadService {
336
336
  && imageData[10] == 'i' && imageData[11] == 'f';
337
337
 
338
338
  if (isAvif) {
339
- Log.d(TAG, "Detected AVIF image format");
339
+ NativeLog.d(TAG, "Detected AVIF image format");
340
340
  byte[] strippedBytes = imageData;
341
341
  if (containsExifMarkerInBytes(imageData)) {
342
342
  try {
343
343
  strippedBytes = AvifExifStripper.stripForDecode(imageData);
344
- Log.d(
344
+ NativeLog.d(
345
345
  TAG,
346
346
  "Stripped Exif metadata item for decode: "
347
347
  + imageData.length
@@ -349,21 +349,21 @@ public class BlePhotoUploadService {
349
349
  + strippedBytes.length
350
350
  + " bytes");
351
351
  } catch (Exception e) {
352
- Log.w(TAG, "stripForDecode failed, using raw AVIF: " + e.getMessage());
352
+ NativeLog.w(TAG, "stripForDecode failed, using raw AVIF: " + e.getMessage());
353
353
  strippedBytes = imageData;
354
354
  }
355
355
  }
356
356
  Bitmap bmp = decodeAvifBytes(strippedBytes);
357
357
  if (bmp == null && strippedBytes != imageData) {
358
- Log.w(TAG, "Stripped AVIF decode failed; retrying original BLE bytes");
358
+ NativeLog.w(TAG, "Stripped AVIF decode failed; retrying original BLE bytes");
359
359
  bmp = decodeAvifBytes(imageData);
360
360
  }
361
361
  return bmp;
362
362
  }
363
- Log.d(TAG, "Detected JPEG image format");
363
+ NativeLog.d(TAG, "Detected JPEG image format");
364
364
  return BitmapFactory.decodeByteArray(imageData, 0, imageData.length);
365
365
  } catch (Exception e) {
366
- Log.e(TAG, "Failed to decode image", e);
366
+ NativeLog.e(TAG, "Failed to decode image", e);
367
367
  return null;
368
368
  }
369
369
  }
@@ -376,12 +376,12 @@ public class BlePhotoUploadService {
376
376
  return bmp;
377
377
  }
378
378
  } catch (Exception | LinkageError e) {
379
- Log.w(TAG, "HeifCoder AVIF decode unavailable/failed, trying BitmapFactory: " + e.getMessage());
379
+ NativeLog.w(TAG, "HeifCoder AVIF decode unavailable/failed, trying BitmapFactory: " + e.getMessage());
380
380
  }
381
381
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
382
382
  return BitmapFactory.decodeByteArray(avifBytes, 0, avifBytes.length);
383
383
  }
384
- Log.e(TAG, "AVIF decoding requires Android 12+ (API 31+). Current API: " + Build.VERSION.SDK_INT);
384
+ NativeLog.e(TAG, "AVIF decoding requires Android 12+ (API 31+). Current API: " + Build.VERSION.SDK_INT);
385
385
  return null;
386
386
  }
387
387
 
@@ -402,7 +402,7 @@ public class BlePhotoUploadService {
402
402
  .append(" rate=").append(samplingRateHz).append("Hz")
403
403
  .append(" duration=").append(durationMs).append("ms")
404
404
  .append(" startNs=").append(startTimeNs);
405
- Log.d(TAG, sb.toString());
405
+ NativeLog.d(TAG, sb.toString());
406
406
 
407
407
  if (samples != null && samples.length() > 0) {
408
408
  // Log first and last sample: [timestampMs, ax, ay, az, gx, gy, gz]
@@ -412,14 +412,14 @@ public class BlePhotoUploadService {
412
412
  }
413
413
  }
414
414
  } catch (Exception e) {
415
- Log.w(TAG, "logImuData: failed to parse IMU JSON: " + e.getMessage());
415
+ NativeLog.w(TAG, "logImuData: failed to parse IMU JSON: " + e.getMessage());
416
416
  }
417
417
  }
418
418
 
419
419
  private static void logSample(String label, @Nullable JSONArray sample) {
420
420
  if (sample == null || sample.length() < 7) return;
421
421
  try {
422
- Log.d(
422
+ NativeLog.d(
423
423
  TAG,
424
424
  "IMU " + label + " sample:"
425
425
  + " t=" + sample.optLong(0) + "ms"
@@ -430,7 +430,7 @@ public class BlePhotoUploadService {
430
430
  + ", " + String.format("%.3f", sample.optDouble(5))
431
431
  + ", " + String.format("%.3f", sample.optDouble(6)) + "]rad/s");
432
432
  } catch (Exception e) {
433
- Log.w(TAG, "logSample: " + e.getMessage());
433
+ NativeLog.w(TAG, "logSample: " + e.getMessage());
434
434
  }
435
435
  }
436
436
 
@@ -467,9 +467,9 @@ public class BlePhotoUploadService {
467
467
  Request request = requestBuilder.build();
468
468
 
469
469
  if (!effectiveWebhookUrl.equals(webhookUrl)) {
470
- Log.d(TAG, "Uploading BLE fallback photo to local receiver via loopback: " + effectiveWebhookUrl);
470
+ NativeLog.d(TAG, "Uploading BLE fallback photo to local receiver via loopback: " + effectiveWebhookUrl);
471
471
  } else {
472
- Log.d(TAG, "Uploading photo to webhook: " + webhookUrl);
472
+ NativeLog.d(TAG, "Uploading photo to webhook: " + webhookUrl);
473
473
  }
474
474
  long startMs = System.currentTimeMillis();
475
475
  traceRelayUploadStart(requestId, effectiveWebhookUrl, webhookUrl, authToken, sourceImageBytes, jpegData.length, startMs);
@@ -504,7 +504,7 @@ public class BlePhotoUploadService {
504
504
  true,
505
505
  "uploaded");
506
506
  responseTraced = true;
507
- Log.d(TAG, "Upload successful. Response code: " + response.code());
507
+ NativeLog.d(TAG, "Upload successful. Response code: " + response.code());
508
508
  return responseBody;
509
509
  } catch (IOException e) {
510
510
  if (!responseTraced) {
@@ -665,11 +665,11 @@ public class BlePhotoUploadService {
665
665
  UploadCallback callback) {
666
666
  new Thread(() -> {
667
667
  try {
668
- Log.d(TAG, "Uploading pre-decoded JPEG. Size: " + jpegData.length + " bytes");
668
+ NativeLog.d(TAG, "Uploading pre-decoded JPEG. Size: " + jpegData.length + " bytes");
669
669
  String responseBody = uploadToWebhook(jpegData, requestId, webhookUrl, authToken);
670
670
  callback.onSuccess(requestId, responseBody);
671
671
  } catch (Exception e) {
672
- Log.e(TAG, "Error uploading JPEG photo", e);
672
+ NativeLog.e(TAG, "Error uploading JPEG photo", e);
673
673
  callback.onError(requestId, e.getMessage());
674
674
  }
675
675
  }).start();
@@ -423,7 +423,7 @@ class G1FontLoaderKt {
423
423
  fontMap[glyph.char] = FontGlyph(glyph.width, glyph.height)
424
424
  }
425
425
 
426
- println("Hardcoded font data loaded successfully! ${fontMap.size} glyphs mapped.")
426
+ com.mentra.bluetoothsdk.Bridge.log("Hardcoded font data loaded successfully! ${fontMap.size} glyphs mapped.")
427
427
  }
428
428
 
429
429
  fun getGlyph(character: Char): FontGlyph {