xref: /aosp_15_r20/frameworks/native/libs/binder/rust/sys/BinderBindings.hpp (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1 /*
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 #include <android/binder_ibinder.h>
18 #include <android/binder_parcel.h>
19 #include <android/binder_status.h>
20 
21 /* Platform only */
22 #if defined(ANDROID_PLATFORM) || defined(__ANDROID_VENDOR__)
23 #include <android/binder_ibinder_platform.h>
24 #include <android/binder_manager.h>
25 #include <android/binder_parcel_platform.h>
26 #include <android/binder_process.h>
27 #include <android/binder_rpc.h>
28 #include <android/binder_shell.h>
29 #include <android/binder_stability.h>
30 #endif
31 
32 namespace android {
33 
34 namespace c_interface {
35 
36 // Expose error codes from anonymous enum in binder_status.h
37 enum StatusCode {
38     OK = STATUS_OK,
39     UNKNOWN_ERROR = STATUS_UNKNOWN_ERROR,
40     NO_MEMORY = STATUS_NO_MEMORY,
41     INVALID_OPERATION = STATUS_INVALID_OPERATION,
42     BAD_VALUE = STATUS_BAD_VALUE,
43     BAD_TYPE = STATUS_BAD_TYPE,
44     NAME_NOT_FOUND = STATUS_NAME_NOT_FOUND,
45     PERMISSION_DENIED = STATUS_PERMISSION_DENIED,
46     NO_INIT = STATUS_NO_INIT,
47     ALREADY_EXISTS = STATUS_ALREADY_EXISTS,
48     DEAD_OBJECT = STATUS_DEAD_OBJECT,
49     FAILED_TRANSACTION = STATUS_FAILED_TRANSACTION,
50     BAD_INDEX = STATUS_BAD_INDEX,
51     NOT_ENOUGH_DATA = STATUS_NOT_ENOUGH_DATA,
52     WOULD_BLOCK = STATUS_WOULD_BLOCK,
53     TIMED_OUT = STATUS_TIMED_OUT,
54     UNKNOWN_TRANSACTION = STATUS_UNKNOWN_TRANSACTION,
55     FDS_NOT_ALLOWED = STATUS_FDS_NOT_ALLOWED,
56     UNEXPECTED_NULL = STATUS_UNEXPECTED_NULL,
57 };
58 
59 // Expose exception codes from anonymous enum in binder_status.h
60 enum ExceptionCode {
61     NONE = EX_NONE,
62     SECURITY = EX_SECURITY,
63     BAD_PARCELABLE = EX_BAD_PARCELABLE,
64     ILLEGAL_ARGUMENT = EX_ILLEGAL_ARGUMENT,
65     NULL_POINTER = EX_NULL_POINTER,
66     ILLEGAL_STATE = EX_ILLEGAL_STATE,
67     NETWORK_MAIN_THREAD = EX_NETWORK_MAIN_THREAD,
68     UNSUPPORTED_OPERATION = EX_UNSUPPORTED_OPERATION,
69     SERVICE_SPECIFIC = EX_SERVICE_SPECIFIC,
70     PARCELABLE = EX_PARCELABLE,
71 
72     /**
73      * This is special, and indicates to native binder proxies that the
74      * transaction has failed at a low level.
75      */
76     TRANSACTION_FAILED = EX_TRANSACTION_FAILED,
77 };
78 
79 namespace consts {
80 
81 enum {
82     FIRST_CALL_TRANSACTION = FIRST_CALL_TRANSACTION,
83     LAST_CALL_TRANSACTION = LAST_CALL_TRANSACTION,
84 };
85 
86 enum {
87     FLAG_ONEWAY = FLAG_ONEWAY,
88 #if defined(ANDROID_PLATFORM) || defined(__ANDROID_VENDOR__)
89     FLAG_CLEAR_BUF = FLAG_CLEAR_BUF,
90     FLAG_PRIVATE_LOCAL = FLAG_PRIVATE_LOCAL,
91 #endif
92 };
93 
94 } // namespace consts
95 
96 } // namespace c_interface
97 
98 } // namespace android
99