blob: 04869a170f72a7ebd5be42c5dcc05e8fef18eb74 [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 Wasilczyka9e451a2024-05-22 12:18:42 -070029LIBBINDER_EXPORTED void trace_int(uint64_t tag, const char* name, int32_t value);
Tomasz Wasilczykdaf727a2023-11-21 13:50:09 -080030
Tomasz Wasilczyk639490b2023-11-01 13:49:41 -070031status_t setNonBlocking(borrowed_fd fd);
Andrei Homescu7c0b79f2022-06-30 02:00:46 +000032
33status_t getRandomBytes(uint8_t* data, size_t size);
34
Andrei Homescu24ad36e2022-08-04 01:33:33 +000035status_t dupFileDescriptor(int oldFd, int* newFd);
36
Andrei Homescu024727b2022-08-24 23:54:59 +000037std::unique_ptr<RpcTransportCtxFactory> makeDefaultRpcTransportCtxFactory();
38
Frederick Maylef7b65d12024-05-14 16:55:14 -070039LIBBINDER_INTERNAL_EXPORTED ssize_t
40sendMessageOnSocket(const RpcTransportFd& socket, iovec* iovs, int niovs,
41 const std::vector<std::variant<unique_fd, borrowed_fd>>* ancillaryFds);
David Brazdil21c887c2022-09-23 12:25:18 +010042
Frederick Maylef7b65d12024-05-14 16:55:14 -070043LIBBINDER_INTERNAL_EXPORTED ssize_t
44receiveMessageFromSocket(const RpcTransportFd& socket, iovec* iovs, int niovs,
45 std::vector<std::variant<unique_fd, borrowed_fd>>* ancillaryFds);
David Brazdil21c887c2022-09-23 12:25:18 +010046
Tomasz Wasilczyk0d9dec22023-10-06 20:28:49 +000047uint64_t GetThreadId();
48
Tomasz Wasilczyk346f1042023-10-09 17:02:46 +000049bool report_sysprop_change();
50
Tomasz Wasilczyk0d9dec22023-10-06 20:28:49 +000051} // namespace android::binder::os