blob: 582fa2fae545d01a37ff7295f1bb45dcf11c3779 [file] [log] [blame]
Daniel Zheng1a01a1c2023-01-30 23:29:50 +00001//
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 Zheng1a01a1c2023-01-30 23:29:50 +000021#include "fastboot_driver.h"
Daniel Zheng1a01a1c2023-01-30 23:29:50 +000022
23class Task {
24 public:
25 Task() = default;
26 virtual void Run() = 0;
Daniel Zheng1a01a1c2023-01-30 23:29:50 +000027 virtual ~Task() = default;
28};
Daniel Zheng0d307182023-01-31 21:07:53 +000029
30class 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 Zheng71b3b432023-01-30 17:43:00 +000047
48class 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};