@mojro/react-native-gnss-tracking-health 0.0.0-stage → 0.1.1
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.
- package/LICENSE +21 -0
- package/README.md +374 -2
- package/android/build.gradle +31 -0
- package/android/src/main/AndroidManifest.xml +34 -0
- package/android/src/main/java/com/gnsstrackinghealth/GnssTrackingHealthPackage.java +31 -0
- package/android/src/main/java/com/gnsstrackinghealth/GnssTrackingHealthSettingsModule.java +636 -0
- package/android/src/main/java/com/gnsstrackinghealth/autodatetime/AutoDateTimeModule.java +87 -0
- package/android/src/main/java/com/gnsstrackinghealth/autodatetime/AutoDateTimePackage.java +27 -0
- package/package.json +55 -3
- package/src/TrackingQualityMonitor.js +607 -0
- package/src/adapters/normalizeLocation.js +65 -0
- package/src/backgroundSettings.js +392 -0
- package/src/config.js +96 -0
- package/src/constants.js +161 -0
- package/src/deviceFitness.js +135 -0
- package/src/gnssMonitor.js +245 -0
- package/src/hooks/useDeviceFitness.js +65 -0
- package/src/hooks/useSystemHealth.js +54 -0
- package/src/hooks/useTimeValidation.js +42 -0
- package/src/hooks/useTrackingMonitor.js +265 -0
- package/src/hooks/useTrackingQuality.js +118 -0
- package/src/hooks/useTrackingQualityAlerts.js +22 -0
- package/src/index.d.ts +521 -0
- package/src/index.js +129 -0
- package/src/systemHealth.js +118 -0
- package/src/timeValidation.js +174 -0
- package/src/traceAnalyzer.js +100 -0
- package/src/utils/distance.js +16 -0
- package/src/utils/logger.js +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,375 @@
|
|
|
1
|
-
#
|
|
1
|
+
# react-native-gnss-tracking-health
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Device fitness, GNSS satellite coverage, system health, and tracking-quality alerts for React Native.
|
|
4
|
+
|
|
5
|
+
- **Peer dependency:** [`react-native-gnss-status-checker`](https://www.npmjs.com/package/react-native-gnss-status-checker) (Android GNSS)
|
|
6
|
+
- **Location traces:** feed from **any** tracking library (BGGeolocation, expo-location, etc.) via `ingestLocation`
|
|
7
|
+
- **Independent modules:** device fitness, system health, time/timezone validation
|
|
8
|
+
- **Alerts + in-app notifications:** via `configure({ showNotification })`
|
|
9
|
+
- **Hooks** for a tracking-quality screen
|
|
10
|
+
|
|
11
|
+
This package was extracted from the Mojro driver-app Tracking Quality POC. The app code is unchanged — wire this library when ready.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
yarn add react-native-gnss-tracking-health react-native-gnss-status-checker
|
|
19
|
+
# optional
|
|
20
|
+
yarn add react-native-device-info @notifee/react-native
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Link / rebuild native for `react-native-gnss-status-checker`.
|
|
24
|
+
|
|
25
|
+
Local path (development):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
yarn add file:../react-native-gnss-tracking-health
|
|
29
|
+
# or
|
|
30
|
+
yarn add /Users/you/Desktop/react-native-gnss-tracking-health
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Quick start
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import BackgroundGeolocation from "react-native-background-geolocation";
|
|
39
|
+
import {
|
|
40
|
+
configure,
|
|
41
|
+
useTrackingQuality,
|
|
42
|
+
validateTimeAndTimezone,
|
|
43
|
+
getThresholds,
|
|
44
|
+
} from "react-native-gnss-tracking-health";
|
|
45
|
+
import { showNotification } from "./utils/notifeeUtil"; // your app
|
|
46
|
+
|
|
47
|
+
// Once at app boot — thresholds optional; library defaults apply
|
|
48
|
+
configure({
|
|
49
|
+
getPowerSaveMode: () => BackgroundGeolocation.isPowerSaveMode(),
|
|
50
|
+
isIgnoringBatteryOptimizations: () =>
|
|
51
|
+
BackgroundGeolocation.deviceSettings.isIgnoringBatteryOptimizations(),
|
|
52
|
+
showNotification: (title, message) =>
|
|
53
|
+
showNotification(title, message, { debounce: true }),
|
|
54
|
+
persistAlert: (alert) => {
|
|
55
|
+
// saveLog / analytics
|
|
56
|
+
},
|
|
57
|
+
thresholds: {
|
|
58
|
+
minSatellitesForGoodFix: 8,
|
|
59
|
+
tripStartSatWindowMs: 45_000,
|
|
60
|
+
poorAccuracyThresholdM: 40,
|
|
61
|
+
},
|
|
62
|
+
// apiLevelThresholds: { MIN_ACCEPTABLE_FOR_TRACKING: 26 },
|
|
63
|
+
});
|
|
64
|
+
// getThresholds() → merged defaults + overrides
|
|
65
|
+
|
|
66
|
+
// Feed traces from your tracker (BGGeolocation example)
|
|
67
|
+
BackgroundGeolocation.onLocation((location) => {
|
|
68
|
+
// import { trackingQualityMonitor } from 'react-native-gnss-tracking-health'
|
|
69
|
+
trackingQualityMonitor.ingestLocation(location);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Gate session validations (accuracy / throttle / teleport) on tracking active
|
|
73
|
+
BackgroundGeolocation.onEnabledChange((enabled) => {
|
|
74
|
+
trackingQualityMonitor.setLocationTrackingActive(!!enabled);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// Once at login / session restore (independent of tracking)
|
|
78
|
+
trackingQualityMonitor.evaluateDeviceFitnessOnLogin();
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Session rules** (poor accuracy, throttle, teleport, mock) run only while `setLocationTrackingActive(true)`.
|
|
82
|
+
|
|
83
|
+
**Poor-accuracy timer:** starts when accuracy is poor (default > 50m) or sats are low; **resets immediately** when a fix arrives with good accuracy (≤ 50m).
|
|
84
|
+
|
|
85
|
+
**Throttle:** while tracking is active, if time since last ingested fix ≥ `max(throttleMinGapMs, expectedTraceIntervalMs × throttleGapMultiplier)` (default **3 minutes**), raises `LOCATION_THROTTLING`.
|
|
86
|
+
|
|
87
|
+
### Screen hooks
|
|
88
|
+
|
|
89
|
+
Use `useTrackingMonitor` for a POC-equivalent surface (status + alerts + throttled live log + controls).
|
|
90
|
+
`useTrackingQuality` is a lighter status/control hook without the live log buffer.
|
|
91
|
+
|
|
92
|
+
```jsx
|
|
93
|
+
import React from "react";
|
|
94
|
+
import { View, Text, Button, FlatList } from "react-native";
|
|
95
|
+
import { useTrackingMonitor } from "react-native-gnss-tracking-health";
|
|
96
|
+
|
|
97
|
+
export function TrackingQualityScreen() {
|
|
98
|
+
const {
|
|
99
|
+
status,
|
|
100
|
+
deviceFitness,
|
|
101
|
+
latestGnss,
|
|
102
|
+
latestSystem,
|
|
103
|
+
recentAlerts,
|
|
104
|
+
logs,
|
|
105
|
+
locationTrackingActive,
|
|
106
|
+
start,
|
|
107
|
+
stop,
|
|
108
|
+
onTripStarted,
|
|
109
|
+
evaluateDeviceFitness,
|
|
110
|
+
setLocationTrackingActive,
|
|
111
|
+
} = useTrackingMonitor();
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<View>
|
|
115
|
+
<Text>Running: {String(status.running)}</Text>
|
|
116
|
+
<Text>Tracking active: {String(locationTrackingActive)}</Text>
|
|
117
|
+
<Text>Fitness: {deviceFitness?.fitness}</Text>
|
|
118
|
+
<Text>
|
|
119
|
+
Sats: {latestGnss?.satellitesVisible}/{latestGnss?.satellitesUsedInFix}
|
|
120
|
+
</Text>
|
|
121
|
+
<Text>Battery: {latestSystem?.batteryLevel}%</Text>
|
|
122
|
+
<Button
|
|
123
|
+
title="Start"
|
|
124
|
+
onPress={() => {
|
|
125
|
+
setLocationTrackingActive(true);
|
|
126
|
+
start({ tripId: `trip-${Date.now()}`, notifyDriver: true });
|
|
127
|
+
}}
|
|
128
|
+
/>
|
|
129
|
+
<Button title="Trip start" onPress={() => onTripStarted(`trip-${Date.now()}`)} />
|
|
130
|
+
<Button title="Fitness" onPress={() => evaluateDeviceFitness()} />
|
|
131
|
+
<Button
|
|
132
|
+
title="Stop"
|
|
133
|
+
onPress={() => {
|
|
134
|
+
setLocationTrackingActive(false);
|
|
135
|
+
stop();
|
|
136
|
+
}}
|
|
137
|
+
/>
|
|
138
|
+
{recentAlerts.map((a) => (
|
|
139
|
+
<Text key={`${a.type}-${a.at}`}>{a.type}: {a.message}</Text>
|
|
140
|
+
))}
|
|
141
|
+
<FlatList
|
|
142
|
+
data={logs}
|
|
143
|
+
keyExtractor={(item) => item.id}
|
|
144
|
+
renderItem={({ item }) => (
|
|
145
|
+
<Text>
|
|
146
|
+
[{item.level}] {item.message}
|
|
147
|
+
</Text>
|
|
148
|
+
)}
|
|
149
|
+
/>
|
|
150
|
+
</View>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Event names match the driver app (`TrackingQualityMonitor:alert|status|gnss|action`) so existing listeners keep working.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Independent APIs
|
|
160
|
+
|
|
161
|
+
### Device fitness
|
|
162
|
+
|
|
163
|
+
```js
|
|
164
|
+
import { assessDeviceFitness, useDeviceFitness } from "react-native-gnss-tracking-health";
|
|
165
|
+
|
|
166
|
+
const { fitness, evaluate, capableForTracking } = useDeviceFitness();
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Uses API level + GNSS capability flags + settings — **not** live satellite counts.
|
|
170
|
+
|
|
171
|
+
### System health
|
|
172
|
+
|
|
173
|
+
```js
|
|
174
|
+
import { collectSystemHealth, useSystemHealth } from "react-native-gnss-tracking-health";
|
|
175
|
+
|
|
176
|
+
const health = await collectSystemHealth();
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Background restrictions (battery optimization + OEM allowlists)
|
|
180
|
+
|
|
181
|
+
Android only. The library ships a small native module (autolinked; rebuild the app after installing). It reports **two different settings separately**:
|
|
182
|
+
|
|
183
|
+
| Setting | Detectable? | How |
|
|
184
|
+
|---------|-------------|-----|
|
|
185
|
+
| Android "Ignore battery optimizations" (Doze) | **Yes** | `PowerManager.isIgnoringBatteryOptimizations()` |
|
|
186
|
+
| OEM allowlists (Samsung Never sleeping apps, Oppo/OnePlus Startup manager, Vivo Background startup, Xiaomi Autostart, …) | **No** | OEMs expose intents to *open* the screen but no public API to *read* membership |
|
|
187
|
+
|
|
188
|
+
Because no OEM lets an app read these lists, the library never reports membership as verified. `neverSleepingApps.verifiable` is always `false`; `userConfirmed` only reflects what the driver told you via `setNeverSleepingAppsConfirmed()` (persisted natively).
|
|
189
|
+
|
|
190
|
+
Supported OEM families for direct navigation: **Samsung**, **Xiaomi/Redmi/POCO**, **Huawei/Honor**, **Oppo**, **Realme**, **OnePlus**, **Vivo/iQOO**, **Asus**, **Nokia/HMD**, **Letv/LeEco**, **Meizu**, **Motorola/Moto**.
|
|
191
|
+
|
|
192
|
+
```js
|
|
193
|
+
import {
|
|
194
|
+
getBackgroundSettingsStatus,
|
|
195
|
+
openNeverSleepingApps,
|
|
196
|
+
openBatteryOptimizationSettings,
|
|
197
|
+
setNeverSleepingAppsConfirmed,
|
|
198
|
+
NEVER_SLEEPING_STATE,
|
|
199
|
+
} from "react-native-gnss-tracking-health";
|
|
200
|
+
|
|
201
|
+
const s = await getBackgroundSettingsStatus();
|
|
202
|
+
// s.ignoringBatteryOptimizations -> true | false (verified) | null
|
|
203
|
+
// s.isSamsung, s.oemFamily, s.manufacturer, s.model
|
|
204
|
+
// s.neverSleepingApps = {
|
|
205
|
+
// applicable, verifiable: false,
|
|
206
|
+
// state: "not_applicable" | "unverified" | "user_confirmed" | "user_reported_missing",
|
|
207
|
+
// userConfirmed: true | false | null,
|
|
208
|
+
// settingsScreenAvailable, oemFamily, label, target
|
|
209
|
+
// }
|
|
210
|
+
|
|
211
|
+
if (
|
|
212
|
+
s.neverSleepingApps.applicable &&
|
|
213
|
+
s.neverSleepingApps.state !== NEVER_SLEEPING_STATE.USER_CONFIRMED
|
|
214
|
+
) {
|
|
215
|
+
const r = await openNeverSleepingApps(); // OEM screen only (no generic fallback)
|
|
216
|
+
// { opened, target, isOemScreen, manufacturer, oemFamily }
|
|
217
|
+
if (!r.opened) await openBatteryOptimizationSettings(); // fallback
|
|
218
|
+
// When the driver returns, ask them, then:
|
|
219
|
+
await setNeverSleepingAppsConfirmed(true); // or false / null to clear
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
`collectSystemHealth()` also includes `manufacturer`, `isSamsung`, `oemFamily` and `neverSleepingApps`. These are diagnostic only and do **not** affect device fitness. If `configure({ isIgnoringBatteryOptimizations })` is not set, the native PowerManager check is used.
|
|
224
|
+
|
|
225
|
+
Samsung's screen is `com.samsung.android.sm.ACTION_OPEN_CHECKABLE_LISTACTIVITY` (package `com.samsung.android.lool`, `activity_type=2`). ColorOS / OxygenOS / Oplus devices try `com.oplus.safecenter` then legacy `com.coloros.safecenter` / `com.oneplus.security`. Vivo tries Background startup + whitelist activities. OEM screens change between OS versions, so `openNeverSleepingApps()` resolves `{ opened: false }` instead of throwing; test on the builds you support. The library manifest adds the `<queries>` entries needed on Android 11+.
|
|
226
|
+
|
|
227
|
+
#### Open the right background screen on any Android device
|
|
228
|
+
|
|
229
|
+
```js
|
|
230
|
+
import { openBackgroundRestrictionSettings } from "react-native-gnss-tracking-health";
|
|
231
|
+
|
|
232
|
+
const r = await openBackgroundRestrictionSettings();
|
|
233
|
+
// { opened: true, target: "xiaomi_autostart", isOemScreen: true, manufacturer: "Xiaomi", oemFamily: "xiaomi" }
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Tries, in order: the manufacturer's own screen (Samsung Never sleeping apps, Xiaomi Autostart, Huawei/Honor Startup manager, Oppo/Realme/OnePlus Startup manager, Vivo/iQOO Background startup, Asus, Nokia, Letv, Meizu, Motorola/Lenovo background or system battery list), then Android's "Optimize battery usage" list, then this app's "App info" page. It never rejects. `target` tells you which one opened (`isOemScreen: false` means a universal fallback). OEM screens are undocumented and vary by model and OS version, so test on the devices you support. No manufacturer lets an app read whether it was added to these lists, so this only navigates; it cannot verify.
|
|
237
|
+
|
|
238
|
+
### Time / timezone (standalone)
|
|
239
|
+
|
|
240
|
+
Android auto date/time + timezone lives in its **own native package** (not mixed with battery-settings code), matching the driver-app layout:
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
android/src/main/java/com/gnsstrackinghealth/
|
|
244
|
+
GnssTrackingHealthSettingsModule.java # battery + OEM allowlist screens
|
|
245
|
+
autodatetime/
|
|
246
|
+
AutoDateTimeModule.java # AUTO_TIME + AUTO_TIME_ZONE
|
|
247
|
+
AutoDateTimePackage.java
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Clock skew uses HTTP `Date` headers (JS, both platforms) with the **same rule as the driver app**: skewed only when **all three** sources respond and all are beyond the threshold; otherwise `null` (inconclusive) or `false` (OK). Host apps only consume the flags:
|
|
251
|
+
|
|
252
|
+
```js
|
|
253
|
+
import {
|
|
254
|
+
validateTimeAndTimezone,
|
|
255
|
+
isClockSkewed,
|
|
256
|
+
isAutomaticDateTimeEnabled,
|
|
257
|
+
openDateTimeSettings,
|
|
258
|
+
useTimeValidation,
|
|
259
|
+
} from "react-native-gnss-tracking-health";
|
|
260
|
+
|
|
261
|
+
const result = await validateTimeAndTimezone();
|
|
262
|
+
// {
|
|
263
|
+
// autoDateTimeEnabled, // Android: true|false ; iOS: null
|
|
264
|
+
// clockSkewed,
|
|
265
|
+
// badTimeOrTimezone,
|
|
266
|
+
// ...
|
|
267
|
+
// }
|
|
268
|
+
|
|
269
|
+
if (result.autoDateTimeEnabled === false) {
|
|
270
|
+
await openDateTimeSettings();
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Optional override: `configure({ isAutomaticDateTimeEnabled: () => ... })`.
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Location adapter
|
|
279
|
+
|
|
280
|
+
Any shape is accepted; normalize helpers understand BGGeolocation and common GPS objects:
|
|
281
|
+
|
|
282
|
+
```js
|
|
283
|
+
ingestLocation(bgLocation);
|
|
284
|
+
ingestLocation({ latitude, longitude, accuracy, mocked, timestamp });
|
|
285
|
+
ingestLocation({ coords: { latitude, longitude, accuracy }, mock: false });
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Alerts
|
|
291
|
+
|
|
292
|
+
| Type | Meaning |
|
|
293
|
+
|------|---------|
|
|
294
|
+
| `LOCATION_MOCKED` | Mock GPS |
|
|
295
|
+
| `LOW_SATELLITE_AFTER_TRIP_START` | < 6 sats in first 30s |
|
|
296
|
+
| `POOR_TRACKING_SUSTAINED` | Poor accuracy/sats > 10 min |
|
|
297
|
+
| `ABNORMAL_TRACE` | Teleport jump |
|
|
298
|
+
| `BATTERY_OPTIMIZATION_ENABLED` | Android batt opt |
|
|
299
|
+
| `LOW_POWER_MODE` | Power saver |
|
|
300
|
+
| `LOCATION_THROTTLING` | Sparse traces |
|
|
301
|
+
| `BACKGROUND_TRACKING_RESTRICTED` | BG restriction proxy |
|
|
302
|
+
| `BAD_TIME_TIMEZONE` | Auto time off / clock skew |
|
|
303
|
+
|
|
304
|
+
Notifications fire only when `configure({ showNotification })` is set and `start({ notify: true })` (default).
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## Configurable thresholds
|
|
309
|
+
|
|
310
|
+
All numeric defaults live in `DEFAULT_THRESHOLDS` / `DEFAULT_API_LEVEL_THRESHOLDS`.
|
|
311
|
+
Pass partial overrides via `configure({ thresholds, apiLevelThresholds })`.
|
|
312
|
+
Read the merged result with `getThresholds()` / `getApiLevelThresholds()`.
|
|
313
|
+
|
|
314
|
+
| Key | Default | Meaning |
|
|
315
|
+
|-----|---------|---------|
|
|
316
|
+
| `tripStartSatWindowMs` | 30000 | Trip-start sat window |
|
|
317
|
+
| `minSatellitesForGoodFix` | 6 | Min sats for “good” |
|
|
318
|
+
| `poorTrackingDurationMs` | 600000 | Sustained poor tracking |
|
|
319
|
+
| `poorAccuracyThresholdM` | 50 | Poor accuracy (m) |
|
|
320
|
+
| `teleportImpliedSpeedKmh` | 200 | Teleport speed |
|
|
321
|
+
| `teleportMinJumpMeters` | 500 | Teleport distance |
|
|
322
|
+
| `expectedTraceIntervalMs` | 60000 | Expected fix interval |
|
|
323
|
+
| `throttleGapMultiplier` | 3 | Throttle gap × expected |
|
|
324
|
+
| `throttleMinGapMs` | 180000 | Min throttle gap |
|
|
325
|
+
| `systemCheckIntervalMs` | 60000 | System health poll |
|
|
326
|
+
| `alertCooldownMs` | 300000 | Per-alert-type cooldown |
|
|
327
|
+
| `timeSkewThresholdMinutes` | 2 | Clock skew |
|
|
328
|
+
| `lowBatteryFraction` | 0.15 | Low battery (0..1) |
|
|
329
|
+
|
|
330
|
+
## GNSS interval note
|
|
331
|
+
|
|
332
|
+
GNSS uses Android `GnssStatus.Callback` (typically ~1 Hz). The trip-start rule uses `tripStartSatWindowMs` (default **30s**). System health re-checks every `systemCheckIntervalMs` (default **60s**). There is no fixed app timer for GNSS polling.
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Example app
|
|
337
|
+
|
|
338
|
+
A full React Native **0.88.1** demo lives in [`example/`](./example). It mirrors the driver-app Tracking Quality POC UI (fitness, GNSS, system health, alerts, live log) and uses **BGGeolocation Start / Stop** instead of a real trip:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
cd example
|
|
342
|
+
# set LICENSE_KEY in src/setupTracking.js
|
|
343
|
+
yarn install
|
|
344
|
+
yarn android # or yarn ios
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
See [`example/README.md`](./example/README.md) for controls, patches, and demo thresholds.
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## Project layout
|
|
352
|
+
|
|
353
|
+
```
|
|
354
|
+
src/
|
|
355
|
+
TrackingQualityMonitor.js # orchestrator + singleton
|
|
356
|
+
gnssMonitor.js # peer: react-native-gnss-status-checker
|
|
357
|
+
deviceFitness.js
|
|
358
|
+
systemHealth.js
|
|
359
|
+
backgroundSettings.js # battery optimization + OEM allowlist screens
|
|
360
|
+
timeValidation.js # standalone time/tz
|
|
361
|
+
traceAnalyzer.js
|
|
362
|
+
adapters/normalizeLocation.js
|
|
363
|
+
hooks/
|
|
364
|
+
constants.js
|
|
365
|
+
config.js
|
|
366
|
+
index.js
|
|
367
|
+
android/ # native module (Java): settings status + deep links
|
|
368
|
+
example/ # RN demo with BGGeolocation start/stop
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## License
|
|
374
|
+
|
|
375
|
+
MIT
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
|
|
3
|
+
def safeExtGet(prop, fallback) {
|
|
4
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
android {
|
|
8
|
+
namespace "com.gnsstrackinghealth"
|
|
9
|
+
|
|
10
|
+
compileSdkVersion safeExtGet('compileSdkVersion', 35)
|
|
11
|
+
|
|
12
|
+
defaultConfig {
|
|
13
|
+
minSdkVersion safeExtGet('minSdkVersion', 24)
|
|
14
|
+
targetSdkVersion safeExtGet('targetSdkVersion', 35)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
compileOptions {
|
|
18
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
19
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
repositories {
|
|
24
|
+
google()
|
|
25
|
+
mavenCentral()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
dependencies {
|
|
29
|
+
// Version is supplied by the host app's React Native Gradle plugin.
|
|
30
|
+
implementation "com.facebook.react:react-android"
|
|
31
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
2
|
+
|
|
3
|
+
<!--
|
|
4
|
+
Package visibility (Android 11+): lets the library resolve the OEM
|
|
5
|
+
system-manager apps that host the "Never sleeping apps" / autostart /
|
|
6
|
+
background-startup screens opened by openBackgroundRestrictionSettings().
|
|
7
|
+
Merged into the host app's manifest automatically.
|
|
8
|
+
-->
|
|
9
|
+
<queries>
|
|
10
|
+
<package android:name="com.samsung.android.lool" />
|
|
11
|
+
<package android:name="com.miui.securitycenter" />
|
|
12
|
+
<package android:name="com.miui.powerkeeper" />
|
|
13
|
+
<package android:name="com.huawei.systemmanager" />
|
|
14
|
+
<!-- ColorOS / OxygenOS / Oplus (Oppo, Realme, OnePlus) -->
|
|
15
|
+
<package android:name="com.oplus.safecenter" />
|
|
16
|
+
<package android:name="com.oplus.battery" />
|
|
17
|
+
<package android:name="com.coloros.safecenter" />
|
|
18
|
+
<package android:name="com.coloros.oppoguardelf" />
|
|
19
|
+
<package android:name="com.oppo.safe" />
|
|
20
|
+
<package android:name="com.oneplus.security" />
|
|
21
|
+
<!-- Vivo / iQOO -->
|
|
22
|
+
<package android:name="com.vivo.permissionmanager" />
|
|
23
|
+
<package android:name="com.iqoo.secure" />
|
|
24
|
+
<package android:name="com.vivo.abe" />
|
|
25
|
+
<package android:name="com.asus.mobilemanager" />
|
|
26
|
+
<package android:name="com.evenwell.powersaving.g3" />
|
|
27
|
+
<package android:name="com.letv.android.letvsafe" />
|
|
28
|
+
<package android:name="com.meizu.safe" />
|
|
29
|
+
<!-- Motorola / Lenovo (some Motos share Lenovo security screens) -->
|
|
30
|
+
<package android:name="com.lenovo.security" />
|
|
31
|
+
<package android:name="com.lenovo.safecenter" />
|
|
32
|
+
</queries>
|
|
33
|
+
|
|
34
|
+
</manifest>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
package com.gnsstrackinghealth;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage;
|
|
4
|
+
import com.facebook.react.bridge.NativeModule;
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
7
|
+
import com.gnsstrackinghealth.autodatetime.AutoDateTimeModule;
|
|
8
|
+
|
|
9
|
+
import java.util.Arrays;
|
|
10
|
+
import java.util.Collections;
|
|
11
|
+
import java.util.List;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Autolinked package: battery / Samsung settings + AutoDateTime module.
|
|
15
|
+
* AutoDateTime lives in {@code com.gnsstrackinghealth.autodatetime} (own folder),
|
|
16
|
+
* not inside the settings module.
|
|
17
|
+
*/
|
|
18
|
+
public class GnssTrackingHealthPackage implements ReactPackage {
|
|
19
|
+
|
|
20
|
+
@Override
|
|
21
|
+
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
|
22
|
+
return Arrays.<NativeModule>asList(
|
|
23
|
+
new GnssTrackingHealthSettingsModule(reactContext),
|
|
24
|
+
new AutoDateTimeModule(reactContext));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Override
|
|
28
|
+
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
|
29
|
+
return Collections.<ViewManager>emptyList();
|
|
30
|
+
}
|
|
31
|
+
}
|