Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | #ifndef STATS_SERVICE_H |
| 18 | #define STATS_SERVICE_H |
| 19 | |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame^] | 20 | #include "StatsLogProcessor.h" |
| 21 | |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 22 | #include <android/os/BnStatsManager.h> |
Joe Onorato | 2cbc2cc | 2017-08-30 17:03:23 -0700 | [diff] [blame] | 23 | #include <binder/IResultReceiver.h> |
| 24 | #include <binder/IShellCallback.h> |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame^] | 25 | #include <frameworks/base/cmds/statsd/src/statsd_config.pb.h> |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 26 | #include <utils/Looper.h> |
| 27 | |
| 28 | #include <deque> |
| 29 | #include <mutex> |
| 30 | |
| 31 | using namespace android; |
| 32 | using namespace android::base; |
| 33 | using namespace android::binder; |
| 34 | using namespace android::os; |
| 35 | using namespace std; |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame^] | 36 | using android::os::statsd::StatsdConfig; |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 37 | |
| 38 | // ================================================================================ |
| 39 | class StatsService : public BnStatsManager { |
| 40 | public: |
| 41 | StatsService(const sp<Looper>& handlerLooper); |
| 42 | virtual ~StatsService(); |
| 43 | |
Joe Onorato | 2cbc2cc | 2017-08-30 17:03:23 -0700 | [diff] [blame] | 44 | virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags); |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 45 | |
Joe Onorato | 2cbc2cc | 2017-08-30 17:03:23 -0700 | [diff] [blame] | 46 | virtual status_t dump(int fd, const Vector<String16>& args); |
| 47 | |
| 48 | virtual status_t command(FILE* in, FILE* out, FILE* err, Vector<String8>& args); |
| 49 | |
| 50 | virtual Status systemRunning(); |
Yao Chen | 482d272 | 2017-09-12 13:25:43 -0700 | [diff] [blame] | 51 | |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame^] | 52 | virtual status_t setProcessor(const sp<StatsLogProcessor>& main_processor); |
| 53 | |
Yao Chen | 482d272 | 2017-09-12 13:25:43 -0700 | [diff] [blame] | 54 | private: |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame^] | 55 | sp<StatsLogProcessor> m_processor; // Reference to the processor for updating configs. |
Yao Chen | 482d272 | 2017-09-12 13:25:43 -0700 | [diff] [blame] | 56 | status_t doPrintStatsLog(FILE* out, const Vector<String8>& args); |
| 57 | void printCmdHelp(FILE* out); |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame^] | 58 | status_t doLoadConfig(FILE* in); |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | #endif // STATS_SERVICE_H |