-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
71 lines (60 loc) · 2.3 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* eslint-disable import/no-commonjs */
/* eslint-disable no-sync */
const fs = require("fs");
const colors = require("colors");
const { adbExec, hasAdbConnectedDevice, loadProperties } = require("./adb");
const { fastbootExec, isUserspace, loadVariables } = require("./fastboot");
const { show_menu } = require("./prompt");
if (!fs.existsSync("super")) {
fs.mkdirSync("super");
}
if (!fs.existsSync("firmware")) {
fs.mkdirSync("firmware");
}
async function start_app() {
await adbExec({ cmd: "start-server" });
const adbConnected = await hasAdbConnectedDevice();
const fbDevices = await fastbootExec({ cmd: "devices" });
const fastbootConnected = fbDevices.split("\n").length >= 2;
console.log("\nWelcome to Motorola Flash Tool\n".bold.underline);
console.log(
"Telegram support group: https://t.me/motoflashtool\n".bold.underline
);
let sku,
carrier = "";
if (adbConnected) {
const properties = await loadProperties();
console.log("Connected device :".bgBrightWhite.black);
console.log("Device : " + properties["ro.boot.device"] + "\n");
console.log("SKU : " + properties["ro.boot.hardware.sku"] + "\n");
sku = properties["ro.boot.hardware.sku"];
console.log("Carrier : " + properties["ro.boot.carrier"] + "\n");
carrier = properties["ro.boot.carrier"];
console.log("Current slot : " + properties["ro.boot.slot_suffix"] + "\n");
console.log(
"Dynamic partitions : " + properties["ro.boot.dynamic_partitions"] + "\n"
);
console.log("Current mode: Android\n");
} else if (fastbootConnected) {
const userSpace = await isUserspace();
const variables = await loadVariables();
console.log("Connected device :".bgBrightWhite.black);
console.log("Device : " + variables.product);
if (!userSpace) {
console.log("SKU : " + variables.sku);
console.log("Carrier : " + variables["ro.carrier"]);
sku = variables.sku;
carrier = variables["ro.carrier"];
}
console.log("Current slot : " + variables["current-slot"]);
if (!userSpace) {
console.log("\nCurrent mode: bootloader");
} else {
console.log("\nCurrent mode: fastbootd");
}
} else {
console.log("Please connect a device before using the tool.".brightRed);
}
show_menu(fastbootConnected || adbConnected, sku, carrier);
}
start_app();