@mentra/bluetooth-sdk 3.3.0-dev.919 → 3.3.0-dev.921

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.
@@ -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.3.0"
6
- const val RELEASE_IDENTITY: String = "3.3.0-dev.919"
7
- const val RELEASE_SET_ID: String = "mentra-3.3.0-dev.919"
8
- const val SOURCE_COMMIT: String = "3697e9557c96587e96d31e1f3fd2e4a15080b618"
9
- const val OTA_MANIFEST_URL: String = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-dev.919.json"
10
- const val OTA_MANIFEST_SHA256: String = "f3bb4c1c2c9ee6dbcfdb3e0353bd9b7c08eea13d9aebda3e772b3a6c0d573eaf"
6
+ const val RELEASE_IDENTITY: String = "3.3.0-dev.921"
7
+ const val RELEASE_SET_ID: String = "mentra-3.3.0-dev.921"
8
+ const val SOURCE_COMMIT: String = "cfa5334f4b5e9b7c6f48d900d4fe0bafe34b1ddc"
9
+ const val OTA_MANIFEST_URL: String = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-dev.921.json"
10
+ const val OTA_MANIFEST_SHA256: String = "a0387d2e72295e7de7fa462763d321e7dcaf5c0e9b571ecc417e5c738ed2a517"
11
11
  }
@@ -29,6 +29,10 @@ internal class ClassicAudioConnectionTracker(
29
29
  val connected: Boolean
30
30
  get() = connectedProfiles.isNotEmpty()
31
31
 
32
+ /** BLE may already be gone when the user explicitly disconnects Classic audio. */
33
+ @Synchronized
34
+ fun targetForDisconnect(): String? = targetAddress
35
+
32
36
  @Synchronized
33
37
  fun setTarget(address: String) {
34
38
  val normalizedAddress = address.normalizedBluetoothAddress()
@@ -7987,7 +7987,11 @@ class MentraLive : SGCManager() {
7987
7987
 
7988
7988
  // Tear down Classic (A2DP/HFP) before GATT close. Closing only the proxy left the
7989
7989
  // phone's system Bluetooth UI showing Mentra Live still connected.
7990
- val classicDevice = connectedDevice
7990
+ // BLE loss clears connectedDevice while the OS audio profiles can remain connected.
7991
+ // Use this session's existing Classic target before resetting the tracker below.
7992
+ val classicDevice = connectedDevice ?: classicAudioConnectionTracker.targetForDisconnect()?.let {
7993
+ bluetoothAdapter?.getRemoteDevice(it)
7994
+ }
7991
7995
  disconnectClassicProfiles(classicDevice)
7992
7996
  closeA2dpProxy()
7993
7997
  classicAudioConnectionTracker.reset()
@@ -0,0 +1,133 @@
1
+ package com.mentra.bluetoothsdk.sgcs
2
+
3
+ import android.bluetooth.BluetoothA2dp
4
+ import android.bluetooth.BluetoothAdapter
5
+ import android.bluetooth.BluetoothDevice
6
+ import android.bluetooth.BluetoothGatt
7
+ import android.bluetooth.BluetoothHeadset
8
+ import android.bluetooth.BluetoothProfile
9
+ import android.os.Looper
10
+ import androidx.test.core.app.ApplicationProvider
11
+ import com.mentra.bluetoothsdk.Bridge
12
+ import com.mentra.bluetoothsdk.DeviceStore
13
+ import java.time.Duration
14
+ import org.junit.Assert.assertEquals
15
+ import org.junit.Assert.assertNull
16
+ import org.junit.Before
17
+ import org.junit.Test
18
+ import org.junit.runner.RunWith
19
+ import org.robolectric.RobolectricTestRunner
20
+ import org.robolectric.Shadows.shadowOf
21
+ import org.robolectric.annotation.Config
22
+ import org.robolectric.annotation.Implementation
23
+ import org.robolectric.annotation.Implements
24
+ import org.robolectric.annotation.LooperMode
25
+ import org.robolectric.shadow.api.Shadow
26
+ import org.robolectric.shadows.ShadowBluetoothA2dp
27
+ import org.robolectric.shadows.ShadowBluetoothHeadset
28
+ import org.robolectric.util.ReflectionHelpers
29
+
30
+ @RunWith(RobolectricTestRunner::class)
31
+ @Config(sdk = [33], shadows = [G1PairingTest.ShadowLc3Cpp::class,
32
+ MentraLiveClassicDisconnectTest.RecordingA2dp::class,
33
+ MentraLiveClassicDisconnectTest.RecordingHeadset::class],
34
+ instrumentedPackages = ["com.mentra.lc3Lib"])
35
+ @LooperMode(LooperMode.Mode.PAUSED)
36
+ class MentraLiveClassicDisconnectTest {
37
+ private val adapter = BluetoothAdapter.getDefaultAdapter()
38
+ private val target = adapter.getRemoteDevice("AA:BB:CC:DD:EE:FF")
39
+ private val other = adapter.getRemoteDevice("11:22:33:44:55:66")
40
+ private val a2dp = Shadow.newInstanceOf(BluetoothA2dp::class.java)
41
+ private val headset = Shadow.newInstanceOf(BluetoothHeadset::class.java)
42
+ private val audio: RecordingA2dp = Shadow.extract(a2dp)
43
+ private val handsfree: RecordingHeadset = Shadow.extract(headset)
44
+
45
+ @Before fun setup() {
46
+ Bridge.initialize(ApplicationProvider.getApplicationContext())
47
+ shadowOf(adapter).setState(BluetoothAdapter.STATE_ON)
48
+ shadowOf(target).setName("MENTRA_LIVE_TEST")
49
+ shadowOf(target).setBondState(BluetoothDevice.BOND_BONDED)
50
+ DeviceStore.set("bluetooth", "device_name", "MENTRA_LIVE_TEST")
51
+ DeviceStore.set("bluetooth", "device_address", target.address)
52
+ DeviceStore.set("bluetooth", "pending_device_name", "MENTRA_LIVE_TEST")
53
+ DeviceStore.set("bluetooth", "pending_device_address", target.address)
54
+ }
55
+
56
+ @Test fun `BLE loss followed by explicit disconnect releases both Classic profiles and keeps bond`() {
57
+ assertDisconnect(dropBle = true)
58
+ }
59
+
60
+ @Test fun `explicit disconnect with BLE still connected releases both Classic profiles`() {
61
+ assertDisconnect(dropBle = false)
62
+ }
63
+
64
+ private fun assertDisconnect(dropBle: Boolean) {
65
+ val live = MentraLive()
66
+ try {
67
+ live.connectById("MENTRA_LIVE_TEST")
68
+ shadowOf(Looper.getMainLooper()).idle()
69
+ shadowOf(target).simulateGattConnectionChange(BluetoothGatt.GATT_SUCCESS, BluetoothProfile.STATE_CONNECTED)
70
+ shadowOf(Looper.getMainLooper()).idle()
71
+ if (dropBle) {
72
+ shadowOf(target).simulateGattConnectionChange(BluetoothGatt.GATT_SUCCESS, BluetoothProfile.STATE_DISCONNECTED)
73
+ shadowOf(Looper.getMainLooper()).idle()
74
+ assertNull(ReflectionHelpers.getField<BluetoothDevice?>(live, "connectedDevice"))
75
+ }
76
+ installConnectedProfiles()
77
+ live.disconnect()
78
+ shadowOf(Looper.getMainLooper()).idle()
79
+ assertEquals(listOf(target), audio.disconnected)
80
+ assertEquals(listOf(target), handsfree.disconnected)
81
+ assertEquals(BluetoothProfile.STATE_CONNECTED, a2dp.getConnectionState(other))
82
+ assertEquals(BluetoothProfile.STATE_CONNECTED, headset.getConnectionState(other))
83
+ assertEquals(BluetoothDevice.BOND_BONDED, target.bondState)
84
+ } finally {
85
+ live.destroy()
86
+ shadowOf(Looper.getMainLooper()).idleFor(Duration.ofSeconds(2))
87
+ }
88
+ }
89
+
90
+ @Test fun `a manager with no connection session does not disconnect an unrelated bonded device`() {
91
+ val live = MentraLive()
92
+ try {
93
+ installConnectedProfiles()
94
+ live.disconnect()
95
+ shadowOf(Looper.getMainLooper()).idle()
96
+ assertEquals(emptyList<BluetoothDevice>(), audio.disconnected)
97
+ assertEquals(emptyList<BluetoothDevice>(), handsfree.disconnected)
98
+ } finally {
99
+ live.destroy()
100
+ shadowOf(Looper.getMainLooper()).idleFor(Duration.ofSeconds(2))
101
+ }
102
+ }
103
+
104
+ private fun installConnectedProfiles() {
105
+ for (device in listOf(target, other)) {
106
+ audio.addDevice(device, BluetoothProfile.STATE_CONNECTED)
107
+ handsfree.addDevice(device, BluetoothProfile.STATE_CONNECTED)
108
+ }
109
+ shadowOf(adapter).setProfileProxy(BluetoothProfile.A2DP, a2dp)
110
+ shadowOf(adapter).setProfileProxy(BluetoothProfile.HEADSET, headset)
111
+ }
112
+
113
+ // The real MentraLive lifecycle runs; only Android's audio profile services are simulated.
114
+ @Implements(BluetoothA2dp::class)
115
+ class RecordingA2dp : ShadowBluetoothA2dp() {
116
+ val disconnected = mutableListOf<BluetoothDevice>()
117
+ @Implementation fun disconnect(device: BluetoothDevice): Boolean {
118
+ disconnected.add(device)
119
+ removeDevice(device)
120
+ return true
121
+ }
122
+ }
123
+
124
+ @Implements(BluetoothHeadset::class)
125
+ class RecordingHeadset : ShadowBluetoothHeadset() {
126
+ val disconnected = mutableListOf<BluetoothDevice>()
127
+ @Implementation fun disconnect(device: BluetoothDevice): Boolean {
128
+ disconnected.add(device)
129
+ removeDevice(device)
130
+ return true
131
+ }
132
+ }
133
+ }
@@ -1,10 +1,10 @@
1
1
  export const BLUETOOTH_SDK_RELEASE_METADATA = Object.freeze({
2
2
  "schemaVersion": 1,
3
3
  "familyBaseVersion": "3.3.0",
4
- "releaseIdentity": "3.3.0-dev.919",
5
- "releaseSetId": "mentra-3.3.0-dev.919",
6
- "sourceCommit": "3697e9557c96587e96d31e1f3fd2e4a15080b618",
7
- "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-dev.919.json",
8
- "otaManifestSha256": "f3bb4c1c2c9ee6dbcfdb3e0353bd9b7c08eea13d9aebda3e772b3a6c0d573eaf"
4
+ "releaseIdentity": "3.3.0-dev.921",
5
+ "releaseSetId": "mentra-3.3.0-dev.921",
6
+ "sourceCommit": "cfa5334f4b5e9b7c6f48d900d4fe0bafe34b1ddc",
7
+ "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-dev.921.json",
8
+ "otaManifestSha256": "a0387d2e72295e7de7fa462763d321e7dcaf5c0e9b571ecc417e5c738ed2a517"
9
9
  });
10
10
  //# sourceMappingURL=releaseMetadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"releaseMetadata.js","sourceRoot":"","sources":["../../src/generated/releaseMetadata.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,8BAA8B,GAA0C,MAAM,CAAC,MAAM,CAAC;IACjG,eAAe,EAAE,CAAC;IAClB,mBAAmB,EAAE,OAAO;IAC5B,iBAAiB,EAAE,eAAe;IAClC,cAAc,EAAE,sBAAsB;IACtC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,iIAAiI;IACnJ,mBAAmB,EAAE,kEAAkE;CACxF,CAAC,CAAA","sourcesContent":["/** Generated by release CI. Do not edit in a release checkout. */\nexport interface BluetoothSdkReleaseMetadata {\n schemaVersion: 1\n familyBaseVersion: string | null\n releaseIdentity: string | null\n releaseSetId: string | null\n sourceCommit: string | null\n otaManifestUrl: string | null\n otaManifestSha256: string | null\n}\n\nexport const BLUETOOTH_SDK_RELEASE_METADATA: Readonly<BluetoothSdkReleaseMetadata> = Object.freeze({\n \"schemaVersion\": 1,\n \"familyBaseVersion\": \"3.3.0\",\n \"releaseIdentity\": \"3.3.0-dev.919\",\n \"releaseSetId\": \"mentra-3.3.0-dev.919\",\n \"sourceCommit\": \"3697e9557c96587e96d31e1f3fd2e4a15080b618\",\n \"otaManifestUrl\": \"https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-dev.919.json\",\n \"otaManifestSha256\": \"f3bb4c1c2c9ee6dbcfdb3e0353bd9b7c08eea13d9aebda3e772b3a6c0d573eaf\"\n})\n"]}
1
+ {"version":3,"file":"releaseMetadata.js","sourceRoot":"","sources":["../../src/generated/releaseMetadata.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,8BAA8B,GAA0C,MAAM,CAAC,MAAM,CAAC;IACjG,eAAe,EAAE,CAAC;IAClB,mBAAmB,EAAE,OAAO;IAC5B,iBAAiB,EAAE,eAAe;IAClC,cAAc,EAAE,sBAAsB;IACtC,cAAc,EAAE,0CAA0C;IAC1D,gBAAgB,EAAE,iIAAiI;IACnJ,mBAAmB,EAAE,kEAAkE;CACxF,CAAC,CAAA","sourcesContent":["/** Generated by release CI. Do not edit in a release checkout. */\nexport interface BluetoothSdkReleaseMetadata {\n schemaVersion: 1\n familyBaseVersion: string | null\n releaseIdentity: string | null\n releaseSetId: string | null\n sourceCommit: string | null\n otaManifestUrl: string | null\n otaManifestSha256: string | null\n}\n\nexport const BLUETOOTH_SDK_RELEASE_METADATA: Readonly<BluetoothSdkReleaseMetadata> = Object.freeze({\n \"schemaVersion\": 1,\n \"familyBaseVersion\": \"3.3.0\",\n \"releaseIdentity\": \"3.3.0-dev.921\",\n \"releaseSetId\": \"mentra-3.3.0-dev.921\",\n \"sourceCommit\": \"cfa5334f4b5e9b7c6f48d900d4fe0bafe34b1ddc\",\n \"otaManifestUrl\": \"https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-dev.921.json\",\n \"otaManifestSha256\": \"a0387d2e72295e7de7fa462763d321e7dcaf5c0e9b571ecc417e5c738ed2a517\"\n})\n"]}
@@ -16,7 +16,7 @@ enum BluetoothSdkDefaults {
16
16
  /// silently disable it on every pair the app touches.
17
17
  static let autoPowerOffEnabled = false
18
18
  private static let infoSdkVersionKey = "MentraBluetoothSdkVersion"
19
- private static let swiftPackageSdkVersion = "3.3.0-dev.919"
19
+ private static let swiftPackageSdkVersion = "3.3.0-dev.921"
20
20
  private static let swiftPackageSdkVersionPlaceholder = "__MENTRA" + "_BLUETOOTH_SDK_VERSION__"
21
21
 
22
22
  private static func normalizedSdkVersion(_ value: String?) -> String? {
@@ -3,9 +3,9 @@ import Foundation
3
3
  /// Generated by release CI. Do not edit in a release checkout.
4
4
  enum GeneratedReleaseMetadata {
5
5
  static let familyBaseVersion = "3.3.0"
6
- static let releaseIdentity = "3.3.0-dev.919"
7
- static let releaseSetId = "mentra-3.3.0-dev.919"
8
- static let sourceCommit = "3697e9557c96587e96d31e1f3fd2e4a15080b618"
9
- static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-dev.919.json"
10
- static let otaManifestSha256 = "f3bb4c1c2c9ee6dbcfdb3e0353bd9b7c08eea13d9aebda3e772b3a6c0d573eaf"
6
+ static let releaseIdentity = "3.3.0-dev.921"
7
+ static let releaseSetId = "mentra-3.3.0-dev.921"
8
+ static let sourceCommit = "cfa5334f4b5e9b7c6f48d900d4fe0bafe34b1ddc"
9
+ static let otaManifestUrl = "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-dev.921.json"
10
+ static let otaManifestSha256 = "a0387d2e72295e7de7fa462763d321e7dcaf5c0e9b571ecc417e5c738ed2a517"
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentra/bluetooth-sdk",
3
- "version": "3.3.0-dev.919",
3
+ "version": "3.3.0-dev.921",
4
4
  "description": "SDK for communicating with smart glasses",
5
5
  "main": "build/index.js",
6
6
  "react-native": "src/index.ts",
@@ -114,7 +114,7 @@
114
114
  "registry": "https://registry.npmjs.org/"
115
115
  },
116
116
  "dependencies": {
117
- "@mentra/cloud-protocol": "3.3.0-dev.919"
117
+ "@mentra/cloud-protocol": "3.3.0-dev.921"
118
118
  },
119
119
  "devDependencies": {
120
120
  "@types/node": "^25.9.3",
@@ -12,9 +12,9 @@ export interface BluetoothSdkReleaseMetadata {
12
12
  export const BLUETOOTH_SDK_RELEASE_METADATA: Readonly<BluetoothSdkReleaseMetadata> = Object.freeze({
13
13
  "schemaVersion": 1,
14
14
  "familyBaseVersion": "3.3.0",
15
- "releaseIdentity": "3.3.0-dev.919",
16
- "releaseSetId": "mentra-3.3.0-dev.919",
17
- "sourceCommit": "3697e9557c96587e96d31e1f3fd2e4a15080b618",
18
- "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-dev.919.json",
19
- "otaManifestSha256": "f3bb4c1c2c9ee6dbcfdb3e0353bd9b7c08eea13d9aebda3e772b3a6c0d573eaf"
15
+ "releaseIdentity": "3.3.0-dev.921",
16
+ "releaseSetId": "mentra-3.3.0-dev.921",
17
+ "sourceCommit": "cfa5334f4b5e9b7c6f48d900d4fe0bafe34b1ddc",
18
+ "otaManifestUrl": "https://artifactscdn.mentraglass.com/Mentra-Community/MentraOS/releases/mentra-builds-v3.3.0/mentra-live-ota-3.3.0-dev.921.json",
19
+ "otaManifestSha256": "a0387d2e72295e7de7fa462763d321e7dcaf5c0e9b571ecc417e5c738ed2a517"
20
20
  })