Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 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 | |
JeiFeng Lee | ba11730 | 2019-10-23 13:20:41 +0800 | [diff] [blame] | 22 | constexpr unsigned int kMaxDownloadSizeDefault = 0x10000000; |
Yifan Hong | b299cb7 | 2021-02-17 13:44:49 -0800 | [diff] [blame] | 23 | constexpr unsigned int kMaxFetchSizeDefault = 0x10000000; |
Hridya Valsaraju | aae84e8 | 2018-10-08 13:10:25 -0700 | [diff] [blame] | 24 | |
Hridya Valsaraju | dea91b4 | 2018-07-17 11:14:01 -0700 | [diff] [blame] | 25 | class FastbootDevice; |
| 26 | |
| 27 | enum class FastbootResult { |
| 28 | OKAY, |
| 29 | FAIL, |
| 30 | INFO, |
| 31 | DATA, |
| 32 | }; |
| 33 | |
| 34 | // Execute a command with the given arguments (possibly empty). |
| 35 | using CommandHandler = std::function<bool(FastbootDevice*, const std::vector<std::string>&)>; |
| 36 | |
| 37 | bool DownloadHandler(FastbootDevice* device, const std::vector<std::string>& args); |
| 38 | bool SetActiveHandler(FastbootDevice* device, const std::vector<std::string>& args); |
| 39 | bool ShutDownHandler(FastbootDevice* device, const std::vector<std::string>& args); |
| 40 | bool RebootHandler(FastbootDevice* device, const std::vector<std::string>& args); |
| 41 | bool RebootBootloaderHandler(FastbootDevice* device, const std::vector<std::string>& args); |
| 42 | bool RebootFastbootHandler(FastbootDevice* device, const std::vector<std::string>& args); |
| 43 | bool RebootRecoveryHandler(FastbootDevice* device, const std::vector<std::string>& args); |
Hridya Valsaraju | 31d2c26 | 2018-07-20 13:35:50 -0700 | [diff] [blame] | 44 | bool GetVarHandler(FastbootDevice* device, const std::vector<std::string>& args); |
David Anderson | 12211d1 | 2018-07-24 15:21:20 -0700 | [diff] [blame] | 45 | bool EraseHandler(FastbootDevice* device, const std::vector<std::string>& args); |
| 46 | bool FlashHandler(FastbootDevice* device, const std::vector<std::string>& args); |
David Anderson | 0d4277d | 2018-07-31 13:27:37 -0700 | [diff] [blame] | 47 | bool CreatePartitionHandler(FastbootDevice* device, const std::vector<std::string>& args); |
| 48 | bool DeletePartitionHandler(FastbootDevice* device, const std::vector<std::string>& args); |
| 49 | bool ResizePartitionHandler(FastbootDevice* device, const std::vector<std::string>& args); |
David Anderson | 38b3c7a | 2018-08-15 16:27:42 -0700 | [diff] [blame] | 50 | bool UpdateSuperHandler(FastbootDevice* device, const std::vector<std::string>& args); |
Hridya Valsaraju | a15fe31 | 2018-09-14 13:58:21 -0700 | [diff] [blame] | 51 | bool OemCmdHandler(FastbootDevice* device, const std::vector<std::string>& args); |
David Anderson | 1d504e3 | 2019-01-15 14:38:20 -0800 | [diff] [blame] | 52 | bool GsiHandler(FastbootDevice* device, const std::vector<std::string>& args); |
David Anderson | ab8f466 | 2019-10-21 16:45:59 -0700 | [diff] [blame] | 53 | bool SnapshotUpdateHandler(FastbootDevice* device, const std::vector<std::string>& args); |
Yifan Hong | a4eb475 | 2021-02-16 19:37:21 -0800 | [diff] [blame] | 54 | bool FetchHandler(FastbootDevice* device, const std::vector<std::string>& args); |