blob: bd0e6f9a116790249685851bf2c1c14f6a837b06 [file] [log] [blame]
Mathias Agopian208059f2009-05-18 15:08:03 -07001/*
2 * Copyright (C) 2008 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// All static variables go here, to control initialization and
18// destruction order in the library.
19
20#include <private/binder/Static.h>
21
Mathias Agopian002e1e52013-05-06 20:20:50 -070022#include <binder/BufferedTextOutput.h>
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070023#include <binder/IPCThreadState.h>
Mathias Agopian208059f2009-05-18 15:08:03 -070024#include <utils/Log.h>
25
26namespace android {
27
Mathias Agopian002e1e52013-05-06 20:20:50 -070028// ------------ Text output streams
29
30Vector<int32_t> gTextBuffers;
31
32class LogTextOutput : public BufferedTextOutput
33{
34public:
35 LogTextOutput() : BufferedTextOutput(MULTITHREADED) { }
36 virtual ~LogTextOutput() { };
37
38protected:
39 virtual status_t writeLines(const struct iovec& vec, size_t N)
40 {
41 //android_writevLog(&vec, N); <-- this is now a no-op
42 if (N != 1) ALOGI("WARNING: writeLines N=%zu\n", N);
43 ALOGI("%.*s", (int)vec.iov_len, (const char*) vec.iov_base);
44 return NO_ERROR;
45 }
46};
47
48class FdTextOutput : public BufferedTextOutput
49{
50public:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070051 explicit FdTextOutput(int fd) : BufferedTextOutput(MULTITHREADED), mFD(fd) { }
Mathias Agopian002e1e52013-05-06 20:20:50 -070052 virtual ~FdTextOutput() { };
53
54protected:
55 virtual status_t writeLines(const struct iovec& vec, size_t N)
56 {
57 writev(mFD, &vec, N);
58 return NO_ERROR;
59 }
60
61private:
62 int mFD;
63};
64
65static LogTextOutput gLogTextOutput;
66static FdTextOutput gStdoutTextOutput(STDOUT_FILENO);
67static FdTextOutput gStderrTextOutput(STDERR_FILENO);
68
69TextOutput& alog(gLogTextOutput);
70TextOutput& aout(gStdoutTextOutput);
71TextOutput& aerr(gStderrTextOutput);
72
Mathias Agopian208059f2009-05-18 15:08:03 -070073// ------------ ProcessState.cpp
74
Yabin Cuic39caf32018-06-05 14:34:36 -070075Mutex& gProcessMutex = *new Mutex;
Mathias Agopian208059f2009-05-18 15:08:03 -070076sp<ProcessState> gProcess;
77
Dianne Hackborn7e790af2014-11-11 12:22:53 -080078// ------------ IServiceManager.cpp
Mathias Agopian208059f2009-05-18 15:08:03 -070079
80Mutex gDefaultServiceManagerLock;
81sp<IServiceManager> gDefaultServiceManager;
Jiyong Park47f876b2018-04-17 13:56:46 +090082#ifndef __ANDROID_VNDK__
Mathias Agopian208059f2009-05-18 15:08:03 -070083sp<IPermissionController> gPermissionController;
Jiyong Park47f876b2018-04-17 13:56:46 +090084#endif
Yunfan Chen788e1c42018-03-29 16:52:09 +090085bool gSystemBootCompleted = false;
Mathias Agopian208059f2009-05-18 15:08:03 -070086
87} // namespace android