@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.
- package/README.md +20 -14
- package/android/src/main/AndroidManifest.xml +10 -0
- package/android/src/main/java/com/gnsstrackinghealth/GnssTrackingHealthSettingsModule.java +358 -153
- package/package.json +1 -1
- package/src/TrackingQualityMonitor.js +9 -2
- package/src/backgroundSettings.js +175 -40
- package/src/index.d.ts +62 -17
- package/src/index.js +5 -1
- package/src/systemHealth.js +5 -3
|
@@ -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.
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
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)
|
|
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
|
-
|
|
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",
|
|
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
|
|
120
|
-
*
|
|
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
|
-
|
|
126
|
-
|
|
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
|
-
|
|
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
|
|
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 (
|
|
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
|
|
216
|
-
return "
|
|
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
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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
|
|
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
|
|
429
|
+
String oemFamily = detectOemFamily();
|
|
294
430
|
List<SettingsTarget> targets = new ArrayList<>();
|
|
295
431
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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 (
|
|
344
|
-
|
|
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
|
-
"
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
true));
|
|
619
|
+
"battery_optimization",
|
|
620
|
+
new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS),
|
|
621
|
+
false));
|
|
354
622
|
targets.add(new SettingsTarget(
|
|
355
|
-
"
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
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.
|
|
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
|
-
|
|
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:
|
|
514
|
+
meta: {
|
|
515
|
+
powerSaveMode: !!health.powerSaveMode,
|
|
516
|
+
lowPowerMode: !!health.lowPowerMode,
|
|
517
|
+
...health,
|
|
518
|
+
},
|
|
512
519
|
});
|
|
513
520
|
}
|
|
514
521
|
|