From b4f2f22e7bf9377de7e9b4ae3f92f107485ef1a7 Mon Sep 17 00:00:00 2001 From: Max Bassett Date: Wed, 10 Aug 2016 13:58:28 -0400 Subject: [PATCH] [Android Only] Added more functions Notably 'isIgnoringBatteryOptimizations' and 'addAppToBatteryWhitelist' --- www/powermanagement.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/www/powermanagement.js b/www/powermanagement.js index e9c93fc..7961a7b 100644 --- a/www/powermanagement.js +++ b/www/powermanagement.js @@ -65,9 +65,30 @@ PowerManagement.prototype.dim = function(successCallback,failureCallback) { * @param successCallback function to be called when the device's idle state returns successfully * @param errorCallback function to be called when there was a problem with checking the device's idle state */ - PowerManagement.prototype.isDeviceIdleMode = function(successCallback,failureCallback) { cordova.exec(successCallback, failureCallback, 'PowerManagement', 'isDeviceIdleMode', []); } +/** + * Checks if the app has been added to the battery optimization whitelist (i.e. ignores battery optimization). Android Only. + * *** Requires minimum API level 23 *** + * + * @param successCallback function to be called when the check of the battery optimization whitelist returns successfully + * @param errorCallback function to be called when there was a problem with the check of the battery optimization whitelist + */ +PowerManagement.prototype.isIgnoringBatteryOptimizations = function (successCallback,failureCallback) { + cordova.exec(successCallback, failureCallback, 'PowerManagement', 'isIgnoringBatteryOptimizations', []); +}; + +/** + * Opens a dialog that allows the use to add the app to the battery optimization whitelist. Android Only. + * *** Requires minimum API level 23 *** + * + * @param successCallback function to be called when adding the app to the battery optimization whitelist is successful + * @param errorCallback function to be called when there was a problem with adding the app to the battery optimization whitelist + */ +PowerManagement.prototype.addAppToBatteryWhitelist = function (successCallback,failureCallback) { + cordova.exec(successCallback, failureCallback, 'PowerManagement', 'addAppToBatteryWhitelist', []); +}; + module.exports = new PowerManagement();