• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #pragma once
2 
3 /*
4  * Copyright (C) 2021 The Android Open Source Project
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #include <chrono>
20 #include <memory>
21 #include <ostream>
22 #include <vector>
23 
24 namespace aidl {
25 namespace google {
26 namespace hardware {
27 namespace power {
28 namespace impl {
29 namespace pixel {
30 
31 // Abstracted so we can mock in tests.
32 class IFilesystem {
33   public:
~IFilesystem()34     virtual ~IFilesystem() {}
35     virtual bool ListDirectory(const std::string &path, std::vector<std::string> *result) const = 0;
36     virtual bool ReadFileStream(const std::string &path,
37                                 std::unique_ptr<std::istream> *result) const = 0;
38     // Resets the file stream, so that the next read will read from the beginning.
39     // This function exists in IFilesystem rather than using istream::seekg directly. This is
40     // so we can mock this function in tests, allowing us to return different data on reset.
41     virtual bool ResetFileStream(const std::unique_ptr<std::istream> &fileStream) const = 0;
42 };
43 
44 }  // namespace pixel
45 }  // namespace impl
46 }  // namespace power
47 }  // namespace hardware
48 }  // namespace google
49 }  // namespace aidl
50