blob: afa2c3f1286761fad3709fb7235bbceb35d18232 [file] [log] [blame]
Amin Hassani0882a512018-04-05 16:25:44 -07001//
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
17#include <string>
18
19#include "update_engine/common/action.h"
20#include "update_engine/common/boot_control_interface.h"
21
Jakub Pawlowskia4847db2018-07-26 00:29:42 -070022#include <gtest/gtest_prod.h>
23
Amin Hassani0882a512018-04-05 16:25:44 -070024namespace chromeos_update_engine {
25
26class UpdateBootFlagsAction : public AbstractAction {
27 public:
28 explicit UpdateBootFlagsAction(BootControlInterface* boot_control)
29 : boot_control_(boot_control) {}
30
31 void PerformAction() override;
32
33 static std::string StaticType() { return "UpdateBootFlagsAction"; }
34 std::string Type() const override { return StaticType(); }
35
36 void CompleteUpdateBootFlags(bool successful);
37
38 private:
39 FRIEND_TEST(UpdateBootFlagsActionTest, SimpleTest);
40 FRIEND_TEST(UpdateBootFlagsActionTest, DoubleActionTest);
41
42 // Originally, both of these flags are false. Once UpdateBootFlags is called,
43 // |is_running_| is set to true. As soon as UpdateBootFlags completes its
44 // asynchronous run, |is_running_| is reset to false and |updated_boot_flags_|
45 // is set to true. From that point on there will be no more changes to these
46 // flags.
47 //
48 // True if have updated the boot flags.
49 static bool updated_boot_flags_;
50 // True if we are still updating the boot flags.
51 static bool is_running_;
52
53 // Used for setting the boot flag.
54 BootControlInterface* boot_control_;
55
56 DISALLOW_COPY_AND_ASSIGN(UpdateBootFlagsAction);
57};
58
59} // namespace chromeos_update_engine