blob: 5703eb75159d326de8e0df56ef4a2dfc81276d37 [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
Frederick Maylef7b65d12024-05-14 16:55:14 -070027LIBBINDER_EXPORTED void trace_begin(uint64_t tag, const char* name);
28LIBBINDER_EXPORTED void trace_end(uint64_t tag);
Tomasz Wasilczykdaf727a2023-11-21 13:50:09 -080029
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
Frederick Maylef7b65d12024-05-14 16:55:14 -070038LIBBINDER_INTERNAL_EXPORTED ssize_t
39sendMessageOnSocket(const RpcTransportFd& socket, iovec* iovs, int niovs,
40 const std::vector<std::variant<unique_fd, borrowed_fd>>* ancillaryFds);
David Brazdil21c887c2022-09-23 12:25:18 +010041
Frederick Maylef7b65d12024-05-14 16:55:14 -070042LIBBINDER_INTERNAL_EXPORTED ssize_t
43receiveMessageFromSocket(const RpcTransportFd& socket, iovec* iovs, int niovs,
44 std::vector<std::variant<unique_fd, borrowed_fd>>* ancillaryFds);
David Brazdil21c887c2022-09-23 12:25:18 +010045
Tomasz Wasilczyk0d9dec22023-10-06 20:28:49 +000046uint64_t GetThreadId();
47
Tomasz Wasilczyk346f1042023-10-09 17:02:46 +000048bool report_sysprop_change();
49
Tomasz Wasilczyk0d9dec22023-10-06 20:28:49 +000050} // namespace android::binder::os