1 /* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #![allow(dead_code)] 17 18 use std::ffi::{c_char, c_void, c_ulong}; 19 20 /// CRemoteObject is a member of RemoteObject, 21 /// RemoteObject always contained a native CRemoteObject pointer. 22 #[repr(C)] 23 pub struct CRemoteObject { 24 _private: [u8; 0], 25 } 26 27 /// CIRemoteObject is a member of CRemoteObject, 28 /// CRemoteObject always contained a native CIRemoteObject pointer. 29 /// Please refer to the CRemoteObject object on side c 30 #[repr(C)] 31 pub struct CIRemoteObject { 32 _private: [u8; 0], 33 } 34 35 #[repr(C)] 36 pub struct CDeathRecipient { 37 _private: [u8; 0], 38 } 39 40 #[repr(C)] 41 pub struct CParcel { 42 _private: [u8; 0], 43 } 44 45 #[repr(C)] 46 pub struct CAshmem { 47 _private: [u8; 0], 48 } 49 50 // Callback function type for OnRemoteRequest() from native, this 51 // callback will be called when native recive client IPC request. 52 pub type OnRemoteRequest = unsafe extern "C" fn ( 53 user_data: *mut c_void, 54 code: u32, 55 data: *const CParcel, 56 reply: *mut CParcel 57 ) -> i32; 58 59 // Callback function type for OnRemoteDump() from native, this 60 // callback will be called when native recive client IPC dump. 61 pub type OnRemoteDump = unsafe extern "C" fn ( 62 user_data: *mut c_void, 63 data: *const CParcel, 64 ) -> i32; 65 66 // Callback function type for OnRemoteObjectDestroy() from native, 67 // this callback will be called when native remote object destroyed. 68 pub type OnRemoteObjectDestroy = unsafe extern "C" fn ( 69 user_data: *mut c_void 70 ); 71 72 // Callback function type for OnDeathRecipientCb() from native, 73 // this callback will be called when remote stub is destroyed. 74 pub type OnDeathRecipientCb = unsafe extern "C" fn ( 75 callback: *mut c_void 76 ); 77 78 // Callback function type for OnDeathRecipientDestroyCb() from native, 79 // this callback will be called when native CDeathRecipient destroyed. 80 pub type OnDeathRecipientDestroyCb = unsafe extern "C" fn ( 81 callback: *mut c_void 82 ); 83 84 // Callback function type for OnCParcelBytesAllocator() from native, 85 // this callback will be called when native parcel need allocate buffer 86 // for string or bytes buffer by rust. 87 pub type OnCParcelBytesAllocator<T> = unsafe extern "C" fn ( 88 value: *mut c_void, 89 buffer: *mut *mut T, 90 len: i32 91 ) -> bool; 92 93 pub type OnCParcelAllocator = unsafe extern "C" fn ( 94 value: *mut c_void, 95 len: i32 96 ) -> bool; 97 98 // Callback function type for CParcelReadStringArray() from native. 99 // Rust side need read string one by one from native according calling 100 // CParcelReadStringElement(). 101 pub type OnStringArrayRead = unsafe extern "C" fn( 102 data: *const c_void, // C++ vector pointer 103 value: *mut c_void, // Rust vector pointer 104 len: u32 // C++ vector length 105 ) -> bool; 106 107 // Callback function type for CParcelReadString16Array() from native. 108 // Rust side need read string one by one from native according calling 109 // CParcelReadString16Element(). 110 pub type OnString16ArrayRead = unsafe extern "C" fn( 111 data: *const c_void, // C++ vector pointer 112 value: *mut c_void, // Rust vector pointer 113 len: u32 // C++ vector length 114 ) -> bool; 115 116 // Callback function type for CParcelWriteStringArray() from native. 117 // Rust side need write string one by one to native according calling 118 // CParcelWriteStringElement(). 119 pub type OnStringArrayWrite = unsafe extern "C" fn( 120 array: *const c_void, // C++ vector pointer 121 value: *mut c_void, // Rust vector pointer 122 len: u32, // Rust vector length 123 ) -> bool; 124 125 // Callback function type for CParcelWriteString16Array() from native. 126 // Rust side need write string one by one to native according calling 127 // CParcelWriteString16Element(). 128 pub type OnString16ArrayWrite = unsafe extern "C" fn( 129 array: *const c_void, // C++ vector pointer 130 value: *mut c_void, // Rust vector pointer 131 len: u32, // Rust vector length 132 ) -> bool; 133 134 pub type OnCParcelWriteElement = unsafe extern "C" fn ( 135 value: *mut CParcel, 136 arr: *const c_void, 137 index: c_ulong, 138 ) -> bool; 139 140 pub type OnCParcelReadElement = unsafe extern "C" fn ( 141 value: *const CParcel, 142 arr: *mut c_void, 143 index: c_ulong, 144 ) -> bool; 145 146 // C interface for IPC core object 147 extern "C" { CreateCRemoteObject(object: *mut c_void) -> *mut CRemoteObject148 pub fn CreateCRemoteObject(object: *mut c_void) -> *mut CRemoteObject; GetCIRemoteObject(object: *mut CRemoteObject) -> *mut c_void149 pub fn GetCIRemoteObject(object: *mut CRemoteObject) -> *mut c_void; CreateRemoteStub(descripor: *const c_char, on_remote_request: OnRemoteRequest, on_remote_object_destroy: OnRemoteObjectDestroy, user_data: *const c_void, on_remote_dump: OnRemoteDump) -> *mut CRemoteObject150 pub fn CreateRemoteStub(descripor: *const c_char, on_remote_request: OnRemoteRequest, 151 on_remote_object_destroy: OnRemoteObjectDestroy, 152 user_data: *const c_void, on_remote_dump: OnRemoteDump) -> *mut CRemoteObject; RemoteObjectIncStrongRef(object: *mut CRemoteObject)153 pub fn RemoteObjectIncStrongRef(object: *mut CRemoteObject); RemoteObjectDecStrongRef(object: *mut CRemoteObject)154 pub fn RemoteObjectDecStrongRef(object: *mut CRemoteObject); 155 RemoteObjectSendRequest(object: *mut CRemoteObject, code: u32, data: *const CParcel, reply: *mut CParcel, is_async: bool) -> i32156 pub fn RemoteObjectSendRequest(object: *mut CRemoteObject, code: u32, 157 data: *const CParcel, reply: *mut CParcel, is_async: bool) -> i32; RemoteObjectLessThan(object: *const CRemoteObject, other: *const CRemoteObject) -> bool158 pub fn RemoteObjectLessThan(object: *const CRemoteObject, 159 other: *const CRemoteObject) -> bool; 160 CreateDeathRecipient(onDeathRecipient: OnDeathRecipientCb, onDestroy: OnDeathRecipientDestroyCb, userData: *const c_void) -> *mut CDeathRecipient161 pub fn CreateDeathRecipient(onDeathRecipient: OnDeathRecipientCb, 162 onDestroy: OnDeathRecipientDestroyCb, 163 userData: *const c_void) -> *mut CDeathRecipient; DeathRecipientDecStrongRef(recipient: *mut CDeathRecipient)164 pub fn DeathRecipientDecStrongRef(recipient: *mut CDeathRecipient); AddDeathRecipient(object: *mut CRemoteObject, recipient: *mut CDeathRecipient) -> bool165 pub fn AddDeathRecipient(object: *mut CRemoteObject, 166 recipient: *mut CDeathRecipient) -> bool; RemoveDeathRecipient(object: *mut CRemoteObject, recipient: *mut CDeathRecipient) -> bool167 pub fn RemoveDeathRecipient(object: *mut CRemoteObject, 168 recipient: *mut CDeathRecipient) -> bool; 169 IsProxyObject(object: *mut CRemoteObject) -> bool170 pub fn IsProxyObject(object: *mut CRemoteObject) -> bool; Dump(object: *mut CRemoteObject, fd: i32, parcel: *mut CParcel) -> i32171 pub fn Dump(object: *mut CRemoteObject, fd: i32, parcel: *mut CParcel) -> i32; 172 IsObjectDead(object: *mut CRemoteObject) -> bool173 pub fn IsObjectDead(object: *mut CRemoteObject) -> bool; GetInterfaceDescriptor(object: *mut CRemoteObject, value: *mut c_void, allocator: OnCParcelBytesAllocator::<u16>) -> bool174 pub fn GetInterfaceDescriptor(object: *mut CRemoteObject, 175 value: *mut c_void, allocator: OnCParcelBytesAllocator::<u16>) -> bool; 176 } 177 178 // C interface for Parcel 179 extern "C" { CParcelObtain() -> *mut CParcel180 pub fn CParcelObtain() -> *mut CParcel; CParcelDecStrongRef(parcel: *mut CParcel)181 pub fn CParcelDecStrongRef(parcel: *mut CParcel); 182 CParcelWriteBool(parcel: *mut CParcel, value: bool) -> bool183 pub fn CParcelWriteBool(parcel: *mut CParcel, value: bool) -> bool; CParcelReadBool(parcel: *const CParcel, value: *mut bool) -> bool184 pub fn CParcelReadBool(parcel: *const CParcel, value: *mut bool) -> bool; CParcelWriteInt8(parcel: *mut CParcel, value: i8) -> bool185 pub fn CParcelWriteInt8(parcel: *mut CParcel, value: i8) -> bool; CParcelReadInt8(parcel: *const CParcel, value: *mut i8) -> bool186 pub fn CParcelReadInt8(parcel: *const CParcel, value: *mut i8) -> bool; CParcelWriteInt16(parcel: *mut CParcel, value: i16) -> bool187 pub fn CParcelWriteInt16(parcel: *mut CParcel, value: i16) -> bool; CParcelReadInt16(parcel: *const CParcel, value: *mut i16) -> bool188 pub fn CParcelReadInt16(parcel: *const CParcel, value: *mut i16) -> bool; CParcelWriteInt32(parcel: *mut CParcel, value: i32) -> bool189 pub fn CParcelWriteInt32(parcel: *mut CParcel, value: i32) -> bool; CParcelReadInt32(parcel: *const CParcel, value: *mut i32) -> bool190 pub fn CParcelReadInt32(parcel: *const CParcel, value: *mut i32) -> bool; CParcelWriteInt64(parcel: *mut CParcel, value: i64) -> bool191 pub fn CParcelWriteInt64(parcel: *mut CParcel, value: i64) -> bool; CParcelReadInt64(parcel: *const CParcel, value: *mut i64) -> bool192 pub fn CParcelReadInt64(parcel: *const CParcel, value: *mut i64) -> bool; CParcelWriteFloat(parcel: *mut CParcel, value: f32) -> bool193 pub fn CParcelWriteFloat(parcel: *mut CParcel, value: f32) -> bool; CParcelReadFloat(parcel: *const CParcel, value: *mut f32) -> bool194 pub fn CParcelReadFloat(parcel: *const CParcel, value: *mut f32) -> bool; CParcelWriteDouble(parcel: *mut CParcel, value: f64) -> bool195 pub fn CParcelWriteDouble(parcel: *mut CParcel, value: f64) -> bool; CParcelReadDouble(parcel: *const CParcel, value: *mut f64) -> bool196 pub fn CParcelReadDouble(parcel: *const CParcel, value: *mut f64) -> bool; CParcelWriteString(parcel: *mut CParcel, value: *const c_char, len: i32) -> bool197 pub fn CParcelWriteString(parcel: *mut CParcel, value: *const c_char, len: i32) -> bool; CParcelReadString(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool198 pub fn CParcelReadString(parcel: *const CParcel, value: *mut c_void, 199 allocator: OnCParcelBytesAllocator::<u8>) -> bool; CParcelWriteString16(parcel: *mut CParcel, value: *const c_char, len: i32) -> bool200 pub fn CParcelWriteString16(parcel: *mut CParcel, value: *const c_char, len: i32) -> bool; CParcelReadString16(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool201 pub fn CParcelReadString16(parcel: *const CParcel, value: *mut c_void, 202 allocator: OnCParcelBytesAllocator::<u8>) -> bool; CParcelWriteInterfaceToken(parcel: *mut CParcel, token: *const c_char, len: i32) -> bool203 pub fn CParcelWriteInterfaceToken(parcel: *mut CParcel, 204 token: *const c_char, len: i32) -> bool; CParcelReadInterfaceToken(parcel: *const CParcel, token: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool205 pub fn CParcelReadInterfaceToken(parcel: *const CParcel, token: *mut c_void, 206 allocator: OnCParcelBytesAllocator::<u8>) -> bool; CParcelWriteRemoteObject(parcel: *mut CParcel, object: *mut CRemoteObject) -> bool207 pub fn CParcelWriteRemoteObject(parcel: *mut CParcel, object: *mut CRemoteObject) -> bool; CParcelReadRemoteObject(parcel: *const CParcel) -> *mut CRemoteObject208 pub fn CParcelReadRemoteObject(parcel: *const CParcel) -> *mut CRemoteObject; CParcelWriteBuffer(parcel: *mut CParcel, value: *const u8, len: u32) -> bool209 pub fn CParcelWriteBuffer(parcel: *mut CParcel, value: *const u8, len: u32) -> bool; CParcelReadBuffer(parcel: *const CParcel, value: *mut u8, len: u32) -> bool210 pub fn CParcelReadBuffer(parcel: *const CParcel, value: *mut u8, len: u32) -> bool; CParcelWriteRawData(parcel: *mut CParcel, value: *const u8, len: u32) -> bool211 pub fn CParcelWriteRawData(parcel: *mut CParcel, value: *const u8, len: u32) -> bool; CParcelReadRawData(parcel: *const CParcel, len: u32) -> *mut u8212 pub fn CParcelReadRawData(parcel: *const CParcel, len: u32) -> *mut u8; CParcelWriteFileDescriptor(parcel: *mut CParcel, fd: i32) -> bool213 pub fn CParcelWriteFileDescriptor(parcel: *mut CParcel, fd: i32) -> bool; CParcelReadFileDescriptor(parcel: *const CParcel, fd: *mut i32) -> bool214 pub fn CParcelReadFileDescriptor(parcel: *const CParcel, fd: *mut i32) -> bool; 215 CParcelWriteBoolArray(parcel: *mut CParcel, value: *const bool, len: i32) -> bool216 pub fn CParcelWriteBoolArray(parcel: *mut CParcel, value: *const bool, len: i32) -> bool; CParcelReadBoolArray(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<bool>) -> bool217 pub fn CParcelReadBoolArray(parcel: *const CParcel, value: *mut c_void, 218 allocator: OnCParcelBytesAllocator::<bool>) -> bool; CParcelWriteInt8Array(parcel: *mut CParcel, value: *const i8, len: i32) -> bool219 pub fn CParcelWriteInt8Array(parcel: *mut CParcel, value: *const i8, len: i32) -> bool; CParcelReadInt8Array(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<i8>) -> bool220 pub fn CParcelReadInt8Array(parcel: *const CParcel, value: *mut c_void, 221 allocator: OnCParcelBytesAllocator::<i8>) -> bool; CParcelWriteInt16Array(parcel: *mut CParcel, value: *const i16, len: i32) -> bool222 pub fn CParcelWriteInt16Array(parcel: *mut CParcel, value: *const i16, len: i32) -> bool; CParcelReadInt16Array(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<i16>) -> bool223 pub fn CParcelReadInt16Array(parcel: *const CParcel, value: *mut c_void, 224 allocator: OnCParcelBytesAllocator::<i16>) -> bool; CParcelWriteInt32Array(parcel: *mut CParcel, value: *const i32, len: i32) -> bool225 pub fn CParcelWriteInt32Array(parcel: *mut CParcel, value: *const i32, len: i32) -> bool; CParcelReadInt32Array(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<i32>) -> bool226 pub fn CParcelReadInt32Array(parcel: *const CParcel, value: *mut c_void, 227 allocator: OnCParcelBytesAllocator::<i32>) -> bool; CParcelWriteInt64Array(parcel: *mut CParcel, value: *const i64, len: i32) -> bool228 pub fn CParcelWriteInt64Array(parcel: *mut CParcel, value: *const i64, len: i32) -> bool; CParcelReadInt64Array(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<i64>) -> bool229 pub fn CParcelReadInt64Array(parcel: *const CParcel, value: *mut c_void, 230 allocator: OnCParcelBytesAllocator::<i64>) -> bool; CParcelWriteFloatArray(parcel: *mut CParcel, value: *const f32, len: i32) -> bool231 pub fn CParcelWriteFloatArray(parcel: *mut CParcel, value: *const f32, len: i32) -> bool; CParcelReadFloatArray(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<f32>) -> bool232 pub fn CParcelReadFloatArray(parcel: *const CParcel, value: *mut c_void, 233 allocator: OnCParcelBytesAllocator::<f32>) -> bool; CParcelWriteDoubleArray(parcel: *mut CParcel, value: *const f64, len: i32) -> bool234 pub fn CParcelWriteDoubleArray(parcel: *mut CParcel, value: *const f64, len: i32) -> bool; CParcelReadDoubleArray(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelBytesAllocator::<f64>) -> bool235 pub fn CParcelReadDoubleArray(parcel: *const CParcel, value: *mut c_void, 236 allocator: OnCParcelBytesAllocator::<f64>) -> bool; CParcelWriteStringArray(parcel: *mut CParcel, value: *const c_void, len: i32, writer: OnStringArrayWrite) -> bool237 pub fn CParcelWriteStringArray(parcel: *mut CParcel, value: *const c_void, len: i32, 238 writer: OnStringArrayWrite) -> bool; CParcelWriteString16Array(parcel: *mut CParcel, value: *const c_void, len: i32, writer: OnString16ArrayWrite) -> bool239 pub fn CParcelWriteString16Array(parcel: *mut CParcel, value: *const c_void, len: i32, 240 writer: OnString16ArrayWrite) -> bool; CParcelWriteStringElement(data: *const c_void, value: *const c_char, len: i32) -> bool241 pub fn CParcelWriteStringElement(data: *const c_void, value: *const c_char, 242 len: i32) -> bool; CParcelWritU16stringElement(data: *const c_void, value: *const c_char, len: i32) -> bool243 pub fn CParcelWritU16stringElement(data: *const c_void, value: *const c_char, 244 len: i32) -> bool; CParcelReadStringArray(parcel: *const CParcel, value: *mut c_void, reader: OnStringArrayRead) -> bool245 pub fn CParcelReadStringArray(parcel: *const CParcel, value: *mut c_void, 246 reader: OnStringArrayRead) -> bool; CParcelReadString16Array(parcel: *const CParcel, value: *mut c_void, reader: OnString16ArrayRead) -> bool247 pub fn CParcelReadString16Array(parcel: *const CParcel, value: *mut c_void, 248 reader: OnString16ArrayRead) -> bool; CParcelReadStringElement(index: u32, data: *const c_void, value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool249 pub fn CParcelReadStringElement(index: u32, data: *const c_void, value: *mut c_void, 250 allocator: OnCParcelBytesAllocator::<u8>) -> bool; CParcelReadString16Element(index: u32, data: *const c_void, value: *mut c_void, allocator: OnCParcelBytesAllocator::<u16>) -> bool251 pub fn CParcelReadString16Element(index: u32, data: *const c_void, value: *mut c_void, 252 allocator: OnCParcelBytesAllocator::<u16>) -> bool; CParcelWriteParcelableArray(parcel: *mut CParcel, value: *const c_void, len: i32, element_writer: OnCParcelWriteElement) -> bool253 pub fn CParcelWriteParcelableArray(parcel: *mut CParcel, value: *const c_void, len: i32, 254 element_writer: OnCParcelWriteElement) -> bool; CParcelReadParcelableArray(parcel: *const CParcel, value: *mut c_void, allocator: OnCParcelAllocator, element_reader: OnCParcelReadElement ) -> bool255 pub fn CParcelReadParcelableArray(parcel: *const CParcel, value: *mut c_void, 256 allocator: OnCParcelAllocator, element_reader: OnCParcelReadElement ) -> bool; 257 CParcelGetDataSize(parcel: *const CParcel) -> u32258 pub fn CParcelGetDataSize(parcel: *const CParcel) -> u32; CParcelSetDataSize(parcel: *mut CParcel, new_size: u32) -> bool259 pub fn CParcelSetDataSize(parcel: *mut CParcel, new_size: u32) -> bool; CParcelGetDataCapacity(parcel: *const CParcel) -> u32260 pub fn CParcelGetDataCapacity(parcel: *const CParcel) -> u32; CParcelSetDataCapacity(parcel: *mut CParcel, new_size: u32) -> bool261 pub fn CParcelSetDataCapacity(parcel: *mut CParcel, new_size: u32) -> bool; CParcelGetMaxCapacity(parcel: *const CParcel) -> u32262 pub fn CParcelGetMaxCapacity(parcel: *const CParcel) -> u32; CParcelSetMaxCapacity(parcel: *mut CParcel, new_size: u32) -> bool263 pub fn CParcelSetMaxCapacity(parcel: *mut CParcel, new_size: u32) -> bool; CParcelGetWritableBytes(parcel: *const CParcel) -> u32264 pub fn CParcelGetWritableBytes(parcel: *const CParcel) -> u32; CParcelGetReadableBytes(parcel: *const CParcel) -> u32265 pub fn CParcelGetReadableBytes(parcel: *const CParcel) -> u32; CParcelGetReadPosition(parcel: *const CParcel) -> u32266 pub fn CParcelGetReadPosition(parcel: *const CParcel) -> u32; CParcelGetWritePosition(parcel: *const CParcel) -> u32267 pub fn CParcelGetWritePosition(parcel: *const CParcel) -> u32; CParcelRewindRead(parcel: *mut CParcel, new_pos: u32) -> bool268 pub fn CParcelRewindRead(parcel: *mut CParcel, new_pos: u32) -> bool; CParcelRewindWrite(parcel: *mut CParcel, new_pos: u32) -> bool269 pub fn CParcelRewindWrite(parcel: *mut CParcel, new_pos: u32) -> bool; CParcelWriteAshmem(parcel: *mut CParcel, ashmem: *mut CAshmem) -> bool270 pub fn CParcelWriteAshmem(parcel: *mut CParcel, ashmem: *mut CAshmem) -> bool; CParcelReadAshmem(parcel: *const CParcel) -> *mut CAshmem271 pub fn CParcelReadAshmem(parcel: *const CParcel) -> *mut CAshmem; 272 CParcelContainFileDescriptors(parcel: *const CParcel) -> bool273 pub fn CParcelContainFileDescriptors(parcel: *const CParcel) -> bool; CParcelGetRawDataSize(parcel: *const CParcel) -> usize274 pub fn CParcelGetRawDataSize(parcel: *const CParcel) -> usize; CParcelGetRawDataCapacity(parcel: *const CParcel) -> usize275 pub fn CParcelGetRawDataCapacity(parcel: *const CParcel) -> usize; CParcelClearFileDescriptor(parcel: *mut CParcel)276 pub fn CParcelClearFileDescriptor(parcel: *mut CParcel); CParcelSetClearFdFlag(parcel: *mut CParcel)277 pub fn CParcelSetClearFdFlag(parcel: *mut CParcel); CParcelAppend(parcel: *mut CParcel, data: *mut CParcel) -> bool278 pub fn CParcelAppend(parcel: *mut CParcel, data: *mut CParcel) -> bool; 279 } 280 281 // C interface for Ashmem 282 extern "C" { CreateCAshmem(name: *const c_char, size: i32) -> *mut CAshmem283 pub fn CreateCAshmem(name: *const c_char, size: i32) -> *mut CAshmem; CAshmemIncStrongRef(ashmem: *mut CAshmem)284 pub fn CAshmemIncStrongRef(ashmem: *mut CAshmem); CAshmemDecStrongRef(ashmem: *mut CAshmem)285 pub fn CAshmemDecStrongRef(ashmem: *mut CAshmem); 286 CloseCAshmem(ashmem: *mut CAshmem)287 pub fn CloseCAshmem(ashmem: *mut CAshmem); MapCAshmem(ashmem: *mut CAshmem, mapType: i32) -> bool288 pub fn MapCAshmem(ashmem: *mut CAshmem, mapType: i32) -> bool; MapReadAndWriteCAshmem(ashmem: *mut CAshmem) -> bool289 pub fn MapReadAndWriteCAshmem(ashmem: *mut CAshmem) -> bool; MapReadOnlyCAshmem(ashmem: *mut CAshmem) -> bool290 pub fn MapReadOnlyCAshmem(ashmem: *mut CAshmem) -> bool; UnmapCAshmem(ashmem: *mut CAshmem)291 pub fn UnmapCAshmem(ashmem: *mut CAshmem); SetCAshmemProtection(ashmem: *mut CAshmem, protectionType: i32) -> bool292 pub fn SetCAshmemProtection(ashmem: *mut CAshmem, protectionType: i32) -> bool; GetCAshmemProtection(ashmem: *const CAshmem) -> i32293 pub fn GetCAshmemProtection(ashmem: *const CAshmem) -> i32; GetCAshmemSize(ashmem: *const CAshmem) -> i32294 pub fn GetCAshmemSize(ashmem: *const CAshmem) -> i32; WriteToCAshmem(ashmem: *mut CAshmem, data: *const u8, size: i32, offset: i32) -> bool295 pub fn WriteToCAshmem(ashmem: *mut CAshmem, data: *const u8, 296 size: i32, offset: i32) -> bool; ReadFromCAshmem(ashmem: *const CAshmem, size: i32, offset: i32) -> *const u8297 pub fn ReadFromCAshmem(ashmem: *const CAshmem, size: i32, offset: i32) -> *const u8; GetCAshmemFd(ashmem: *const CAshmem) -> i32298 pub fn GetCAshmemFd(ashmem: *const CAshmem) -> i32; 299 } 300 301 // C interface for IPC miscellaneous 302 extern "C" { GetContextManager() -> *mut CRemoteObject303 pub fn GetContextManager() -> *mut CRemoteObject; JoinWorkThread()304 pub fn JoinWorkThread(); StopWorkThread()305 pub fn StopWorkThread(); GetCallingTokenId() -> u64306 pub fn GetCallingTokenId() -> u64; GetFirstToekenId() -> u64307 pub fn GetFirstToekenId() -> u64; GetSelfToekenId() -> u64308 pub fn GetSelfToekenId() -> u64; GetCallingPid() -> u64309 pub fn GetCallingPid() -> u64; GetCallingUid() -> u64310 pub fn GetCallingUid() -> u64; 311 SetMaxWorkThreadNum(maxThreadNum: i32) -> bool312 pub fn SetMaxWorkThreadNum(maxThreadNum: i32) -> bool; IsLocalCalling() -> bool313 pub fn IsLocalCalling() -> bool; SetCallingIdentity(identity: *const c_char) -> bool314 pub fn SetCallingIdentity(identity: *const c_char) -> bool; GetLocalDeviceID(value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool315 pub fn GetLocalDeviceID(value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool; GetCallingDeviceID(value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool316 pub fn GetCallingDeviceID(value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool; ResetCallingIdentity(value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool317 pub fn ResetCallingIdentity(value: *mut c_void, allocator: OnCParcelBytesAllocator::<u8>) -> bool; 318 IsHandlingTransaction() -> bool319 pub fn IsHandlingTransaction() -> bool; 320 }