Daniel Zheng | 1a01a1c | 2023-01-30 23:29:50 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2020 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 <sstream> |
| 19 | #include <string> |
| 20 | |
Daniel Zheng | 1a01a1c | 2023-01-30 23:29:50 +0000 | [diff] [blame] | 21 | #include "fastboot_driver.h" |
Daniel Zheng | 1a01a1c | 2023-01-30 23:29:50 +0000 | [diff] [blame] | 22 | |
| 23 | class Task { |
| 24 | public: |
| 25 | Task() = default; |
| 26 | virtual void Run() = 0; |
Daniel Zheng | 1a01a1c | 2023-01-30 23:29:50 +0000 | [diff] [blame] | 27 | virtual ~Task() = default; |
| 28 | }; |
Daniel Zheng | 0d30718 | 2023-01-31 21:07:53 +0000 | [diff] [blame] | 29 | |
| 30 | class FlashTask : public Task { |
| 31 | public: |
| 32 | FlashTask(const std::string& _slot); |
| 33 | FlashTask(const std::string& _slot, bool _force_flash); |
| 34 | FlashTask(const std::string& _slot, bool _force_flash, const std::string& _pname); |
| 35 | FlashTask(const std::string& _slot, bool _force_flash, const std::string& _pname, |
| 36 | const std::string& _fname); |
| 37 | |
| 38 | void Run() override; |
| 39 | ~FlashTask() {} |
| 40 | |
| 41 | private: |
| 42 | const std::string pname_; |
| 43 | const std::string fname_; |
| 44 | const std::string slot_; |
| 45 | bool force_flash_ = false; |
| 46 | }; |
Daniel Zheng | 71b3b43 | 2023-01-30 17:43:00 +0000 | [diff] [blame^] | 47 | |
| 48 | class RebootTask : public Task { |
| 49 | public: |
| 50 | RebootTask(fastboot::FastBootDriver* _fb); |
| 51 | RebootTask(fastboot::FastBootDriver* _fb, const std::string _reboot_target); |
| 52 | void Run() override; |
| 53 | ~RebootTask() {} |
| 54 | |
| 55 | private: |
| 56 | const std::string reboot_target_ = ""; |
| 57 | fastboot::FastBootDriver* fb_; |
| 58 | }; |