Skip to content

Commit

Permalink
Merge pull request #861 from ubports/low-power
Browse files Browse the repository at this point in the history
Add low power warning, resolves #27
  • Loading branch information
Flohack74 authored Aug 27, 2019
2 parents 2cea6f7 + aa72e1b commit e66cfc6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ var handleBootstrapError = (err, errM, bootstrapEvent, backToFunction) => {
bootstrapEvent.emit("user:connection-lost", backToFunction);
} else if (err.locked) {
bootstrapEvent.emit("user:oem-lock", backToFunction);
} else if (err.lowPower) {
bootstrapEvent.emit("user:low-power");
} else {
bootstrapEvent.emit("error", errM);
}
Expand Down
2 changes: 2 additions & 0 deletions src/fastboot.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ var handleError = (c, r, e, password, callback) => {
e.includes("FAILED (data transfer failure (Protocol error))")
) {
callback({ connectionLost: true });
} else if (e.includes("FAILED (remote: low power, need battery charging.)")) {
callback({ lowPower: true });
} else {
callback(true, "Fastboot: Unknown error: " + utils.hidePassword(r,password) + " " + utils.hidePassword(e,password));
}
Expand Down
1 change: 1 addition & 0 deletions src/html/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ html
include modals/error
include modals/password
include modals/oem-lock
include modals/low-power
include modals/select-device
include modals/developer-mode
include modals/options
Expand Down
14 changes: 14 additions & 0 deletions src/html/modals/low-power.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#low-power-modal.modal.fade(tabindex='-1', data-backdrop='static', data-keyboard='false', role='dialog')
.modal-dialog(role='document')
.modal-content
.modal-header
button.close(type='button', data-dismiss='modal', aria-label='Close')
span(aria-hidden='true') ×
h4#myModalLabel.modal-title Low Power
.modal-body
p
| The battery of your device is critically low. This can cause severe Problems while flashing.
b
| Please let your device charge for a while and try again.
.modal-footer
button.btn.btn-default(type='button', data-dismiss='modal', onclick="location.reload()") Try again
3 changes: 3 additions & 0 deletions src/html/scripts/main.pug
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ script.
modals.show("connection-lost");
$("#btn-reconnect").click(callback);
});
installEvent.on("user:low-power", (callback) => {
modals.show("low-power");
});
installEvent.on("user:oem-lock", (callback) => {
modals.show('oem-lock');
$("#btn-unlock").click(() => {
Expand Down

0 comments on commit e66cfc6

Please sign in to comment.