blob: ff00d989d63c9c2829542ccddb665ca371e6a012 [file] [log] [blame]
Lakshman Annadorai6094e9a2020-01-31 10:03:33 -08001/**
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
17#define LOG_TAG "carwatchdogd"
18#define DEBUG false
19
20#include "IoPerfCollection.h"
21
22#include <log/log.h>
23
24namespace android {
25namespace automotive {
26namespace watchdog {
27
28using android::base::Error;
29using android::base::Errorf;
30using android::base::Result;
31
32Result<void> IoPerfCollection::start() {
33 Mutex::Autolock lock(mMutex);
34 if (mCurrCollectionEvent != CollectionEvent::NONE) {
35 return Error() << "Cannot start I/O performance collection more than once";
36 }
37 mCurrCollectionEvent = CollectionEvent::BOOT_TIME;
38
39 // TODO(b/148486340): Implement this method.
40 return Error() << "Unimplemented method";
41}
42
43Result<void> IoPerfCollection::onBootFinished() {
44 Mutex::Autolock lock(mMutex);
45 if (mCurrCollectionEvent != CollectionEvent::BOOT_TIME) {
46 return Error() << "Current collection event " << toEventString(mCurrCollectionEvent)
47 << " != " << toEventString(CollectionEvent::BOOT_TIME)
48 << " collection event";
49 }
50
51 // TODO(b/148486340): Implement this method.
52 return Error() << "Unimplemented method";
53}
54
55status_t IoPerfCollection::dump(int /*fd*/) {
56 Mutex::Autolock lock(mMutex);
57
58 // TODO(b/148486340): Implement this method.
59 return INVALID_OPERATION;
60}
61
62status_t IoPerfCollection::startCustomCollection(std::chrono::seconds /*interval*/,
63 std::chrono::seconds /*maxDuration*/) {
64 Mutex::Autolock lock(mMutex);
65 if (mCurrCollectionEvent != CollectionEvent::PERIODIC) {
66 ALOGE(
67 "Cannot start a custom collection when "
68 "the current collection event %s != %s collection event",
69 toEventString(mCurrCollectionEvent).c_str(),
70 toEventString(CollectionEvent::PERIODIC).c_str());
71 return INVALID_OPERATION;
72 }
73
74 // TODO(b/148486340): Implement this method.
75 return INVALID_OPERATION;
76}
77
78status_t IoPerfCollection::endCustomCollection(int /*fd*/) {
79 Mutex::Autolock lock(mMutex);
80 if (mCurrCollectionEvent != CollectionEvent::CUSTOM) {
81 ALOGE("No custom collection is running");
82 return INVALID_OPERATION;
83 }
84
85 // TODO(b/148486340): Implement this method.
86 return INVALID_OPERATION;
87}
88
89Result<void> IoPerfCollection::collect() {
90 Mutex::Autolock lock(mMutex);
91
92 // TODO(b/148486340): Implement this method.
93 return Error() << "Unimplemented method";
94}
95
96Result<void> IoPerfCollection::collectUidIoPerfDataLocked() {
97 // TODO(b/148486340): Implement this method.
98 return Error() << "Unimplemented method";
99}
100
101Result<void> IoPerfCollection::collectSystemIoPerfDataLocked() {
102 // TODO(b/148486340): Implement this method.
103 return Error() << "Unimplemented method";
104}
105
106Result<void> IoPerfCollection::collectProcessIoPerfDataLocked() {
107 // TODO(b/148486340): Implement this method.
108 return Error() << "Unimplemented method";
109}
110
111} // namespace watchdog
112} // namespace automotive
113} // namespace android