blob: df07916f7a6b2eb2e381669045b179c1daa92535 [file] [log] [blame]
Steven Moreland5553ac42020-11-11 02:14:45 +00001/*
2 * Copyright (C) 2020 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#define LOG_TAG "RpcServer"
18
19#include <sys/socket.h>
20#include <sys/un.h>
21
22#include <vector>
23
24#include <binder/Parcel.h>
25#include <binder/RpcServer.h>
26#include <log/log.h>
27#include "RpcState.h"
28
29#include "RpcWireFormat.h"
30
31namespace android {
32
33using base::unique_fd;
34
35RpcServer::RpcServer() {}
36RpcServer::~RpcServer() {}
37
38sp<RpcServer> RpcServer::make() {
39 return new RpcServer;
40}
41
42void RpcServer::iUnderstandThisCodeIsExperimentalAndIWillNotUseItInProduction() {
43 mAgreedExperimental = true;
44}
45
46sp<RpcConnection> RpcServer::addClientConnection() {
47 LOG_ALWAYS_FATAL_IF(!mAgreedExperimental, "no!");
48
49 auto connection = RpcConnection::make();
50 connection->setForServer(this);
51 mConnections.push_back(connection);
52 return connection;
53}
54
55void RpcServer::setRootObject(const sp<IBinder>& binder) {
56 LOG_ALWAYS_FATAL_IF(mRootObject != nullptr, "There can only be one root object");
57 mRootObject = binder;
58}
59
60sp<IBinder> RpcServer::getRootObject() {
61 return mRootObject;
62}
63
64} // namespace android