Steven Moreland | 80e1e6d | 2019-06-21 12:35:59 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 26 | using ::android::sp; |
| 27 | using ::android::ProcessState; |
| 28 | using ::android::IPCThreadState; |
| 29 | using ::android::ServiceManager; |
| 30 | using ::android::Access; |
| 31 | |
| 32 | int 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 Moreland | 1ac84c4 | 2019-07-10 17:51:27 -0700 | [diff] [blame^] | 41 | sp<ProcessState> ps = ProcessState::initWithDriver(driver); |
| 42 | ps->setThreadPoolMaxThreadCount(0); |
| 43 | ps->setCallRestriction(ProcessState::CallRestriction::FATAL_IF_NOT_ONEWAY); |
Steven Moreland | 80e1e6d | 2019-06-21 12:35:59 -0700 | [diff] [blame] | 44 | |
| 45 | sp<ServiceManager> manager = new ServiceManager(std::make_unique<Access>()); |
| 46 | IPCThreadState::self()->setTheContextObject(manager); |
Steven Moreland | 1ac84c4 | 2019-07-10 17:51:27 -0700 | [diff] [blame^] | 47 | ps->becomeContextManager(nullptr, nullptr); |
Steven Moreland | 80e1e6d | 2019-06-21 12:35:59 -0700 | [diff] [blame] | 48 | |
| 49 | IPCThreadState::self()->joinThreadPool(); |
| 50 | |
| 51 | // should not be reached |
| 52 | return EXIT_FAILURE; |
| 53 | } |