blob: 9f6193b97a5d93956c1f83aee4f96eb9a8c16e59 [file] [log] [blame]
Steven Moreland80e1e6d2019-06-21 12:35:59 -07001/*
2 * Copyright (C) 2019 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#include <android-base/logging.h>
18#include <binder/IPCThreadState.h>
19#include <binder/ProcessState.h>
20#include <binder/Status.h>
21#include <utils/StrongPointer.h>
22
23#include "Access.h"
24#include "ServiceManager.h"
25
26using ::android::sp;
27using ::android::ProcessState;
28using ::android::IPCThreadState;
29using ::android::ServiceManager;
30using ::android::Access;
31
32int main(int argc, char** argv) {
33 if (argc > 2) {
34 LOG(FATAL) << "usage: " << argv[0] << " [binder driver]";
35 }
36
37 const char* driver = argc == 2 ? argv[1] : "/dev/binder";
38
39 android::base::InitLogging(nullptr, &android::base::KernelLogger);
40
Steven Moreland1ac84c42019-07-10 17:51:27 -070041 sp<ProcessState> ps = ProcessState::initWithDriver(driver);
42 ps->setThreadPoolMaxThreadCount(0);
43 ps->setCallRestriction(ProcessState::CallRestriction::FATAL_IF_NOT_ONEWAY);
Steven Moreland80e1e6d2019-06-21 12:35:59 -070044
45 sp<ServiceManager> manager = new ServiceManager(std::make_unique<Access>());
46 IPCThreadState::self()->setTheContextObject(manager);
Steven Moreland1ac84c42019-07-10 17:51:27 -070047 ps->becomeContextManager(nullptr, nullptr);
Steven Moreland80e1e6d2019-06-21 12:35:59 -070048
49 IPCThreadState::self()->joinThreadPool();
50
51 // should not be reached
52 return EXIT_FAILURE;
53}