also looking at this
iOS: the Bluetooth scan pair — ratchet 35 → 33
#97
10 files
+679
-3
| @@ -51,6 +51,7 @@ const char craft_slice_page[] = | ||
| 51 | 51 | "var sentAuth = false, sentSiriAdd = false, sentSiriDel = false;\n" |
| 52 | 52 | "var sentPdfOpen = false, sentPdfClose = false;\n" |
| 53 | 53 | "var sentDownload = false, sentWatch = false, sentSettings = false;\n" |
| 54 | "var sentBtStart = false, sentBtStop = false;\n" | |
| 54 | 55 | "window.__craftBridgeError = function (ctx) {\n" |
| 55 | 56 | " // The message crossed Zig's escaping with a backslash, quote, and\n" |
| 56 | 57 | " // newline intact; anything mangled and this equality fails, i=7 never\n" |
| @@ -77,6 +78,16 @@ const char craft_slice_page[] = | ||
| 77 | 78 | " // NOT_FOUND, not PLATFORM_NOT_SUPPORTED: WatchConnectivity is linked,\n" |
| 78 | 79 | " // so this is WCSession itself reporting no reachable watch rather than\n" |
| 79 | 80 | " // a missing class. Before this phase the action was not served at all.\n" |
| 81 | " // PLATFORM_NOT_SUPPORTED, specifically: CoreBluetooth is linked and the\n" | |
| 82 | " // usage description is present, so this is the radio's own state and\n" | |
| 83 | " // not a missing class or a missing plist key. Swift answers all five\n" | |
| 84 | " // unusable states with one string; this one names which.\n" | |
| 85 | " if (!sentBtStart && ctx && ctx.error === true && ctx.id === 103\n" | |
| 86 | " && ctx.code === 'PLATFORM_NOT_SUPPORTED') {\n" | |
| 87 | " sentBtStart = true;\n" | |
| 88 | " bridge.postMessage({t:'mobile', a:'getDeviceInfo', i:56});\n" | |
| 89 | " bridge.postMessage({t:'mobile', a:'stopBluetoothScan', i:104});\n" | |
| 90 | " }\n" | |
| 80 | 91 | " if (!sentWatch && ctx && ctx.error === true && ctx.id === 101\n" |
| 81 | 92 | " && ctx.code === 'NOT_FOUND') {\n" |
| 82 | 93 | " sentWatch = true;\n" |
| @@ -173,6 +184,10 @@ const char craft_slice_page[] = | ||
| 173 | 184 | " // was parsed and routed — and the donation ran without throwing.\n" |
| 174 | 185 | " // A bare string path, landed inside the app container's Documents.\n" |
| 175 | 186 | " // Nothing but a real download-and-move produces it.\n" |
| 187 | " if (!sentBtStop && action === 'stopBluetoothScan' && payload === true) {\n" | |
| 188 | " sentBtStop = true;\n" | |
| 189 | " bridge.postMessage({t:'mobile', a:'getDeviceInfo', i:58});\n" | |
| 190 | " }\n" | |
| 176 | 191 | " if (!sentSettings && action === 'openSettings' && typeof payload === 'boolean') {\n" |
| 177 | 192 | " sentSettings = true;\n" |
| 178 | 193 | " bridge.postMessage({t:'mobile', a:'getDeviceInfo', i:54});\n" |
| @@ -314,6 +329,15 @@ const char craft_slice_page[] = | ||
| 314 | 329 | " // only branch the Swift shim reaches there.\n" |
| 315 | 330 | " bridge.postMessage({t:'mobile', a:'sendToWatch',\n" |
| 316 | 331 | " d: JSON.stringify({message:{action:'ping'}}), i:101});\n" |
| 332 | " // A simulator has no Bluetooth radio, so CBCentralManager reports\n" | |
| 333 | " // unsupported and the scan is refused from the state callback — not\n" | |
| 334 | " // from the handler, which returns before the radio has said anything.\n" | |
| 335 | " // Only the start here. Posting the stop alongside it would race: a\n" | |
| 336 | " // stop while a start is still awaiting its first state callback\n" | |
| 337 | " // answers that start CANCELLED, which is the module's deliberate fix\n" | |
| 338 | " // for the promise Swift drops — and would mask the state refusal this\n" | |
| 339 | " // asserts. The stop goes out once the start has been answered.\n" | |
| 340 | " bridge.postMessage({t:'mobile', a:'startBluetoothScan', i:103});\n" | |
| 317 | 341 | " // A Tier-0 action migrated in this phase, served by Zig directly.\n" |
| 318 | 342 | " bridge.postMessage({t:'mobile', a:'getAppState', i:88});\n" |
| 319 | 343 | " // And one the shim answers by rejecting, to prove the error route.\n" |