return;
}
- LOG("Succeed to write\n");
+ LOG("Progress : %d%%\n", percent);
}
/*-----------------------------------------------------------------------------
----------------------------------------------------------------------------*/
static void *__thread_draw_progress(void *arg)
{
- int expected_duration = 45000*1000; /* usec */
+ int expected_duration = 45; /* sec */
int count = 20;
- int loop_duration = (expected_duration / count);
- int init_progress = (80 + 2);
- int exit_progress = (100 - 2);
- float progress = (float)init_progress;
- float prog_step = (float)(((float)exit_progress - (float)init_progress) / (float)count);
-
- while (count > 0) {
- usleep(loop_duration);
+ useconds_t period = expected_duration * 1000000 / count;
+ int from = 82;
+ int to = 98;
+ float progress = from;
+ float progress_increment = (float)(to - from) / (float)count;
+
+ /**
+ * Convert tick to progress
+ *
+ * 0 ~ count -> from ~ to
+ */
+ for (int tick = 0; tick < count; tick++) {
fota_gui_update_progress((int)progress);
- progress += prog_step;
- count --;
+ progress += progress_increment;
+ usleep(period);
}
return NULL;
void fota_gui_progress(void * pbUserData, unsigned long uPercent)
{
int percent;
+ int from, to;
ua_dataSS_t *ua_data = (ua_dataSS_t *)pbUserData;
ua_update_data_t *ua_update_data = ua_data->update_data;
else
percent = ua_update_data->weight_offset + (ua_update_data->weight * uPercent / 100);
- /* re-arrange progress percentage betwen scout & update */
- if (ua_data->ua_operation == UI_OP_SCOUT) {
- percent = percent / 5;
- } else if ((ua_data->ua_operation == UI_OP_SCOUT_UPDATE)
- || (ua_data->ua_operation == UI_OP_UPDATE)) {
- if (dm_verity_status == DM_VERITY_ENABLED)
- percent = 20 + percent * 3 / 5; /* 20 ~ 80 */
- else
- percent = 20 + percent * 4 / 5; /* 20 ~ 100 */
+ /**
+ * re-arrange progress percentage between scout & update
+ *
+ * 0 ~ 100 -> from ~ to
+ */
+ switch (ua_data->ua_operation) {
+ case UI_OP_SCOUT:
+ from = 0;
+ to = 20;
+ break;
+ case UI_OP_SCOUT_UPDATE:
+ case UI_OP_UPDATE:
+ from = 20;
+ to = (dm_verity_status == DM_VERITY_ENABLED) ? 80 : 100;
+ break;
+ default:
+ from = 0;
+ to = 100;
+ break;
}
+ percent = from + ((to - from) * percent / 100);
if (ua_op_mode == UA_OP_MODE_FG)
fota_gui_update_progress(percent); /* update progress bar and text */