Fixed #6 Underlocking causing crashes on Android
I fixed this as per the solution in the issue, by surrounding the release with a try / catch block
This commit is contained in:
parent
2b6c92b0c4
commit
317a3ccbf3
@ -116,10 +116,15 @@ public class PowerManagement extends CordovaPlugin {
|
|||||||
PluginResult result = null;
|
PluginResult result = null;
|
||||||
|
|
||||||
if( this.wakeLock != null ) {
|
if( this.wakeLock != null ) {
|
||||||
this.wakeLock.release();
|
try {
|
||||||
this.wakeLock = null;
|
this.wakeLock.release();
|
||||||
|
result = new PluginResult(PluginResult.Status.OK, "OK");
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
result = new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION, "WakeLock already released");
|
||||||
|
}
|
||||||
|
|
||||||
result = new PluginResult(PluginResult.Status.OK, "OK");
|
this.wakeLock = null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION, "No WakeLock active - acquire first");
|
result = new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION, "No WakeLock active - acquire first");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user