コード例 #1
0
ファイル: nandroid.c プロジェクト: M1cha/miui_recovery
static void yaffs_callback(const char* filename)
{
    if (filename == NULL)
        return;
    const char* justfile = basename(filename);
    char tmp[PATH_MAX];
    struct timeval curtime;
    gettimeofday(&curtime,NULL);
    /*
     * Only update once every NANDROID_UPDATE_INTERVAL
     * milli seconds.  We don't need frequent progress
     * updates and updating every file uses WAY
     * too much CPU time.
     */
    yaffs_files_count++;
    if(delta_milliseconds(lastupdate,curtime) > NANDROID_UPDATE_INTERVAL)
      {
        strcpy(tmp, justfile);
        if (tmp[strlen(tmp) - 1] == '\n')
          tmp[strlen(tmp) - 1] = NULL;
        if (strlen(tmp) < 30) {
        lastupdate = curtime;
          ui_print("%s", tmp);
	}

        if (yaffs_files_total != 0)
          ui_set_progress((float)yaffs_files_count / (float)yaffs_files_total);
      }
}
コード例 #2
0
ファイル: ui.c プロジェクト: ShunYea/bootable_recovery
void ui_print(const char *fmt, ...)
{
    char buf[256];
    va_list ap;
    char *locale_fmt = "";

    locale_fmt = ui_translate(fmt);
    va_start(ap, locale_fmt);
    vsnprintf(buf, 256, locale_fmt, ap);
    va_end(ap);

    if (ui_log_stdout)
        fputs(buf, stdout);

    // if we are running 'ui nice' mode, we do not want to force a screen update
    // for this line if not necessary.
    ui_niced = 0;
    if (ui_nice) {
        struct timeval curtime;
        gettimeofday(&curtime, NULL);
        long ms = delta_milliseconds(lastupdate, curtime);
        if (ms < NICE_INTERVAL && ms >= 0) {
            ui_niced = 1;
            return;
        }
    }

    // This can get called before ui_init(), so be careful.
    pthread_mutex_lock(&gUpdateMutex);
    gettimeofday(&lastupdate, NULL);
    if (text_rows > 0 && text_cols > 0) {
        char *ptr;
        for (ptr = buf; *ptr != '\0'; ++ptr) {
            if (*ptr == '\n' || text_col >= text_cols) {
                text[text_row][text_col] = '\0';
                text_col = 0;
                text_row = (text_row + 1) % text_rows;
                if (text_row == text_top) text_top = (text_top + 1) % text_rows;
            }
            if (*ptr != '\n') text[text_row][text_col++] = *ptr;
        }
        text[text_row][text_col] = '\0';
        update_screen_locked();
    }
    pthread_mutex_unlock(&gUpdateMutex);
}
コード例 #3
0
// Updates only the progress bar, if possible, otherwise redraws the screen.
// Should only be called with gUpdateMutex locked.
static void update_progress_locked(void) {
    if (!ui_has_initialized)
        return;

    // set minimum delay between progress updates if we have a text overlay
    // exception: gProgressScopeDuration != 0: to keep zip installer refresh behavior
    struct timeval curtime;
    gettimeofday(&curtime, NULL);
    long delta_ms = delta_milliseconds(lastprogupd, curtime);
    if (show_text && gProgressScopeDuration == 0 && lastprogupd.tv_sec > 0
            && delta_ms < UI_MIN_PROG_DELTA_MS) {
        return;
    }

    if (show_text || !gPagesIdentical) {
        draw_screen_locked();    // Must redraw the whole screen
        gPagesIdentical = 1;
    } else {
        draw_progress_locked();  // Draw only the progress bar and overlays
    }
    gr_flip();
}
コード例 #4
0
	float processing_system::get_milliseconds_left(augs::deterministic_timeout& t) const {
		if (!t.was_set) 
			return 0.f;

		return std::max(0.0, t.timeout_ms - (parent_world.current_step_number - t.step_recorded) * delta_milliseconds());
	}
コード例 #5
0
	bool processing_system::passed(augs::deterministic_timeout& t) const {
		return !t.was_set || (parent_world.current_step_number - t.step_recorded) * delta_milliseconds() >= t.timeout_ms;
	}
コード例 #6
0
ファイル: ui.c プロジェクト: Hachamacha/philz
void ui_print(const char *fmt, ...)
{
    char buf[256];
    va_list ap;
    va_start(ap, fmt);
    vsnprintf(buf, 256, fmt, ap);
    va_end(ap);

    // check if we need to exclude some line from write to log file
    // first line is line 0
    if (ui_log_stdout && no_stdout_line >= 0) {
        char str[256];
        char buf2[256];
        char buf3[256] = "";

        // copy the buffer to modify it
        strcpy(buf2, buf);
        char *ptr = strtok(buf2, "\n");
        int i = 0;
        while(ptr != NULL) {
            // parse the buffer and exclude the line we do not want to write to recovery.log file
            if (i != no_stdout_line) {
                strcpy(str, ptr);
                // log only nandroid non empty lines
                if (strcmp(str, " ") != 0) {
                    strcat(str, "\n");
                    strcat(buf3, str);
                }
            }
            ptr = strtok(NULL, "\n");
            ++i;
        }
        fputs(buf3, stdout);
    }
    else if (ui_log_stdout)
        fputs(buf, stdout);

    // if we are running 'ui nice' mode, we do not want to force a screen update
    // for this line if not necessary.
    ui_niced = 0;
    if (ui_nice) {
        struct timeval curtime;
        gettimeofday(&curtime, NULL);
        long ms = delta_milliseconds(lastupdate, curtime);
        if (ms < NICE_INTERVAL && ms >= 0) {
            ui_niced = 1;
            return;
        }
    }

    // This can get called before ui_init(), so be careful.
    pthread_mutex_lock(&gUpdateMutex);
    gettimeofday(&lastupdate, NULL);
    if (text_rows > 0 && text_cols > 0) {
        char *ptr;
        for (ptr = buf; *ptr != '\0'; ++ptr) {
            if (*ptr == '\n' || text_col >= text_cols) {
                text[text_row][text_col] = '\0';
                text_col = 0;
                text_row = (text_row + 1) % text_rows;
                if (text_row == text_top) text_top = (text_top + 1) % text_rows;
            }
            if (*ptr != '\n') text[text_row][text_col++] = *ptr;
        }
        text[text_row][text_col] = '\0';
        update_screen_locked();
    }
    pthread_mutex_unlock(&gUpdateMutex);
}