Yao Chen | 49954cd | 2018-04-18 13:48:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | #pragma once |
| 17 | |
| 18 | #include <sysutils/SocketListener.h> |
| 19 | #include <utils/RefBase.h> |
| 20 | #include "logd/LogListener.h" |
| 21 | |
| 22 | // DEFAULT_OVERFLOWUID is defined in linux/highuid.h, which is not part of |
| 23 | // the uapi headers for userspace to use. This value is filled in on the |
| 24 | // out-of-band socket credentials if the OS fails to find one available. |
| 25 | // One of the causes of this is if SO_PASSCRED is set, all the packets before |
| 26 | // that point will have this value. We also use it in a fake credential if |
| 27 | // no socket credentials are supplied. |
| 28 | #ifndef DEFAULT_OVERFLOWUID |
| 29 | #define DEFAULT_OVERFLOWUID 65534 |
| 30 | #endif |
| 31 | |
| 32 | namespace android { |
| 33 | namespace os { |
| 34 | namespace statsd { |
| 35 | |
| 36 | class StatsSocketListener : public SocketListener, public virtual android::RefBase { |
| 37 | public: |
| 38 | StatsSocketListener(const sp<LogListener>& listener); |
| 39 | |
| 40 | virtual ~StatsSocketListener(); |
| 41 | |
| 42 | protected: |
| 43 | virtual bool onDataAvailable(SocketClient* cli); |
| 44 | |
| 45 | private: |
| 46 | static int getLogSocket(); |
| 47 | /** |
| 48 | * Who is going to get the events when they're read. |
| 49 | */ |
| 50 | sp<LogListener> mListener; |
| 51 | }; |
| 52 | } // namespace statsd |
| 53 | } // namespace os |
| 54 | } // namespace android |