@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.
@@ -6,6 +6,7 @@ import android.content.ComponentName;
6
6
  import android.content.Context;
7
7
  import android.content.Intent;
8
8
  import android.content.SharedPreferences;
9
+ import android.content.pm.PackageManager;
9
10
  import android.net.Uri;
10
11
  import android.os.Build;
11
12
  import android.os.PowerManager;
@@ -30,10 +31,13 @@ import java.util.Locale;
30
31
  * 1. Android "Ignore battery optimizations" (Doze allowlist)
31
32
  * -> verifiable via PowerManager.isIgnoringBatteryOptimizations().
32
33
  *
33
- * 2. Samsung "Never sleeping apps" (One UI Device Care)
34
- * -> Samsung documents an intent to OPEN the screen, but exposes no
35
- * public API to READ whether this app is on the list. We therefore
36
- * never claim it as verified; we only remember what the user told us.
34
+ * 2. OEM "keep running / autostart / never sleeping" allowlists
35
+ * (Samsung Never sleeping apps, Xiaomi Autostart, Huawei Startup manager,
36
+ * Oppo/Realme/OnePlus Startup manager, Vivo/iQOO Background startup, …)
37
+ * -> OEMs document (or leak) intents to OPEN these screens, but none expose
38
+ * a public API to READ whether this app is on the list. We therefore
39
+ * never claim membership as verified; we only remember what the user
40
+ * told us via setNeverSleepingAppsConfirmed().
37
41
  *
38
42
  * Automatic date/time lives in a separate package:
39
43
  * {@link com.gnsstrackinghealth.autodatetime.AutoDateTimeModule}.
@@ -56,6 +60,21 @@ public class GnssTrackingHealthSettingsModule extends ReactContextBaseJavaModule
56
60
  private static final String SAMSUNG_EXTRA_ACTIVITY_TYPE = "activity_type";
57
61
  private static final int SAMSUNG_ACTIVITY_NEVER_SLEEPING = 2;
58
62
 
63
+ /** OEM families that ship a dedicated background-allowlist screen. */
64
+ private static final String OEM_NONE = "none";
65
+ private static final String OEM_SAMSUNG = "samsung";
66
+ private static final String OEM_XIAOMI = "xiaomi";
67
+ private static final String OEM_HUAWEI = "huawei";
68
+ private static final String OEM_OPPO = "oppo";
69
+ private static final String OEM_REALME = "realme";
70
+ private static final String OEM_ONEPLUS = "oneplus";
71
+ private static final String OEM_VIVO = "vivo";
72
+ private static final String OEM_ASUS = "asus";
73
+ private static final String OEM_NOKIA = "nokia";
74
+ private static final String OEM_LETV = "letv";
75
+ private static final String OEM_MEIZU = "meizu";
76
+ private static final String OEM_MOTOROLA = "motorola";
77
+
59
78
  public GnssTrackingHealthSettingsModule(ReactApplicationContext reactContext) {
60
79
  super(reactContext);
61
80
  }
@@ -71,21 +90,35 @@ public class GnssTrackingHealthSettingsModule extends ReactContextBaseJavaModule
71
90
 
72
91
  /**
73
92
  * Resolves a map with device info, the verifiable battery-optimization
74
- * flag, and the (unverifiable) Never sleeping apps context.
93
+ * flag, and the (unverifiable) OEM background-allowlist context.
75
94
  */
76
95
  @ReactMethod
77
96
  public void getBackgroundSettingsStatus(Promise promise) {
78
97
  try {
79
98
  WritableMap map = Arguments.createMap();
80
- boolean samsung = isSamsung();
99
+ String oemFamily = detectOemFamily();
100
+ boolean samsung = OEM_SAMSUNG.equals(oemFamily);
101
+ SettingsTarget oemScreen = findFirstResolvableOemTarget();
81
102
 
82
103
  map.putString("manufacturer", Build.MANUFACTURER);
83
104
  map.putString("brand", Build.BRAND);
84
105
  map.putString("model", Build.MODEL);
85
106
  map.putInt("sdkInt", Build.VERSION.SDK_INT);
86
107
  map.putBoolean("isSamsung", samsung);
108
+ map.putString("oemFamily", oemFamily);
109
+ map.putBoolean("oemRestrictionApplicable", !OEM_NONE.equals(oemFamily));
110
+ if (OEM_NONE.equals(oemFamily)) {
111
+ map.putNull("oemRestrictionLabel");
112
+ } else {
113
+ map.putString("oemRestrictionLabel", oemRestrictionLabel(oemFamily));
114
+ }
87
115
  map.putBoolean("ignoringBatteryOptimizations", isIgnoringBatteryOptimizationsInternal());
88
- map.putBoolean("neverSleepingScreenAvailable", isNeverSleepingScreenAvailable());
116
+ map.putBoolean("neverSleepingScreenAvailable", oemScreen != null);
117
+ if (oemScreen != null) {
118
+ map.putString("oemRestrictionTarget", oemScreen.id);
119
+ } else {
120
+ map.putNull("oemRestrictionTarget");
121
+ }
89
122
 
90
123
  SharedPreferences prefs = prefs();
91
124
  if (prefs.contains(KEY_NEVER_SLEEPING_CONFIRMED)) {
@@ -116,17 +149,36 @@ public class GnssTrackingHealthSettingsModule extends ReactContextBaseJavaModule
116
149
  // ---------------------------------------------------------------------
117
150
 
118
151
  /**
119
- * Opens Samsung's "Never sleeping apps" list. Resolves false when the
120
- * device is not Samsung or the screen cannot be opened.
152
+ * Opens this device's OEM background-allowlist screen (Samsung Never
153
+ * sleeping apps, Oppo/OnePlus Startup manager, Vivo Background startup,
154
+ * Xiaomi Autostart, …). Resolves false when the OEM has no such screen
155
+ * or none of the known activities can be started.
156
+ *
157
+ * Unlike {@link #openBackgroundRestrictionSettings}, this never falls
158
+ * back to the generic Android battery-optimization / app-info screens —
159
+ * callers that want those should use openBackgroundRestrictionSettings
160
+ * or openBatteryOptimizationSettings.
121
161
  */
122
162
  @ReactMethod
123
163
  public void openNeverSleepingApps(Promise promise) {
124
164
  try {
125
- if (!isSamsung()) {
126
- promise.resolve(false);
165
+ WritableMap result = Arguments.createMap();
166
+ result.putString("manufacturer", Build.MANUFACTURER);
167
+ result.putString("oemFamily", detectOemFamily());
168
+
169
+ SettingsTarget oemScreen = findFirstResolvableOemTarget();
170
+ if (oemScreen != null && launch(oemScreen.intent)) {
171
+ result.putBoolean("opened", true);
172
+ result.putString("target", oemScreen.id);
173
+ result.putBoolean("isOemScreen", true);
174
+ promise.resolve(result);
127
175
  return;
128
176
  }
129
- promise.resolve(launch(neverSleepingIntent()));
177
+
178
+ result.putBoolean("opened", false);
179
+ result.putString("target", "none");
180
+ result.putBoolean("isOemScreen", false);
181
+ promise.resolve(result);
130
182
  } catch (Exception e) {
131
183
  promise.reject("OPEN_SETTINGS_FAILED", e);
132
184
  }
@@ -138,22 +190,24 @@ public class GnssTrackingHealthSettingsModule extends ReactContextBaseJavaModule
138
190
  *
139
191
  * 1. Manufacturer-specific screen (Samsung Never sleeping apps, Xiaomi
140
192
  * Autostart, Huawei/Honor Startup manager, Oppo/Realme/OnePlus
141
- * Startup manager, Vivo/iQOO Background startup, Asus, Nokia, Letv).
193
+ * Startup manager, Vivo/iQOO Background startup, Asus, Nokia, Letv,
194
+ * Meizu, Motorola).
142
195
  * 2. Android "Optimize battery usage" list (all devices).
143
196
  * 3. This app's system "App info" page (all devices).
144
197
  *
145
198
  * OEM activities are undocumented and change between OS versions, so each
146
199
  * is tried and skipped if it cannot be started. Resolves
147
- * {opened, target, isOemScreen, manufacturer}; never claims the app was
148
- * added to any list (no OEM exposes a way to read that).
200
+ * {opened, target, isOemScreen, manufacturer, oemFamily}; never claims
201
+ * the app was added to any list (no OEM exposes a way to read that).
149
202
  */
150
203
  @ReactMethod
151
204
  public void openBackgroundRestrictionSettings(Promise promise) {
152
205
  try {
153
206
  WritableMap result = Arguments.createMap();
154
207
  result.putString("manufacturer", Build.MANUFACTURER);
208
+ result.putString("oemFamily", detectOemFamily());
155
209
 
156
- for (SettingsTarget target : buildSettingsTargets()) {
210
+ for (SettingsTarget target : buildSettingsTargets(/* oemOnly */ false)) {
157
211
  if (launch(target.intent)) {
158
212
  result.putBoolean("opened", true);
159
213
  result.putString("target", target.id);
@@ -185,7 +239,7 @@ public class GnssTrackingHealthSettingsModule extends ReactContextBaseJavaModule
185
239
  }
186
240
 
187
241
  // ---------------------------------------------------------------------
188
- // User confirmation (Samsung exposes no way to read the list)
242
+ // User confirmation (OEMs expose no way to read the list)
189
243
  // ---------------------------------------------------------------------
190
244
 
191
245
  @ReactMethod
@@ -212,8 +266,87 @@ public class GnssTrackingHealthSettingsModule extends ReactContextBaseJavaModule
212
266
  // Internals
213
267
  // ---------------------------------------------------------------------
214
268
 
215
- private boolean isSamsung() {
216
- return "samsung".equalsIgnoreCase(Build.MANUFACTURER);
269
+ private String vendorBlob() {
270
+ return (Build.MANUFACTURER + " " + Build.BRAND).toLowerCase(Locale.ROOT);
271
+ }
272
+
273
+ /**
274
+ * Best-effort OEM family from manufacturer/brand. Used for labels and to
275
+ * decide whether the OEM-allowlist flow is applicable. Detection is
276
+ * independent of whether a known activity currently resolves.
277
+ */
278
+ private String detectOemFamily() {
279
+ String vendor = vendorBlob();
280
+ if (vendor.contains("samsung")) {
281
+ return OEM_SAMSUNG;
282
+ }
283
+ if (vendor.contains("xiaomi") || vendor.contains("redmi") || vendor.contains("poco")) {
284
+ return OEM_XIAOMI;
285
+ }
286
+ if (vendor.contains("huawei") || vendor.contains("honor")) {
287
+ return OEM_HUAWEI;
288
+ }
289
+ // OnePlus / Realme before generic Oppo — they share ColorOS/Oplus screens
290
+ // but we still surface the specific brand in status.
291
+ if (vendor.contains("oneplus")) {
292
+ return OEM_ONEPLUS;
293
+ }
294
+ if (vendor.contains("realme")) {
295
+ return OEM_REALME;
296
+ }
297
+ if (vendor.contains("oppo")) {
298
+ return OEM_OPPO;
299
+ }
300
+ if (vendor.contains("vivo") || vendor.contains("iqoo")) {
301
+ return OEM_VIVO;
302
+ }
303
+ if (vendor.contains("asus")) {
304
+ return OEM_ASUS;
305
+ }
306
+ if (vendor.contains("nokia") || vendor.contains("hmd")) {
307
+ return OEM_NOKIA;
308
+ }
309
+ if (vendor.contains("letv") || vendor.contains("leeco")) {
310
+ return OEM_LETV;
311
+ }
312
+ if (vendor.contains("meizu")) {
313
+ return OEM_MEIZU;
314
+ }
315
+ // Motorola / Moto (Lenovo-owned). Near-stock Android; some builds still
316
+ // ship Lenovo security / pure-background screens.
317
+ if (vendor.contains("motorola") || vendor.contains("moto")) {
318
+ return OEM_MOTOROLA;
319
+ }
320
+ return OEM_NONE;
321
+ }
322
+
323
+ private static String oemRestrictionLabel(String oemFamily) {
324
+ switch (oemFamily) {
325
+ case OEM_SAMSUNG:
326
+ return "Never sleeping apps";
327
+ case OEM_XIAOMI:
328
+ return "Autostart / Battery saver";
329
+ case OEM_HUAWEI:
330
+ return "Startup manager / App launch";
331
+ case OEM_OPPO:
332
+ case OEM_REALME:
333
+ case OEM_ONEPLUS:
334
+ return "Startup manager";
335
+ case OEM_VIVO:
336
+ return "Background startup / Whitelist";
337
+ case OEM_ASUS:
338
+ return "Auto-start manager";
339
+ case OEM_NOKIA:
340
+ return "Power saver exceptions";
341
+ case OEM_LETV:
342
+ return "Autoboot manager";
343
+ case OEM_MEIZU:
344
+ return "Background management";
345
+ case OEM_MOTOROLA:
346
+ return "Battery optimization / Background apps";
347
+ default:
348
+ return "Background restrictions";
349
+ }
217
350
  }
218
351
 
219
352
  private boolean isIgnoringBatteryOptimizationsInternal() {
@@ -232,16 +365,18 @@ public class GnssTrackingHealthSettingsModule extends ReactContextBaseJavaModule
232
365
  return intent;
233
366
  }
234
367
 
235
- private boolean isNeverSleepingScreenAvailable() {
236
- if (!isSamsung()) {
237
- return false;
238
- }
239
- try {
240
- return neverSleepingIntent()
241
- .resolveActivity(getReactApplicationContext().getPackageManager()) != null;
242
- } catch (RuntimeException e) {
243
- return false;
368
+ private SettingsTarget findFirstResolvableOemTarget() {
369
+ PackageManager pm = getReactApplicationContext().getPackageManager();
370
+ for (SettingsTarget target : buildSettingsTargets(/* oemOnly */ true)) {
371
+ try {
372
+ if (target.intent.resolveActivity(pm) != null) {
373
+ return target;
374
+ }
375
+ } catch (RuntimeException ignored) {
376
+ // Keep looking.
377
+ }
244
378
  }
379
+ return null;
245
380
  }
246
381
 
247
382
  /** Starts the intent from the foreground activity when possible. */
@@ -285,142 +420,212 @@ public class GnssTrackingHealthSettingsModule extends ReactContextBaseJavaModule
285
420
 
286
421
  /**
287
422
  * Ordered list of screens to try. Only the current manufacturer's OEM
288
- * screens are included, followed by the universal Android fallbacks.
423
+ * screens are included; when {@code oemOnly} is false the universal
424
+ * Android fallbacks are appended.
289
425
  */
290
- private List<SettingsTarget> buildSettingsTargets() {
426
+ private List<SettingsTarget> buildSettingsTargets(boolean oemOnly) {
291
427
  ReactApplicationContext context = getReactApplicationContext();
292
428
  String appPackage = context.getPackageName();
293
- String vendor = (Build.MANUFACTURER + " " + Build.BRAND).toLowerCase(Locale.ROOT);
429
+ String oemFamily = detectOemFamily();
294
430
  List<SettingsTarget> targets = new ArrayList<>();
295
431
 
296
- if (isSamsung()) {
297
- targets.add(new SettingsTarget("samsung_never_sleeping", neverSleepingIntent(), true));
298
- targets.add(new SettingsTarget(
299
- "samsung_battery",
300
- component("com.samsung.android.lool",
301
- "com.samsung.android.sm.battery.ui.BatteryActivity"),
302
- true));
303
- targets.add(new SettingsTarget(
304
- "samsung_battery_legacy",
305
- component("com.samsung.android.lool",
306
- "com.samsung.android.sm.ui.battery.BatteryActivity"),
307
- true));
308
- }
309
-
310
- if (vendor.contains("xiaomi") || vendor.contains("redmi") || vendor.contains("poco")) {
311
- CharSequence label = context.getPackageManager()
312
- .getApplicationLabel(context.getApplicationInfo());
313
- Intent powerKeeper = component("com.miui.powerkeeper",
314
- "com.miui.powerkeeper.ui.HiddenAppsConfigActivity");
315
- powerKeeper.putExtra("package_name", appPackage);
316
- powerKeeper.putExtra("package_label", label == null ? appPackage : label.toString());
317
- targets.add(new SettingsTarget("xiaomi_battery_saver_app", powerKeeper, true));
318
- targets.add(new SettingsTarget(
319
- "xiaomi_autostart",
320
- component("com.miui.securitycenter",
321
- "com.miui.permcenter.autostart.AutoStartManagementActivity"),
322
- true));
323
- }
324
-
325
- if (vendor.contains("huawei") || vendor.contains("honor")) {
326
- targets.add(new SettingsTarget(
327
- "huawei_startup_manager",
328
- component("com.huawei.systemmanager",
329
- "com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity"),
330
- true));
331
- targets.add(new SettingsTarget(
332
- "huawei_app_launch",
333
- component("com.huawei.systemmanager",
334
- "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity"),
335
- true));
336
- targets.add(new SettingsTarget(
337
- "huawei_protected_apps",
338
- component("com.huawei.systemmanager",
339
- "com.huawei.systemmanager.optimize.process.ProtectActivity"),
340
- true));
432
+ switch (oemFamily) {
433
+ case OEM_SAMSUNG:
434
+ targets.add(new SettingsTarget("samsung_never_sleeping", neverSleepingIntent(), true));
435
+ targets.add(new SettingsTarget(
436
+ "samsung_battery",
437
+ component("com.samsung.android.lool",
438
+ "com.samsung.android.sm.battery.ui.BatteryActivity"),
439
+ true));
440
+ targets.add(new SettingsTarget(
441
+ "samsung_battery_legacy",
442
+ component("com.samsung.android.lool",
443
+ "com.samsung.android.sm.ui.battery.BatteryActivity"),
444
+ true));
445
+ break;
446
+
447
+ case OEM_XIAOMI:
448
+ CharSequence label = context.getPackageManager()
449
+ .getApplicationLabel(context.getApplicationInfo());
450
+ Intent powerKeeper = component("com.miui.powerkeeper",
451
+ "com.miui.powerkeeper.ui.HiddenAppsConfigActivity");
452
+ powerKeeper.putExtra("package_name", appPackage);
453
+ powerKeeper.putExtra("package_label", label == null ? appPackage : label.toString());
454
+ targets.add(new SettingsTarget("xiaomi_battery_saver_app", powerKeeper, true));
455
+ targets.add(new SettingsTarget(
456
+ "xiaomi_autostart",
457
+ component("com.miui.securitycenter",
458
+ "com.miui.permcenter.autostart.AutoStartManagementActivity"),
459
+ true));
460
+ break;
461
+
462
+ case OEM_HUAWEI:
463
+ targets.add(new SettingsTarget(
464
+ "huawei_startup_manager",
465
+ component("com.huawei.systemmanager",
466
+ "com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity"),
467
+ true));
468
+ targets.add(new SettingsTarget(
469
+ "huawei_app_launch",
470
+ component("com.huawei.systemmanager",
471
+ "com.huawei.systemmanager.appcontrol.activity.StartupAppControlActivity"),
472
+ true));
473
+ targets.add(new SettingsTarget(
474
+ "huawei_protected_apps",
475
+ component("com.huawei.systemmanager",
476
+ "com.huawei.systemmanager.optimize.process.ProtectActivity"),
477
+ true));
478
+ break;
479
+
480
+ case OEM_OPPO:
481
+ case OEM_REALME:
482
+ case OEM_ONEPLUS:
483
+ // ColorOS / OxygenOS / newer Oplus builds share these screens.
484
+ // Prefer newer com.oplus.* packages, then legacy ColorOS / Oppo /
485
+ // OnePlus security packages.
486
+ targets.add(new SettingsTarget(
487
+ "oplus_startup_manager",
488
+ component("com.oplus.safecenter",
489
+ "com.oplus.safecenter.permission.startup.StartupAppListActivity"),
490
+ true));
491
+ targets.add(new SettingsTarget(
492
+ "oplus_startup_manager_alt",
493
+ component("com.oplus.safecenter",
494
+ "com.oplus.safecenter.startupapp.StartupAppListActivity"),
495
+ true));
496
+ targets.add(new SettingsTarget(
497
+ "coloros_startup_manager",
498
+ component("com.coloros.safecenter",
499
+ "com.coloros.safecenter.permission.startup.StartupAppListActivity"),
500
+ true));
501
+ targets.add(new SettingsTarget(
502
+ "coloros_startup_manager_alt",
503
+ component("com.coloros.safecenter",
504
+ "com.coloros.safecenter.startupapp.StartupAppListActivity"),
505
+ true));
506
+ targets.add(new SettingsTarget(
507
+ "oppo_startup_manager_legacy",
508
+ component("com.oppo.safe",
509
+ "com.oppo.safe.permission.startup.StartupAppListActivity"),
510
+ true));
511
+ targets.add(new SettingsTarget(
512
+ "oneplus_chain_launch",
513
+ component("com.oneplus.security",
514
+ "com.oneplus.security.chainlaunch.view.ChainLaunchAppListActivity"),
515
+ true));
516
+ targets.add(new SettingsTarget(
517
+ "oplus_battery",
518
+ component("com.oplus.battery",
519
+ "com.oplus.powermanager.fuelgaue.PowerConsumptionActivity"),
520
+ true));
521
+ targets.add(new SettingsTarget(
522
+ "coloros_battery",
523
+ component("com.coloros.oppoguardelf",
524
+ "com.coloros.powermanager.fuelgaue.PowerUsageModelActivity"),
525
+ true));
526
+ break;
527
+
528
+ case OEM_VIVO:
529
+ targets.add(new SettingsTarget(
530
+ "vivo_background_startup",
531
+ component("com.vivo.permissionmanager",
532
+ "com.vivo.permissionmanager.activity.BgStartUpManagerActivity"),
533
+ true));
534
+ targets.add(new SettingsTarget(
535
+ "vivo_whitelist",
536
+ component("com.iqoo.secure",
537
+ "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity"),
538
+ true));
539
+ targets.add(new SettingsTarget(
540
+ "vivo_background_startup_alt",
541
+ component("com.iqoo.secure",
542
+ "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager"),
543
+ true));
544
+ targets.add(new SettingsTarget(
545
+ "vivo_high_power",
546
+ component("com.vivo.abe",
547
+ "com.vivo.applicationbehaviorengine.ui.ExcessivePowerManagerActivity"),
548
+ true));
549
+ break;
550
+
551
+ case OEM_ASUS:
552
+ targets.add(new SettingsTarget(
553
+ "asus_autostart",
554
+ component("com.asus.mobilemanager",
555
+ "com.asus.mobilemanager.autostart.AutoStartActivity"),
556
+ true));
557
+ targets.add(new SettingsTarget(
558
+ "asus_power_saver",
559
+ component("com.asus.mobilemanager",
560
+ "com.asus.mobilemanager.powersaver.PowerSaverSettings"),
561
+ true));
562
+ break;
563
+
564
+ case OEM_NOKIA:
565
+ targets.add(new SettingsTarget(
566
+ "nokia_power_saver",
567
+ component("com.evenwell.powersaving.g3",
568
+ "com.evenwell.powersaving.g3.exception.PowerSaverExceptionActivity"),
569
+ true));
570
+ break;
571
+
572
+ case OEM_LETV:
573
+ targets.add(new SettingsTarget(
574
+ "letv_autoboot",
575
+ component("com.letv.android.letvsafe",
576
+ "com.letv.android.letvsafe.AutobootManageActivity"),
577
+ true));
578
+ break;
579
+
580
+ case OEM_MEIZU:
581
+ targets.add(new SettingsTarget(
582
+ "meizu_smart_bg",
583
+ component("com.meizu.safe",
584
+ "com.meizu.safe.permission.SmartBGActivity"),
585
+ true));
586
+ targets.add(new SettingsTarget(
587
+ "meizu_security",
588
+ component("com.meizu.safe",
589
+ "com.meizu.safe.security.SHOW_APPSEC"),
590
+ true));
591
+ break;
592
+
593
+ case OEM_MOTOROLA:
594
+ // Some Lenovo-era / regional Motos expose these; most Motos are
595
+ // near-stock and only the system battery list applies.
596
+ targets.add(new SettingsTarget(
597
+ "lenovo_pure_background",
598
+ component("com.lenovo.security",
599
+ "com.lenovo.security.purebackground.PureBackgroundActivity"),
600
+ true));
601
+ targets.add(new SettingsTarget(
602
+ "lenovo_safecenter",
603
+ component("com.lenovo.safecenter",
604
+ "com.lenovo.safecenter.MainTab.LeSafeMainActivity"),
605
+ true));
606
+ targets.add(new SettingsTarget(
607
+ "motorola_battery_optimization",
608
+ new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS),
609
+ true));
610
+ break;
611
+
612
+ default:
613
+ break;
341
614
  }
342
615
 
343
- if (vendor.contains("oppo") || vendor.contains("realme") || vendor.contains("oneplus")) {
344
- targets.add(new SettingsTarget(
345
- "coloros_startup_manager",
346
- component("com.coloros.safecenter",
347
- "com.coloros.safecenter.permission.startup.StartupAppListActivity"),
348
- true));
616
+ if (!oemOnly) {
617
+ // Universal Android fallbacks (every device).
349
618
  targets.add(new SettingsTarget(
350
- "coloros_startup_manager_alt",
351
- component("com.coloros.safecenter",
352
- "com.coloros.safecenter.startupapp.StartupAppListActivity"),
353
- true));
619
+ "battery_optimization",
620
+ new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS),
621
+ false));
354
622
  targets.add(new SettingsTarget(
355
- "oppo_startup_manager_legacy",
356
- component("com.oppo.safe",
357
- "com.oppo.safe.permission.startup.StartupAppListActivity"),
358
- true));
359
- targets.add(new SettingsTarget(
360
- "oneplus_chain_launch",
361
- component("com.oneplus.security",
362
- "com.oneplus.security.chainlaunch.view.ChainLaunchAppListActivity"),
363
- true));
623
+ "app_details",
624
+ new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
625
+ Uri.parse("package:" + appPackage)),
626
+ false));
364
627
  }
365
628
 
366
- if (vendor.contains("vivo") || vendor.contains("iqoo")) {
367
- targets.add(new SettingsTarget(
368
- "vivo_background_startup",
369
- component("com.vivo.permissionmanager",
370
- "com.vivo.permissionmanager.activity.BgStartUpManagerActivity"),
371
- true));
372
- targets.add(new SettingsTarget(
373
- "vivo_whitelist",
374
- component("com.iqoo.secure",
375
- "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity"),
376
- true));
377
- targets.add(new SettingsTarget(
378
- "vivo_background_startup_alt",
379
- component("com.iqoo.secure",
380
- "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager"),
381
- true));
382
- }
383
-
384
- if (vendor.contains("asus")) {
385
- targets.add(new SettingsTarget(
386
- "asus_autostart",
387
- component("com.asus.mobilemanager",
388
- "com.asus.mobilemanager.autostart.AutoStartActivity"),
389
- true));
390
- targets.add(new SettingsTarget(
391
- "asus_power_saver",
392
- component("com.asus.mobilemanager",
393
- "com.asus.mobilemanager.powersaver.PowerSaverSettings"),
394
- true));
395
- }
396
-
397
- if (vendor.contains("nokia") || vendor.contains("hmd")) {
398
- targets.add(new SettingsTarget(
399
- "nokia_power_saver",
400
- component("com.evenwell.powersaving.g3",
401
- "com.evenwell.powersaving.g3.exception.PowerSaverExceptionActivity"),
402
- true));
403
- }
404
-
405
- if (vendor.contains("letv") || vendor.contains("leeco")) {
406
- targets.add(new SettingsTarget(
407
- "letv_autoboot",
408
- component("com.letv.android.letvsafe",
409
- "com.letv.android.letvsafe.AutobootManageActivity"),
410
- true));
411
- }
412
-
413
- // Universal Android fallbacks (every device).
414
- targets.add(new SettingsTarget(
415
- "battery_optimization",
416
- new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS),
417
- false));
418
- targets.add(new SettingsTarget(
419
- "app_details",
420
- new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
421
- Uri.parse("package:" + appPackage)),
422
- false));
423
-
424
629
  return targets;
425
630
  }
426
631
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mojro/react-native-gnss-tracking-health",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "GNSS coverage, device fitness, system health, and tracking-quality alerts for React Native. Accepts location traces from any tracking library; peer-depends on react-native-gnss-status-checker.",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -501,14 +501,21 @@ class TrackingQualityMonitor {
501
501
  });
502
502
  }
503
503
 
504
- if (health.powerSaveMode || health.lowPowerMode) {
504
+ // Alert only when OS power-save / Low Power Mode is explicitly on.
505
+ // `lowPowerMode` already includes `powerSaveMode`; keep both checks for
506
+ // hosts that set only one flag in a custom collectSystemHealth override.
507
+ if (health.powerSaveMode === true || health.lowPowerMode === true) {
505
508
  this.#raiseAlert({
506
509
  type: ALERT_TYPES.LOW_POWER_MODE,
507
510
  severity: ALERT_SEVERITY.WARNING,
508
511
  title: "Low power / battery saver on",
509
512
  message:
510
513
  "Power save mode can throttle GPS. Turn it off for accurate trip tracking.",
511
- meta: health,
514
+ meta: {
515
+ powerSaveMode: !!health.powerSaveMode,
516
+ lowPowerMode: !!health.lowPowerMode,
517
+ ...health,
518
+ },
512
519
  });
513
520
  }
514
521