cordova.plugins.diagnostic 7.2.10 → 7.3.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/.specstory/.project.json +5 -6
- package/.specstory/cli/config.toml +82 -0
- package/.specstory/history/2026-05-08_15-16-55Z-implement-device-power-mode-features.md +67 -0
- package/.specstory/statistics.json +13 -0
- package/CHANGELOG.md +8 -0
- package/README.md +468 -372
- package/cordova.plugins.diagnostic.d.ts +43 -0
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/android/Diagnostic.java +84 -0
- package/src/ios/Diagnostic.h +2 -0
- package/src/ios/Diagnostic.m +26 -0
- package/src/ios/Diagnostic_Bluetooth.m +3 -1
- package/www/android/diagnostic.js +62 -1
- package/www/ios/diagnostic.js +27 -1
|
@@ -21,6 +21,7 @@ interface Diagnostic {
|
|
|
21
21
|
"ACCESS_BACKGROUND_LOCATION": "ACCESS_BACKGROUND_LOCATION";
|
|
22
22
|
"ACCESS_COARSE_LOCATION": "ACCESS_COARSE_LOCATION";
|
|
23
23
|
"ACCESS_FINE_LOCATION": "ACCESS_FINE_LOCATION";
|
|
24
|
+
"ACCESS_LOCAL_NETWORK": "ACCESS_LOCAL_NETWORK";
|
|
24
25
|
"ACCESS_MEDIA_LOCATION": "ACCESS_MEDIA_LOCATION";
|
|
25
26
|
"ACTIVITY_RECOGNITION": "ACTIVITY_RECOGNITION";
|
|
26
27
|
"ADD_VOICEMAIL": "ADD_VOICEMAIL";
|
|
@@ -36,6 +37,7 @@ interface Diagnostic {
|
|
|
36
37
|
"NEARBY_WIFI_DEVICES": "NEARBY_WIFI_DEVICES";
|
|
37
38
|
"POST_NOTIFICATIONS": "POST_NOTIFICATIONS";
|
|
38
39
|
"PROCESS_OUTGOING_CALLS": "PROCESS_OUTGOING_CALLS";
|
|
40
|
+
"RANGING": "RANGING";
|
|
39
41
|
"READ_CALENDAR": "READ_CALENDAR";
|
|
40
42
|
"READ_CALL_LOG": "READ_CALL_LOG";
|
|
41
43
|
"READ_CONTACTS": "READ_CONTACTS";
|
|
@@ -43,6 +45,7 @@ interface Diagnostic {
|
|
|
43
45
|
"READ_MEDIA_AUDIO": "READ_MEDIA_AUDIO";
|
|
44
46
|
"READ_MEDIA_IMAGES": "READ_MEDIA_IMAGES";
|
|
45
47
|
"READ_MEDIA_VIDEO": "READ_MEDIA_VIDEO";
|
|
48
|
+
"READ_MEDIA_VISUAL_USER_SELECTED": "READ_MEDIA_VISUAL_USER_SELECTED";
|
|
46
49
|
"READ_PHONE_NUMBERS": "READ_PHONE_NUMBERS";
|
|
47
50
|
"READ_PHONE_STATE": "READ_PHONE_STATE";
|
|
48
51
|
"READ_SMS": "READ_SMS";
|
|
@@ -741,6 +744,46 @@ interface Diagnostic {
|
|
|
741
744
|
errorCallback: (error: string) => void
|
|
742
745
|
) => void;
|
|
743
746
|
|
|
747
|
+
/**
|
|
748
|
+
* Checks if low power mode is currently enabled on the device.
|
|
749
|
+
* @param successCallback
|
|
750
|
+
* @param errorCallback
|
|
751
|
+
*/
|
|
752
|
+
isLowPowerModeEnabled?: (
|
|
753
|
+
successCallback: (enabled: boolean) => void,
|
|
754
|
+
errorCallback: (error: string) => void
|
|
755
|
+
) => void;
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Registers a function to be called when low power mode changes.
|
|
759
|
+
* @param successCallback
|
|
760
|
+
*/
|
|
761
|
+
onLowPowerModeChange?: (
|
|
762
|
+
successCallback: (enabled: boolean) => void
|
|
763
|
+
) => void;
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* ANDROID ONLY
|
|
767
|
+
* Checks if the app is currently ignoring battery optimizations.
|
|
768
|
+
* @param successCallback
|
|
769
|
+
* @param errorCallback
|
|
770
|
+
*/
|
|
771
|
+
isIgnoringBatteryOptimizations?: (
|
|
772
|
+
successCallback: (enabled: boolean) => void,
|
|
773
|
+
errorCallback: (error: string) => void
|
|
774
|
+
) => void;
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* ANDROID ONLY
|
|
778
|
+
* Prompts the user to allow the app to ignore battery optimizations.
|
|
779
|
+
* @param successCallback
|
|
780
|
+
* @param errorCallback
|
|
781
|
+
*/
|
|
782
|
+
requestIgnoreBatteryOptimizations?: (
|
|
783
|
+
successCallback: () => void,
|
|
784
|
+
errorCallback: (error: string) => void
|
|
785
|
+
) => void;
|
|
786
|
+
|
|
744
787
|
/**
|
|
745
788
|
* ANDROID ONLY
|
|
746
789
|
* Checks if high-accuracy locations are available to the app from GPS hardware.
|
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
|
|
3
3
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
4
|
id="cordova.plugins.diagnostic"
|
|
5
|
-
version="7.
|
|
5
|
+
version="7.3.1">
|
|
6
6
|
|
|
7
7
|
<name>Diagnostic</name>
|
|
8
8
|
<description>Cordova/Phonegap plugin to check the state of Location/WiFi/Camera/Bluetooth device settings.</description>
|
|
@@ -46,13 +46,16 @@ import android.Manifest;
|
|
|
46
46
|
import android.app.Activity;
|
|
47
47
|
import android.app.AlarmManager;
|
|
48
48
|
import android.app.PendingIntent;
|
|
49
|
+
import android.content.BroadcastReceiver;
|
|
49
50
|
import android.content.SharedPreferences;
|
|
51
|
+
import android.content.IntentFilter;
|
|
50
52
|
import android.content.pm.ApplicationInfo;
|
|
51
53
|
import android.content.pm.PackageInfo;
|
|
52
54
|
import android.net.ConnectivityManager;
|
|
53
55
|
import android.net.Uri;
|
|
54
56
|
import android.os.BatteryManager;
|
|
55
57
|
import android.os.Build;
|
|
58
|
+
import android.os.PowerManager;
|
|
56
59
|
import android.util.Log;
|
|
57
60
|
|
|
58
61
|
import android.content.Context;
|
|
@@ -146,6 +149,12 @@ public class Diagnostic extends CordovaPlugin{
|
|
|
146
149
|
// API 34+
|
|
147
150
|
Diagnostic.addBiDirMapEntry(_permissionsMap, "READ_MEDIA_VISUAL_USER_SELECTED", "android.permission.READ_MEDIA_VISUAL_USER_SELECTED");
|
|
148
151
|
|
|
152
|
+
// API 36+
|
|
153
|
+
Diagnostic.addBiDirMapEntry(_permissionsMap, "RANGING", "android.permission.RANGING");
|
|
154
|
+
|
|
155
|
+
// API 37+
|
|
156
|
+
Diagnostic.addBiDirMapEntry(_permissionsMap, "ACCESS_LOCAL_NETWORK", "android.permission.ACCESS_LOCAL_NETWORK");
|
|
157
|
+
|
|
149
158
|
permissionsMap = Collections.unmodifiableMap(_permissionsMap);
|
|
150
159
|
}
|
|
151
160
|
|
|
@@ -263,6 +272,7 @@ public class Diagnostic extends CordovaPlugin{
|
|
|
263
272
|
|
|
264
273
|
protected SharedPreferences sharedPref;
|
|
265
274
|
protected SharedPreferences.Editor editor;
|
|
275
|
+
protected boolean currentLowPowerModeEnabled = false;
|
|
266
276
|
|
|
267
277
|
/*************
|
|
268
278
|
* Public API
|
|
@@ -291,10 +301,31 @@ public class Diagnostic extends CordovaPlugin{
|
|
|
291
301
|
applicationContext = this.cordova.getActivity().getApplicationContext();
|
|
292
302
|
sharedPref = cordova.getActivity().getSharedPreferences(TAG, Activity.MODE_PRIVATE);
|
|
293
303
|
editor = sharedPref.edit();
|
|
304
|
+
currentLowPowerModeEnabled = isLowPowerModeEnabled();
|
|
305
|
+
|
|
306
|
+
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
|
|
307
|
+
try {
|
|
308
|
+
applicationContext.registerReceiver(lowPowerModeChangedReceiver, new IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED));
|
|
309
|
+
} catch (Exception e) {
|
|
310
|
+
logWarning("Unable to register low power mode change receiver: " + e.getMessage());
|
|
311
|
+
}
|
|
312
|
+
}
|
|
294
313
|
|
|
295
314
|
super.initialize(cordova, webView);
|
|
296
315
|
}
|
|
297
316
|
|
|
317
|
+
@Override
|
|
318
|
+
public void onDestroy() {
|
|
319
|
+
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
|
|
320
|
+
try {
|
|
321
|
+
applicationContext.unregisterReceiver(lowPowerModeChangedReceiver);
|
|
322
|
+
} catch (Exception e) {
|
|
323
|
+
logWarning("Unable to unregister low power mode change receiver: " + e.getMessage());
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
super.onDestroy();
|
|
327
|
+
}
|
|
328
|
+
|
|
298
329
|
/**
|
|
299
330
|
* Executes the request and returns PluginResult.
|
|
300
331
|
*
|
|
@@ -351,6 +382,13 @@ public class Diagnostic extends CordovaPlugin{
|
|
|
351
382
|
callbackContext.success(getCPUArchitecture());
|
|
352
383
|
} else if(action.equals("getCurrentBatteryLevel")) {
|
|
353
384
|
callbackContext.success(getCurrentBatteryLevel());
|
|
385
|
+
} else if(action.equals("isLowPowerModeEnabled")) {
|
|
386
|
+
callbackContext.success(isLowPowerModeEnabled() ? 1 : 0);
|
|
387
|
+
} else if(action.equals("isIgnoringBatteryOptimizations")) {
|
|
388
|
+
callbackContext.success(isIgnoringBatteryOptimizations() ? 1 : 0);
|
|
389
|
+
} else if(action.equals("requestIgnoreBatteryOptimizations")) {
|
|
390
|
+
requestIgnoreBatteryOptimizations();
|
|
391
|
+
callbackContext.success();
|
|
354
392
|
} else if(action.equals("isAirplaneModeEnabled")) {
|
|
355
393
|
callbackContext.success(isAirplaneModeEnabled() ? 1 : 0);
|
|
356
394
|
} else if(action.equals("getDeviceOSVersion")) {
|
|
@@ -861,6 +899,17 @@ public class Diagnostic extends CordovaPlugin{
|
|
|
861
899
|
executeGlobalJavascript("cordova.plugins.diagnostic." + jsString);
|
|
862
900
|
}
|
|
863
901
|
|
|
902
|
+
protected final BroadcastReceiver lowPowerModeChangedReceiver = new BroadcastReceiver() {
|
|
903
|
+
@Override
|
|
904
|
+
public void onReceive(Context context, Intent intent) {
|
|
905
|
+
final String action = intent.getAction();
|
|
906
|
+
if(instance != null && PowerManager.ACTION_POWER_SAVE_MODE_CHANGED.equals(action)){
|
|
907
|
+
Log.v(TAG, "lowPowerModeChangedReceiver");
|
|
908
|
+
instance.notifyLowPowerModeChange();
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
|
|
864
913
|
/**
|
|
865
914
|
* Performs a warm app restart - restarts only Cordova main activity
|
|
866
915
|
*/
|
|
@@ -953,6 +1002,41 @@ public class Diagnostic extends CordovaPlugin{
|
|
|
953
1002
|
return bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
|
|
954
1003
|
}
|
|
955
1004
|
|
|
1005
|
+
protected boolean isLowPowerModeEnabled(){
|
|
1006
|
+
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP){
|
|
1007
|
+
return false;
|
|
1008
|
+
}
|
|
1009
|
+
PowerManager powerManager = (PowerManager) cordova.getContext().getApplicationContext().getSystemService(Context.POWER_SERVICE);
|
|
1010
|
+
return powerManager != null && powerManager.isPowerSaveMode();
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
protected boolean isIgnoringBatteryOptimizations(){
|
|
1014
|
+
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.M){
|
|
1015
|
+
return true;
|
|
1016
|
+
}
|
|
1017
|
+
PowerManager powerManager = (PowerManager) cordova.getContext().getApplicationContext().getSystemService(Context.POWER_SERVICE);
|
|
1018
|
+
return powerManager != null && powerManager.isIgnoringBatteryOptimizations(cordova.getActivity().getPackageName());
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
protected void requestIgnoreBatteryOptimizations(){
|
|
1022
|
+
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.M || isIgnoringBatteryOptimizations()){
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
|
1027
|
+
intent.setData(Uri.parse("package:" + cordova.getActivity().getPackageName()));
|
|
1028
|
+
cordova.getActivity().startActivity(intent);
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
protected void notifyLowPowerModeChange(){
|
|
1032
|
+
boolean lowPowerModeEnabled = isLowPowerModeEnabled();
|
|
1033
|
+
if(lowPowerModeEnabled != currentLowPowerModeEnabled){
|
|
1034
|
+
currentLowPowerModeEnabled = lowPowerModeEnabled;
|
|
1035
|
+
logDebug("Low power mode changed to: " + lowPowerModeEnabled);
|
|
1036
|
+
executePluginJavascript("_onLowPowerModeChange(" + (lowPowerModeEnabled ? "true" : "false") + ");");
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
|
|
956
1040
|
// https://stackoverflow.com/a/18237962/777265
|
|
957
1041
|
protected boolean hasBuildPermission(String permission)
|
|
958
1042
|
{
|
package/src/ios/Diagnostic.h
CHANGED
|
@@ -28,6 +28,7 @@ extern NSString*const AUTHORIZATION_LIMITED;
|
|
|
28
28
|
|
|
29
29
|
@property (nonatomic) float osVersion;
|
|
30
30
|
@property (nonatomic) BOOL debugEnabled;
|
|
31
|
+
@property (nonatomic, strong) id lowPowerModeChangeObserver;
|
|
31
32
|
|
|
32
33
|
// Plugin API
|
|
33
34
|
- (void) enableDebug: (CDVInvokedUrlCommand*)command;
|
|
@@ -35,6 +36,7 @@ extern NSString*const AUTHORIZATION_LIMITED;
|
|
|
35
36
|
- (void) getBackgroundRefreshStatus: (CDVInvokedUrlCommand*)command;
|
|
36
37
|
- (void) getArchitecture: (CDVInvokedUrlCommand*)command;
|
|
37
38
|
- (void) getCurrentBatteryLevel: (CDVInvokedUrlCommand*)command;
|
|
39
|
+
- (void) isLowPowerModeEnabled: (CDVInvokedUrlCommand*)command;
|
|
38
40
|
- (void) getDeviceOSVersion: (CDVInvokedUrlCommand*)command;
|
|
39
41
|
- (void) getBuildOSVersion: (CDVInvokedUrlCommand*)command;
|
|
40
42
|
- (void) isMobileDataAuthorized: (CDVInvokedUrlCommand*)command;
|
package/src/ios/Diagnostic.m
CHANGED
|
@@ -41,6 +41,7 @@ static Diagnostic* diagnostic = nil;
|
|
|
41
41
|
static CTCellularData* cellularData;
|
|
42
42
|
#endif
|
|
43
43
|
|
|
44
|
+
|
|
44
45
|
/********************************/
|
|
45
46
|
#pragma mark - Public static functions
|
|
46
47
|
/********************************/
|
|
@@ -126,6 +127,12 @@ static CTCellularData* cellularData;
|
|
|
126
127
|
#if !TARGET_OS_MACCATALYST
|
|
127
128
|
cellularData = [[CTCellularData alloc] init];
|
|
128
129
|
#endif
|
|
130
|
+
|
|
131
|
+
self.lowPowerModeChangeObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSProcessInfoPowerStateDidChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
|
|
132
|
+
BOOL isLowPowerModeEnabled = [[NSProcessInfo processInfo] isLowPowerModeEnabled];
|
|
133
|
+
[self logDebug:[NSString stringWithFormat:@"Low power mode changed to: %@", isLowPowerModeEnabled ? @"true" : @"false"]];
|
|
134
|
+
[self executeGlobalJavascript:[NSString stringWithFormat:@"cordova.plugins.diagnostic._onLowPowerModeChange(%@);", isLowPowerModeEnabled ? @"true" : @"false"]];
|
|
135
|
+
}];
|
|
129
136
|
}
|
|
130
137
|
|
|
131
138
|
// https://stackoverflow.com/a/38441011/777265
|
|
@@ -186,6 +193,18 @@ static CTCellularData* cellularData;
|
|
|
186
193
|
}];
|
|
187
194
|
}
|
|
188
195
|
|
|
196
|
+
- (void) isLowPowerModeEnabled: (CDVInvokedUrlCommand*)command {
|
|
197
|
+
[self.commandDelegate runInBackground:^{
|
|
198
|
+
@try {
|
|
199
|
+
BOOL isLowPowerModeEnabled = [[NSProcessInfo processInfo] isLowPowerModeEnabled];
|
|
200
|
+
[self logDebug:[NSString stringWithFormat:@"Low power mode enabled: %@", isLowPowerModeEnabled ? @"true" : @"false"]];
|
|
201
|
+
[self sendPluginResultBool:isLowPowerModeEnabled :command];
|
|
202
|
+
}@catch (NSException *exception) {
|
|
203
|
+
[self handlePluginException:exception :command];
|
|
204
|
+
}
|
|
205
|
+
}];
|
|
206
|
+
}
|
|
207
|
+
|
|
189
208
|
- (void) getDeviceOSVersion: (CDVInvokedUrlCommand*)command {
|
|
190
209
|
[self.commandDelegate runInBackground:^{
|
|
191
210
|
@try {
|
|
@@ -419,6 +438,13 @@ static CTCellularData* cellularData;
|
|
|
419
438
|
return [[NSUserDefaults standardUserDefaults] objectForKey:key];
|
|
420
439
|
}
|
|
421
440
|
|
|
441
|
+
- (void)dealloc {
|
|
442
|
+
if(self.lowPowerModeChangeObserver != nil){
|
|
443
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self.lowPowerModeChangeObserver];
|
|
444
|
+
self.lowPowerModeChangeObserver = nil;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
422
448
|
@end
|
|
423
449
|
|
|
424
450
|
|
|
@@ -156,12 +156,14 @@ static NSString*const LOG_TAG = @"Diagnostic_Bluetooth[native]";
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
- (void) ensureBluetoothManager {
|
|
159
|
-
|
|
159
|
+
@synchronized(self) {
|
|
160
|
+
if(![self.bluetoothManager isKindOfClass:[CBCentralManager class]]){
|
|
160
161
|
self.bluetoothManager = [[CBCentralManager alloc]
|
|
161
162
|
initWithDelegate:self
|
|
162
163
|
queue:dispatch_get_main_queue()
|
|
163
164
|
options:@{CBCentralManagerOptionShowPowerAlertKey: @(NO)}];
|
|
164
165
|
[self centralManagerDidUpdateState:self.bluetoothManager]; // Send initial state
|
|
166
|
+
}
|
|
165
167
|
}
|
|
166
168
|
}
|
|
167
169
|
|
|
@@ -32,6 +32,7 @@ var Diagnostic = (function(){
|
|
|
32
32
|
"ACCESS_BACKGROUND_LOCATION": "ACCESS_BACKGROUND_LOCATION",
|
|
33
33
|
"ACCESS_COARSE_LOCATION": "ACCESS_COARSE_LOCATION",
|
|
34
34
|
"ACCESS_FINE_LOCATION": "ACCESS_FINE_LOCATION",
|
|
35
|
+
"ACCESS_LOCAL_NETWORK": "ACCESS_LOCAL_NETWORK",
|
|
35
36
|
"ACCESS_MEDIA_LOCATION": "ACCESS_MEDIA_LOCATION",
|
|
36
37
|
"ACTIVITY_RECOGNITION": "ACTIVITY_RECOGNITION",
|
|
37
38
|
"ADD_VOICEMAIL": "ADD_VOICEMAIL",
|
|
@@ -47,6 +48,7 @@ var Diagnostic = (function(){
|
|
|
47
48
|
"NEARBY_WIFI_DEVICES": "NEARBY_WIFI_DEVICES",
|
|
48
49
|
"POST_NOTIFICATIONS": "POST_NOTIFICATIONS",
|
|
49
50
|
"PROCESS_OUTGOING_CALLS": "PROCESS_OUTGOING_CALLS",
|
|
51
|
+
"RANGING": "RANGING",
|
|
50
52
|
"READ_CALENDAR": "READ_CALENDAR",
|
|
51
53
|
"READ_CALL_LOG": "READ_CALL_LOG",
|
|
52
54
|
"READ_CONTACTS": "READ_CONTACTS",
|
|
@@ -54,6 +56,7 @@ var Diagnostic = (function(){
|
|
|
54
56
|
"READ_MEDIA_AUDIO": "READ_MEDIA_AUDIO",
|
|
55
57
|
"READ_MEDIA_IMAGES": "READ_MEDIA_IMAGES",
|
|
56
58
|
"READ_MEDIA_VIDEO": "READ_MEDIA_VIDEO",
|
|
59
|
+
"READ_MEDIA_VISUAL_USER_SELECTED": "READ_MEDIA_VISUAL_USER_SELECTED",
|
|
57
60
|
"READ_PHONE_NUMBERS": "READ_PHONE_NUMBERS",
|
|
58
61
|
"READ_PHONE_STATE": "READ_PHONE_STATE",
|
|
59
62
|
"READ_SMS": "READ_SMS",
|
|
@@ -112,7 +115,8 @@ var Diagnostic = (function(){
|
|
|
112
115
|
*
|
|
113
116
|
****************************/
|
|
114
117
|
// Placeholder listeners
|
|
115
|
-
Diagnostic.
|
|
118
|
+
Diagnostic._onLowPowerModeChange =
|
|
119
|
+
Diagnostic._onNFCStateChange =
|
|
116
120
|
Diagnostic._onPermissionRequestComplete = function(){};
|
|
117
121
|
|
|
118
122
|
Diagnostic._combinePermissionStatuses = function(statuses){
|
|
@@ -484,6 +488,63 @@ var Diagnostic = (function(){
|
|
|
484
488
|
[]);
|
|
485
489
|
};
|
|
486
490
|
|
|
491
|
+
/**
|
|
492
|
+
* Checks if low power mode is currently enabled on device.
|
|
493
|
+
*
|
|
494
|
+
* @param {Function} successCallback - The callback which will be called when the operation is successful.
|
|
495
|
+
* This callback function is passed a single boolean parameter which is TRUE if low power mode is enabled.
|
|
496
|
+
* @param {Function} errorCallback - The callback which will be called when the operation encounters an error.
|
|
497
|
+
* This callback function is passed a single string parameter containing the error message.
|
|
498
|
+
*/
|
|
499
|
+
Diagnostic.isLowPowerModeEnabled = function(successCallback, errorCallback){
|
|
500
|
+
return cordova.exec(Diagnostic._ensureBoolean(successCallback),
|
|
501
|
+
errorCallback,
|
|
502
|
+
'Diagnostic',
|
|
503
|
+
'isLowPowerModeEnabled',
|
|
504
|
+
[]);
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Checks if the app is currently ignoring battery optimizations.
|
|
509
|
+
*
|
|
510
|
+
* @param {Function} successCallback - The callback which will be called when the operation is successful.
|
|
511
|
+
* This callback function is passed a single boolean parameter which is TRUE if the app is ignoring battery optimizations.
|
|
512
|
+
* @param {Function} errorCallback - The callback which will be called when the operation encounters an error.
|
|
513
|
+
* This callback function is passed a single string parameter containing the error message.
|
|
514
|
+
*/
|
|
515
|
+
Diagnostic.isIgnoringBatteryOptimizations = function(successCallback, errorCallback){
|
|
516
|
+
return cordova.exec(Diagnostic._ensureBoolean(successCallback),
|
|
517
|
+
errorCallback,
|
|
518
|
+
'Diagnostic',
|
|
519
|
+
'isIgnoringBatteryOptimizations',
|
|
520
|
+
[]);
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Prompts the user to allow the app to ignore battery optimizations.
|
|
525
|
+
*
|
|
526
|
+
* @param {Function} successCallback - The callback which will be called when the request intent is opened.
|
|
527
|
+
* @param {Function} errorCallback - The callback which will be called when the operation encounters an error.
|
|
528
|
+
* This callback function is passed a single string parameter containing the error message.
|
|
529
|
+
*/
|
|
530
|
+
Diagnostic.requestIgnoreBatteryOptimizations = function(successCallback, errorCallback){
|
|
531
|
+
return cordova.exec(successCallback,
|
|
532
|
+
errorCallback,
|
|
533
|
+
'Diagnostic',
|
|
534
|
+
'requestIgnoreBatteryOptimizations',
|
|
535
|
+
[]);
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Registers a function to be called when the device low power mode changes.
|
|
540
|
+
*
|
|
541
|
+
* @param {Function} successCallback - The callback which will be called when low power mode changes.
|
|
542
|
+
* This callback function is passed a single boolean parameter which is TRUE if low power mode is enabled.
|
|
543
|
+
*/
|
|
544
|
+
Diagnostic.onLowPowerModeChange = function(successCallback) {
|
|
545
|
+
Diagnostic._onLowPowerModeChange = successCallback || function(){};
|
|
546
|
+
};
|
|
547
|
+
|
|
487
548
|
/**
|
|
488
549
|
* Checks if airplane mode is enabled on device.
|
|
489
550
|
*
|
package/www/ios/diagnostic.js
CHANGED
|
@@ -154,6 +154,32 @@ var Diagnostic = (function(){
|
|
|
154
154
|
[]);
|
|
155
155
|
};
|
|
156
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Checks if low power mode is currently enabled on device.
|
|
159
|
+
*
|
|
160
|
+
* @param {Function} successCallback - The callback which will be called when the operation is successful.
|
|
161
|
+
* This callback function is passed a single boolean parameter which is TRUE if low power mode is enabled.
|
|
162
|
+
* @param {Function} errorCallback - The callback which will be called when the operation encounters an error.
|
|
163
|
+
* This callback function is passed a single string parameter containing the error message.
|
|
164
|
+
*/
|
|
165
|
+
Diagnostic.isLowPowerModeEnabled = function(successCallback, errorCallback){
|
|
166
|
+
return cordova.exec(Diagnostic._ensureBoolean(successCallback),
|
|
167
|
+
errorCallback,
|
|
168
|
+
'Diagnostic',
|
|
169
|
+
'isLowPowerModeEnabled',
|
|
170
|
+
[]);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Registers a function to be called when the device low power mode changes.
|
|
175
|
+
*
|
|
176
|
+
* @param {Function} successCallback - The callback which will be called when low power mode changes.
|
|
177
|
+
* This callback function is passed a single boolean parameter which is TRUE if low power mode is enabled.
|
|
178
|
+
*/
|
|
179
|
+
Diagnostic.onLowPowerModeChange = function(successCallback) {
|
|
180
|
+
Diagnostic._onLowPowerModeChange = successCallback || function(){};
|
|
181
|
+
};
|
|
182
|
+
|
|
157
183
|
/**
|
|
158
184
|
* Checks if mobile data is authorized for this app.
|
|
159
185
|
* Returns true if the per-app Mobile Data setting is set to enabled (regardless of whether the device is currently connected to a cellular network)
|
|
@@ -1228,7 +1254,7 @@ var Diagnostic = (function(){
|
|
|
1228
1254
|
}
|
|
1229
1255
|
};
|
|
1230
1256
|
|
|
1231
|
-
|
|
1257
|
+
Diagnostic._onLowPowerModeChange = function(){};
|
|
1232
1258
|
|
|
1233
1259
|
return Diagnostic;
|
|
1234
1260
|
})();
|