cordova.plugins.diagnostic 7.1.1 → 7.1.3

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/CHANGELOG.md CHANGED
@@ -1,4 +1,25 @@
1
1
  # CHANGELOG
2
+ **v7.1.3**
3
+ * (android) update camera module to support READ_MEDIA permissions on Android 13+
4
+ * (android): For new runtime permissions added in API 33, consider them implicitly granted if the build SDK >= 33 and device runtime is < 33.
5
+ * Resolves [#493](https://github.com/dpa99c/cordova-diagnostic-plugin/issues/493)
6
+ * (android) fix: Return error if attempting to change Bluetooth state when build SDK >= API 33 as this is no longer support.
7
+ * Resolves [#496](https://github.com/dpa99c/cordova-diagnostic-plugin/issues/496)
8
+ * (android) fix: getExternalSdCardDetails on API 33
9
+ * Merged from PR [#495](https://github.com/dpa99c/cordova-diagnostic-plugin/pull/495)
10
+ * (types) Using unlimited arrays in the TypeScript definition
11
+ * Merged from PR [#497](https://github.com/dpa99c/cordova-diagnostic-plugin/pull/497)
12
+
13
+
14
+ **v7.1.2**
15
+ * (Android) fix: Data roaming setting not available on API 32+
16
+ * (Android) Support new media storage permissions on Android 13 / API 33.
17
+ * Resolves [#488](https://github.com/dpa99c/cordova-diagnostic-plugin/issues/488).
18
+ * (ios) bugfix: Check argument for Photo Library Access Level is not null before attempting to perform string compare.
19
+ * Resolves [#483](https://github.com/dpa99c/cordova-diagnostic-plugin/issues/483).
20
+ * (doc) Document issue with "Only this time" option in run-time permissions on Android 11+.
21
+ * Resolves [#486](https://github.com/dpa99c/cordova-diagnostic-plugin/issues/486).
22
+
2
23
 
3
24
  **v7.1.1**
4
25
  * (Android, iOS) feat: Add `isMobileDataEnabled()` to core module.
package/README.md CHANGED
@@ -2,155 +2,155 @@ Cordova diagnostic plugin [![Latest Stable Version](https://img.shields.io/npm/v
2
2
  =========================
3
3
 
4
4
  <!-- doctoc README.md --maxlevel=3 -->
5
- <!-- START doctoc generated TOC please keep comment here to allow auto update -->
6
- <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
7
-
8
-
9
- - [Overview](#overview)
10
- - [Important notes](#important-notes)
11
- - [Minimum supported versions](#minimum-supported-versions)
12
- - [Native environment required](#native-environment-required)
13
- - [Building for Android](#building-for-android)
14
- - [Installation](#installation)
15
- - [Using the Cordova/Phonegap/Ionic CLI](#using-the-cordovaphonegapionic-cli)
16
- - [AndroidX Library](#androidx-library)
17
- - [Specifying modules](#specifying-modules)
18
- - [Available modules](#available-modules)
19
- - [Reporting issues](#reporting-issues)
20
- - [Reporting a bug or problem](#reporting-a-bug-or-problem)
21
- - [Requesting a new feature](#requesting-a-new-feature)
22
- - [Usage](#usage)
23
- - [Core module](#core-module)
24
- - [switchToSettings()](#switchtosettings)
25
- - [switchToWirelessSettings()](#switchtowirelesssettings)
26
- - [switchToMobileDataSettings()](#switchtomobiledatasettings)
27
- - [permissionStatus constants](#permissionstatus-constants)
28
- - [getPermissionAuthorizationStatus()](#getpermissionauthorizationstatus)
29
- - [getPermissionsAuthorizationStatus()](#getpermissionsauthorizationstatus)
30
- - [requestRuntimePermission()](#requestruntimepermission)
31
- - [requestRuntimePermissions()](#requestruntimepermissions)
32
- - [isRequestingPermission()](#isrequestingpermission)
33
- - [registerPermissionRequestCompleteHandler()](#registerpermissionrequestcompletehandler)
34
- - [isDataRoamingEnabled()](#isdataroamingenabled)
35
- - [isADBModeEnabled()](#isadbmodeenabled)
36
- - [isDeviceRooted()](#isdevicerooted)
37
- - [isBackgroundRefreshAuthorized()](#isbackgroundrefreshauthorized)
38
- - [getBackgroundRefreshStatus()](#getbackgroundrefreshstatus)
39
- - [cpuArchitecture constants](#cpuarchitecture-constants)
40
- - [getArchitecture()](#getarchitecture)
41
- - [restart()](#restart)
42
- - [enableDebug()](#enabledebug)
43
- - [getCurrentBatteryLevel()](#getcurrentbatterylevel)
44
- - [isAirplaneModeEnabled()](#isairplanemodeenabled)
45
- - [isMobileDataEnabled()](#ismobiledataenabled)
46
- - [getDeviceOSVersion()](#getdeviceosversion)
47
- - [getBuildOSVersion()](#getbuildosversion)
48
- - [Location module](#location-module)
49
- - [locationMode constants](#locationmode-constants)
50
- - [locationAuthorizationMode constants](#locationauthorizationmode-constants)
51
- - [locationAccuracyAuthorization constants](#locationaccuracyauthorization-constants)
52
- - [isLocationAvailable()](#islocationavailable)
53
- - [isLocationEnabled()](#islocationenabled)
54
- - [isGpsLocationAvailable()](#isgpslocationavailable)
55
- - [isGpsLocationEnabled()](#isgpslocationenabled)
56
- - [isNetworkLocationAvailable()](#isnetworklocationavailable)
57
- - [isNetworkLocationEnabled()](#isnetworklocationenabled)
58
- - [getLocationMode()](#getlocationmode)
59
- - [isLocationAuthorized()](#islocationauthorized)
60
- - [getLocationAuthorizationStatus()](#getlocationauthorizationstatus)
61
- - [getLocationAuthorizationStatuses()](#getlocationauthorizationstatuses)
62
- - [requestLocationAuthorization()](#requestlocationauthorization)
63
- - [registerLocationStateChangeHandler()](#registerlocationstatechangehandler)
64
- - [getLocationAccuracyAuthorization()](#getlocationaccuracyauthorization)
65
- - [requestTemporaryFullAccuracyAuthorization()](#requesttemporaryfullaccuracyauthorization)
66
- - [registerLocationAccuracyAuthorizationChangeHandler()](#registerlocationaccuracyauthorizationchangehandler)
67
- - [switchToLocationSettings()](#switchtolocationsettings)
68
- - [Bluetooth module](#bluetooth-module)
69
- - [bluetoothState constants](#bluetoothstate-constants)
70
- - [isBluetoothAvailable()](#isbluetoothavailable)
71
- - [isBluetoothEnabled()](#isbluetoothenabled)
72
- - [hasBluetoothSupport()](#hasbluetoothsupport)
73
- - [hasBluetoothLESupport()](#hasbluetoothlesupport)
74
- - [hasBluetoothLEPeripheralSupport()](#hasbluetoothleperipheralsupport)
75
- - [getBluetoothState()](#getbluetoothstate)
76
- - [setBluetoothState()](#setbluetoothstate)
77
- - [getBluetoothAuthorizationStatus()](#getbluetoothauthorizationstatus)
78
- - [getBluetoothAuthorizationStatuses()](#getbluetoothauthorizationstatuses)
79
- - [requestBluetoothAuthorization()](#requestbluetoothauthorization)
80
- - [registerBluetoothStateChangeHandler()](#registerbluetoothstatechangehandler)
81
- - [switchToBluetoothSettings()](#switchtobluetoothsettings)
82
- - [WiFi module](#wifi-module)
83
- - [isWifiAvailable()](#iswifiavailable)
84
- - [isWifiEnabled()](#iswifienabled)
85
- - [setWifiState()](#setwifistate)
86
- - [switchToWifiSettings()](#switchtowifisettings)
87
- - [Camera module](#camera-module)
88
- - [isCameraPresent()](#iscamerapresent)
89
- - [isCameraAvailable()](#iscameraavailable)
90
- - [isCameraAuthorized()](#iscameraauthorized)
91
- - [getCameraAuthorizationStatus()](#getcameraauthorizationstatus)
92
- - [requestCameraAuthorization()](#requestcameraauthorization)
93
- - [isCameraRollAuthorized()](#iscamerarollauthorized)
94
- - [getCameraRollAuthorizationStatus()](#getcamerarollauthorizationstatus)
95
- - [requestCameraRollAuthorization()](#requestcamerarollauthorization)
96
- - [presentLimitedLibraryPicker()](#presentlimitedlibrarypicker)
97
- - [Notifications module](#notifications-module)
98
- - [remoteNotificationType constants](#remotenotificationtype-constants)
99
- - [isRemoteNotificationsEnabled()](#isremotenotificationsenabled)
100
- - [isRegisteredForRemoteNotifications()](#isregisteredforremotenotifications)
101
- - [getRemoteNotificationTypes()](#getremotenotificationtypes)
102
- - [getRemoteNotificationsAuthorizationStatus()](#getremotenotificationsauthorizationstatus)
103
- - [requestRemoteNotificationsAuthorization()](#requestremotenotificationsauthorization)
104
- - [switchToNotificationSettings()](#switchtonotificationsettings)
105
- - [Microphone module](#microphone-module)
106
- - [isMicrophoneAuthorized()](#ismicrophoneauthorized)
107
- - [getMicrophoneAuthorizationStatus()](#getmicrophoneauthorizationstatus)
108
- - [requestMicrophoneAuthorization()](#requestmicrophoneauthorization)
109
- - [Contacts module](#contacts-module)
110
- - [isContactsAuthorized()](#iscontactsauthorized)
111
- - [getContactsAuthorizationStatus()](#getcontactsauthorizationstatus)
112
- - [requestContactsAuthorization()](#requestcontactsauthorization)
113
- - [Calendar module](#calendar-module)
114
- - [isCalendarAuthorized()](#iscalendarauthorized)
115
- - [getCalendarAuthorizationStatus()](#getcalendarauthorizationstatus)
116
- - [requestCalendarAuthorization()](#requestcalendarauthorization)
117
- - [Reminders module](#reminders-module)
118
- - [isRemindersAuthorized()](#isremindersauthorized)
119
- - [getRemindersAuthorizationStatus()](#getremindersauthorizationstatus)
120
- - [requestRemindersAuthorization()](#requestremindersauthorization)
121
- - [Motion module](#motion-module)
122
- - [motionStatus constants](#motionstatus-constants)
123
- - [isMotionAvailable()](#ismotionavailable)
124
- - [isMotionRequestOutcomeAvailable()](#ismotionrequestoutcomeavailable)
125
- - [requestMotionAuthorization()](#requestmotionauthorization)
126
- - [getMotionAuthorizationStatus()](#getmotionauthorizationstatus)
127
- - [NFC module](#nfc-module)
128
- - [NFCState constants](#nfcstate-constants)
129
- - [isNFCPresent()](#isnfcpresent)
130
- - [isNFCEnabled()](#isnfcenabled)
131
- - [isNFCAvailable()](#isnfcavailable)
132
- - [registerNFCStateChangeHandler()](#registernfcstatechangehandler)
133
- - [switchToNFCSettings()](#switchtonfcsettings)
134
- - [External storage module](#external-storage-module)
135
- - [isExternalStorageAuthorized()](#isexternalstorageauthorized)
136
- - [getExternalStorageAuthorizationStatus()](#getexternalstorageauthorizationstatus)
137
- - [requestExternalStorageAuthorization()](#requestexternalstorageauthorization)
138
- - [getExternalSdCardDetails()](#getexternalsdcarddetails)
139
- - [Platform Notes](#platform-notes)
140
- - [Android](#android)
141
- - [Android permissions](#android-permissions)
142
- - [Android Auto Backup](#android-auto-backup)
143
- - [iOS](#ios)
144
- - [iOS usage description messages](#ios-usage-description-messages)
145
- - [Example project](#example-project)
146
- - [Screenshots](#screenshots)
147
- - [Android](#android-1)
148
- - [iOS](#ios-1)
149
- - [Release notes](#release-notes)
150
- - [Credits](#credits)
151
- - [License](#license)
152
-
153
- <!-- END doctoc generated TOC please keep comment here to allow auto update -->
5
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
6
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
7
+
8
+
9
+ - [Overview](#overview)
10
+ - [Important notes](#important-notes)
11
+ - [Minimum supported versions](#minimum-supported-versions)
12
+ - [Native environment required](#native-environment-required)
13
+ - [Building for Android](#building-for-android)
14
+ - [Installation](#installation)
15
+ - [Using the Cordova/Phonegap/Ionic CLI](#using-the-cordovaphonegapionic-cli)
16
+ - [AndroidX Library](#androidx-library)
17
+ - [Specifying modules](#specifying-modules)
18
+ - [Available modules](#available-modules)
19
+ - [Reporting issues](#reporting-issues)
20
+ - [Reporting a bug or problem](#reporting-a-bug-or-problem)
21
+ - [Requesting a new feature](#requesting-a-new-feature)
22
+ - [Usage](#usage)
23
+ - [Core module](#core-module)
24
+ - [switchToSettings()](#switchtosettings)
25
+ - [switchToWirelessSettings()](#switchtowirelesssettings)
26
+ - [switchToMobileDataSettings()](#switchtomobiledatasettings)
27
+ - [permissionStatus constants](#permissionstatus-constants)
28
+ - [getPermissionAuthorizationStatus()](#getpermissionauthorizationstatus)
29
+ - [getPermissionsAuthorizationStatus()](#getpermissionsauthorizationstatus)
30
+ - [requestRuntimePermission()](#requestruntimepermission)
31
+ - [requestRuntimePermissions()](#requestruntimepermissions)
32
+ - [isRequestingPermission()](#isrequestingpermission)
33
+ - [registerPermissionRequestCompleteHandler()](#registerpermissionrequestcompletehandler)
34
+ - [isDataRoamingEnabled()](#isdataroamingenabled)
35
+ - [isADBModeEnabled()](#isadbmodeenabled)
36
+ - [isDeviceRooted()](#isdevicerooted)
37
+ - [isBackgroundRefreshAuthorized()](#isbackgroundrefreshauthorized)
38
+ - [getBackgroundRefreshStatus()](#getbackgroundrefreshstatus)
39
+ - [cpuArchitecture constants](#cpuarchitecture-constants)
40
+ - [getArchitecture()](#getarchitecture)
41
+ - [restart()](#restart)
42
+ - [enableDebug()](#enabledebug)
43
+ - [getCurrentBatteryLevel()](#getcurrentbatterylevel)
44
+ - [isAirplaneModeEnabled()](#isairplanemodeenabled)
45
+ - [isMobileDataEnabled()](#ismobiledataenabled)
46
+ - [getDeviceOSVersion()](#getdeviceosversion)
47
+ - [getBuildOSVersion()](#getbuildosversion)
48
+ - [Location module](#location-module)
49
+ - [locationMode constants](#locationmode-constants)
50
+ - [locationAuthorizationMode constants](#locationauthorizationmode-constants)
51
+ - [locationAccuracyAuthorization constants](#locationaccuracyauthorization-constants)
52
+ - [isLocationAvailable()](#islocationavailable)
53
+ - [isLocationEnabled()](#islocationenabled)
54
+ - [isGpsLocationAvailable()](#isgpslocationavailable)
55
+ - [isGpsLocationEnabled()](#isgpslocationenabled)
56
+ - [isNetworkLocationAvailable()](#isnetworklocationavailable)
57
+ - [isNetworkLocationEnabled()](#isnetworklocationenabled)
58
+ - [getLocationMode()](#getlocationmode)
59
+ - [isLocationAuthorized()](#islocationauthorized)
60
+ - [getLocationAuthorizationStatus()](#getlocationauthorizationstatus)
61
+ - [getLocationAuthorizationStatuses()](#getlocationauthorizationstatuses)
62
+ - [requestLocationAuthorization()](#requestlocationauthorization)
63
+ - [registerLocationStateChangeHandler()](#registerlocationstatechangehandler)
64
+ - [getLocationAccuracyAuthorization()](#getlocationaccuracyauthorization)
65
+ - [requestTemporaryFullAccuracyAuthorization()](#requesttemporaryfullaccuracyauthorization)
66
+ - [registerLocationAccuracyAuthorizationChangeHandler()](#registerlocationaccuracyauthorizationchangehandler)
67
+ - [switchToLocationSettings()](#switchtolocationsettings)
68
+ - [Bluetooth module](#bluetooth-module)
69
+ - [bluetoothState constants](#bluetoothstate-constants)
70
+ - [isBluetoothAvailable()](#isbluetoothavailable)
71
+ - [isBluetoothEnabled()](#isbluetoothenabled)
72
+ - [hasBluetoothSupport()](#hasbluetoothsupport)
73
+ - [hasBluetoothLESupport()](#hasbluetoothlesupport)
74
+ - [hasBluetoothLEPeripheralSupport()](#hasbluetoothleperipheralsupport)
75
+ - [getBluetoothState()](#getbluetoothstate)
76
+ - [setBluetoothState()](#setbluetoothstate)
77
+ - [getBluetoothAuthorizationStatus()](#getbluetoothauthorizationstatus)
78
+ - [getBluetoothAuthorizationStatuses()](#getbluetoothauthorizationstatuses)
79
+ - [requestBluetoothAuthorization()](#requestbluetoothauthorization)
80
+ - [registerBluetoothStateChangeHandler()](#registerbluetoothstatechangehandler)
81
+ - [switchToBluetoothSettings()](#switchtobluetoothsettings)
82
+ - [WiFi module](#wifi-module)
83
+ - [isWifiAvailable()](#iswifiavailable)
84
+ - [isWifiEnabled()](#iswifienabled)
85
+ - [setWifiState()](#setwifistate)
86
+ - [switchToWifiSettings()](#switchtowifisettings)
87
+ - [Camera module](#camera-module)
88
+ - [isCameraPresent()](#iscamerapresent)
89
+ - [isCameraAvailable()](#iscameraavailable)
90
+ - [isCameraAuthorized()](#iscameraauthorized)
91
+ - [getCameraAuthorizationStatus()](#getcameraauthorizationstatus)
92
+ - [requestCameraAuthorization()](#requestcameraauthorization)
93
+ - [isCameraRollAuthorized()](#iscamerarollauthorized)
94
+ - [getCameraRollAuthorizationStatus()](#getcamerarollauthorizationstatus)
95
+ - [requestCameraRollAuthorization()](#requestcamerarollauthorization)
96
+ - [presentLimitedLibraryPicker()](#presentlimitedlibrarypicker)
97
+ - [Notifications module](#notifications-module)
98
+ - [remoteNotificationType constants](#remotenotificationtype-constants)
99
+ - [isRemoteNotificationsEnabled()](#isremotenotificationsenabled)
100
+ - [isRegisteredForRemoteNotifications()](#isregisteredforremotenotifications)
101
+ - [getRemoteNotificationTypes()](#getremotenotificationtypes)
102
+ - [getRemoteNotificationsAuthorizationStatus()](#getremotenotificationsauthorizationstatus)
103
+ - [requestRemoteNotificationsAuthorization()](#requestremotenotificationsauthorization)
104
+ - [switchToNotificationSettings()](#switchtonotificationsettings)
105
+ - [Microphone module](#microphone-module)
106
+ - [isMicrophoneAuthorized()](#ismicrophoneauthorized)
107
+ - [getMicrophoneAuthorizationStatus()](#getmicrophoneauthorizationstatus)
108
+ - [requestMicrophoneAuthorization()](#requestmicrophoneauthorization)
109
+ - [Contacts module](#contacts-module)
110
+ - [isContactsAuthorized()](#iscontactsauthorized)
111
+ - [getContactsAuthorizationStatus()](#getcontactsauthorizationstatus)
112
+ - [requestContactsAuthorization()](#requestcontactsauthorization)
113
+ - [Calendar module](#calendar-module)
114
+ - [isCalendarAuthorized()](#iscalendarauthorized)
115
+ - [getCalendarAuthorizationStatus()](#getcalendarauthorizationstatus)
116
+ - [requestCalendarAuthorization()](#requestcalendarauthorization)
117
+ - [Reminders module](#reminders-module)
118
+ - [isRemindersAuthorized()](#isremindersauthorized)
119
+ - [getRemindersAuthorizationStatus()](#getremindersauthorizationstatus)
120
+ - [requestRemindersAuthorization()](#requestremindersauthorization)
121
+ - [Motion module](#motion-module)
122
+ - [motionStatus constants](#motionstatus-constants)
123
+ - [isMotionAvailable()](#ismotionavailable)
124
+ - [isMotionRequestOutcomeAvailable()](#ismotionrequestoutcomeavailable)
125
+ - [requestMotionAuthorization()](#requestmotionauthorization)
126
+ - [getMotionAuthorizationStatus()](#getmotionauthorizationstatus)
127
+ - [NFC module](#nfc-module)
128
+ - [NFCState constants](#nfcstate-constants)
129
+ - [isNFCPresent()](#isnfcpresent)
130
+ - [isNFCEnabled()](#isnfcenabled)
131
+ - [isNFCAvailable()](#isnfcavailable)
132
+ - [registerNFCStateChangeHandler()](#registernfcstatechangehandler)
133
+ - [switchToNFCSettings()](#switchtonfcsettings)
134
+ - [External storage module](#external-storage-module)
135
+ - [isExternalStorageAuthorized()](#isexternalstorageauthorized)
136
+ - [getExternalStorageAuthorizationStatus()](#getexternalstorageauthorizationstatus)
137
+ - [requestExternalStorageAuthorization()](#requestexternalstorageauthorization)
138
+ - [getExternalSdCardDetails()](#getexternalsdcarddetails)
139
+ - [Platform Notes](#platform-notes)
140
+ - [Android](#android)
141
+ - [Android permissions](#android-permissions)
142
+ - [Android Auto Backup](#android-auto-backup)
143
+ - [iOS](#ios)
144
+ - [iOS usage description messages](#ios-usage-description-messages)
145
+ - [Example project](#example-project)
146
+ - [Screenshots](#screenshots)
147
+ - [Android](#android-1)
148
+ - [iOS](#ios-1)
149
+ - [Release notes](#release-notes)
150
+ - [Credits](#credits)
151
+ - [License](#license)
152
+
153
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
154
154
 
155
155
 
156
156
  # Overview
@@ -651,6 +651,7 @@ Platforms: Android
651
651
 
652
652
  Checks if the device data roaming setting is enabled.
653
653
  Returns true if data roaming is enabled.
654
+ Not available on Android 12L / API 32+
654
655
 
655
656
  cordova.plugins.diagnostic.isDataRoamingEnabled(successCallback, errorCallback);
656
657
 
@@ -2193,13 +2194,11 @@ Notes:
2193
2194
  - On Android & iOS this returns true if the device has a camera AND the application is authorized to use it.
2194
2195
 
2195
2196
  Notes for Android:
2196
- - On Android by default this checks run-time permission for both `READ_EXTERNAL_STORAGE` and `CAMERA` because [cordova-plugin-camera@2.2+](https://github.com/apache/cordova-plugin-camera) requires both of these permissions.
2197
- - The call signature `cordova.plugins.diagnostic.isCameraAvailable(successCallback, errorCallback, externalStorage)` is also supported for benefit of the [ionic-native Promise API wrapper](https://github.com/driftyco/ionic-native/blob/master/src/%40ionic-native/plugins/diagnostic/index.ts).
2197
+ - By default this also checks run-time storage permissions in addition to `CAMERA` permission because [cordova-plugin-camera](https://github.com/apache/cordova-plugin-camera) requires both of these permission sets.
2198
+ - On Android 13+, storage permissions are `READ_MEDIA_IMAGES` and `READ_MEDIA_VIDEO`. On Android 12 and below, storage permissions are `READ_EXTERNAL_STORAGE` and `WRITE_EXTERNAL_STORAGE`.
2198
2199
 
2199
2200
  ```
2200
- cordova.plugins.diagnostic.isCameraAvailable(params);
2201
- cordova.plugins.diagnostic.isCameraAvailable(successCallback, errorCallback, params)
2202
- cordova.plugins.diagnostic.isCameraAvailable(successCallback, errorCallback, externalStorage)
2201
+ cordova.plugins.diagnostic.isCameraAvailable(successCallback, errorCallback, storage)
2203
2202
  ```
2204
2203
 
2205
2204
  #### Parameters
@@ -2208,32 +2207,11 @@ cordova.plugins.diagnostic.isCameraAvailable(successCallback, errorCallback, ext
2208
2207
  The function is passed a single boolean parameter which is TRUE if camera is present and authorized for use.
2209
2208
  - {Function} errorCallback - The callback which will be called when operation encounters an error.
2210
2209
  The function is passed a single string parameter containing the error message.
2211
- - {Boolean} externalStorage - (Android only) If true, checks permission for `READ_EXTERNAL_STORAGE` in addition to `CAMERA` run-time permission.
2212
- Defaults to true.
2210
+ - {Boolean} storage - (Android only) If true, requests storage permissions in addition to `CAMERA` run-time permission. Defaults to true.
2213
2211
 
2214
2212
 
2215
2213
  #### Example usage
2216
2214
 
2217
- cordova.plugins.diagnostic.isCameraAvailable({
2218
- successCallback: function(available){
2219
- console.log("Camera is " + (available ? "available" : "not available"));
2220
- },
2221
- errorCallback: function(error){
2222
- console.error("The following error occurred: "+error);
2223
- },
2224
- externalStorage: false
2225
- });
2226
-
2227
- cordova.plugins.diagnostic.isCameraAvailable(
2228
- function(available){
2229
- console.log("Camera is " + (available ? "available" : "not available"));
2230
- }, function(error){
2231
- console.error("The following error occurred: "+error);
2232
- }, {
2233
- externalStorage: false
2234
- }
2235
- );
2236
-
2237
2215
  cordova.plugins.diagnostic.isCameraAvailable(
2238
2216
  function(available){
2239
2217
  console.log("Camera is " + (available ? "available" : "not available"));
@@ -2250,13 +2228,11 @@ Checks if the application is authorized to use the camera.
2250
2228
 
2251
2229
  Notes for Android:
2252
2230
  - This is intended for Android 6 / API 23 and above. Calling on Android 5.1 / API 22 and below will always return TRUE as permissions are already granted at installation time.
2253
- - By default this checks run-time permission for both `READ_EXTERNAL_STORAGE` and `CAMERA` because [cordova-plugin-camera@2.2+](https://github.com/apache/cordova-plugin-camera) requires both of these permissions.
2254
- - The call signature `cordova.plugins.diagnostic.isCameraAuthorized(successCallback, errorCallback, externalStorage)` is also supported for benefit of the [ionic-native Promise API wrapper](https://github.com/driftyco/ionic-native/blob/master/src/%40ionic-native/plugins/diagnostic/index.ts).
2231
+ - By default this also checks run-time storage permissions in addition to `CAMERA` permission because [cordova-plugin-camera](https://github.com/apache/cordova-plugin-camera) requires both of these permission sets.
2232
+ - On Android 13+, storage permissions are `READ_MEDIA_IMAGES` and `READ_MEDIA_VIDEO`. On Android 12 and below, storage permissions are `READ_EXTERNAL_STORAGE` and `WRITE_EXTERNAL_STORAGE`.
2255
2233
 
2256
2234
  ```
2257
- cordova.plugins.diagnostic.isCameraAuthorized(params);
2258
- cordova.plugins.diagnostic.isCameraAuthorized(successCallback, errorCallback, params)
2259
- cordova.plugins.diagnostic.isCameraAuthorized(successCallback, errorCallback, externalStorage)
2235
+ cordova.plugins.diagnostic.isCameraAuthorized(successCallback, errorCallback, storage)
2260
2236
  ```
2261
2237
 
2262
2238
  #### Parameters
@@ -2265,31 +2241,10 @@ cordova.plugins.diagnostic.isCameraAuthorized(successCallback, errorCallback, ex
2265
2241
  The function is passed a single boolean parameter which is TRUE if camera is authorized for use.
2266
2242
  - {Function} errorCallback - The callback which will be called when operation encounters an error.
2267
2243
  The function is passed a single string parameter containing the error message.
2268
- - {Boolean} externalStorage - (Android only) If true, checks permission for `READ_EXTERNAL_STORAGE` in addition to `CAMERA` run-time permission.
2269
- Defaults to true.
2244
+ - {Boolean} storage - (Android only) If true, requests storage permissions in addition to `CAMERA` run-time permission. Defaults to true.
2270
2245
 
2271
2246
  #### Example usage
2272
2247
 
2273
- cordova.plugins.diagnostic.isCameraAuthorized({
2274
- successCallback: function(authorized){
2275
- console.log("App is " + (authorized ? "authorized" : "denied") + " access to the camera");
2276
- },
2277
- errorCallback: function(error){
2278
- console.error("The following error occurred: "+error);
2279
- },
2280
- externalStorage: false
2281
- });
2282
-
2283
- cordova.plugins.diagnostic.isCameraAuthorized(
2284
- function(authorized){
2285
- console.log("App is " + (authorized ? "authorized" : "denied") + " access to the camera");
2286
- }, function(error){
2287
- console.error("The following error occurred: "+error);
2288
- }, {
2289
- externalStorage: false
2290
- }
2291
- );
2292
-
2293
2248
  cordova.plugins.diagnostic.isCameraAuthorized(
2294
2249
  function(authorized){
2295
2250
  console.log("App is " + (authorized ? "authorized" : "denied") + " access to the camera");
@@ -2306,13 +2261,11 @@ Returns the camera authorization status for the application.
2306
2261
 
2307
2262
  Notes for Android:
2308
2263
  - This is intended for Android 6 / API 23 and above. Calling on Android 5.1 / API 22 and below will always return GRANTED status as permissions are already granted at installation time.
2309
- - By default this checks run-time permission for both `READ_EXTERNAL_STORAGE` and `CAMERA` because [cordova-plugin-camera@2.2+](https://github.com/apache/cordova-plugin-camera) requires both of these permissions.
2310
- - The call signature `cordova.plugins.diagnostic.getCameraAuthorizationStatus(successCallback, errorCallback, externalStorage)` is also supported for benefit of the [ionic-native Promise API wrapper](https://github.com/driftyco/ionic-native/blob/master/src/%40ionic-native/plugins/diagnostic/index.ts).
2264
+ - By default this also checks run-time storage permissions in addition to `CAMERA` permission because [cordova-plugin-camera](https://github.com/apache/cordova-plugin-camera) requires both of these permission sets.
2265
+ - On Android 13+, storage permissions are `READ_MEDIA_IMAGES` and `READ_MEDIA_VIDEO`. On Android 12 and below, storage permissions are `READ_EXTERNAL_STORAGE` and `WRITE_EXTERNAL_STORAGE`.
2311
2266
 
2312
2267
  ```
2313
- cordova.plugins.diagnostic.getCameraAuthorizationStatus(params);
2314
- cordova.plugins.diagnostic.getCameraAuthorizationStatus(successCallback, errorCallback, params)
2315
- cordova.plugins.diagnostic.getCameraAuthorizationStatus(successCallback, errorCallback, externalStorage)
2268
+ cordova.plugins.diagnostic.getCameraAuthorizationStatus(successCallback, errorCallback, storage)
2316
2269
  ```
2317
2270
 
2318
2271
  #### Parameters
@@ -2321,36 +2274,11 @@ cordova.plugins.diagnostic.getCameraAuthorizationStatus(successCallback, errorCa
2321
2274
  The function is passed a single string parameter which indicates the authorization status as a [permissionStatus constant](#permissionstatus-constants).
2322
2275
  - {Function} errorCallback - The callback which will be called when operation encounters an error.
2323
2276
  The function is passed a single string parameter containing the error message.
2324
- - {Boolean} externalStorage - (Android only) If true, checks permission for `READ_EXTERNAL_STORAGE` in addition to `CAMERA` run-time permission.
2325
- Defaults to true.
2277
+ - {Boolean} storage - (Android only) If true, requests storage permissions in addition to `CAMERA` run-time permission. Defaults to true.
2326
2278
 
2327
2279
 
2328
2280
  #### Example usage
2329
2281
 
2330
- cordova.plugins.diagnostic.getCameraAuthorizationStatus({
2331
- successCallback: function(status){
2332
- if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
2333
- console.log("Camera use is authorized");
2334
- }
2335
- },
2336
- errorCallback: function(error){
2337
- console.error("The following error occurred: "+error);
2338
- },
2339
- externalStorage: false
2340
- });
2341
-
2342
- cordova.plugins.diagnostic.getCameraAuthorizationStatus(
2343
- function(status){
2344
- if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
2345
- console.log("Camera use is authorized");
2346
- }
2347
- }, function(error){
2348
- console.error("The following error occurred: "+error);
2349
- }, {
2350
- externalStorage: false
2351
- }
2352
- );
2353
-
2354
2282
  cordova.plugins.diagnostic.getCameraAuthorizationStatus(
2355
2283
  function(status){
2356
2284
  if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
@@ -2375,49 +2303,25 @@ this plugin provides a default message, but you should override this with your s
2375
2303
 
2376
2304
  Notes for Android:
2377
2305
  - This is intended for Android 6 / API 23 and above. Calling on Android 5.1 / API 22 and below will have no effect as the permissions are already granted at installation time.
2378
- - By default this requests run-time permission for both `READ_EXTERNAL_STORAGE` and `CAMERA` because [cordova-plugin-camera@2.2+](https://github.com/apache/cordova-plugin-camera) requires both of these permissions.
2306
+ - By default this requests run-time storage permissions in addition to `CAMERA` permission because [cordova-plugin-camera](https://github.com/apache/cordova-plugin-camera) requires both of these permission sets.
2307
+ - On Android 13+, storage permissions are `READ_MEDIA_IMAGES` and `READ_MEDIA_VIDEO`. On Android 12 and below, storage permissions are `READ_EXTERNAL_STORAGE` and `WRITE_EXTERNAL_STORAGE`.
2379
2308
  - Requested run-time permissions which must be added to `AndroidManifest.xml` - see [Android camera permissions](#android-camera-permissions).
2380
- - The call signature `cordova.plugins.diagnostic.requestCameraAuthorization(successCallback, errorCallback, externalStorage)` is also supported for benefit of the [ionic-native Promise API wrapper](https://github.com/driftyco/ionic-native/blob/master/src/%40ionic-native/plugins/diagnostic/index.ts).
2381
2309
 
2382
2310
  ```
2383
- cordova.plugins.diagnostic.requestCameraAuthorization(params);
2384
- cordova.plugins.diagnostic.requestCameraAuthorization(successCallback, errorCallback, params)
2385
- cordova.plugins.diagnostic.requestCameraAuthorization(successCallback, errorCallback, externalStorage)
2311
+ cordova.plugins.diagnostic.requestCameraAuthorization(successCallback, errorCallback, storage)
2386
2312
  ```
2387
2313
 
2388
2314
  #### Parameters
2389
2315
 
2390
2316
  - {Object} params - (optional) parameters:
2391
2317
  - {Function} successCallback - The callback which will be called when operation is successful.
2392
- The function is passed a single string parameter indicating whether access to the camera was granted or denied:
2393
- `cordova.plugins.diagnostic.permissionStatus.GRANTED` or `cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS`
2318
+ The function is passed a single string parameter indicating the resulting permission status.
2394
2319
  - {Function} errorCallback - The callback which will be called when operation encounters an error.
2395
2320
  The function is passed a single string parameter containing the error message.
2396
- - {Boolean} externalStorage - (Android only) If true, requests permission for `READ_EXTERNAL_STORAGE` in addition to `CAMERA` run-time permission.
2397
- Defaults to true.
2321
+ - {Boolean} storage - (Android only) If true, requests storage permissions in addition to `CAMERA` run-time permission. Defaults to true.
2398
2322
 
2399
2323
  #### Example usage
2400
2324
 
2401
- cordova.plugins.diagnostic.requestCameraAuthorization({
2402
- successCallback: function(status){
2403
- console.log("Authorization request for camera use was " + (status == cordova.plugins.diagnostic.permissionStatus.GRANTED ? "granted" : "denied"));
2404
- },
2405
- errorCallback: function(error){
2406
- console.error(error);
2407
- },
2408
- externalStorage: false
2409
- });
2410
-
2411
- cordova.plugins.diagnostic.requestCameraAuthorization(
2412
- function(status){
2413
- console.log("Authorization request for camera use was " + (status == cordova.plugins.diagnostic.permissionStatus.GRANTED ? "granted" : "denied"));
2414
- }, function(error){
2415
- console.error("The following error occurred: "+error);
2416
- }, {
2417
- externalStorage: false
2418
- }
2419
- );
2420
-
2421
2325
  cordova.plugins.diagnostic.requestCameraAuthorization(
2422
2326
  function(status){
2423
2327
  console.log("Authorization request for camera use was " + (status == cordova.plugins.diagnostic.permissionStatus.GRANTED ? "granted" : "denied"));
@@ -3764,13 +3668,97 @@ The plugin defines all [dangerous permissions](http://developer.android.com/guid
3764
3668
  - `cordova.plugins.diagnostic.permission.WRITE_CONTACTS`
3765
3669
  - `cordova.plugins.diagnostic.permission.WRITE_EXTERNAL_STORAGE`
3766
3670
 
3671
+
3672
+ ##### Android 11+ runtime permissions
3673
+ Android 11 introduced a new option for the user when granting runtime permissions: "Only this time"/"Ask every time".
3674
+ This allows the user to temporarily grant a permission only for the current app session: the requested permission will be available to the app during the current session but when the app is restarted, permission will be revoked and the app will have to request it again.
3675
+ This causes a problem for this plugin because it is unable to detect that the permission has been silently revoked by Android in the new app session.
3676
+
3677
+ When runtime permissions were introduced in Android 6.0, there was already a deficiency in the Android permissions model: the Android SDK provides no way to differentiate between a permission that has not been requested yet (`NOT_REQUESTED`) or has been permanently denied (`DENIED_ALWAYS`) - they have the same programmatic state. Therefore this plugin uses local persistent storage to flag when a given permission has been requested and granted via the plugin. So if Android indicates `NOT_REQUESTED`/`DENIED_ALWAYS`, the plugin uses the state of the persistent flag to determine if that permission has been requested before and therefore can differentiate between `NOT_REQUESTED` and `DENIED_ALWAYS`.
3678
+
3679
+ This worked fine up until Android 10, however the "Only this time" option added in Android 11 causes a problem:
3680
+ There's no way for the plugin to tell if the user pressed "Only this time" or "Allow always" in the permissions dialog because the programmatic outcome in Android is the same: the permission state is `GRANTED`.
3681
+ Therefore in both cases, the plugin flags this permission as having been requested.
3682
+ But if the user pressed "Only this time", when the app is restarted the permission is silently revoked by Android and so when the native Android state indicates `NOT_REQUESTED`/`DENIED_ALWAYS`, the plugin determines that since the flag has been set for that permission, the state must be `DENIED_ALWAYS`.
3683
+
3684
+ There is no programmatic solution that the plugin can implement to solve this - it is a deficiency in the Android permission states model.
3685
+ There is however a workaround which is to assume that even if the reported permission status is `DENIED_ALWAYS`, the permission *may* still be requestable.
3686
+
3687
+ Here's a short example of how to do this using the `CAMERA` permission:
3688
+
3689
+ ```javascript
3690
+
3691
+ let diagnostic, deviceOS;
3692
+ let cameraDeniedAlwaysAfterRequesting = false;
3693
+
3694
+ function onDeviceReady(){
3695
+ diagnostic = cordova.plugins.diagnostic; // alias to shorter namespace
3696
+ diagnostic.getDeviceOSVersion(function(osDetails){
3697
+ deviceOS = osDetails;
3698
+ checkCameraPermission();
3699
+ })
3700
+ }
3701
+
3702
+ function checkCameraPermission(){
3703
+ diagnostic.getPermissionAuthorizationStatus(function(status){
3704
+
3705
+ // If running on Android 11+ and status is DENIED_ALWAYS, assume it can still be requested (i.e. user selected "Only once" in previous app session)
3706
+ if(deviceOS.apiLevel >= 30 && status === diagnostic.permissionStatus.DENIED_ALWAYS && !cameraDeniedAlwaysAfterRequesting){
3707
+ status = diagnostic.permissionStatus.DENIED_ONCE;
3708
+ }
3709
+
3710
+ switch(status){
3711
+ case diagnostic.permissionStatus.GRANTED:
3712
+ console.log("Camera permission is allowed")
3713
+ break;
3714
+ case diagnostic.permissionStatus.NOT_REQUESTED:
3715
+ console.log("Camera permission not requested yet - requesting...")
3716
+ requestCameraPermission();
3717
+ break;
3718
+ case diagnostic.permissionStatus.DENIED_ONCE:
3719
+ console.log("Camera permission denied but can still request - requesting...")
3720
+ requestCameraPermission();
3721
+ break;
3722
+ case diagnostic.permissionStatus.DENIED_ONCE:
3723
+ console.log("Camera permission permanently denied - can't request");
3724
+ break;
3725
+ }
3726
+ }, console.error, diagnostic.permission.CAMERA)
3727
+ };
3728
+
3729
+ function requestCameraPermission(){
3730
+ diagnostic.requestRuntimePermission(function(status){
3731
+
3732
+ // If result is DENIED_ALWAYS after requesting then it really is permanently denied
3733
+ if(status === diagnostic.permissionStatus.DENIED_ALWAYS){
3734
+ cameraDeniedAlwaysAfterRequesting = true;
3735
+ }
3736
+
3737
+ // Re-check permission
3738
+ checkCameraPermission();
3739
+
3740
+ }, console.error, diagnostic.permission.CAMERA);
3741
+ }
3742
+
3743
+ document.addEventListener("deviceready", onDeviceReady, false);
3744
+
3745
+ ```
3746
+
3747
+
3748
+
3767
3749
  ##### Runtime permissions example project
3768
3750
 
3769
3751
  While the [cordova-diagnostic-plugin-example](https://github.com/dpa99c/cordova-diagnostic-plugin-example) illustrates use of runtime permissions in the context of requesting location and camera access, the [cordova-diagnostic-plugin-android-runtime-example](https://github.com/dpa99c/cordova-diagnostic-plugin-android-runtime-example) project explicitly illustrates use of Android runtime permissions with this plugin.
3770
3752
 
3771
3753
  ##### Android Camera permissions
3772
3754
 
3773
- Note that the Android variant of [`requestCameraAuthorization()`](#requestcameraauthorization) requests the `READ_EXTERNAL_STORAGE` permission, in addition to the `CAMERA` permission.
3755
+ Note that the Android variant of [`requestCameraAuthorization()`](#requestcameraauthorization), in addition to the `CAMERA` permission, by default also requests storage permissions.
3756
+ This is because the Android camera API requires access to the device's storage to store captured images and videos.
3757
+
3758
+ On Android <=12, this requires the `WRITE_EXTERNAL_STORAGE` and `READ_EXTERNAL_STORAGE` permissions.
3759
+ On Android >12, this requires the `READ_MEDIA_IMAGES` and `READ_MEDIA_VIDEO` permissions.
3760
+
3761
+ the `READ_EXTERNAL_STORAGE` permission.
3774
3762
  This is because the [cordova-plugin-camera@2.2+](https://github.com/apache/cordova-plugin-camera) requires both of these permissions.
3775
3763
 
3776
3764
  So to use this method in conjunction with the Cordova camera plugin, make sure you are using the most recent `cordova-plugin-camera` release: v2.2.0 or above.
@@ -1001,7 +1001,7 @@ interface Diagnostic {
1001
1001
  * @param errorCallback
1002
1002
  */
1003
1003
  presentLimitedLibraryPicker?: (
1004
- successCallback: (identifiers?: [string]) => void,
1004
+ successCallback: (identifiers?: string[]) => void,
1005
1005
  errorCallback: (error: string) => void
1006
1006
  ) => void;
1007
1007
 
@@ -1149,7 +1149,7 @@ interface Diagnostic {
1149
1149
  requestBluetoothAuthorization?: (
1150
1150
  successCallback: () => void,
1151
1151
  errorCallback: (error: string) => void,
1152
- permissions?: ([string])
1152
+ permissions?: (string[])
1153
1153
  ) => void;
1154
1154
 
1155
1155
  /**
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.1.1",
2
+ "version": "7.1.3",
3
3
  "name": "cordova.plugins.diagnostic",
4
4
  "cordova_name": "Diagnostic",
5
5
  "description": "Cordova/Phonegap plugin to check the state of Location/WiFi/Camera/Bluetooth device settings.",
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.1.1">
5
+ version="7.1.3">
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>
@@ -266,6 +266,11 @@ public class Diagnostic extends CordovaPlugin{
266
266
  switchToWirelessSettings();
267
267
  callbackContext.success();
268
268
  } else if(action.equals("isDataRoamingEnabled")) {
269
+ if(Build.VERSION.SDK_INT <= 32) { // Android 12L
270
+ callbackContext.success(isDataRoamingEnabled() ? 1 : 0);
271
+ } else {
272
+ callbackContext.error("Data roaming setting not available on Android 12L / API32+");
273
+ }
269
274
  callbackContext.success(isDataRoamingEnabled() ? 1 : 0);
270
275
  } else if(action.equals("getPermissionAuthorizationStatus")) {
271
276
  this.getPermissionAuthorizationStatus(args);
@@ -315,13 +320,7 @@ public class Diagnostic extends CordovaPlugin{
315
320
 
316
321
 
317
322
  public boolean isDataRoamingEnabled() throws Exception {
318
- boolean result;
319
- if (Build.VERSION.SDK_INT < 17) {
320
- result = Settings.System.getInt(this.cordova.getActivity().getContentResolver(), Settings.Global.DATA_ROAMING, 0) == 1;
321
- }else{
322
- result = Settings.Global.getInt(this.cordova.getActivity().getContentResolver(), Settings.Global.DATA_ROAMING, 0) == 1;
323
- }
324
- return result;
323
+ return Settings.Global.getInt(this.cordova.getActivity().getContentResolver(), Settings.Global.DATA_ROAMING, 0) == 1;
325
324
  }
326
325
 
327
326
  public void switchToAppSettings() {
@@ -565,7 +564,7 @@ public class Diagnostic extends CordovaPlugin{
565
564
  String androidPermission = permissionsMap.get(permission);
566
565
  Log.v(TAG, "Get authorisation status for "+androidPermission);
567
566
  boolean granted = hasRuntimePermission(androidPermission);
568
- if(granted){
567
+ if(granted || isPermissionImplicitlyGranted(permission)){
569
568
  statuses.put(permission, Diagnostic.STATUS_GRANTED);
570
569
  }else{
571
570
  boolean showRationale = shouldShowRequestPermissionRationale(this.cordova.getActivity(), androidPermission);
@@ -589,7 +588,7 @@ public class Diagnostic extends CordovaPlugin{
589
588
  for(int i = 0; i<currentPermissionsStatuses.names().length(); i++){
590
589
  String permission = currentPermissionsStatuses.names().getString(i);
591
590
  boolean granted = currentPermissionsStatuses.getString(permission) == Diagnostic.STATUS_GRANTED;
592
- if(granted){
591
+ if(granted || isPermissionImplicitlyGranted(permission)){
593
592
  Log.d(TAG, "Permission already granted for "+permission);
594
593
  JSONObject requestStatuses = permissionStatuses.get(String.valueOf(requestId));
595
594
  requestStatuses.put(permission, Diagnostic.STATUS_GRANTED);
@@ -610,6 +609,26 @@ public class Diagnostic extends CordovaPlugin{
610
609
  }
611
610
  }
612
611
 
612
+ protected boolean isPermissionImplicitlyGranted(String permission) throws Exception{
613
+ boolean isImplicitlyGranted = false;
614
+ int buildTargetSdkVersion = getBuildTargetSdkVersion();
615
+ int deviceRuntimeSdkVersion = getDeviceRuntimeSdkVersion();
616
+
617
+ if(buildTargetSdkVersion >= 33 && deviceRuntimeSdkVersion < 33 && (
618
+ permission.equals("ACCESS_BACKGROUND_LOCATION") ||
619
+ permission.equals("POST_NOTIFICATIONS") ||
620
+ permission.equals("READ_MEDIA_AUDIO") ||
621
+ permission.equals("READ_MEDIA_IMAGES") ||
622
+ permission.equals("READ_MEDIA_VIDEO") ||
623
+ permission.equals("BODY_SENSORS_BACKGROUND") ||
624
+ permission.equals("NEARBY_WIFI_DEVICES")
625
+
626
+ )) {
627
+ isImplicitlyGranted = true;
628
+ }
629
+ return isImplicitlyGranted;
630
+ }
631
+
613
632
  protected void sendRuntimeRequestResult(int requestId){
614
633
  String sRequestId = String.valueOf(requestId);
615
634
  CallbackContext context = callbackContexts.get(sRequestId);
@@ -658,6 +677,17 @@ public class Diagnostic extends CordovaPlugin{
658
677
  return arr;
659
678
  }
660
679
 
680
+ protected JSONArray stringArrayToJsonArray(String[] array) throws JSONException{
681
+ if(array==null)
682
+ return null;
683
+
684
+ JSONArray arr = new JSONArray();
685
+ for(int i=0; i<array.length; i++) {
686
+ arr.put(i, array[i]);
687
+ }
688
+ return arr;
689
+ }
690
+
661
691
  protected CallbackContext getContextById(String requestId) throws Exception{
662
692
  if (!callbackContexts.containsKey(requestId)) {
663
693
  throw new Exception("No context found for request id=" + requestId);
@@ -853,31 +883,51 @@ public class Diagnostic extends CordovaPlugin{
853
883
  public JSONObject getDeviceOSVersion() throws Exception{
854
884
  JSONObject details = new JSONObject();
855
885
  details.put("version", Build.VERSION.RELEASE);
856
- details.put("apiLevel", Build.VERSION.SDK_INT);
857
- details.put("apiName", getNameForApiLevel(Build.VERSION.SDK_INT));
886
+ int buildVersion = getDeviceRuntimeSdkVersion();
887
+ details.put("apiLevel", buildVersion);
888
+ details.put("apiName", getNameForApiLevel(buildVersion));
858
889
  return details;
859
890
  }
860
891
 
892
+ protected int getDeviceRuntimeSdkVersion() {
893
+ return Build.VERSION.SDK_INT;
894
+ }
895
+
861
896
  public JSONObject getBuildOSVersion() throws Exception{
862
897
  JSONObject details = new JSONObject();
898
+ int targetVersion = getBuildTargetSdkVersion();
899
+ int minVersion = getBuildMinimumSdkVersion();
900
+
901
+ details.put("targetApiLevel", targetVersion);
902
+ details.put("targetApiName", getNameForApiLevel(targetVersion));
903
+ details.put("minApiLevel", minVersion);
904
+ details.put("minApiName", getNameForApiLevel(minVersion));
905
+ return details;
906
+ }
907
+
908
+ protected int getBuildTargetSdkVersion() throws Exception{
863
909
  int targetVersion = 0;
864
- int minVersion = 0;
865
910
  Activity activity = instance.cordova.getActivity();
866
911
  ApplicationInfo applicationInfo = activity.getPackageManager().getApplicationInfo(activity.getPackageName(), 0);
867
912
  if (applicationInfo != null) {
868
913
  targetVersion = applicationInfo.targetSdkVersion;
914
+ }
915
+ return targetVersion;
916
+ }
917
+
918
+ protected int getBuildMinimumSdkVersion() throws Exception{
919
+ int minVersion = 0;
920
+ Activity activity = instance.cordova.getActivity();
921
+ ApplicationInfo applicationInfo = activity.getPackageManager().getApplicationInfo(activity.getPackageName(), 0);
922
+ if (applicationInfo != null) {
869
923
  if(Build.VERSION.SDK_INT >= 24){
870
924
  minVersion = applicationInfo.minSdkVersion;
871
925
  }
872
926
  }
873
-
874
- details.put("targetApiLevel", targetVersion);
875
- details.put("targetApiName", getNameForApiLevel(targetVersion));
876
- details.put("minApiLevel", minVersion);
877
- details.put("minApiName", getNameForApiLevel(minVersion));
878
- return details;
927
+ return minVersion;
879
928
  }
880
929
 
930
+
881
931
  // https://stackoverflow.com/a/55946200/777265
882
932
  protected String getNameForApiLevel(int apiLevel) throws Exception{
883
933
  Field[] fields = Build.VERSION_CODES.class.getFields();
@@ -890,6 +940,15 @@ public class Diagnostic extends CordovaPlugin{
890
940
  return codeName;
891
941
  }
892
942
 
943
+ protected String[] concatStrings(String[] A, String[] B) {
944
+ int aLen = A.length;
945
+ int bLen = B.length;
946
+ String[] C= new String[aLen+bLen];
947
+ System.arraycopy(A, 0, C, 0, aLen);
948
+ System.arraycopy(B, 0, C, aLen, bLen);
949
+ return C;
950
+ }
951
+
893
952
  /************
894
953
  * Overrides
895
954
  ***********/
@@ -244,6 +244,10 @@ public class Diagnostic_Bluetooth extends CordovaPlugin {
244
244
  callbackContext.error("Cannot change Bluetooth state as device does not support Bluetooth");
245
245
  return;
246
246
  }
247
+ if(Build.VERSION.SDK_INT >= 33){ // TIRAMISU / Android 13
248
+ callbackContext.error("Cannot change Bluetooth state on Android 13+ as this is no longer supported");
249
+ return;
250
+ }
247
251
 
248
252
  BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
249
253
  boolean isEnabled = bluetoothAdapter.isEnabled();
@@ -252,9 +256,11 @@ public class Diagnostic_Bluetooth extends CordovaPlugin {
252
256
 
253
257
  if (statuses.getString("BLUETOOTH_CONNECT").equals(Diagnostic.STATUS_GRANTED)) {
254
258
  if (enable && !isEnabled) {
259
+ https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#enable()
255
260
  bluetoothAdapter.enable();
256
261
  }
257
262
  else if(!enable && isEnabled) {
263
+ https://developer.android.com/reference/android/bluetooth/BluetoothAdapter#disable()
258
264
  bluetoothAdapter.disable();
259
265
  }
260
266
  callbackContext.success();
@@ -22,8 +22,10 @@ package cordova.plugins;
22
22
  * Imports
23
23
  */
24
24
 
25
+ import android.Manifest;
25
26
  import android.content.pm.PackageManager;
26
27
  import android.hardware.Camera;
28
+ import android.os.Build;
27
29
  import android.util.Log;
28
30
 
29
31
  import org.apache.cordova.CallbackContext;
@@ -32,6 +34,9 @@ import org.apache.cordova.CordovaPlugin;
32
34
  import org.apache.cordova.CordovaWebView;
33
35
  import org.json.JSONArray;
34
36
  import org.json.JSONException;
37
+ import org.json.JSONObject;
38
+
39
+ import java.util.Objects;
35
40
 
36
41
  /**
37
42
  * Diagnostic plugin implementation for Android
@@ -49,6 +54,16 @@ public class Diagnostic_Camera extends CordovaPlugin{
49
54
  */
50
55
  public static final String TAG = "Diagnostic_Camera";
51
56
 
57
+ protected static final String cameraPermission = "CAMERA";
58
+ protected static String[] storagePermissions;
59
+ static {
60
+ if (android.os.Build.VERSION.SDK_INT >= 33) { // Build.VERSION_CODES.TIRAMISU / Android 13
61
+ storagePermissions = new String[]{ "READ_MEDIA_IMAGES", "READ_MEDIA_VIDEO" };
62
+ } else {
63
+ storagePermissions = new String[]{ "READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE" };
64
+ }
65
+ }
66
+
52
67
 
53
68
  /*************
54
69
  * Variables *
@@ -106,12 +121,16 @@ public class Diagnostic_Camera extends CordovaPlugin{
106
121
  try {
107
122
  if(action.equals("isCameraPresent")) {
108
123
  callbackContext.success(isCameraPresent() ? 1 : 0);
124
+ } else if(action.equals("requestCameraAuthorization")) {
125
+ requestCameraAuthorization(args, callbackContext);
126
+ } else if(action.equals("getCameraAuthorizationStatus")) {
127
+ getCameraAuthorizationStatus(args, callbackContext);
109
128
  } else {
110
129
  diagnostic.handleError("Invalid action");
111
130
  return false;
112
131
  }
113
132
  }catch(Exception e ) {
114
- diagnostic.handleError("Exception occurred: ".concat(e.getMessage()));
133
+ diagnostic.handleError("Exception occurred: ".concat(Objects.requireNonNull(e.getMessage())));
115
134
  return false;
116
135
  }
117
136
  return true;
@@ -120,7 +139,7 @@ public class Diagnostic_Camera extends CordovaPlugin{
120
139
  public boolean isCameraPresent() {
121
140
  int numberOfCameras = Camera.getNumberOfCameras();
122
141
  PackageManager pm = this.cordova.getActivity().getPackageManager();
123
- final boolean deviceHasCameraFlag = pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);
142
+ final boolean deviceHasCameraFlag = android.os.Build.VERSION.SDK_INT >= 32 ? pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY) : pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);
124
143
  boolean result = (deviceHasCameraFlag && numberOfCameras>0 );
125
144
  return result;
126
145
  }
@@ -130,5 +149,25 @@ public class Diagnostic_Camera extends CordovaPlugin{
130
149
  * Internals
131
150
  ***********/
132
151
 
152
+ private String[] getPermissions(boolean storage){
153
+ String[] permissions = {cameraPermission};
154
+ if(storage){
155
+ permissions = Diagnostic.instance.concatStrings(permissions, storagePermissions);
156
+ }
157
+ return permissions;
158
+ }
159
+
160
+ private void requestCameraAuthorization(JSONArray args, CallbackContext callbackContext) throws Exception{
161
+ boolean storage = args.getBoolean(0);
162
+ String[] permissions = getPermissions(storage);
163
+ int requestId = Diagnostic.instance.storeContextByRequestId(callbackContext);
164
+ Diagnostic.instance._requestRuntimePermissions(Diagnostic.instance.stringArrayToJsonArray(permissions), requestId);
165
+ }
133
166
 
167
+ private void getCameraAuthorizationStatus(JSONArray args, CallbackContext callbackContext) throws Exception{
168
+ boolean storage = args.getBoolean(0);
169
+ String[] permissions = getPermissions(storage);
170
+ JSONObject statuses = Diagnostic.instance._getPermissionsAuthorizationStatus(permissions);
171
+ callbackContext.success(statuses);
172
+ }
134
173
  }
@@ -136,11 +136,15 @@ public class Diagnostic_External_Storage extends CordovaPlugin{
136
136
  ***********/
137
137
 
138
138
  protected void getExternalSdCardDetails() throws Exception{
139
- String permission = diagnostic.permissionsMap.get(externalStoragePermission);
140
- if (diagnostic.hasRuntimePermission(permission)) {
139
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
141
140
  _getExternalSdCardDetails();
142
141
  } else {
143
- diagnostic.requestRuntimePermission(permission, Diagnostic.GET_EXTERNAL_SD_CARD_DETAILS_PERMISSION_REQUEST);
142
+ String permission = diagnostic.permissionsMap.get(externalStoragePermission);
143
+ if (diagnostic.hasRuntimePermission(permission)) {
144
+ _getExternalSdCardDetails();
145
+ } else {
146
+ diagnostic.requestRuntimePermission(permission, Diagnostic.GET_EXTERNAL_SD_CARD_DETAILS_PERMISSION_REQUEST);
147
+ }
144
148
  }
145
149
  }
146
150
 
@@ -253,7 +253,7 @@ static NSString*const PHOTOLIBRARY_ACCESS_LEVEL_READ_WRITE = @"read_write";
253
253
 
254
254
  - (PHAccessLevel) resolveAccessLevelFromArgument:(NSString*) s_accessLevel API_AVAILABLE(ios(14)){
255
255
  PHAccessLevel ph_accessLevel;
256
- if([s_accessLevel isEqualToString:PHOTOLIBRARY_ACCESS_LEVEL_READ_WRITE]){
256
+ if(![diagnostic isNull:s_accessLevel] && [s_accessLevel isEqualToString:PHOTOLIBRARY_ACCESS_LEVEL_READ_WRITE]){
257
257
  ph_accessLevel = PHAccessLevelReadWrite;
258
258
  }else{
259
259
  ph_accessLevel = PHAccessLevelAddOnly;
@@ -28,23 +28,6 @@ var Diagnostic_Camera = (function(){
28
28
  *
29
29
  ********************/
30
30
 
31
- function combineCameraStatuses(statuses){
32
- var cameraStatus = statuses[Diagnostic.permission.CAMERA],
33
- mediaStatus = statuses[Diagnostic.permission.READ_EXTERNAL_STORAGE],
34
- status;
35
-
36
- if(cameraStatus === Diagnostic.permissionStatus.DENIED_ALWAYS || mediaStatus === Diagnostic.permissionStatus.DENIED_ALWAYS){
37
- status = Diagnostic.permissionStatus.DENIED_ALWAYS;
38
- }else if(cameraStatus === Diagnostic.permissionStatus.DENIED_ONCE || mediaStatus === Diagnostic.permissionStatus.DENIED_ONCE){
39
- status = Diagnostic.permissionStatus.DENIED_ONCE;
40
- }else if(cameraStatus === Diagnostic.permissionStatus.NOT_REQUESTED || mediaStatus === Diagnostic.permissionStatus.NOT_REQUESTED){
41
- status = Diagnostic.permissionStatus.NOT_REQUESTED;
42
- }else{
43
- status = Diagnostic.permissionStatus.GRANTED;
44
- }
45
- return status;
46
- }
47
-
48
31
  function mapFromLegacyCameraApi() {
49
32
  var params;
50
33
  if (typeof arguments[0] === "function") {
@@ -54,7 +37,7 @@ var Diagnostic_Camera = (function(){
54
37
  params.errorCallback = arguments[1];
55
38
  }
56
39
  if(arguments.length > 2 && arguments[2] === false) {
57
- params.externalStorage = arguments[2];
40
+ params.storage = arguments[2];
58
41
  }
59
42
  }else { // if (typeof arguments[0] === "object")
60
43
  params = arguments[0];
@@ -91,8 +74,10 @@ var Diagnostic_Camera = (function(){
91
74
  * This callback function is passed a single boolean parameter which is TRUE if camera is present and authorized for use.
92
75
  * - {Function} errorCallback - The callback which will be called when the operation encounters an error.
93
76
  * This callback function is passed a single string parameter containing the error message.
94
- * - {Boolean} externalStorage - (Android only) If true, checks permission for READ_EXTERNAL_STORAGE in addition to CAMERA run-time permission.
95
- * cordova-plugin-camera@2.2+ requires both of these permissions. Defaults to true.
77
+ * - {Boolean} storage - (Android only) If true, requests storage permissions in addition to CAMERA run-time permission.
78
+ * On Android 13+, storage permissions are READ_MEDIA_IMAGES and READ_MEDIA_VIDEO. On Android 9-12, storage permission is READ_EXTERNAL_STORAGE.
79
+ * cordova-plugin-camera requires both storage and camera permissions.
80
+ * Defaults to true.
96
81
  */
97
82
  Diagnostic_Camera.isCameraAvailable = function(params) {
98
83
  params = mapFromLegacyCameraApi.apply(this, arguments);
@@ -130,47 +115,51 @@ var Diagnostic_Camera = (function(){
130
115
  * - {Function} successCallback - function to call on successful request for runtime permissions.
131
116
  * This callback function is passed a single string parameter which defines the resulting authorisation status as a value in cordova.plugins.diagnostic.permissionStatus.
132
117
  * - {Function} errorCallback - function to call on failure to request authorisation.
133
- * - {Boolean} externalStorage - (Android only) If true, requests permission for READ_EXTERNAL_STORAGE in addition to CAMERA run-time permission.
134
- * cordova-plugin-camera@2.2+ requires both of these permissions. Defaults to true.
118
+ * - {Boolean} storage - (Android only) If true, requests storage permissions in addition to CAMERA run-time permission.
119
+ * On Android 13+, storage permissions are READ_MEDIA_IMAGES and READ_MEDIA_VIDEO. On Android 9-12, storage permission is READ_EXTERNAL_STORAGE.
120
+ * cordova-plugin-camera requires both storage and camera permissions.
121
+ * Defaults to true.
135
122
  */
136
123
  Diagnostic_Camera.requestCameraAuthorization = function(params){
137
124
  params = mapFromLegacyCameraApi.apply(this, arguments);
138
125
 
139
- var permissions = [Diagnostic.permission.CAMERA];
140
- if(params.externalStorage !== false){
141
- permissions.push(Diagnostic.permission.READ_EXTERNAL_STORAGE);
142
- }
143
-
144
126
  params.successCallback = params.successCallback || function(){};
145
127
  var onSuccess = function(statuses){
146
- params.successCallback(numberOfKeys(statuses) > 1 ? combineCameraStatuses(statuses): statuses[Diagnostic.permission.CAMERA]);
128
+ params.successCallback(numberOfKeys(statuses) > 1 ? cordova.plugins.diagnostic._combinePermissionStatuses(statuses): statuses[Diagnostic.permission.CAMERA]);
147
129
  };
148
- Diagnostic.requestRuntimePermissions(onSuccess, params.errorCallback, permissions);
130
+
131
+ return cordova.exec(onSuccess,
132
+ params.errorCallback,
133
+ 'Diagnostic_Camera',
134
+ 'requestCameraAuthorization',
135
+ [!!params.storage]);
149
136
  };
150
137
 
151
138
  /**
152
139
  * Returns the authorisation status for runtime permissions to use the camera.
153
140
  * Note: this is intended for Android 6 / API 23 and above. Calling on Android 5 / API 22 and below will always return GRANTED status as permissions are already granted at installation time.
154
141
  * @param {Object} params - (optional) parameters:
155
- * - {Function} successCallback - function to call on successful request for runtime permissions status.
142
+ * - {Function} successCallback - function to call on successful request for runtime permission status.
156
143
  * This callback function is passed a single string parameter which defines the current authorisation status as a value in cordova.plugins.diagnostic.permissionStatus.
157
144
  * - {Function} errorCallback - function to call on failure to request authorisation status.
158
- * - {Boolean} externalStorage - (Android only) If true, checks permission for READ_EXTERNAL_STORAGE in addition to CAMERA run-time permission.
159
- * cordova-plugin-camera@2.2+ requires both of these permissions. Defaults to true.
145
+ * - {Boolean} storage - (Android only) If true, requests storage permissions in addition to CAMERA run-time permission.
146
+ * On Android 13+, storage permissions are READ_MEDIA_IMAGES and READ_MEDIA_VIDEO. On Android 9-12, storage permission is READ_EXTERNAL_STORAGE.
147
+ * cordova-plugin-camera requires both storage and camera permissions.
148
+ * Defaults to true.
160
149
  */
161
150
  Diagnostic_Camera.getCameraAuthorizationStatus = function(params){
162
151
  params = mapFromLegacyCameraApi.apply(this, arguments);
163
152
 
164
- var permissions = [Diagnostic.permission.CAMERA];
165
- if(params.externalStorage !== false){
166
- permissions.push(Diagnostic.permission.READ_EXTERNAL_STORAGE);
167
- }
168
-
169
153
  params.successCallback = params.successCallback || function(){};
170
154
  var onSuccess = function(statuses){
171
- params.successCallback(numberOfKeys(statuses) > 1 ? combineCameraStatuses(statuses): statuses[Diagnostic.permission.CAMERA]);
155
+ params.successCallback(numberOfKeys(statuses) > 1 ? cordova.plugins.diagnostic._combinePermissionStatuses(statuses): statuses[Diagnostic.permission.CAMERA]);
172
156
  };
173
- Diagnostic.getPermissionsAuthorizationStatus(onSuccess, params.errorCallback, permissions);
157
+
158
+ return cordova.exec(onSuccess,
159
+ params.errorCallback,
160
+ 'Diagnostic_Camera',
161
+ 'getCameraAuthorizationStatus',
162
+ [!!params.storage]);
174
163
  };
175
164
 
176
165
  /**
@@ -180,8 +169,10 @@ var Diagnostic_Camera = (function(){
180
169
  * - {Function} successCallback - function to call on successful request for runtime permissions status.
181
170
  * This callback function is passed a single boolean parameter which is TRUE if the app currently has runtime authorisation to use location.
182
171
  * - {Function} errorCallback - function to call on failure to request authorisation status.
183
- * - {Boolean} externalStorage - (Android only) If true, checks permission for READ_EXTERNAL_STORAGE in addition to CAMERA run-time permission.
184
- * cordova-plugin-camera@2.2+ requires both of these permissions. Defaults to true.
172
+ * - {Boolean} storage - (Android only) If true, requests storage permissions in addition to CAMERA run-time permission.
173
+ * On Android 13+, storage permissions are READ_MEDIA_IMAGES and READ_MEDIA_VIDEO. On Android 9-12, storage permission is READ_EXTERNAL_STORAGE.
174
+ * cordova-plugin-camera requires both storage and camera permissions.
175
+ * Defaults to true.
185
176
  */
186
177
  Diagnostic_Camera.isCameraAuthorized = function(params){
187
178
  params = mapFromLegacyCameraApi.apply(this, arguments);
@@ -194,7 +185,7 @@ var Diagnostic_Camera = (function(){
194
185
  Diagnostic_Camera.getCameraAuthorizationStatus({
195
186
  successCallback: onSuccess,
196
187
  errorCallback: params.errorCallback,
197
- externalStorage: params.externalStorage
188
+ storage: params.storage
198
189
  });
199
190
  };
200
191
 
@@ -111,12 +111,35 @@ var Diagnostic = (function(){
111
111
  Diagnostic._onNFCStateChange =
112
112
  Diagnostic._onPermissionRequestComplete = function(){};
113
113
 
114
+ Diagnostic._combinePermissionStatuses = function(statuses){
115
+ var status = Diagnostic.permissionStatus.NOT_REQUESTED;
116
+ if(anyStatusIs(statuses, Diagnostic.permissionStatus.DENIED_ALWAYS)){
117
+ status = Diagnostic.permissionStatus.DENIED_ALWAYS;
118
+ }else if(anyStatusIs(statuses, Diagnostic.permissionStatus.DENIED_ONCE)){
119
+ status = Diagnostic.permissionStatus.DENIED_ONCE;
120
+ }else if(anyStatusIs(statuses, Diagnostic.permissionStatus.GRANTED)){
121
+ status = Diagnostic.permissionStatus.GRANTED;
122
+ }
123
+ return status;
124
+ };
125
+
114
126
  /********************
115
127
  *
116
128
  * Internal functions
117
129
  *
118
130
  ********************/
119
131
 
132
+ function anyStatusIs(statuses, status){
133
+ var anyStatus = false;
134
+ for(var permission in statuses){
135
+ if(statuses[permission] === status){
136
+ anyStatus = true;
137
+ break;
138
+ }
139
+ }
140
+ return anyStatus;
141
+ }
142
+
120
143
  function checkForInvalidPermissions(permissions, errorCallback){
121
144
  if(typeof(permissions) !== "object") permissions = [permissions];
122
145
  var valid = true, invalidPermissions = [];
@@ -49,20 +49,13 @@ var Diagnostic_Location = (function(){
49
49
  function combineLocationStatuses(statuses){
50
50
  var coarseStatus = statuses[Diagnostic.permission.ACCESS_COARSE_LOCATION],
51
51
  fineStatus = statuses[Diagnostic.permission.ACCESS_FINE_LOCATION],
52
- backgroundStatus = typeof statuses[Diagnostic.permission.ACCESS_BACKGROUND_LOCATION] !== "undefined" ? statuses[Diagnostic.permission.ACCESS_BACKGROUND_LOCATION] : true
53
- status;
52
+ backgroundStatus = typeof statuses[Diagnostic.permission.ACCESS_BACKGROUND_LOCATION] !== "undefined" ? statuses[Diagnostic.permission.ACCESS_BACKGROUND_LOCATION] : true;
54
53
 
55
- var GRANTED = backgroundStatus === Diagnostic.permissionStatus.GRANTED ? Diagnostic.permissionStatus.GRANTED : Diagnostic.permissionStatus.GRANTED_WHEN_IN_USE;
56
-
57
- if(coarseStatus === Diagnostic.permissionStatus.GRANTED || fineStatus === Diagnostic.permissionStatus.GRANTED){
58
- status = GRANTED;
59
- }else if(coarseStatus === Diagnostic.permissionStatus.DENIED_ONCE || fineStatus === Diagnostic.permissionStatus.DENIED_ONCE){
60
- status = Diagnostic.permissionStatus.DENIED_ONCE;
61
- }else if(coarseStatus === Diagnostic.permissionStatus.DENIED_ALWAYS || fineStatus === Diagnostic.permissionStatus.DENIED_ALWAYS){
62
- status = Diagnostic.permissionStatus.DENIED_ALWAYS;
63
- }else if(coarseStatus === Diagnostic.permissionStatus.NOT_REQUESTED || fineStatus === Diagnostic.permissionStatus.NOT_REQUESTED){
64
- status = Diagnostic.permissionStatus.NOT_REQUESTED;
54
+ var status = cordova.plugins.diagnostic._combinePermissionStatuses([coarseStatus, fineStatus]);
55
+ if(status === Diagnostic.permissionStatus.GRANTED && backgroundStatus !== Diagnostic.permissionStatus.GRANTED){
56
+ status = Diagnostic.permissionStatus.GRANTED_WHEN_IN_USE;
65
57
  }
58
+
66
59
  return status;
67
60
  }
68
61