blob: a609b6fd482272a9306362272f7889d6db1ec1c3 [file] [log] [blame]
Mathias Agopiana1e6bc82010-07-14 18:41:18 -07001/*
2 * Copyright (C) 2010 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 */
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080016
Mathias Agopian4f4f0942013-08-19 17:26:18 -070017#include <binder/IServiceManager.h>
18#include <binder/IPCThreadState.h>
19#include <binder/ProcessState.h>
20#include <binder/IServiceManager.h>
Mathias Agopian7ffaa7c2013-07-22 12:20:28 -070021#include "SurfaceFlinger.h"
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080022
23using namespace android;
24
Mathias Agopiana1e6bc82010-07-14 18:41:18 -070025int main(int argc, char** argv) {
Mathias Agopian64a1e082012-04-19 17:31:53 -070026 // When SF is launched in its own process, limit the number of
27 // binder threads to 4.
28 ProcessState::self()->setThreadPoolMaxThreadCount(4);
Mathias Agopian4f4f0942013-08-19 17:26:18 -070029
30 // instantiate surfaceflinger
31 sp<SurfaceFlinger> flinger = new SurfaceFlinger();
32
33 // initialize before clients can connect
34 flinger->init();
35
36 // start the thread pool
37 sp<ProcessState> ps(ProcessState::self());
38 ps->startThreadPool();
39
40 // publish surface flinger
41 sp<IServiceManager> sm(defaultServiceManager());
42 sm->addService(String16(SurfaceFlinger::getServiceName()), flinger, false);
43
44 // run in this thread
45 flinger->run();
46
Mathias Agopiana1e6bc82010-07-14 18:41:18 -070047 return 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080048}