feat(power-management): add power management support (#489)

This commit is contained in:
Ibrahim Hadeed 2016-08-27 02:02:23 -04:00 committed by GitHub
parent 00d87dba98
commit cd82a5393e
2 changed files with 52 additions and 0 deletions

View File

@ -72,6 +72,7 @@ import { OneSignal } from './plugins/onesignal';
import { PhotoViewer } from './plugins/photo-viewer';
import { ScreenOrientation } from './plugins/screen-orientation';
import { PinDialog } from './plugins/pin-dialog';
import { PowerManagement } from './plugins/power-management';
import { Printer } from './plugins/printer';
import { Push } from './plugins/push';
import { SafariViewController } from './plugins/safari-view-controller';
@ -178,6 +179,7 @@ OneSignal,
PhotoViewer,
ScreenOrientation,
PinDialog,
PowerManagement,
Screenshot,
SecureStorage,
Shake,
@ -266,6 +268,7 @@ window['IonicNative'] = {
PhotoViewer: PhotoViewer,
ScreenOrientation: ScreenOrientation,
PinDialog: PinDialog,
PowerManagement: PowerManagement,
SafariViewController: SafariViewController,
Screenshot: Screenshot,
SecureStorage: SecureStorage,

View File

@ -0,0 +1,49 @@
import {Plugin, Cordova} from './plugin';
/**
* @name PowerManagement
* @description
* The PowerManagement plugin offers access to the devices power-management functionality.
* It should be used for applications which keep running for a long time without any user interaction.
*
* @usage
* ```
* import {PowerManagement} from 'ionic-native';
*
* PowerManagement.acquire()
* .then(onSuccess)
* .catch(onError);
*
* ```
*/
@Plugin({
plugin: 'cordova-plugin-powermanagement-orig',
pluginRef: 'https://github.com/Viras-/cordova-plugin-powermanagement',
repo: 'powerManagement'
})
export class PowerManagement {
/**
* Acquire a wakelock by calling this.
*/
@Cordova()
static acquire(): Promise<any> {return; }
/**
* This acquires a partial wakelock, allowing the screen to be dimmed.
*/
@Cordova()
static dim(): Promise<any> {return; }
/**
* Release the wakelock. It's important to do this when you're finished with the wakelock, to avoid unnecessary battery drain.
*/
@Cordova()
static release(): Promise<any> {return; }
/**
* By default, the plugin will automatically release a wakelock when your app is paused (e.g. when the screen is turned off, or the user switches to another app).
* It will reacquire the wakelock upon app resume. If you would prefer to disable this behaviour, you can use this function.
* @param set {boolean}
*/
@Cordova()
static setReleaseOnPause(set: boolean): Promise<any> {return; }
}