blob: c8ceb42ac8ad37564f418056ec57b9760d387554 [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
41 ProcessState::self()->initWithDriver(driver);
42 ProcessState::self()->setThreadPoolMaxThreadCount(0);
43 ProcessState::self()->setCallRestriction(
44 ProcessState::CallRestriction::FATAL_IF_NOT_ONEWAY);
45
46 sp<ServiceManager> manager = new ServiceManager(std::make_unique<Access>());
47 IPCThreadState::self()->setTheContextObject(manager);
48 ProcessState::self()->becomeContextManager(nullptr, nullptr);
49
50 IPCThreadState::self()->joinThreadPool();
51
52 // should not be reached
53 return EXIT_FAILURE;
54}