@mojro/react-native-gnss-tracking-health 0.1.0 → 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.
@@ -7,16 +7,18 @@ import { getLogger } from "./utils/logger";
7
7
  * Two separate settings, reported separately:
8
8
  *
9
9
  * - Android "Ignore battery optimizations" -> VERIFIED via PowerManager.
10
- * - Samsung "Never sleeping apps" list -> NOT verifiable. Samsung
11
- * documents an intent to open the screen but no public API to read
12
- * whether this app is on the list. We report `verifiable: false` and
13
- * only surface what the user has told us (`userConfirmed`).
10
+ * - OEM background-allowlist screens -> NOT verifiable.
11
+ * Samsung "Never sleeping apps", Xiaomi Autostart, Huawei Startup manager,
12
+ * Oppo/Realme/OnePlus Startup manager, Vivo/iQOO Background startup, etc.
13
+ * OEMs expose intents to open these screens but no public API to read
14
+ * whether this app is on the list. We report `verifiable: false` and only
15
+ * surface what the user has told us (`userConfirmed`).
14
16
  */
15
17
 
16
18
  export const NEVER_SLEEPING_STATE = {
17
- /** Not a Samsung Android device — the list does not exist. */
19
+ /** Not an OEM that ships a dedicated allowlist screen. */
18
20
  NOT_APPLICABLE: "not_applicable",
19
- /** Samsung device, nothing known (cannot be read from the OS). */
21
+ /** OEM device, nothing known (cannot be read from the OS). */
20
22
  UNVERIFIED: "unverified",
21
23
  /** User said the app is on the list (self-reported, not verified). */
22
24
  USER_CONFIRMED: "user_confirmed",
@@ -25,7 +27,8 @@ export const NEVER_SLEEPING_STATE = {
25
27
  };
26
28
 
27
29
  const NEVER_SLEEPING_NOTE =
28
- "Samsung exposes no public API to verify the Never sleeping apps list. " +
30
+ "OEM background-allowlist screens (Never sleeping apps, Autostart, " +
31
+ "Startup manager, etc.) expose no public API to verify membership. " +
29
32
  "This value is only what the user reported.";
30
33
 
31
34
  function getNative() {
@@ -42,13 +45,77 @@ function jsManufacturer() {
42
45
  return Platform.constants?.Manufacturer || null;
43
46
  }
44
47
 
48
+ function jsBrand() {
49
+ if (Platform.OS !== "android") {
50
+ return null;
51
+ }
52
+ return Platform.constants?.Brand || null;
53
+ }
54
+
55
+ /** Best-effort OEM family from manufacturer/brand when native is unavailable. */
56
+ export function detectOemFamilyFromVendor(manufacturer, brand) {
57
+ const vendor = `${manufacturer || ""} ${brand || ""}`.toLowerCase();
58
+ if (vendor.includes("samsung")) return "samsung";
59
+ if (
60
+ vendor.includes("xiaomi") ||
61
+ vendor.includes("redmi") ||
62
+ vendor.includes("poco")
63
+ ) {
64
+ return "xiaomi";
65
+ }
66
+ if (vendor.includes("huawei") || vendor.includes("honor")) return "huawei";
67
+ if (vendor.includes("oneplus")) return "oneplus";
68
+ if (vendor.includes("realme")) return "realme";
69
+ if (vendor.includes("oppo")) return "oppo";
70
+ if (vendor.includes("vivo") || vendor.includes("iqoo")) return "vivo";
71
+ if (vendor.includes("asus")) return "asus";
72
+ if (vendor.includes("nokia") || vendor.includes("hmd")) return "nokia";
73
+ if (vendor.includes("letv") || vendor.includes("leeco")) return "letv";
74
+ if (vendor.includes("meizu")) return "meizu";
75
+ if (vendor.includes("motorola") || vendor.includes("moto")) return "motorola";
76
+ return "none";
77
+ }
78
+
79
+ export function oemRestrictionLabelForFamily(oemFamily) {
80
+ switch (oemFamily) {
81
+ case "samsung":
82
+ return "Never sleeping apps";
83
+ case "xiaomi":
84
+ return "Autostart / Battery saver";
85
+ case "huawei":
86
+ return "Startup manager / App launch";
87
+ case "oppo":
88
+ case "realme":
89
+ case "oneplus":
90
+ return "Startup manager";
91
+ case "vivo":
92
+ return "Background startup / Whitelist";
93
+ case "asus":
94
+ return "Auto-start manager";
95
+ case "nokia":
96
+ return "Power saver exceptions";
97
+ case "letv":
98
+ return "Autoboot manager";
99
+ case "meizu":
100
+ return "Background management";
101
+ case "motorola":
102
+ return "Battery optimization / Background apps";
103
+ default:
104
+ return null;
105
+ }
106
+ }
107
+
45
108
  function buildNeverSleeping({
46
- isSamsung,
109
+ applicable,
47
110
  userConfirmed,
48
111
  settingsScreenAvailable,
112
+ oemFamily,
113
+ label,
114
+ target,
49
115
  }) {
116
+ const isApplicable = !!applicable;
50
117
  let state = NEVER_SLEEPING_STATE.NOT_APPLICABLE;
51
- if (isSamsung) {
118
+ if (isApplicable) {
52
119
  if (userConfirmed === true) {
53
120
  state = NEVER_SLEEPING_STATE.USER_CONFIRMED;
54
121
  } else if (userConfirmed === false) {
@@ -58,15 +125,53 @@ function buildNeverSleeping({
58
125
  }
59
126
  }
60
127
  return {
61
- applicable: !!isSamsung,
128
+ applicable: isApplicable,
62
129
  verifiable: false,
63
130
  state,
64
- userConfirmed: isSamsung ? userConfirmed ?? null : null,
131
+ userConfirmed: isApplicable ? userConfirmed ?? null : null,
65
132
  settingsScreenAvailable: !!settingsScreenAvailable,
133
+ oemFamily: oemFamily || "none",
134
+ label: label || null,
135
+ target: target || null,
66
136
  note: NEVER_SLEEPING_NOTE,
67
137
  };
68
138
  }
69
139
 
140
+ function emptyOpenResult(manufacturer = null, oemFamily = "none") {
141
+ return {
142
+ opened: false,
143
+ target: "none",
144
+ isOemScreen: false,
145
+ manufacturer,
146
+ oemFamily,
147
+ };
148
+ }
149
+
150
+ function normalizeOpenResult(raw, fallbackManufacturer) {
151
+ // Legacy native builds resolved a bare boolean from openNeverSleepingApps.
152
+ if (typeof raw === "boolean") {
153
+ return {
154
+ opened: raw,
155
+ target: raw ? "oem" : "none",
156
+ isOemScreen: raw,
157
+ manufacturer: fallbackManufacturer,
158
+ oemFamily: detectOemFamilyFromVendor(fallbackManufacturer, jsBrand()),
159
+ };
160
+ }
161
+ return {
162
+ opened: !!raw?.opened,
163
+ target: raw?.target || "none",
164
+ isOemScreen: !!raw?.isOemScreen,
165
+ manufacturer: raw?.manufacturer || fallbackManufacturer,
166
+ oemFamily:
167
+ raw?.oemFamily ||
168
+ detectOemFamilyFromVendor(
169
+ raw?.manufacturer || fallbackManufacturer,
170
+ jsBrand()
171
+ ),
172
+ };
173
+ }
174
+
70
175
  /**
71
176
  * Collect both background-restriction statuses.
72
177
  * Never rejects: falls back to a best-effort JS-only result when the native
@@ -83,20 +188,27 @@ export async function getBackgroundSettingsStatus() {
83
188
  );
84
189
  }
85
190
  const manufacturer = jsManufacturer();
86
- const isSamsung = String(manufacturer || "").toLowerCase() === "samsung";
191
+ const brand = jsBrand();
192
+ const oemFamily = detectOemFamilyFromVendor(manufacturer, brand);
193
+ const applicable = oemFamily !== "none";
194
+ const isSamsung = oemFamily === "samsung";
87
195
  return {
88
196
  platform: Platform.OS,
89
197
  nativeModuleAvailable: false,
90
198
  manufacturer,
91
- brand: Platform.constants?.Brand || null,
199
+ brand,
92
200
  model: Platform.constants?.Model || null,
93
201
  sdkInt: null,
94
202
  isSamsung,
203
+ oemFamily,
95
204
  ignoringBatteryOptimizations: null,
96
205
  neverSleepingApps: buildNeverSleeping({
97
- isSamsung,
206
+ applicable,
98
207
  userConfirmed: null,
99
208
  settingsScreenAvailable: false,
209
+ oemFamily,
210
+ label: oemRestrictionLabelForFamily(oemFamily),
211
+ target: null,
100
212
  }),
101
213
  checkedAt,
102
214
  };
@@ -104,6 +216,13 @@ export async function getBackgroundSettingsStatus() {
104
216
 
105
217
  try {
106
218
  const raw = await native.getBackgroundSettingsStatus();
219
+ const oemFamily =
220
+ raw.oemFamily ||
221
+ detectOemFamilyFromVendor(raw.manufacturer, raw.brand);
222
+ const applicable =
223
+ typeof raw.oemRestrictionApplicable === "boolean"
224
+ ? raw.oemRestrictionApplicable
225
+ : oemFamily !== "none";
107
226
  return {
108
227
  platform: Platform.OS,
109
228
  nativeModuleAvailable: true,
@@ -111,27 +230,38 @@ export async function getBackgroundSettingsStatus() {
111
230
  brand: raw.brand,
112
231
  model: raw.model,
113
232
  sdkInt: raw.sdkInt,
114
- isSamsung: !!raw.isSamsung,
233
+ isSamsung: !!raw.isSamsung || oemFamily === "samsung",
234
+ oemFamily,
115
235
  ignoringBatteryOptimizations: !!raw.ignoringBatteryOptimizations,
116
236
  neverSleepingApps: buildNeverSleeping({
117
- isSamsung: !!raw.isSamsung,
237
+ applicable,
118
238
  userConfirmed: raw.neverSleepingUserConfirmed ?? null,
119
239
  settingsScreenAvailable: !!raw.neverSleepingScreenAvailable,
240
+ oemFamily,
241
+ label:
242
+ raw.oemRestrictionLabel || oemRestrictionLabelForFamily(oemFamily),
243
+ target: raw.oemRestrictionTarget ?? null,
120
244
  }),
121
245
  checkedAt,
122
246
  };
123
247
  } catch (error) {
124
248
  getLogger().warn("getBackgroundSettingsStatus failed:", error?.message);
249
+ const manufacturer = jsManufacturer();
250
+ const oemFamily = detectOemFamilyFromVendor(manufacturer, jsBrand());
125
251
  return {
126
252
  platform: Platform.OS,
127
253
  nativeModuleAvailable: true,
128
- manufacturer: jsManufacturer(),
129
- isSamsung: false,
254
+ manufacturer,
255
+ oemFamily,
256
+ isSamsung: oemFamily === "samsung",
130
257
  ignoringBatteryOptimizations: null,
131
258
  neverSleepingApps: buildNeverSleeping({
132
- isSamsung: false,
259
+ applicable: false,
133
260
  userConfirmed: null,
134
261
  settingsScreenAvailable: false,
262
+ oemFamily: "none",
263
+ label: null,
264
+ target: null,
135
265
  }),
136
266
  error: error?.message || "getBackgroundSettingsStatus failed",
137
267
  checkedAt,
@@ -157,20 +287,30 @@ export async function isIgnoringBatteryOptimizations() {
157
287
  }
158
288
 
159
289
  /**
160
- * Open Samsung's "Never sleeping apps" screen.
161
- * Resolves false when the device is not Samsung or the screen is unavailable
162
- * (callers can then fall back to openBatteryOptimizationSettings()).
290
+ * Open this device's OEM background-allowlist screen (Samsung Never sleeping
291
+ * apps, Oppo/OnePlus Startup manager, Vivo Background startup, Xiaomi
292
+ * Autostart, …). Does NOT fall back to generic Android screens — use
293
+ * openBackgroundRestrictionSettings() or openBatteryOptimizationSettings()
294
+ * for that.
295
+ *
296
+ * Never rejects. Resolves:
297
+ * { opened, target, isOemScreen, manufacturer, oemFamily }
163
298
  */
164
299
  export async function openNeverSleepingApps() {
300
+ const fallback = emptyOpenResult(
301
+ jsManufacturer(),
302
+ detectOemFamilyFromVendor(jsManufacturer(), jsBrand())
303
+ );
165
304
  const native = getNative();
166
305
  if (!native?.openNeverSleepingApps) {
167
- return false;
306
+ return fallback;
168
307
  }
169
308
  try {
170
- return !!(await native.openNeverSleepingApps());
309
+ const raw = await native.openNeverSleepingApps();
310
+ return normalizeOpenResult(raw, fallback.manufacturer);
171
311
  } catch (error) {
172
312
  getLogger().warn("openNeverSleepingApps failed:", error?.message);
173
- return false;
313
+ return fallback;
174
314
  }
175
315
  }
176
316
 
@@ -179,24 +319,24 @@ export async function openNeverSleepingApps() {
179
319
  * device — works on every Android device, not just Samsung.
180
320
  *
181
321
  * Order tried natively: manufacturer-specific screen (Samsung, Xiaomi, Huawei /
182
- * Honor, Oppo / Realme / OnePlus, Vivo / iQOO, Asus, Nokia, Letv) ->
322
+ * Honor, Oppo / Realme / OnePlus, Vivo / iQOO, Asus, Nokia, Letv, Meizu,
323
+ * Motorola) ->
183
324
  * Android "Optimize battery usage" list -> this app's "App info" page.
184
325
  *
185
326
  * OEM screens are undocumented and vary by model / OS version, so they are
186
327
  * best-effort. Nothing here can verify the app was added to any list.
187
328
  *
188
329
  * Never rejects. Resolves:
189
- * { opened, target, isOemScreen, manufacturer }
330
+ * { opened, target, isOemScreen, manufacturer, oemFamily }
190
331
  * `target` is e.g. "samsung_never_sleeping", "xiaomi_autostart",
332
+ * "coloros_startup_manager", "vivo_background_startup",
191
333
  * "battery_optimization", "app_details", or "none".
192
334
  */
193
335
  export async function openBackgroundRestrictionSettings() {
194
- const fallback = {
195
- opened: false,
196
- target: "none",
197
- isOemScreen: false,
198
- manufacturer: jsManufacturer(),
199
- };
336
+ const fallback = emptyOpenResult(
337
+ jsManufacturer(),
338
+ detectOemFamilyFromVendor(jsManufacturer(), jsBrand())
339
+ );
200
340
  const native = getNative();
201
341
  if (!native?.openBackgroundRestrictionSettings) {
202
342
  if (Platform.OS === "android") {
@@ -208,12 +348,7 @@ export async function openBackgroundRestrictionSettings() {
208
348
  }
209
349
  try {
210
350
  const raw = await native.openBackgroundRestrictionSettings();
211
- return {
212
- opened: !!raw?.opened,
213
- target: raw?.target || "none",
214
- isOemScreen: !!raw?.isOemScreen,
215
- manufacturer: raw?.manufacturer || fallback.manufacturer,
216
- };
351
+ return normalizeOpenResult(raw, fallback.manufacturer);
217
352
  } catch (error) {
218
353
  getLogger().warn("openBackgroundRestrictionSettings failed:", error?.message);
219
354
  return fallback;
@@ -237,7 +372,7 @@ export async function openBatteryOptimizationSettings() {
237
372
  }
238
373
 
239
374
  /**
240
- * Record what the user says about the Never sleeping apps list
375
+ * Record what the user says about the OEM background-allowlist screen
241
376
  * (persisted natively). Pass `null` to clear. This does NOT verify anything.
242
377
  */
243
378
  export async function setNeverSleepingAppsConfirmed(confirmed) {
package/src/index.d.ts CHANGED
@@ -44,11 +44,28 @@ export interface SystemHealthResult {
44
44
  backgroundTrackingRestricted: boolean;
45
45
  manufacturer: string | null;
46
46
  isSamsung: boolean;
47
+ /** OEM family used for background-allowlist navigation, or "none". */
48
+ oemFamily: OemFamily;
47
49
  /** Diagnostic only; does not affect device fitness. */
48
50
  neverSleepingApps: NeverSleepingAppsInfo | null;
49
51
  checkedAt: number;
50
52
  }
51
53
 
54
+ export type OemFamily =
55
+ | "none"
56
+ | "samsung"
57
+ | "xiaomi"
58
+ | "huawei"
59
+ | "oppo"
60
+ | "realme"
61
+ | "oneplus"
62
+ | "vivo"
63
+ | "asus"
64
+ | "nokia"
65
+ | "letv"
66
+ | "meizu"
67
+ | "motorola";
68
+
52
69
  export type NeverSleepingState =
53
70
  | "not_applicable"
54
71
  | "unverified"
@@ -56,15 +73,24 @@ export type NeverSleepingState =
56
73
  | "user_reported_missing";
57
74
 
58
75
  export interface NeverSleepingAppsInfo {
59
- /** True only on Samsung Android devices. */
76
+ /**
77
+ * True on OEMs that ship a dedicated background-allowlist screen
78
+ * (Samsung, Xiaomi, Huawei/Honor, Oppo/Realme/OnePlus, Vivo/iQOO, …).
79
+ */
60
80
  applicable: boolean;
61
- /** Always false: Samsung exposes no public API to read the list. */
81
+ /** Always false: no OEM exposes a public API to read the list. */
62
82
  verifiable: false;
63
83
  state: NeverSleepingState;
64
84
  /** What the user reported (self-reported, NOT verified). */
65
85
  userConfirmed: boolean | null;
66
- /** Whether Samsung's Never sleeping apps screen can be opened. */
86
+ /** Whether a known OEM allowlist screen can be opened on this device. */
67
87
  settingsScreenAvailable: boolean;
88
+ /** Detected OEM family, or "none". */
89
+ oemFamily: OemFamily;
90
+ /** Human label for the OEM screen (e.g. "Never sleeping apps", "Startup manager"). */
91
+ label: string | null;
92
+ /** First resolvable OEM target id, if any (e.g. "samsung_never_sleeping"). */
93
+ target: string | null;
68
94
  note: string;
69
95
  }
70
96
 
@@ -76,6 +102,8 @@ export interface BackgroundSettingsStatus {
76
102
  model?: string | null;
77
103
  sdkInt?: number | null;
78
104
  isSamsung: boolean;
105
+ /** OEM family used for background-allowlist navigation, or "none". */
106
+ oemFamily: OemFamily;
79
107
  /** Verified via PowerManager. null when it cannot be determined. */
80
108
  ignoringBatteryOptimizations: boolean | null;
81
109
  neverSleepingApps: NeverSleepingAppsInfo;
@@ -185,7 +213,7 @@ export interface ConfigureOptions {
185
213
  | ((
186
214
  title: string,
187
215
  message: string,
188
- options?: Record<string, unknown>
216
+ options?: Record<string, unknown>,
189
217
  ) => void | Promise<void>)
190
218
  | null;
191
219
  persistAlert?: ((alert: TrackingQualityAlert) => void) | null;
@@ -224,24 +252,32 @@ export declare const NEVER_SLEEPING_STATE: {
224
252
  USER_CONFIRMED: "user_confirmed";
225
253
  USER_REPORTED_MISSING: "user_reported_missing";
226
254
  };
227
- /** Battery optimization (verified) + Samsung Never sleeping apps (unverifiable). */
255
+ /** Battery optimization (verified) + OEM background allowlist (unverifiable). */
228
256
  export declare function getBackgroundSettingsStatus(): Promise<BackgroundSettingsStatus>;
229
257
  /** Android "Ignore battery optimizations". null when undeterminable. */
230
- export declare function isIgnoringBatteryOptimizations(): Promise<boolean | null>;
231
- /** Opens Samsung's Never sleeping apps screen. false if unavailable / not Samsung. */
232
- export declare function openNeverSleepingApps(): Promise<boolean>;
258
+ export declare function isIgnoringBatteryOptimizations(): Promise<
259
+ boolean | null
260
+ >;
261
+ /**
262
+ * Opens this device's OEM background-allowlist screen only (Samsung Never
263
+ * sleeping, Oppo/OnePlus Startup manager, Vivo Background startup, …).
264
+ * Does not fall back to generic Android screens. Never rejects.
265
+ */
266
+ export declare function openNeverSleepingApps(): Promise<OpenBackgroundRestrictionResult>;
233
267
  export interface OpenBackgroundRestrictionResult {
234
268
  /** true when some settings screen was started. */
235
269
  opened: boolean;
236
270
  /**
237
271
  * Which screen opened, e.g. "samsung_never_sleeping", "xiaomi_autostart",
238
- * "huawei_startup_manager", "coloros_startup_manager", "vivo_background_startup",
239
- * "battery_optimization", "app_details", or "none".
272
+ * "huawei_startup_manager", "coloros_startup_manager", "oplus_startup_manager",
273
+ * "vivo_background_startup", "battery_optimization", "app_details", or "none".
240
274
  */
241
275
  target: string;
242
276
  /** true for a manufacturer-specific screen, false for the universal fallbacks. */
243
277
  isOemScreen: boolean;
244
278
  manufacturer: string | null;
279
+ /** OEM family used to pick the screen, or "none". */
280
+ oemFamily: OemFamily;
245
281
  }
246
282
  /**
247
283
  * Opens the best background / autostart / never-sleeping screen for this
@@ -252,10 +288,19 @@ export interface OpenBackgroundRestrictionResult {
252
288
  export declare function openBackgroundRestrictionSettings(): Promise<OpenBackgroundRestrictionResult>;
253
289
  /** Opens Android's "Optimize battery usage" list. false on failure. */
254
290
  export declare function openBatteryOptimizationSettings(): Promise<boolean>;
255
- /** Persist what the user reports about the list (null clears). Not verification. */
291
+ /** Persist what the user reports about the OEM allowlist (null clears). Not verification. */
256
292
  export declare function setNeverSleepingAppsConfirmed(
257
- confirmed: boolean | null
293
+ confirmed: boolean | null,
258
294
  ): Promise<boolean>;
295
+ /** Best-effort OEM family from manufacturer/brand strings. */
296
+ export declare function detectOemFamilyFromVendor(
297
+ manufacturer?: string | null,
298
+ brand?: string | null,
299
+ ): OemFamily;
300
+ /** Human label for an OEM allowlist screen, or null when oemFamily is "none". */
301
+ export declare function oemRestrictionLabelForFamily(
302
+ oemFamily: OemFamily | string,
303
+ ): string | null;
259
304
  export declare function assessDeviceFitness(options?: {
260
305
  apiLevel?: number | null;
261
306
  systemHealth?: SystemHealthResult | null;
@@ -263,7 +308,7 @@ export declare function assessDeviceFitness(options?: {
263
308
  }): DeviceFitnessResult;
264
309
  export declare function getAndroidApiLevel(): number | null;
265
310
  export declare function getGnssCapabilityProfile(
266
- apiLevel: number | null
311
+ apiLevel: number | null,
267
312
  ): Record<string, unknown>;
268
313
  export declare function scoreApiLevel(apiLevel: number | null): {
269
314
  score: string;
@@ -283,7 +328,9 @@ export declare function getTimeDifferenceInMinutes(options?: {
283
328
  thresholdMinutes?: number;
284
329
  }): Promise<boolean | null>;
285
330
 
286
- export declare function normalizeLocation(raw: unknown): NormalizedLocation | null;
331
+ export declare function normalizeLocation(
332
+ raw: unknown,
333
+ ): NormalizedLocation | null;
287
334
 
288
335
  export declare const ALERT_TYPES: Record<string, string>;
289
336
  export declare const ALERT_SEVERITY: Record<string, AlertSeverity>;
@@ -468,9 +515,7 @@ export declare function useTimeValidation(options?: {
468
515
  badTimeOrTimezone: boolean;
469
516
  };
470
517
 
471
- export declare function useTrackingQualityAlerts(options?: {
472
- max?: number;
473
- }): {
518
+ export declare function useTrackingQualityAlerts(options?: { max?: number }): {
474
519
  alerts: TrackingQualityAlert[];
475
520
  lastAlert: TrackingQualityAlert | null;
476
521
  };
package/src/index.js CHANGED
@@ -18,6 +18,8 @@ import {
18
18
  openBackgroundRestrictionSettings,
19
19
  openBatteryOptimizationSettings,
20
20
  setNeverSleepingAppsConfirmed,
21
+ detectOemFamilyFromVendor,
22
+ oemRestrictionLabelForFamily,
21
23
  } from "./backgroundSettings";
22
24
  import {
23
25
  assessDeviceFitness,
@@ -64,7 +66,7 @@ export {
64
66
  GnssMonitorClass,
65
67
  // Independent modules
66
68
  collectSystemHealth,
67
- // Background restrictions (battery optimization + Samsung Never sleeping apps)
69
+ // Background restrictions (battery optimization + OEM allowlists)
68
70
  NEVER_SLEEPING_STATE,
69
71
  getBackgroundSettingsStatus,
70
72
  isIgnoringBatteryOptimizations,
@@ -72,6 +74,8 @@ export {
72
74
  openBackgroundRestrictionSettings,
73
75
  openBatteryOptimizationSettings,
74
76
  setNeverSleepingAppsConfirmed,
77
+ detectOemFamilyFromVendor,
78
+ oemRestrictionLabelForFamily,
75
79
  assessDeviceFitness,
76
80
  getAndroidApiLevel,
77
81
  getGnssCapabilityProfile,
@@ -79,10 +79,11 @@ export async function collectSystemHealth() {
79
79
  safe(() => getBackgroundSettingsStatus(), null),
80
80
  ]);
81
81
 
82
+ // Only treat explicit power-save / Low Power Mode as LPM.
83
+ // Do NOT use batteryState === "unknown" — DeviceInfo often reports that on
84
+ // Android when charging state is unavailable, which is not battery saver.
82
85
  const lowPowerMode =
83
- !!powerSaveMode ||
84
- powerState?.lowPowerMode === true ||
85
- powerState?.batteryState === "unknown";
86
+ !!powerSaveMode || powerState?.lowPowerMode === true;
86
87
 
87
88
  const backgroundTrackingRestricted =
88
89
  Platform.OS === "android" && batteryOptimizationIgnored === false;
@@ -109,6 +110,7 @@ export async function collectSystemHealth() {
109
110
  backgroundTrackingRestricted,
110
111
  manufacturer: backgroundSettings?.manufacturer ?? null,
111
112
  isSamsung: !!backgroundSettings?.isSamsung,
113
+ oemFamily: backgroundSettings?.oemFamily ?? "none",
112
114
  // Diagnostic only: never feeds device fitness (cannot be verified).
113
115
  neverSleepingApps: backgroundSettings?.neverSleepingApps ?? null,
114
116
  checkedAt: Date.now(),