Merged in Menardi/cordova-plugin-run-in-background/android_optimization (pull request #2)

Add more Android battery optimisation functions

- Go to Battery Optimization settings screen
- Add function to check if battery optimization is enabled or not
This commit is contained in:
Menardi
2019-08-21 20:18:23 +00:00
committed by Nathan Kerr
parent 0da2006f7c
commit 53f3278722
3 changed files with 96 additions and 1 deletions

View File

@@ -177,6 +177,38 @@ exports.disableBatteryOptimizations = function()
}
};
/**
* Opens the system settings screen for battery optimization, allowing the user to
* manually change the optimization settings.
*
* @return [ Void ]
*/
exports.openBatteryOptimizationsSettings = function()
{
if (this._isAndroid)
{
cordova.exec(null, null, 'BackgroundModeExt', 'batterysettings', []);
}
};
/**
* Opens the system settings screen for battery optimization, allowing the user to
* manually change the optimization settings.
*
* @return [ Void ]
*/
exports.isIgnoringBatteryOptimizations = function(callback)
{
if (this._isAndroid)
{
cordova.exec(callback, null, 'BackgroundModeExt', 'optimizationstatus', []);
}
else
{
callback(true);
}
};
/**
* Opens the system settings dialog where the user can tweak or turn off any
* custom app start settings added by the manufacturer if available.