Skip to content

Commit

Permalink
Version 0.1.2-beta
Browse files Browse the repository at this point in the history
- Fix push error
- Sort device dropdown
- Add fastboot format
- More logging
- Add send bug report modial
- Add debug stops and triggers
- Make a bigger window in debug mode
  • Loading branch information
mariogrip committed Jun 1, 2017
1 parent 4b4a2f0 commit f8b81da
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 116 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ubports-installer",
"version": "0.1.0-beta2",
"version": "0.1.2-beta",
"description": "Ubports installer",
"main": "src/main.js",
"bin": "./src/main.js",
Expand Down Expand Up @@ -32,14 +32,15 @@
"bootstrap": "^3.3.7",
"checksum": "^0.1.1",
"commander": "^2.9.0",
"decompress-tarxz": "^2.1.0",
"electron-open-link-in-browser": "^1.0.2",
"electron-sudo": "^3.0.13",
"executable": "^4.1.0",
"forward-emitter": "^0.1.1",
"fs-extra": "^2.0.0",
"getos": "^3.0.1",
"ini": "^1.3.4",
"jquery": "^3.1.1",
"jquery-i18next": "^1.2.0",
"mkdirp": "^0.5.1",
"openurl": "^1.1.1",
"request": "^2.79.0",
Expand Down
3 changes: 2 additions & 1 deletion src/adb.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ var push = (file, dest, pushEvent) => {
}

var pushMany = (files, pushManyEvent) => {
var totalLenght = files.length;
if (files.length <= 0){
pushManyEvent.emit("adbpush:error", "No files provided");
return false;
Expand All @@ -97,7 +98,7 @@ var pushMany = (files, pushManyEvent) => {
pushManyEvent.emit("adbpush:done");
return;
}
pushManyEvent.emit("adbpush:next", files.length)
pushManyEvent.emit("adbpush:next", files.length, totalLenght)

This comment has been minimized.

Copy link
@NeoTheThird

NeoTheThird Jun 1, 2017

Member

totalLenght should be totalLength

This comment has been minimized.

Copy link
@mariogrip

mariogrip Jun 1, 2017

Author Member

whops, will fix it

push(files[0].src, files[0].dest, pushManyEvent);
})
return pushManyEvent
Expand Down
13 changes: 10 additions & 3 deletions src/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ var setEvents = (downloadEvent) => {
downloadEvent.emit("user:write:next", "Downloading", i, t);
});
downloadEvent.on("download:next", (i, t) => {
utils.log.info(`Downloading next file, ${i} left`);
utils.log.info(`Downloading next file, ${i} left, ${t} total`);
downloadEvent.emit("user:write:next", "Downloading", i, t);
});
downloadEvent.on("download:progress", (i) => {
Expand All @@ -252,9 +252,9 @@ var setEvents = (downloadEvent) => {
utils.log.info("Adb push, "+r+"% left");
downloadEvent.emit("user:write:progress", r);
});
downloadEvent.on("adbpush:next", (r) => {
downloadEvent.on("adbpush:next", (r, t) => {
utils.log.info("Start pusing next file, " + r + " files left")
downloadEvent.emit("user:write:next", "Pushing", r);
downloadEvent.emit("user:write:next", "Pushing", r, t);
});
downloadEvent.on("adbpush:start", (r) => {
utils.log.info("Start pusing "+r+" files")
Expand Down Expand Up @@ -377,6 +377,13 @@ module.exports = {
getDeviceSelects: (callback) => {
getDevices((devices) => {
var devicesAppend = [];
devices.sort(function(a, b){
var y = a.name.toLowerCase();
var x = b.name.toLowerCase();
if (x < y) {return -1;}
if (x > y) {return 1;}
return 0;
});
devices.forEach((device) => {
devicesAppend.push("<option name=\"" + device.device + "\">" + device.name + "</option>");
})
Expand Down
66 changes: 65 additions & 1 deletion src/fastboot.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ const path = require("path");
const utils = require("./utils.js")
const fastboot = utils.getPlatformTools().fastboot;

/*
args; string, function
*/
var waitForDevice = (password, callback) => {
utils.log.debug("fastboot: wait for device");
var cmd = "";
if (utils.needRoot())
cmd += "echo " + password + " | sudo -S "
Expand Down Expand Up @@ -52,7 +58,22 @@ var waitForDevice = (password, callback) => {

// Due to limitations with sudo we combind the sudo.exec to one call to prevent
// seperate password prompts
/*
args; array(object), string, function
image object format
[
{
path: string, | path of file
url: string, | url to extract filename
type: string | partition to flash
}
]
*/
var flash = (images, callback, password) => {
utils.log.debug("fastboot: flash; " + images);
var cmd = "";
images.forEach((image, l) => {
if (utils.needRoot())
Expand All @@ -77,6 +98,19 @@ var flash = (images, callback, password) => {
});
}

/*
args; array(object), string, function
image object format
[
{
path: string, | path of file
url: string | url to extract filename
}
]
*/
var boot = (image, password, callback) => {
var cmd="";
if (utils.needRoot())
Expand All @@ -97,9 +131,39 @@ var boot = (image, password, callback) => {
})
});
}
/*
args; array, string, function
*/
var format = (partitions, password, callback) => {
var cmd="";
partitions.forEach((partition, l) => {
if (utils.needRoot())
cmd += "echo " + password + " | sudo -S "
cmd += fastboot + " format " + partition;
if (l !== partitions.length - 1)
cmd += " && "
});
utils.asarExec(fastboot, (asarExec) => {
asarExec.exec(cmd, (c, r, e) => {
if (c) {
if (c.message.includes("incorrect password"))
callback({
password: true
});
else callback(true, "Fastboot: Unknown error: " + r.replace(password, "***") + " " + e.replace(password, "***"));
} else {
callback(c, r, e)
}
asarExec.done();
})
});
}

module.exports = {
flash: flash,
waitForDevice: waitForDevice,
boot: boot
boot: boot,
format: format
}
Loading

0 comments on commit f8b81da

Please sign in to comment.