feat: SDK 0.4.12/0.3.14, background-streaming bridges, one-shot conne…#9
Conversation
|
/sfs |
There was a problem hiding this comment.
needs a pass — the android battery-optimization bridge isn't shippable yet.
design — standalone foreground-service start/stop is a bit awkward, but it mirrors the native surface this release is exposing, so i'm not asking for a bigger wrapper reshuffle here.
functionality — block on the new android battery-exemption API: isIgnoringBatteryOptimizations() can crash on api <23, and the prompt path needs a manifest permission this package doesn't add, so it resolves false unless apps wire extra setup themselves.
comments — clean.
tests — no test files touched in this pr.
For the non-technically inclined
one of the new Android battery-saver helpers can crash on older phones. The other won't actually open the opt-out prompt unless the app adds extra setup, so apps relying on background streaming will think they exposed a fix when they didn't.
prIQ: 91
| /** Whether the app is exempt from battery optimizations (aggressive OEMs kill streams otherwise). */ | ||
| @ReactMethod | ||
| public void isIgnoringBatteryOptimizations(Promise promise){ | ||
| PowerManager pm = (PowerManager) this.reactContext.getSystemService(Context.POWER_SERVICE); | ||
| promise.resolve(pm != null && pm.isIgnoringBatteryOptimizations(this.reactContext.getPackageName())); | ||
| } |
There was a problem hiding this comment.
This calls an API 23-only method unguarded, so older supported Android devices can crash here.
| /** Whether the app is exempt from battery optimizations (aggressive OEMs kill streams otherwise). */ | |
| @ReactMethod | |
| public void isIgnoringBatteryOptimizations(Promise promise){ | |
| PowerManager pm = (PowerManager) this.reactContext.getSystemService(Context.POWER_SERVICE); | |
| promise.resolve(pm != null && pm.isIgnoringBatteryOptimizations(this.reactContext.getPackageName())); | |
| } | |
| /** Whether the app is exempt from battery optimizations (aggressive OEMs kill streams otherwise). */ | |
| @ReactMethod | |
| public void isIgnoringBatteryOptimizations(Promise promise){ | |
| if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M) { | |
| promise.resolve(true); | |
| return; | |
| } | |
| PowerManager pm = (PowerManager) this.reactContext.getSystemService(Context.POWER_SERVICE); | |
| promise.resolve(pm != null && pm.isIgnoringBatteryOptimizations(this.reactContext.getPackageName())); | |
| } |
…ards on battery bridges
|
/sfs |

SDK 0.4.12 / 0.3.14, background-streaming bridges, one-shot connectDevice promise
Bumps both native SDK pins and exposes the new background-streaming capabilities to React Native. Wrapper version → 0.2.7.
The pinned SDKs change
ACCELERATIONto gravity-compensated linear acceleration in SI units (m/s²) on both platforms — a device at rest reports ≈ [0, 0, 0], and iPhone/Android now report identical semantics. Apps interpreting acceleration values should update before adopting 0.2.7.SDK bumps (the point of this release)
startRealtimeno longer starts the service for devices that aren't actually connected.stopStreamcorrectly stops device-motion updates.New API (Android; typed no-ops on iOS)
The foreground service itself starts/stops automatically with
startRealtime/stopRealtimeas of 0.4.12 —startForegroundServiceexists to customize the persistent notification. The battery-optimization pair matters on aggressive OEMs (MIUI etc.) that kill even foreground services without an exemption; apps can check and offer the one-tap system dialog in-flow.Fixed
connectDevice()resolved its promise more than once — the native SDKs reuse the connection callback for every subsequent connection update (e.g. disconnect), so the settled promise got re-resolved and red-boxed in dev ("Tried to resolve a promise more than once"). Both bridges now guard for exactly-once resolution.Tests
Replaced the
it.todoplaceholder with real coverage of the new API: Android calls forward to the native module with correct arguments; iOS resolves as no-ops without touching it. TheconnectDeviceguard is native code, exercised on-device (below) rather than in jest.Verified
End to end via the Terra Grip demo app (BLE, phone sensors, Apple Watch): locked-screen streaming on Android through multi-hundred-update sessions, reconnection after signal loss, and device-switch/unpair flows no longer warn.
yarn lint,yarn typecheck,yarn testall green.