当前位置: 首页>>代码示例>>C++>>正文


C++ set_bootloader_message函数代码示例

本文整理汇总了C++中set_bootloader_message函数的典型用法代码示例。如果您正苦于以下问题:C++ set_bootloader_message函数的具体用法?C++ set_bootloader_message怎么用?C++ set_bootloader_message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了set_bootloader_message函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: maybe_install_firmware_update

int maybe_install_firmware_update(const char *send_intent) {
    if (update_data == NULL || update_length == 0) return 0;

    /* We destroy the cache partition to pass the update image to the
     * bootloader, so all we can really do afterwards is wipe cache and reboot.
     * Set up this instruction now, in case we're interrupted while writing.
     */

    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
    strlcpy(boot.recovery, "recovery\n--wipe_cache\n", sizeof(boot.command));
    if (send_intent != NULL) {
        strlcat(boot.recovery, "--send_intent=", sizeof(boot.recovery));
        strlcat(boot.recovery, send_intent, sizeof(boot.recovery));
        strlcat(boot.recovery, "\n", sizeof(boot.recovery));
    }
    if (set_bootloader_message(&boot)) return -1;

    int width = 0, height = 0, bpp = 0;
    char *busy_image = ui_copy_image(
        BACKGROUND_ICON_FIRMWARE_INSTALLING, &width, &height, &bpp);
    char *fail_image = ui_copy_image(
        BACKGROUND_ICON_FIRMWARE_ERROR, &width, &height, &bpp);

    ui_print("Writing %s image...\n", update_type);
    if (write_update_for_bootloader(
            update_data, update_length,
            width, height, bpp, busy_image, fail_image)) {
        LOGE("Can't write %s image\n(%s)\n", update_type, strerror(errno));
        format_volume("/cache");  // Attempt to clean cache up, at least.
        return -1;
    }

    free(busy_image);
    free(fail_image);

    /* The update image is fully written, so now we can instruct the bootloader
     * to install it.  (After doing so, it will come back here, and we will
     * wipe the cache and reboot into the system.)
     */
    snprintf(boot.command, sizeof(boot.command), "update-%s", update_type);
    if (set_bootloader_message(&boot)) {
        format_volume("/cache");
        return -1;
    }

    reboot(RB_AUTOBOOT);

    // Can't reboot?  WTF?
    LOGE("Can't reboot\n");
    return -1;
}
开发者ID:HyperToxic,项目名称:CWM_REC_6.0.3.2_CHN,代码行数:53,代码来源:firmware.c

示例2: LOGINFO

void TWFunc::Update_Log_File(void) {
	// Copy logs to cache so the system can find out what happened.
	if (PartitionManager.Mount_By_Path("/cache", false)) {
		if (!TWFunc::Path_Exists("/cache/recovery/.")) {
			LOGINFO("Recreating /cache/recovery folder.\n");
			if (mkdir("/cache/recovery", S_IRWXU | S_IRWXG | S_IWGRP | S_IXGRP) != 0)
				LOGINFO("Unable to create /cache/recovery folder.\n");
		}
		Copy_Log(TMP_LOG_FILE, "/cache/recovery/log");
		copy_file("/cache/recovery/log", "/cache/recovery/last_log", 600);
		chown("/cache/recovery/log", 1000, 1000);
		chmod("/cache/recovery/log", 0600);
		chmod("/cache/recovery/last_log", 0640);
	} else {
		LOGINFO("Failed to mount /cache for TWFunc::Update_Log_File\n");
	}

	// Reset bootloader message
	TWPartition* Part = PartitionManager.Find_Partition_By_Path("/misc");
	if (Part != NULL) {
		struct bootloader_message boot;
		memset(&boot, 0, sizeof(boot));
		if (set_bootloader_message(&boot) != 0)
			LOGERR("Unable to set bootloader message.\n");
	}

	if (PartitionManager.Mount_By_Path("/cache", true)) {
		if (unlink("/cache/recovery/command") && errno != ENOENT) {
			LOGINFO("Can't unlink %s\n", "/cache/recovery/command");
		}
	}

	sync();
}
开发者ID:marignygrisgris,项目名称:TWRP-Homebuild,代码行数:34,代码来源:twrp-functions.cpp

示例3: wipe_item_show

STATUS wipe_item_show(menuUnit *p)
{
/* OPPO 2013-01-17 jizhengkang azx Add begin for reason */
	struct bootloader_message boot;
/* OPPO 2013-01-17 jizhengkang Add end */
    int wipe_result;
    
    oppo_debug("start .....\n");
    if (RET_YES == oppo_confirm(3, p->name, p->desc, p->icon)) {
		wipe_result = oppo_wipe_items(p->result);
/* OPPO 2013-01-17 jizhengkang azx Add begin for reason */
		if (!(wipe_result%2)) {
			memset(&boot, 0, sizeof(boot));
			set_bootloader_message(&boot);
			strncpy(p->title_name, "<~wipe.result.success.title>", MENU_LEN);
		} else {
			strncpy(p->title_name, "<~wipe.result.failed.title>", MENU_LEN);
		}
/* OPPO 2013-01-17 jizhengkang Add end */
		wipe_result_confirm(p, wipe_result);
		wipe_item_show_end = 1;
		selectedCount--;
    }
/* OPPO 2013-02-18 jizhengkang azx Add begin for reason */
	selectedCount--;
/* OPPO 2013-02-18 jizhengkang azx Add end */
    oppo_debug("end...\n");
    return MENU_BACK;

}
开发者ID:Jiangyi,项目名称:12055,代码行数:30,代码来源:wipe_ui.c

示例4: mt_set_bootloader_message

/* Write bootloader paramenter block */
int mt_set_bootloader_message(const char *command, const char *status, const char *stage,
    const char *fmt, ...)
{
    int ret;
    int i;
    struct bootloader_message boot;
    va_list vl;

    memset(&boot, 0, sizeof(boot));

    if (command)
        strlcpy(boot.command, command, sizeof(boot.command));
    if (status)
        strlcpy(boot.status, status, sizeof(boot.status));
    if (stage)
        strlcpy(boot.stage, stage, sizeof(boot.stage));
    if (fmt)    {
        va_start(vl, fmt);
        ret = vsprintf(boot.recovery, fmt, vl);
        va_end(vl);
    }

    ret = set_bootloader_message(&boot);
    sync();

    return ret;
}
开发者ID:bju2000,项目名称:MT6797,代码行数:28,代码来源:mt_bootloader.cpp

示例5: finish_recovery

// clear the recovery command and prepare to boot a (hopefully working) system,
// copy our log file to cache as well (for the system to read), and
// record any intent we were asked to communicate back to the system.
// this function is idempotent: call it as many times as you like.
static void
finish_recovery(const char *send_intent) {
    // By this point, we're ready to return to the main system...
    if (send_intent != NULL) {
        FILE *fp = fopen_path(INTENT_FILE, "w");
        if (fp == NULL) {
            LOGE("Can't open %s\n", INTENT_FILE);
        } else {
            fputs(send_intent, fp);
            check_and_fclose(fp, INTENT_FILE);
        }
    }

    // Copy logs to cache so the system can find out what happened.
    copy_log_file(LOG_FILE, true);
    copy_log_file(LAST_LOG_FILE, false);
    chmod(LAST_LOG_FILE, 0640);

    // Reset to normal system boot so recovery won't cycle indefinitely.
    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    set_bootloader_message(&boot);

    // Remove the command file, so recovery won't repeat indefinitely.
    if (ensure_path_mounted(COMMAND_FILE) != 0 ||
        (unlink(COMMAND_FILE) && errno != ENOENT)) {
        LOGW("Can't unlink %s\n", COMMAND_FILE);
    }

    sync();  // For good measure.
}
开发者ID:xiangxin19960319,项目名称:android_bootable_recovery_cn_ics,代码行数:35,代码来源:recovery.c

示例6: reset_mark_block

static void reset_mark_block(void)
{
    // Reset the bootloader message to revert to a normal main system boot.
    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    set_bootloader_message(&boot);
    sync();
}
开发者ID:Besik13,项目名称:iq450_H2_mt6589,代码行数:8,代码来源:install.cpp

示例7: set_sdcard_update_bootloader_message

static void
set_sdcard_update_bootloader_message() {
    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
    strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
    set_bootloader_message(&boot);
}
开发者ID:JCROM-Android,项目名称:jcrom_bootable_recovery_,代码行数:8,代码来源:recovery.cpp

示例8: install_firmware_update

int install_firmware_update(const char *update_type,
                            const char *update_data,
                            size_t update_length,
                            int width, int height, int bpp,
                            const char* busy_image,
                            const char* fail_image,
                            const char *log_filename) {
    if (update_data == NULL || update_length == 0) return 0;

    mtd_scan_partitions();

    /* We destroy the cache partition to pass the update image to the
     * bootloader, so all we can really do afterwards is wipe cache and reboot.
     * Set up this instruction now, in case we're interrupted while writing.
     */

    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
    strlcpy(boot.recovery, "recovery\n--wipe_cache\n", sizeof(boot.command));
    if (set_bootloader_message(&boot)) return -1;

    if (write_update_for_bootloader(
            update_data, update_length,
            width, height, bpp, busy_image, fail_image, log_filename)) {
        LOGE("Can't write %s image\n(%s)\n", update_type, strerror(errno));
        return -1;
    }

    /* The update image is fully written, so now we can instruct the bootloader
     * to install it.  (After doing so, it will come back here, and we will
     * wipe the cache and reboot into the system.)
     */
    snprintf(boot.command, sizeof(boot.command), "update-%s", update_type);
    if (set_bootloader_message(&boot)) {
        return -1;
    }

    reboot(RB_AUTOBOOT);

    // Can't reboot?  WTF?
    LOGE("Can't reboot\n");
    return -1;
}
开发者ID:longlinht,项目名称:android_source,代码行数:44,代码来源:firmware.c

示例9: get_args

static void
get_args(int *argc, char ***argv) 
{
  struct bootloader_message boot;
  memset(&boot, 0, sizeof(boot));
  get_bootloader_message(&boot);  // this may fail, leaving a zeroed structure

  if (boot.command[0] != 0 && boot.command[0] != 255) 
    LOGI("Boot command: %.*s\n", sizeof(boot.command), boot.command);
  

  if (boot.status[0] != 0 && boot.status[0] != 255) 
    LOGI("Boot status: %.*s\n", sizeof(boot.status), boot.status);
  

  // --- if arguments weren't supplied, look in the bootloader control block
  if (*argc <= 1) 
  {
    boot.recovery[sizeof(boot.recovery) - 1] = '\0';  // Ensure termination
    const char *arg = strtok(boot.recovery, "\n");
    if (arg != NULL && !strcmp(arg, "recovery")) 
    {
      *argv = (char **) malloc(sizeof(char *) * MAX_ARGS);
      (*argv)[0] = strdup(arg);
      for (*argc = 1; *argc < MAX_ARGS; ++*argc) 
      {
        if ((arg = strtok(NULL, "\n")) == NULL) 
        	break;
        (*argv)[*argc] = strdup(arg);
      }
      LOGI("Got arguments from boot message\n");
    } 
    else if (boot.recovery[0] != 0 && boot.recovery[0] != 255) 
      LOGE("Bad boot message\n\"%.20s\"\n", boot.recovery);
    
  }

  // --- if that doesn't work, try the command file
  if (*argc <= 1) 
 		get_cmd_file_args(argc, argv);

  // --> write the arguments we have back into the bootloader control block
  // always boot into recovery after this (until finish_recovery() is called)
  strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
  strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
  int i;
  for (i = 1; i < *argc; ++i) 
  {
		strlcat(boot.recovery, (*argv)[i], sizeof(boot.recovery));
		strlcat(boot.recovery, "\n", sizeof(boot.recovery));
  }
  set_bootloader_message(&boot);
}
开发者ID:Mioze7Ae,项目名称:openrecovery,代码行数:53,代码来源:recovery.c

示例10: reset_deltaupdate_recovery_bootmessage

static void reset_deltaupdate_recovery_bootmessage(void)
{
    struct bootloader_message boot;

    memset(&boot, 0, sizeof(boot));

    LOGI("Resetting recovery boot...\n");

    set_bootloader_message(&boot);

    LOGI("boot.command=%s\n",boot.command);
    LOGI("boot.recovery=%s\n",boot.recovery);
}
开发者ID:ebmajor,项目名称:msm7627a_2038_recovery,代码行数:13,代码来源:recovery.c

示例11: get_args

// command line args come from, in decreasing precedence:
//   - the actual command line
//   - the bootloader control block (one per line, after "recovery")
//   - the contents of COMMAND_FILE (one per line)
static void
get_args(int *argc, char ***argv) {
    if (*argc > 1) return;  // actual command line arguments take priority
    char *argv0 = (*argv)[0];

    struct bootloader_message boot;
    if (!get_bootloader_message(&boot)) {
        if (boot.command[0] != 0 && boot.command[0] != 255) {
            LOGI("Boot command: %.*s\n", sizeof(boot.command), boot.command);
        }

        if (boot.status[0] != 0 && boot.status[0] != 255) {
            LOGI("Boot status: %.*s\n", sizeof(boot.status), boot.status);
        }

        // Ensure that from here on, a reboot goes back into recovery
        strcpy(boot.command, "boot-recovery");
        set_bootloader_message(&boot);

        boot.recovery[sizeof(boot.recovery) - 1] = '\0';  // Ensure termination
        const char *arg = strtok(boot.recovery, "\n");
        if (arg != NULL && !strcmp(arg, "recovery")) {
            *argv = (char **) malloc(sizeof(char *) * MAX_ARGS);
            (*argv)[0] = argv0;
            for (*argc = 1; *argc < MAX_ARGS; ++*argc) {
                if ((arg = strtok(NULL, "\n")) == NULL) break;
                (*argv)[*argc] = strdup(arg);
            }
            LOGI("Got arguments from boot message\n");
            return;
        } else if (boot.recovery[0] != 0 && boot.recovery[0] != 255) {
            LOGE("Bad boot message\n\"%.20s\"\n", boot.recovery);
        }
    }

    FILE *fp = fopen_root_path(COMMAND_FILE, "r");
    if (fp == NULL) return;

    *argv = (char **) malloc(sizeof(char *) * MAX_ARGS);
    (*argv)[0] = argv0;  // use the same program name

    char buf[MAX_ARG_LENGTH];
    for (*argc = 1; *argc < MAX_ARGS && fgets(buf, sizeof(buf), fp); ++*argc) {
        (*argv)[*argc] = strdup(strtok(buf, "\r\n"));  // Strip newline.
    }

    check_and_fclose(fp, COMMAND_FILE);
    LOGI("Got arguments from %s\n", COMMAND_FILE);
}
开发者ID:Jib-BAOSP,项目名称:platform_recovery,代码行数:53,代码来源:recovery.c

示例12: finish_recovery

// clear the recovery command and prepare to boot a (hopefully working) system,
// copy our log file to cache as well (for the system to read), and
// record any intent we were asked to communicate back to the system.
// this function is idempotent: call it as many times as you like.
static void
finish_recovery(const char *send_intent) {
    // By this point, we're ready to return to the main system...
    if (send_intent != NULL) {
        FILE *fp = fopen_root_path(INTENT_FILE, "w");
        if (fp == NULL) {
            LOGE("Can't open %s\n", INTENT_FILE);
        } else {
            fputs(send_intent, fp);
            check_and_fclose(fp, INTENT_FILE);
        }
    }

    // Copy logs to cache so the system can find out what happened.
    FILE *log = fopen_root_path(LOG_FILE, "a");
    if (log == NULL) {
        LOGE("Can't open %s\n", LOG_FILE);
    } else {
        FILE *tmplog = fopen(TEMPORARY_LOG_FILE, "r");
        if (tmplog == NULL) {
            LOGE("Can't open %s\n", TEMPORARY_LOG_FILE);
        } else {
            static long tmplog_offset = 0;
            fseek(tmplog, tmplog_offset, SEEK_SET);  // Since last write
            char buf[4096];
            while (fgets(buf, sizeof(buf), tmplog)) fputs(buf, log);
            tmplog_offset = ftell(tmplog);
            check_and_fclose(tmplog, TEMPORARY_LOG_FILE);
        }
        check_and_fclose(log, LOG_FILE);
    }

#ifndef BOARD_HAS_NO_MISC_PARTITION
    // Reset to mormal system boot so recovery won't cycle indefinitely.
    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    set_bootloader_message(&boot);
#endif

    // Remove the command file, so recovery won't repeat indefinitely.
    char path[PATH_MAX] = "";
    if (ensure_root_path_mounted(COMMAND_FILE) != 0 ||
        translate_root_path(COMMAND_FILE, path, sizeof(path)) == NULL ||
        (unlink(path) && errno != ENOENT)) {
        LOGW("Can't unlink %s\n", COMMAND_FILE);
    }

    sync();  // For good measure.
}
开发者ID:bandroidx,项目名称:bravo_recovery,代码行数:53,代码来源:recovery.c

示例13: finish_recovery

// clear the recovery command and prepare to boot a (hopefully working) system,
// copy our log file to cache as well (for the system to read), and
// record any intent we were asked to communicate back to the system.
// this function is idempotent: call it as many times as you like.
static void
finish_recovery(const char *send_intent) {
    // By this point, we're ready to return to the main system...
    if (send_intent != NULL) {
        FILE *fp = fopen_path(INTENT_FILE, "w");
        if (fp == NULL) {
            LOGE("Can't open %s\n", INTENT_FILE);
        } else {
            fputs(send_intent, fp);
            check_and_fclose(fp, INTENT_FILE);
        }
    }

    // Save the locale to cache, so if recovery is next started up
    // without a --locale argument (eg, directly from the bootloader)
    // it will use the last-known locale.
    if (locale != NULL) {
        LOGI("Saving locale \"%s\"\n", locale);
        FILE* fp = fopen_path(LOCALE_FILE, "w");
        fwrite(locale, 1, strlen(locale), fp);
        fflush(fp);
        fsync(fileno(fp));
        check_and_fclose(fp, LOCALE_FILE);
    }

    // Copy logs to cache so the system can find out what happened.
    copy_log_file(TEMPORARY_LOG_FILE, LOG_FILE, true);
    copy_log_file(TEMPORARY_LOG_FILE, LAST_LOG_FILE, false);
    copy_log_file(TEMPORARY_INSTALL_FILE, LAST_INSTALL_FILE, false);
    chmod(LOG_FILE, 0600);
    chown(LOG_FILE, 1000, 1000);   // system user
    chmod(LAST_LOG_FILE, 0640);
    chmod(LAST_INSTALL_FILE, 0644);

    // Reset to normal system boot so recovery won't cycle indefinitely.
    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));
    set_bootloader_message(&boot);

    // Remove the command file, so recovery won't repeat indefinitely.
    if (ensure_path_mounted(COMMAND_FILE) != 0 ||
        (unlink(COMMAND_FILE) && errno != ENOENT)) {
        LOGW("Can't unlink %s\n", COMMAND_FILE);
    }

    ensure_path_unmounted(CACHE_ROOT);
    sync();  // For good measure.
}
开发者ID:menghang,项目名称:a31_422_v33_android,代码行数:52,代码来源:recovery.cpp

示例14: main

int main(int argc, char *argv[])
{
	struct bootloader_message boot;
	const char *command = 0, *status = 0, *recovery = 0;
	int opt, write = 0;

	while ((opt = getopt(argc, argv, "c:s:r:wh")) != -1) {
		switch (opt) {
		case 'c':
			command = strdup(optarg);
			break;
		case 's':
			status = strdup(optarg);
			break;
		case 'r':
			recovery = strdup(optarg);
			break;
		case 'w':
			write = 1;
			break;
        case 'h':
            usage();
            return 0;
        default:
            usage();
            return -1;
		}
	}

	memset(&boot, 0, sizeof(boot));
	get_bootloader_message(&boot);
	if (write) {
		if (command)
			strncpy(boot.command, command, sizeof(boot.command));
		if (status)
			strncpy(boot.status, status, sizeof(boot.status));
		if (recovery)
			strncpy(boot.recovery, recovery, sizeof(boot.recovery));
		set_bootloader_message(&boot);
	} else {
		fprintf(stdout, "command=%s\nstatus=%s\nrecovery=%s\n",
				boot.command, boot.status, boot.recovery);
	}

	return 0;
}
开发者ID:liangxiaoju,项目名称:codes,代码行数:46,代码来源:blmessage.c

示例15: set_deltaupdate_recovery_bootmessage

static void set_deltaupdate_recovery_bootmessage(void)
{
    struct bootloader_message boot;
    memset(&boot, 0, sizeof(boot));

    LOGI("Setting recovery boot...\n");

    if(MAX_NUM_UPDATE_RECOVERY > get_deltaupdate_recoverycount())
    {
       strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
       strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
    }
    else
    {
       LOGI("Recovery mode reached maximum retry. Clear boot message.\n");
    }
    set_bootloader_message(&boot);

    LOGI("boot.command=%s\n",boot.command);
    LOGI("boot.recovery=%s\n",boot.recovery);
}
开发者ID:ebmajor,项目名称:msm7627a_2038_recovery,代码行数:21,代码来源:recovery.c


注:本文中的set_bootloader_message函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。