-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathec_command_factory.h
81 lines (62 loc) · 2.97 KB
/
ec_command_factory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright 2019 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BIOD_EC_COMMAND_FACTORY_H_
#define BIOD_EC_COMMAND_FACTORY_H_
#include <memory>
#include <string>
#include "biod/cros_fp_device_interface.h"
#include "biod/fp_context_command_factory.h"
#include "biod/fp_flashprotect_command.h"
#include "biod/fp_frame_command.h"
#include "biod/fp_info_command.h"
#include "biod/fp_seed_command.h"
namespace biod {
class EcCommandFactoryInterface {
public:
virtual ~EcCommandFactoryInterface() = default;
virtual std::unique_ptr<EcCommandInterface> FpContextCommand(
CrosFpDeviceInterface* cros_fp, const std::string& user_id) = 0;
virtual std::unique_ptr<biod::FpFlashProtectCommand> FpFlashProtectCommand(
const uint32_t flags, const uint32_t mask) = 0;
static_assert(
std::is_base_of<EcCommandInterface, biod::FpFlashProtectCommand>::value,
"All commands created by this class should derive from "
"EcCommandInterface");
virtual std::unique_ptr<biod::FpInfoCommand> FpInfoCommand() = 0;
static_assert(std::is_base_of<EcCommandInterface, biod::FpInfoCommand>::value,
"All commands created by this class should derive from "
"EcCommandInterface");
virtual std::unique_ptr<biod::FpSeedCommand> FpSeedCommand(
const brillo::SecureVector& seed, uint16_t seed_version) = 0;
static_assert(std::is_base_of<EcCommandInterface, biod::FpSeedCommand>::value,
"All commands created by this class should derive from "
"EcCommandInterface");
virtual std::unique_ptr<biod::FpFrameCommand> FpFrameCommand(
int index, uint32_t frame_size, uint16_t max_read_size) = 0;
static_assert(
std::is_base_of<EcCommandInterface, biod::FpFrameCommand>::value,
"All commands created by this class should derive from "
"EcCommandInterface");
// TODO(b/144956297): Add factory methods for all of the EC
// commands we use so that we can easily mock them for testing.
};
class EcCommandFactory : public EcCommandFactoryInterface {
public:
EcCommandFactory() = default;
~EcCommandFactory() override = default;
// Disallow copies
EcCommandFactory(const EcCommandFactory&) = delete;
EcCommandFactory& operator=(const EcCommandFactory&) = delete;
std::unique_ptr<EcCommandInterface> FpContextCommand(
CrosFpDeviceInterface* cros_fp, const std::string& user_id) override;
std::unique_ptr<biod::FpFlashProtectCommand> FpFlashProtectCommand(
const uint32_t flags, const uint32_t mask) override;
std::unique_ptr<biod::FpInfoCommand> FpInfoCommand() override;
std::unique_ptr<biod::FpSeedCommand> FpSeedCommand(
const brillo::SecureVector& seed, uint16_t seed_version) override;
std::unique_ptr<biod::FpFrameCommand> FpFrameCommand(
int index, uint32_t frame_size, uint16_t max_read_size) override;
};
} // namespace biod
#endif // BIOD_EC_COMMAND_FACTORY_H_