blob: bb7caa951b2554202850524ef888beb90e1493d5 [file] [log] [blame]
Andrei Homescu7c0b79f2022-06-30 02:00:46 +00001/*
2 * Copyright (C) 2022 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#pragma once
17
18#include <stddef.h>
19#include <cstdint>
20
Andrei Homescu7c0b79f2022-06-30 02:00:46 +000021#include <android-base/unique_fd.h>
Andrei Homescu024727b2022-08-24 23:54:59 +000022#include <binder/RpcTransport.h>
Andrei Homescu7c0b79f2022-06-30 02:00:46 +000023#include <utils/Errors.h>
24
Tomasz Wasilczyk0d9dec22023-10-06 20:28:49 +000025namespace android::binder::os {
Andrei Homescu7c0b79f2022-06-30 02:00:46 +000026
Tomasz Wasilczyk88aa8c32023-11-01 09:46:07 -070027status_t setNonBlocking(android::base::borrowed_fd fd);
Andrei Homescu7c0b79f2022-06-30 02:00:46 +000028
29status_t getRandomBytes(uint8_t* data, size_t size);
30
Andrei Homescu24ad36e2022-08-04 01:33:33 +000031status_t dupFileDescriptor(int oldFd, int* newFd);
32
Andrei Homescu024727b2022-08-24 23:54:59 +000033std::unique_ptr<RpcTransportCtxFactory> makeDefaultRpcTransportCtxFactory();
34
David Brazdilc3964f62022-10-24 23:06:14 +010035ssize_t sendMessageOnSocket(
David Brazdil21c887c2022-09-23 12:25:18 +010036 const RpcTransportFd& socket, iovec* iovs, int niovs,
37 const std::vector<std::variant<base::unique_fd, base::borrowed_fd>>* ancillaryFds);
38
David Brazdilc3964f62022-10-24 23:06:14 +010039ssize_t receiveMessageFromSocket(
David Brazdil21c887c2022-09-23 12:25:18 +010040 const RpcTransportFd& socket, iovec* iovs, int niovs,
41 std::vector<std::variant<base::unique_fd, base::borrowed_fd>>* ancillaryFds);
42
Tomasz Wasilczyk0d9dec22023-10-06 20:28:49 +000043uint64_t GetThreadId();
44
Tomasz Wasilczyk346f1042023-10-09 17:02:46 +000045bool report_sysprop_change();
46
Tomasz Wasilczyk0d9dec22023-10-06 20:28:49 +000047} // namespace android::binder::os