Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 194e27bf authored by Elliott Hughes's avatar Elliott Hughes Committed by Gerrit Code Review
Browse files

Merge "Modernize fastboot output format."

parents b7ba61ff f238d875
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -109,32 +109,32 @@ static Action& queue_action(Op op, const std::string& cmd) {

void fb_set_active(const std::string& slot) {
    Action& a = queue_action(OP_COMMAND, "set_active:" + slot);
    a.msg = "Setting current slot to '" + slot + "'...";
    a.msg = "Setting current slot to '" + slot + "'";
}

void fb_queue_erase(const std::string& partition) {
    Action& a = queue_action(OP_COMMAND, "erase:" + partition);
    a.msg = "Erasing '" + partition + "'...";
    a.msg = "Erasing '" + partition + "'";
}

void fb_queue_flash_fd(const std::string& partition, int fd, uint32_t sz) {
    Action& a = queue_action(OP_DOWNLOAD_FD, "");
    a.fd = fd;
    a.size = sz;
    a.msg = android::base::StringPrintf("Sending '%s' (%d KB)...", partition.c_str(), sz / 1024);
    a.msg = android::base::StringPrintf("Sending '%s' (%u KB)", partition.c_str(), sz / 1024);

    Action& b = queue_action(OP_COMMAND, "flash:" + partition);
    b.msg = "Writing '" + partition + "'...";
    b.msg = "Writing '" + partition + "'";
}

void fb_queue_flash(const std::string& partition, void* data, uint32_t sz) {
    Action& a = queue_action(OP_DOWNLOAD, "");
    a.data = data;
    a.size = sz;
    a.msg = android::base::StringPrintf("Sending '%s' (%d KB)...", partition.c_str(), sz / 1024);
    a.msg = android::base::StringPrintf("Sending '%s' (%u KB)", partition.c_str(), sz / 1024);

    Action& b = queue_action(OP_COMMAND, "flash:" + partition);
    b.msg = "Writing '" + partition + "'...";
    b.msg = "Writing '" + partition + "'";
}

void fb_queue_flash_sparse(const std::string& partition, struct sparse_file* s, uint32_t sz,
@@ -142,12 +142,12 @@ void fb_queue_flash_sparse(const std::string& partition, struct sparse_file* s,
    Action& a = queue_action(OP_DOWNLOAD_SPARSE, "");
    a.data = s;
    a.size = 0;
    a.msg = android::base::StringPrintf("Sending sparse '%s' %zu/%zu (%d KB)...", partition.c_str(),
    a.msg = android::base::StringPrintf("Sending sparse '%s' %zu/%zu (%u KB)", partition.c_str(),
                                        current, total, sz / 1024);

    Action& b = queue_action(OP_COMMAND, "flash:" + partition);
    b.msg =
        android::base::StringPrintf("Writing '%s' %zu/%zu...", partition.c_str(), current, total);
    b.msg = android::base::StringPrintf("Writing sparse '%s' %zu/%zu", partition.c_str(), current,
                                        total);
}

static int match(const char* str, const char** value, unsigned count) {
@@ -270,7 +270,7 @@ static int cb_do_nothing(Action&, int, const char*) {
void fb_queue_reboot() {
    Action& a = queue_action(OP_COMMAND, "reboot");
    a.func = cb_do_nothing;
    a.msg = "Rebooting...";
    a.msg = "Rebooting";
}

void fb_queue_command(const std::string& cmd, const std::string& msg) {
@@ -289,7 +289,7 @@ void fb_queue_download_fd(const std::string& name, int fd, uint32_t sz) {
    Action& a = queue_action(OP_DOWNLOAD_FD, "");
    a.fd = fd;
    a.size = sz;
    a.msg = android::base::StringPrintf("Sending '%s' (%d KB)", name.c_str(), sz / 1024);
    a.msg = android::base::StringPrintf("Sending '%s' (%u KB)", name.c_str(), sz / 1024);
}

void fb_queue_upload(const std::string& outfile) {
@@ -312,7 +312,7 @@ int64_t fb_execute_queue(Transport* transport) {
    for (auto& a : action_list) {
        a->start = now();
        if (!a->msg.empty()) {
            fprintf(stderr, "%s\n", a->msg.c_str());
            fprintf(stderr, "%-50s ", a->msg.c_str());
        }
        if (a->op == OP_DOWNLOAD) {
            status = fb_download_data(transport, a->data, a->size);
@@ -333,6 +333,7 @@ int64_t fb_execute_queue(Transport* transport) {
            if (status) break;
        } else if (a->op == OP_NOTICE) {
            // We already showed the notice because it's in `Action::msg`.
            fprintf(stderr, "\n");
        } else if (a->op == OP_DOWNLOAD_SPARSE) {
            status = fb_download_data_sparse(transport, reinterpret_cast<sparse_file*>(a->data));
            status = a->func(*a, status, status ? fb_get_error().c_str() : "");
+11 −5
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ static unsigned tags_offset = 0x00000100;

static bool g_disable_verity = false;
static bool g_disable_verification = false;
static bool g_verbose = false;

static const std::string convert_fbe_marker_filename("convert_fbe");

@@ -426,7 +427,7 @@ static int show_help() {
            "                                           trigger a reboot.\n"
            "  --disable-verity                         Set the disable-verity flag in the\n"
            "                                           the vbmeta image being flashed.\n"
            "  --disable-verification                   Set the disable-verification flag in"
            "  --disable-verification                   Set the disable-verification flag in\n"
            "                                           the vbmeta image being flashed.\n"
#if !defined(_WIN32)
            "  --wipe-and-use-fbe                       On devices which support it,\n"
@@ -434,6 +435,7 @@ static int show_help() {
            "                                           enable file-based encryption\n"
#endif
            "  --unbuffered                             Do not buffer input or output.\n"
            "  -v, --verbose                            Verbose output.\n"
            "  --version                                Display version.\n"
            "  -h, --help                               show this message.\n"
        );
@@ -783,8 +785,8 @@ static int64_t get_target_sparse_limit(Transport* transport) {
        fprintf(stderr, "couldn't parse max-download-size '%s'\n", max_download_size.c_str());
        return 0;
    }
    if (limit > 0) {
        fprintf(stderr, "target reported max download size of %" PRId64 " bytes\n", limit);
    if (g_verbose && limit > 0) {
        fprintf(stderr, "Target reported max download size of %" PRId64 " bytes\n", limit);
    }
    return limit;
}
@@ -1517,12 +1519,13 @@ int main(int argc, char **argv)
        {"tags-offset", required_argument, 0, 't'},
        {"help", no_argument, 0, 'h'},
        {"unbuffered", no_argument, 0, 0},
        {"version", no_argument, 0, 0},
        {"slot", required_argument, 0, 0},
        {"set_active", optional_argument, 0, 'a'},
        {"set-active", optional_argument, 0, 'a'},
        {"skip-secondary", no_argument, 0, 0},
        {"skip-reboot", no_argument, 0, 0},
        {"verbose", no_argument, 0, 'v'},
        {"version", no_argument, 0, 0},
        {"disable-verity", no_argument, 0, 0},
        {"disable-verification", no_argument, 0, 0},
#if !defined(_WIN32)
@@ -1534,7 +1537,7 @@ int main(int argc, char **argv)
    serial = getenv("ANDROID_SERIAL");

    while (1) {
        int c = getopt_long(argc, argv, "wub:k:n:r:t:s:S:lc:i:m:ha::", longopts, &longindex);
        int c = getopt_long(argc, argv, "vwub:k:n:r:t:s:S:lc:i:m:ha::", longopts, &longindex);
        if (c < 0) {
            break;
        }
@@ -1589,6 +1592,9 @@ int main(int argc, char **argv)
        case 'u':
            erase_first = false;
            break;
        case 'v':
            g_verbose = true;
            break;
        case 'w':
            wants_wipe = true;
            break;
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ double now() {
void die(const char* fmt, ...) {
    va_list ap;
    va_start(ap, fmt);
    fprintf(stderr,"error: ");
    fprintf(stderr, "fastboot: error: ");
    vfprintf(stderr, fmt, ap);
    fprintf(stderr,"\n");
    va_end(ap);