blob: d8b9e215facdacd9fd12844d663722080ba92de8 [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 Zhengbc01da52023-02-23 03:25:52 +000021#include "fastboot.h"
Daniel Zheng1a01a1c2023-01-30 23:29:50 +000022#include "fastboot_driver.h"
Daniel Zheng1a01a1c2023-01-30 23:29:50 +000023
24class Task {
25 public:
26 Task() = default;
27 virtual void Run() = 0;
Daniel Zheng1a01a1c2023-01-30 23:29:50 +000028 virtual ~Task() = default;
29};
Daniel Zheng0d307182023-01-31 21:07:53 +000030
31class FlashTask : public Task {
32 public:
Daniel Zhengbc01da52023-02-23 03:25:52 +000033 FlashTask(const std::string& _slot, const std::string& _pname);
34 FlashTask(const std::string& _slot, const std::string& _pname, const std::string& _fname);
Daniel Zheng0d307182023-01-31 21:07:53 +000035
36 void Run() override;
37 ~FlashTask() {}
38
39 private:
40 const std::string pname_;
41 const std::string fname_;
42 const std::string slot_;
Daniel Zheng0d307182023-01-31 21:07:53 +000043};
Daniel Zheng71b3b432023-01-30 17:43:00 +000044
45class RebootTask : public Task {
46 public:
Daniel Zhengbc01da52023-02-23 03:25:52 +000047 RebootTask(FlashingPlan* _fp);
48 RebootTask(FlashingPlan* _fp, const std::string& _reboot_target);
Daniel Zheng71b3b432023-01-30 17:43:00 +000049 void Run() override;
50 ~RebootTask() {}
51
52 private:
53 const std::string reboot_target_ = "";
Daniel Zhengbc01da52023-02-23 03:25:52 +000054 FlashingPlan* fp_;
Daniel Zheng71b3b432023-01-30 17:43:00 +000055};