1 /*
2  * Copyright 2021 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 #pragma once
18 
19 #include <aidl/android/automotive/watchdog/PerStateBytes.h>
20 #include <aidl/android/automotive/watchdog/internal/ApplicationCategoryType.h>
21 #include <aidl/android/automotive/watchdog/internal/ComponentType.h>
22 #include <aidl/android/automotive/watchdog/internal/IoOveruseAlertThreshold.h>
23 #include <aidl/android/automotive/watchdog/internal/IoOveruseConfiguration.h>
24 #include <aidl/android/automotive/watchdog/internal/PackageMetadata.h>
25 #include <aidl/android/automotive/watchdog/internal/PerStateIoOveruseThreshold.h>
26 #include <aidl/android/automotive/watchdog/internal/ResourceOveruseConfiguration.h>
27 #include <gmock/gmock.h>
28 
29 #include <string>
30 #include <vector>
31 
32 namespace android {
33 namespace automotive {
34 namespace watchdog {
35 
36 aidl::android::automotive::watchdog::internal::ResourceOveruseConfiguration
37 constructResourceOveruseConfig(
38         const aidl::android::automotive::watchdog::internal::ComponentType type,
39         const std::vector<std::string>&& safeToKill,
40         const std::vector<std::string>&& vendorPrefixes,
41         const std::vector<aidl::android::automotive::watchdog::internal::PackageMetadata>
42                 packageMetadata,
43         const aidl::android::automotive::watchdog::internal::IoOveruseConfiguration&
44                 ioOveruseConfiguration);
45 
46 aidl::android::automotive::watchdog::internal::IoOveruseConfiguration constructIoOveruseConfig(
47         aidl::android::automotive::watchdog::internal::PerStateIoOveruseThreshold componentLevel,
48         const std::vector<
49                 aidl::android::automotive::watchdog::internal::PerStateIoOveruseThreshold>&
50                 packageSpecific,
51         const std::vector<
52                 aidl::android::automotive::watchdog::internal::PerStateIoOveruseThreshold>&
53                 categorySpecific,
54         const std::vector<aidl::android::automotive::watchdog::internal::IoOveruseAlertThreshold>&
55                 systemWide);
56 
57 aidl::android::automotive::watchdog::PerStateBytes toPerStateBytes(const int64_t fgBytes,
58                                                                    const int64_t bgBytes,
59                                                                    const int64_t garageModeBytes);
60 
61 aidl::android::automotive::watchdog::internal::PerStateIoOveruseThreshold
62 toPerStateIoOveruseThreshold(
63         const std::string& name,
64         const aidl::android::automotive::watchdog::PerStateBytes& perStateBytes);
65 
66 aidl::android::automotive::watchdog::internal::PerStateIoOveruseThreshold
67 toPerStateIoOveruseThreshold(const std::string& name, const int64_t fgBytes, const int64_t bgBytes,
68                              const int64_t garageModeBytes);
69 
70 aidl::android::automotive::watchdog::internal::PerStateIoOveruseThreshold
71 toPerStateIoOveruseThreshold(
72         const aidl::android::automotive::watchdog::internal::ComponentType type,
73         const aidl::android::automotive::watchdog::PerStateBytes& perStateBytes);
74 
75 aidl::android::automotive::watchdog::internal::PerStateIoOveruseThreshold
76 toPerStateIoOveruseThreshold(
77         const aidl::android::automotive::watchdog::internal::ComponentType type,
78         const int64_t fgBytes, const int64_t bgBytes, const int64_t garageModeBytes);
79 
80 aidl::android::automotive::watchdog::internal::PackageMetadata toPackageMetadata(
81         std::string packageName,
82         aidl::android::automotive::watchdog::internal::ApplicationCategoryType type);
83 
84 aidl::android::automotive::watchdog::internal::IoOveruseAlertThreshold toIoOveruseAlertThreshold(
85         const int64_t durationInSeconds, const int64_t writtenBytesPerSecond);
86 
87 testing::Matcher<const aidl::android::automotive::watchdog::internal::ResourceOveruseConfiguration&>
88 ResourceOveruseConfigurationMatcher(
89         const aidl::android::automotive::watchdog::internal::ResourceOveruseConfiguration& config);
90 
91 }  // namespace watchdog
92 }  // namespace automotive
93 }  // namespace android
94