blob: 0035aeb2050620233c7a0d5941cd131db1e372a3 [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 Homescu024727b2022-08-24 23:54:59 +000021#include <binder/RpcTransport.h>
Tomasz Wasilczyk639490b2023-11-01 13:49:41 -070022#include <binder/unique_fd.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 Wasilczykdaf727a2023-11-21 13:50:09 -080027void trace_begin(uint64_t tag, const char* name);
28void trace_end(uint64_t tag);
29
Tomasz Wasilczyk639490b2023-11-01 13:49:41 -070030status_t setNonBlocking(borrowed_fd fd);
Andrei Homescu7c0b79f2022-06-30 02:00:46 +000031
32status_t getRandomBytes(uint8_t* data, size_t size);
33
Andrei Homescu24ad36e2022-08-04 01:33:33 +000034status_t dupFileDescriptor(int oldFd, int* newFd);
35
Andrei Homescu024727b2022-08-24 23:54:59 +000036std::unique_ptr<RpcTransportCtxFactory> makeDefaultRpcTransportCtxFactory();
37
Tomasz Wasilczyk639490b2023-11-01 13:49:41 -070038ssize_t sendMessageOnSocket(const RpcTransportFd& socket, iovec* iovs, int niovs,
39 const std::vector<std::variant<unique_fd, borrowed_fd>>* ancillaryFds);
David Brazdil21c887c2022-09-23 12:25:18 +010040
Tomasz Wasilczyk639490b2023-11-01 13:49:41 -070041ssize_t receiveMessageFromSocket(const RpcTransportFd& socket, iovec* iovs, int niovs,
42 std::vector<std::variant<unique_fd, borrowed_fd>>* ancillaryFds);
David Brazdil21c887c2022-09-23 12:25:18 +010043
Tomasz Wasilczyk0d9dec22023-10-06 20:28:49 +000044uint64_t GetThreadId();
45
Tomasz Wasilczyk346f1042023-10-09 17:02:46 +000046bool report_sysprop_change();
47
Tomasz Wasilczyk0d9dec22023-10-06 20:28:49 +000048} // namespace android::binder::os