blob: b5fb8c0bfa3f609a422e1f2b0b54dfcd831cad96 [file] [log] [blame]
Tom Cherry9027af02018-09-24 15:48:09 -07001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
Daniel Zheng1a01a1c2023-01-30 23:29:50 +000028#pragma once
Tom Cherry9027af02018-09-24 15:48:09 -070029
Daniel Zheng0d307182023-01-31 21:07:53 +000030#include <string>
31
Tom Cherry9027af02018-09-24 15:48:09 -070032#include <bootimg.h>
33
34class FastBootTool {
35 public:
36 int Main(int argc, char* argv[]);
37
38 void ParseOsPatchLevel(boot_img_hdr_v1*, const char*);
39 void ParseOsVersion(boot_img_hdr_v1*, const char*);
Jaegeuk Kim638d05e2020-11-09 08:54:13 -080040 unsigned ParseFsOption(const char*);
Tom Cherry9027af02018-09-24 15:48:09 -070041};
Daniel Zheng0d307182023-01-31 21:07:53 +000042
43bool should_flash_in_userspace(const std::string& partition_name);
44bool is_userspace_fastboot();
45void do_flash(const char* pname, const char* fname);
46void do_for_partitions(const std::string& part, const std::string& slot,
47 const std::function<void(const std::string&)>& func, bool force_slot);
48std::string find_item(const std::string& item);
49void reboot_to_userspace_fastboot();
50void syntax_error(const char* fmt, ...);