David Anderson | c053b3b | 2019-01-08 18:22:07 -0800 | [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 | |
David Anderson | b3aff18 | 2019-01-11 14:37:51 -0800 | [diff] [blame] | 17 | #include <getopt.h> |
| 18 | |
| 19 | #include <string> |
| 20 | |
David Anderson | c053b3b | 2019-01-08 18:22:07 -0800 | [diff] [blame] | 21 | #include <android-base/logging.h> |
David Anderson | 4c75673 | 2019-07-12 14:18:37 -0700 | [diff] [blame] | 22 | #include <binder/BinderService.h> |
David Anderson | c053b3b | 2019-01-08 18:22:07 -0800 | [diff] [blame] | 23 | #include <binder/IPCThreadState.h> |
| 24 | #include <binder/ProcessState.h> |
David Anderson | 4c75673 | 2019-07-12 14:18:37 -0700 | [diff] [blame] | 25 | #include <libgsi/libgsi.h> |
| 26 | |
| 27 | #include "gsi_service.h" |
David Anderson | c053b3b | 2019-01-08 18:22:07 -0800 | [diff] [blame] | 28 | |
| 29 | using android::ProcessState; |
| 30 | using android::sp; |
David Anderson | b3aff18 | 2019-01-11 14:37:51 -0800 | [diff] [blame] | 31 | using namespace std::literals; |
David Anderson | c053b3b | 2019-01-08 18:22:07 -0800 | [diff] [blame] | 32 | |
David Anderson | b3aff18 | 2019-01-11 14:37:51 -0800 | [diff] [blame] | 33 | int main(int argc, char** argv) { |
David Anderson | c053b3b | 2019-01-08 18:22:07 -0800 | [diff] [blame] | 34 | android::base::InitLogging(argv, android::base::LogdLogger(android::base::SYSTEM)); |
| 35 | |
David Anderson | b3aff18 | 2019-01-11 14:37:51 -0800 | [diff] [blame] | 36 | if (argc > 1 && argv[1] == "run-startup-tasks"s) { |
| 37 | android::gsi::GsiService::RunStartupTasks(); |
| 38 | exit(0); |
| 39 | } |
| 40 | |
David Anderson | 4c75673 | 2019-07-12 14:18:37 -0700 | [diff] [blame] | 41 | android::gsi::Gsid::Register(); |
David Anderson | c053b3b | 2019-01-08 18:22:07 -0800 | [diff] [blame] | 42 | { |
| 43 | sp<ProcessState> ps(ProcessState::self()); |
| 44 | ps->startThreadPool(); |
| 45 | ps->giveThreadPoolName(); |
| 46 | } |
| 47 | android::IPCThreadState::self()->joinThreadPool(); |
| 48 | |
| 49 | exit(0); |
| 50 | } |