diff options
author | Mathias Agopian <mathias@google.com> | 2013-05-06 20:20:50 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2013-05-07 18:28:11 -0700 |
commit | 002e1e58dfe19dd3e49a59c6827cbf51573941a2 (patch) | |
tree | 6dc444d7f05aa0512e3c97344d86ee0264daf869 /libs/binder/Static.cpp | |
parent | b4f1a027cbadd4cd07341f60f859ae34643b68ae (diff) | |
download | frameworks_native-002e1e58dfe19dd3e49a59c6827cbf51573941a2.zip frameworks_native-002e1e58dfe19dd3e49a59c6827cbf51573941a2.tar.gz frameworks_native-002e1e58dfe19dd3e49a59c6827cbf51573941a2.tar.bz2 |
libutils clean-up
Change-Id: I6ff4cfc736751de2912c697f954e45e275f2d386
Diffstat (limited to 'libs/binder/Static.cpp')
-rw-r--r-- | libs/binder/Static.cpp | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/libs/binder/Static.cpp b/libs/binder/Static.cpp index 12b0308..2062692 100644 --- a/libs/binder/Static.cpp +++ b/libs/binder/Static.cpp @@ -19,30 +19,76 @@ #include <private/binder/Static.h> +#include <binder/BufferedTextOutput.h> #include <binder/IPCThreadState.h> #include <utils/Log.h> namespace android { +// ------------ Text output streams + +Vector<int32_t> gTextBuffers; + +class LogTextOutput : public BufferedTextOutput +{ +public: + LogTextOutput() : BufferedTextOutput(MULTITHREADED) { } + virtual ~LogTextOutput() { }; + +protected: + virtual status_t writeLines(const struct iovec& vec, size_t N) + { + //android_writevLog(&vec, N); <-- this is now a no-op + if (N != 1) ALOGI("WARNING: writeLines N=%zu\n", N); + ALOGI("%.*s", (int)vec.iov_len, (const char*) vec.iov_base); + return NO_ERROR; + } +}; + +class FdTextOutput : public BufferedTextOutput +{ +public: + FdTextOutput(int fd) : BufferedTextOutput(MULTITHREADED), mFD(fd) { } + virtual ~FdTextOutput() { }; + +protected: + virtual status_t writeLines(const struct iovec& vec, size_t N) + { + writev(mFD, &vec, N); + return NO_ERROR; + } + +private: + int mFD; +}; + +static LogTextOutput gLogTextOutput; +static FdTextOutput gStdoutTextOutput(STDOUT_FILENO); +static FdTextOutput gStderrTextOutput(STDERR_FILENO); + +TextOutput& alog(gLogTextOutput); +TextOutput& aout(gStdoutTextOutput); +TextOutput& aerr(gStderrTextOutput); + // ------------ ProcessState.cpp Mutex gProcessMutex; sp<ProcessState> gProcess; -class LibUtilsIPCtStatics +class LibBinderIPCtStatics { public: - LibUtilsIPCtStatics() + LibBinderIPCtStatics() { } - ~LibUtilsIPCtStatics() + ~LibBinderIPCtStatics() { IPCThreadState::shutdown(); } }; -static LibUtilsIPCtStatics gIPCStatics; +static LibBinderIPCtStatics gIPCStatics; // ------------ ServiceManager.cpp |