-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOBILE-4501 cordova-plugin-moodleapp: Add diagnostic plugin
- Loading branch information
1 parent
44a0cea
commit ecc0c24
Showing
12 changed files
with
264 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// (C) Copyright 2015 Moodle Pty Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// (C) Copyright 2015 Moodle Pty Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// (C) Copyright 2015 Moodle Pty Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
/** | ||
* Checks whether device hardware features are enabled or available to the app, e.g. camera, GPS, wifi | ||
*/ | ||
export class Diagnostic { | ||
|
||
/** | ||
* Constants for requesting and reporting the various permission states. | ||
*/ | ||
declare permissionStatus; | ||
|
||
/** | ||
* ANDROID ONLY | ||
* "Dangerous" permissions that need to be requested at run-time (Android 6.0/API 23 and above) | ||
* See http://developer.android.com/guide/topics/security/permissions.html#perm-groups | ||
* | ||
*/ | ||
declare permission; | ||
|
||
constructor() { | ||
this.permissionStatus = { | ||
// Android only | ||
deniedOnce: 'DENIED_ONCE', | ||
|
||
// iOS only | ||
restricted: 'restricted', | ||
ephimeral: 'ephemeral', | ||
provisional: 'provisional', | ||
|
||
// Both iOS and Android | ||
granted: 'authorized' || 'GRANTED', | ||
grantedWhenInUse: 'authorized_when_in_use', | ||
notRequested: 'not_determined' || 'NOT_REQUESTED', | ||
deniedAlways: 'denied_always' || 'DENIED_ALWAYS', | ||
}; | ||
|
||
this.permission = { | ||
acceptHandover: 'ACCEPT_HANDOVER', | ||
accessBackgroundLocation: 'ACCESS_BACKGROUND_LOCATION', | ||
accessCoarseLocation: 'ACCESS_COARSE_LOCATION', | ||
accessFineLocation: 'ACCESS_FINE_LOCATION', | ||
accessMediaLocation: 'ACCESS_MEDIA_LOCATION', | ||
bodySensors: 'BODY_SENSORS', | ||
bodySensorsBackground: 'BODY_SENSORS_BACKGROUND', | ||
getAccounts: 'GET_ACCOUNTS', | ||
readExternalStorage: 'READ_EXTERNAL_STORAGE', | ||
readMediaAudio: 'READ_MEDIA_AUDIO', | ||
readMediaImages: 'READ_MEDIA_IMAGES', | ||
readMediaVideo: 'READ_MEDIA_VIDEO', | ||
readPhoneState: 'READ_PHONE_STATE', | ||
readSms: 'READ_SMS', | ||
receiveMms: 'RECEIVE_MMS', | ||
receiveSms: 'RECEIVE_SMS', | ||
receiveWapPush: 'RECEIVE_WAP_PUSH', | ||
recordAudio: 'RECORD_AUDIO', | ||
sendSms: 'SEND_SMS', | ||
useSip: 'USE_SIP', | ||
uwbRanging: 'UWB_RANGING', | ||
writeExternalStorage: 'WRITE_EXTERNAL_STORAGE', | ||
}; | ||
} | ||
|
||
isLocationEnabled(): Promise<boolean> { | ||
return new Promise<boolean>((resolve, reject) => cordova.exec(resolve, reject, 'Diagnostic', 'isLocationEnabled')); | ||
} | ||
|
||
switchToLocationSettings(): Promise<void> { | ||
return new Promise<void>((resolve, reject) => cordova.exec(resolve, reject, 'Diagnostic', 'switchToLocationSettings')); | ||
} | ||
|
||
switchToSettings(): Promise<void> { | ||
return new Promise<void>((resolve, reject) => cordova.exec(resolve, reject, 'Diagnostic', 'switchToSettings')); | ||
} | ||
|
||
getLocationAuthorizationStatus(): Promise<unknown> { | ||
return new Promise<unknown>((resolve, reject) => | ||
cordova.exec(resolve, reject, 'Diagnostic', 'getLocationAuthorizationStatus')); | ||
} | ||
|
||
requestLocationAuthorization(): Promise<void> { | ||
return new Promise<void>((resolve, reject) => cordova.exec(resolve, reject, 'Diagnostic', 'requestLocationAuthorization')); | ||
} | ||
|
||
requestMicrophoneAuthorization(): Promise<string> { | ||
return new Promise<string>((resolve, reject) => | ||
cordova.exec(resolve, reject, 'Diagnostic', 'requestMicrophoneAuthorization')); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.