blob: 3fa7b3f1ad252b1691efb4133c2c09c6fa6702ba [file] [log] [blame]
David Andersonc053b3b2019-01-08 18:22:07 -08001//
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 Andersonb3aff182019-01-11 14:37:51 -080017#include <getopt.h>
18
19#include <string>
20
David Andersonc053b3b2019-01-08 18:22:07 -080021#include <android-base/logging.h>
David Anderson4c756732019-07-12 14:18:37 -070022#include <binder/BinderService.h>
David Andersonc053b3b2019-01-08 18:22:07 -080023#include <binder/IPCThreadState.h>
24#include <binder/ProcessState.h>
David Anderson4c756732019-07-12 14:18:37 -070025#include <libgsi/libgsi.h>
26
27#include "gsi_service.h"
David Andersonc053b3b2019-01-08 18:22:07 -080028
29using android::ProcessState;
30using android::sp;
David Andersonb3aff182019-01-11 14:37:51 -080031using namespace std::literals;
David Andersonc053b3b2019-01-08 18:22:07 -080032
David Andersonb3aff182019-01-11 14:37:51 -080033int main(int argc, char** argv) {
David Andersonc053b3b2019-01-08 18:22:07 -080034 android::base::InitLogging(argv, android::base::LogdLogger(android::base::SYSTEM));
35
David Andersonb3aff182019-01-11 14:37:51 -080036 if (argc > 1 && argv[1] == "run-startup-tasks"s) {
37 android::gsi::GsiService::RunStartupTasks();
38 exit(0);
39 }
40
David Anderson4c756732019-07-12 14:18:37 -070041 android::gsi::Gsid::Register();
David Andersonc053b3b2019-01-08 18:22:07 -080042 {
43 sp<ProcessState> ps(ProcessState::self());
44 ps->startThreadPool();
45 ps->giveThreadPoolName();
46 }
47 android::IPCThreadState::self()->joinThreadPool();
48
49 exit(0);
50}