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 constexpr unsigned int kMaxFetchSizeDefault = 0x10000000; 24 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); 44 bool GetVarHandler(FastbootDevice* device, const std::vector<std::string>& args); 45 bool EraseHandler(FastbootDevice* device, const std::vector<std::string>& args); 46 bool FlashHandler(FastbootDevice* device, const std::vector<std::string>& args); 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); 50 bool UpdateSuperHandler(FastbootDevice* device, const std::vector<std::string>& args); 51 bool OemCmdHandler(FastbootDevice* device, const std::vector<std::string>& args); 52 bool GsiHandler(FastbootDevice* device, const std::vector<std::string>& args); 53 bool SnapshotUpdateHandler(FastbootDevice* device, const std::vector<std::string>& args); 54 bool FetchHandler(FastbootDevice* device, const std::vector<std::string>& args); 55