1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include <functional>
19 #include <string>
20 #include <vector>
21 
22 constexpr unsigned int kMaxDownloadSizeDefault = 0x10000000;
23 
24 class FastbootDevice;
25 
26 enum class FastbootResult {
27     OKAY,
28     FAIL,
29     INFO,
30     DATA,
31 };
32 
33 // Execute a command with the given arguments (possibly empty).
34 using CommandHandler = std::function<bool(FastbootDevice*, const std::vector<std::string>&)>;
35 
36 bool DownloadHandler(FastbootDevice* device, const std::vector<std::string>& args);
37 bool SetActiveHandler(FastbootDevice* device, const std::vector<std::string>& args);
38 bool ShutDownHandler(FastbootDevice* device, const std::vector<std::string>& args);
39 bool RebootHandler(FastbootDevice* device, const std::vector<std::string>& args);
40 bool RebootBootloaderHandler(FastbootDevice* device, const std::vector<std::string>& args);
41 bool RebootFastbootHandler(FastbootDevice* device, const std::vector<std::string>& args);
42 bool RebootRecoveryHandler(FastbootDevice* device, const std::vector<std::string>& args);
43 bool GetVarHandler(FastbootDevice* device, const std::vector<std::string>& args);
44 bool EraseHandler(FastbootDevice* device, const std::vector<std::string>& args);
45 bool FlashHandler(FastbootDevice* device, const std::vector<std::string>& args);
46 bool CreatePartitionHandler(FastbootDevice* device, const std::vector<std::string>& args);
47 bool DeletePartitionHandler(FastbootDevice* device, const std::vector<std::string>& args);
48 bool ResizePartitionHandler(FastbootDevice* device, const std::vector<std::string>& args);
49 bool UpdateSuperHandler(FastbootDevice* device, const std::vector<std::string>& args);
50 bool OemCmdHandler(FastbootDevice* device, const std::vector<std::string>& args);
51 bool GsiHandler(FastbootDevice* device, const std::vector<std::string>& args);
52 bool SnapshotUpdateHandler(FastbootDevice* device, const std::vector<std::string>& args);
53